You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goal is to reduce access time to herbivore objects when iterating over them. Coherent memory chunks are loaded into L2 and L1 cache, and so the following herbivore object is likely to be accessed a lot faster.
Remove reference to HFT from the CreateHerbivore* classes, but instead store it in the population class and pass it to the creator class as a function parameter.
This way the herbivore objects of all HFTs lie together in memory. This makes sense because total forage demands in one habitat are always calculated across all HFTs.
Make CreateHerbivoreCohort and CreateHerbivorePopulation member variables of WorldConstructor.
This means that the herbivore objects across all habitats are stored in contiguous memory.
Currently that is not necessary because there is no interaction between habitats. In the future this might change, though, if we implement migration across habitats and grid cells.
In WorldConstructor::create_population() pass only the reference to the respective CreateHerbivore* object.
Let CreateHerbivoreCohort and CreateHerbivorePopulation return pointers, not new objects. For this step, just keep all herbivore objects in a member variable: avector of std::unique_ptr objects.
Keep all herbivore objects in big contiguous memory blocks.
Each CreateHerbivore* object has a set of memory blocks (std::list< std::vector<HerbivoreCohort> >).
Each block gets reserved for a certain capacity, and never gets reallocated.
When one block is full, a new block is allocated.
A new herbivore object is created with emplace_back() in the herbivore object vector of the current block.
An herbivore object can be marked as dead, but remains in memory.
Replace dead herbivore objects.
When a new herbivore object is to be created, the blocks are searched for existing dead herbivores first. If one is found, it will be overwritten.
The text was updated successfully, but these errors were encountered:
The goal is to reduce access time to herbivore objects when iterating over them. Coherent memory chunks are loaded into L2 and L1 cache, and so the following herbivore object is likely to be accessed a lot faster.
CreateHerbivore*
classes, but instead store it in the population class and pass it to the creator class as a function parameter.CreateHerbivoreCohort
andCreateHerbivorePopulation
member variables ofWorldConstructor
.WorldConstructor::create_population()
pass only the reference to the respectiveCreateHerbivore*
object.CreateHerbivoreCohort
andCreateHerbivorePopulation
return pointers, not new objects. For this step, just keep all herbivore objects in a member variable: avector ofstd::unique_ptr
objects.CreateHerbivore*
object has a set of memory blocks (std::list< std::vector<HerbivoreCohort> >
).emplace_back()
in the herbivore object vector of the current block.The text was updated successfully, but these errors were encountered: