BioDynaMo
v1.05.120-25dc9790
|
#include <resource_manager.h>
Classes | |
struct | ParallelRemovalAuxData |
Public Member Functions | |
ResourceManager (TRootIOCtor *r) | |
ResourceManager () | |
virtual | ~ResourceManager () |
ResourceManager & | operator= (ResourceManager &&other) noexcept |
void | RebuildAgentUidMap () |
Agent * | GetAgent (const AgentUid &uid) |
Agent * | GetAgent (AgentHandle ah) |
AgentHandle | GetAgentHandle (const AgentUid &uid) const |
void | SwapAgents (std::vector< std::vector< Agent * >> *agents) |
void | AddDiffusionGrid (DiffusionGrid *dgrid) |
void | AddContinuum (Continuum *cm) |
void | RemoveDiffusionGrid (size_t substance_id) |
void | RemoveContinuum (size_t continuum_id) |
DiffusionGrid * | GetDiffusionGrid (size_t substance_id) const |
Continuum * | GetContinuum (size_t continuum_id) const |
Return the continuum model which holds the substance of specified id. More... | |
DiffusionGrid * | GetDiffusionGrid (const std::string &substance_name) const |
Continuum * | GetContinuum (const std::string &continuum_name) const |
template<typename TFunctor > | |
void | ForEachDiffusionGrid (TFunctor &&f) const |
template<typename TFunctor > | |
void | ForEachContinuum (TFunctor &&f) const |
size_t | GetNumAgents (int numa_node=-1) const |
size_t | GetAgentVectorCapacity (int numa_node) |
virtual void | ForEachAgent (const std::function< void(Agent *)> &function, Functor< bool, Agent * > *filter=nullptr) |
virtual void | ForEachAgent (const std::function< void(Agent *, AgentHandle)> &function, Functor< bool, Agent * > *filter=nullptr) |
virtual void | ForEachAgentParallel (Functor< void, Agent * > &function, Functor< bool, Agent * > *filter=nullptr) |
virtual void | ForEachAgentParallel (Operation &op, Functor< bool, Agent * > *filter=nullptr) |
virtual void | ForEachAgentParallel (Functor< void, Agent *, AgentHandle > &function, Functor< bool, Agent * > *filter=nullptr) |
virtual void | ForEachAgentParallel (uint64_t chunk, Functor< void, Agent *, AgentHandle > &function, Functor< bool, Agent * > *filter=nullptr) |
void | Reserve (size_t capacity) |
uint64_t | GrowAgentContainer (size_t additional, size_t numa_node) |
bool | ContainsAgent (const AgentUid &uid) const |
void | ClearAgents () |
virtual void | LoadBalance () |
void | DebugNuma () const |
void | AddAgent (Agent *agent, typename AgentHandle::NumaNode_t numa_node=0) |
Add an agent to the ResourceManager (not thread-safe). This function might invalidate agent references pointing into the ResourceManager. AgentPointer are not affected. For adding agents to a Simulation, use ExecutionContext::AddAgent. More... | |
void | ResizeAgentUidMap () |
virtual void | EndOfIteration () |
virtual void | AddAgents (typename AgentHandle::NumaNode_t numa_node, uint64_t offset, const std::vector< Agent * > &new_agents) |
void | RemoveAgent (const AgentUid &uid) |
void | RemoveAgents (const std::vector< std::vector< AgentUid > * > &uids) |
const TypeIndex * | GetTypeIndex () const |
Protected Member Functions | |
void | MarkEnvironmentOutOfSync () const |
Protected Attributes | |
AgentUidMap< AgentHandle > | uid_ah_map_ = AgentUidMap<AgentHandle>(100u) |
Maps an AgentUid to its storage location in agents_ . More... | |
std::vector< std::vector< Agent * > > | agents_ |
Pointer container for all agents. More... | |
std::vector< std::vector< Agent * > > | agents_lb_ |
Container used during load balancing. More... | |
ThreadInfo * | thread_info_ = ThreadInfo::GetInstance() |
TypeIndex * | type_index_ = nullptr |
ParallelRemovalAuxData | parallel_remove_ |
auxiliary data required for parallel agent removal More... | |
Private Member Functions | |
BDM_CLASS_DEF_NV (ResourceManager, 2) | |
Private Attributes | |
std::unordered_map< uint64_t, Continuum * > | continuum_models_ |
Maps a continuum ID to the pointer to the continuum models. More... | |
Friends | |
class | SimulationBackup |
std::ostream & | operator<< (std::ostream &os, const ResourceManager &rm) |
ResourceManager stores agents and continuum models and provides methods to add, remove, and access them. Agents are uniquely identified by their AgentUid, and AgentHandle. An AgentHandle might change during the simulation.
Definition at line 53 of file resource_manager.h.
|
inlineexplicit |
Definition at line 55 of file resource_manager.h.
bdm::ResourceManager::ResourceManager | ( | ) |
Definition at line 30 of file resource_manager.cc.
|
virtual |
Definition at line 45 of file resource_manager.cc.
|
inline |
Add an agent to the ResourceManager (not thread-safe). This function might invalidate agent references pointing into the ResourceManager. AgentPointer are not affected. For adding agents to a Simulation, use ExecutionContext::AddAgent.
agent | Agent to be added |
numa_node | NUMA node to which the agent will be added (default: 0) |
Definition at line 398 of file resource_manager.h.
|
inlinevirtual |
Adds new_agents
to agents_[numa_node]
. offset
specifies the index at which the first element is inserted. Agents are inserted consecutively. This method is thread safe only if insertion intervals do not overlap!
Definition at line 432 of file resource_manager.h.
|
inline |
Definition at line 126 of file resource_manager.h.
|
inline |
Definition at line 121 of file resource_manager.h.
|
private |
|
inline |
Remove all agents NB: This method is not thread-safe! This function invalidates agent references pointing into the ResourceManager. AgentPointer are not affected.
Definition at line 373 of file resource_manager.h.
|
inline |
Returns true if an agent with the given uid is stored in this ResourceManager.
Definition at line 365 of file resource_manager.h.
void bdm::ResourceManager::DebugNuma | ( | ) | const |
|
inlinevirtual |
Definition at line 426 of file resource_manager.h.
|
inlinevirtual |
Call a function for all or a subset of agents in the simulation.
function | that will be called for each agent |
filter | if specified, function will only be called for agents for which filter(agent) evaluates to true. |
/code{.cpp} rm->ForEachAgent([](Agent* a) { std::cout << a->GetUid() << std::endl; }); /endcode
Definition at line 280 of file resource_manager.h.
|
inlinevirtual |
Definition at line 291 of file resource_manager.h.
|
virtual |
Call a function for all or a subset of agents in the simulation.
function | that will be called for each agent |
filter | if specified, function will only be called for agents for which filter(agent) evaluates to true. Function invocations are parallelized.Uses static scheduling. |
Definition at line 92 of file resource_manager.cc.
|
virtual |
Definition at line 59 of file resource_manager.cc.
|
virtual |
Call an operation for all or a subset of agents in the simulation. Function invocations are parallelized.
Uses static scheduling.
Definition at line 98 of file resource_manager.cc.
|
virtual |
Call a function for all or a subset of agents in the simulation. Function invocations are parallelized.
Uses dynamic scheduling and work stealing. Batch size controlled by chunk
.
chunk | number of agents that are assigned to a thread (batch size) |
Definition at line 104 of file resource_manager.cc.
|
inline |
Execute the given functor for all continuum models /code{.cpp} rm->ForEachContinuum([](Continuum* cm) { ... }); /endcode
Definition at line 248 of file resource_manager.h.
|
inline |
Execute the given functor for all diffusion grids /code{.cpp} rm->ForEachDiffusionGrid([](DiffusionGrid* dgrid) { ... }); /endcode
Definition at line 232 of file resource_manager.h.
|
inline |
Definition at line 111 of file resource_manager.h.
Definition at line 103 of file resource_manager.h.
|
inline |
Definition at line 115 of file resource_manager.h.
size_t bdm::ResourceManager::GetAgentVectorCapacity | ( | int | numa_node | ) |
Definition at line 579 of file resource_manager.cc.
|
inline |
Return the continuum model which holds the substance of specified name Caution: using this function in a tight loop will result in a slow simulation. Use GetContinuum(size_t)
in those cases.
Definition at line 211 of file resource_manager.h.
|
inline |
Return the continuum model which holds the substance of specified id.
Definition at line 179 of file resource_manager.h.
|
inline |
Return the diffusion grid which holds the substance of specified name. Calls back to GetContinuum(std::string) and checks with dynamic_cast if substance_name corresponds to a DiffusionGrid implementation. Caution: using this function in a tight loop will result in a slow simulation. Use GetDiffusionGrid(size_t)
in those cases.
Definition at line 197 of file resource_manager.h.
|
inline |
Return the diffusion grid which holds the substance of specified id. Calls back to GetContinuum() to get the continuum model and used a dynamic_cast to check if the implementation is a DiffusionGrid.
Definition at line 167 of file resource_manager.h.
|
inline |
Returns the total number of agents if numa_node == -1 Otherwise the number of agents in the specific numa node
Definition at line 256 of file resource_manager.h.
|
inline |
Definition at line 492 of file resource_manager.h.
|
inline |
Resize agents_[numa_node]
such that it holds current + additional
elements after this call. Returns the size after
Definition at line 351 of file resource_manager.h.
|
virtual |
Reorder agents such that, agents are distributed to NUMA nodes. Nearby agents will be moved to the same NUMA node.
Definition at line 239 of file resource_manager.cc.
|
protected |
Adding and removing agents does not immediately reflect in the state of the environment. This function sets a flag in the environment such that it is aware of the changes.
Definition at line 588 of file resource_manager.cc.
|
inlinenoexcept |
Definition at line 61 of file resource_manager.h.
|
inline |
Definition at line 90 of file resource_manager.h.
|
inline |
Removes the agent with the given uid.
NB: This method is not thread-safe! This function invalidates agent references pointing into the ResourceManager. AgentPointer are not affected.
Definition at line 460 of file resource_manager.h.
void bdm::ResourceManager::RemoveAgents | ( | const std::vector< std::vector< AgentUid > * > & | uids | ) |
Definition at line 339 of file resource_manager.cc.
|
inline |
Definition at line 153 of file resource_manager.h.
|
inline |
Definition at line 148 of file resource_manager.h.
|
inline |
Reserves enough memory to hold capacity
number of agents for each numa domain.
Definition at line 339 of file resource_manager.h.
|
inline |
Definition at line 414 of file resource_manager.h.
void bdm::ResourceManager::SwapAgents | ( | std::vector< std::vector< Agent * >> * | agents | ) |
Definition at line 584 of file resource_manager.cc.
|
friend |
Definition at line 529 of file resource_manager.h.
|
friend |
Definition at line 519 of file resource_manager.h.
|
protected |
Pointer container for all agents.
Definition at line 503 of file resource_manager.h.
|
protected |
Container used during load balancing.
Definition at line 505 of file resource_manager.h.
|
private |
Maps a continuum ID to the pointer to the continuum models.
Definition at line 524 of file resource_manager.h.
|
protected |
auxiliary data required for parallel agent removal
Definition at line 517 of file resource_manager.h.
|
protected |
Definition at line 507 of file resource_manager.h.
|
protected |
Definition at line 509 of file resource_manager.h.
|
protected |
Maps an AgentUid to its storage location in agents_
.
Definition at line 501 of file resource_manager.h.