#include <resource_manager.h>
|
| 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) |
|
void | SwapAgents (std::vector< std::vector< Agent * >> *agents) |
|
void | AddDiffusionGrid (DiffusionGrid *dgrid) |
|
void | RemoveDiffusionGrid (size_t substance_id) |
|
DiffusionGrid * | GetDiffusionGrid (size_t substance_id) const |
| Return the diffusion grid which holds the substance of specified id. More...
|
|
DiffusionGrid * | GetDiffusionGrid (const std::string &substance_name) const |
|
template<typename TFunctor > |
void | ForEachDiffusionGrid (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) |
|
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 |
|
ResourceManager stores agents and diffusion grids 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 52 of file resource_manager.h.
◆ ResourceManager() [1/2]
bdm::ResourceManager::ResourceManager |
( |
TRootIOCtor * |
r | ) |
|
|
inlineexplicit |
◆ ResourceManager() [2/2]
bdm::ResourceManager::ResourceManager |
( |
| ) |
|
◆ ~ResourceManager()
bdm::ResourceManager::~ResourceManager |
( |
| ) |
|
|
virtual |
◆ AddAgent()
◆ AddAgents()
virtual void bdm::ResourceManager::AddAgents |
( |
typename AgentHandle::NumaNode_t |
numa_node, |
|
|
uint64_t |
offset, |
|
|
const std::vector< Agent * > & |
new_agents |
|
) |
| |
|
inlinevirtual |
Adds new_agents
to agents_[numa_node]
. offset
specifies the index at which the first element is inserted. Agents are inserted consecutively. This methos is thread safe only if insertion intervals do not overlap!
Definition at line 355 of file resource_manager.h.
◆ AddDiffusionGrid()
void bdm::ResourceManager::AddDiffusionGrid |
( |
DiffusionGrid * |
dgrid | ) |
|
|
inline |
◆ BDM_CLASS_DEF_NV()
◆ ClearAgents()
void bdm::ResourceManager::ClearAgents |
( |
| ) |
|
|
inline |
◆ ContainsAgent()
bool bdm::ResourceManager::ContainsAgent |
( |
const AgentUid & |
uid | ) |
const |
|
inline |
◆ DebugNuma()
void bdm::ResourceManager::DebugNuma |
( |
| ) |
const |
◆ EndOfIteration()
virtual void bdm::ResourceManager::EndOfIteration |
( |
| ) |
|
|
inlinevirtual |
◆ ForEachAgent() [1/2]
virtual void bdm::ResourceManager::ForEachAgent |
( |
const std::function< void(Agent *)> & |
function, |
|
|
Functor< bool, Agent * > * |
filter = nullptr |
|
) |
| |
|
inlinevirtual |
Call a function for all or a subset of agents in the simulation.
- Parameters
-
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. |
rm->ForEachAgent([](Agent* a) { std::cout << a->GetUid() << std::endl; });
Definition at line 206 of file resource_manager.h.
◆ ForEachAgent() [2/2]
virtual void bdm::ResourceManager::ForEachAgent |
( |
const std::function< void(Agent *, AgentHandle)> & |
function, |
|
|
Functor< bool, Agent * > * |
filter = nullptr |
|
) |
| |
|
inlinevirtual |
◆ ForEachAgentParallel() [1/4]
void bdm::ResourceManager::ForEachAgentParallel |
( |
Functor< void, Agent * > & |
function, |
|
|
Functor< bool, Agent * > * |
filter = nullptr |
|
) |
| |
|
virtual |
Call a function for all or a subset of agents in the simulation.
- Parameters
-
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. |
- See also
- ForEachAgent
Definition at line 92 of file resource_manager.cc.
◆ ForEachAgentParallel() [2/4]
◆ ForEachAgentParallel() [3/4]
void bdm::ResourceManager::ForEachAgentParallel |
( |
Operation & |
op, |
|
|
Functor< bool, Agent * > * |
filter = nullptr |
|
) |
| |
|
virtual |
Call an operation for all or a subset of agents in the simulation. Function invocations are parallelized.
Uses static scheduling.
- See also
- ForEachAgent
Definition at line 98 of file resource_manager.cc.
◆ ForEachAgentParallel() [4/4]
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
.
- Parameters
-
chunk | number of agents that are assigned to a thread (batch size) |
- See also
- ForEachAgent
Definition at line 104 of file resource_manager.cc.
◆ ForEachDiffusionGrid()
template<typename TFunctor >
void bdm::ResourceManager::ForEachDiffusionGrid |
( |
TFunctor && |
f | ) |
const |
|
inline |
Execute the given functor for all diffusion grids rm->ForEachDiffusionGrid([](DiffusionGrid* dgrid) { ... });
Definition at line 176 of file resource_manager.h.
◆ GetAgent() [1/2]
◆ GetAgent() [2/2]
◆ GetAgentHandle()
◆ GetAgentVectorCapacity()
size_t bdm::ResourceManager::GetAgentVectorCapacity |
( |
int |
numa_node | ) |
|
◆ GetDiffusionGrid() [1/2]
DiffusionGrid* bdm::ResourceManager::GetDiffusionGrid |
( |
const std::string & |
substance_name | ) |
const |
|
inline |
Return the diffusion grid which holds the substance of specified name Caution: using this function in a tight loop will result in a slow simulation. Use GetDiffusionGrid(size_t)
in those cases.
Definition at line 157 of file resource_manager.h.
◆ GetDiffusionGrid() [2/2]
DiffusionGrid* bdm::ResourceManager::GetDiffusionGrid |
( |
size_t |
substance_id | ) |
const |
|
inline |
Return the diffusion grid which holds the substance of specified id.
Definition at line 143 of file resource_manager.h.
◆ GetNumAgents()
size_t bdm::ResourceManager::GetNumAgents |
( |
int |
numa_node = -1 | ) |
const |
|
inline |
Returns the total number of agents if numa_node == -1 Otherwise the number of agents in the specific numa node
Definition at line 184 of file resource_manager.h.
◆ GetTypeIndex()
const TypeIndex* bdm::ResourceManager::GetTypeIndex |
( |
| ) |
const |
|
inline |
◆ GrowAgentContainer()
uint64_t bdm::ResourceManager::GrowAgentContainer |
( |
size_t |
additional, |
|
|
size_t |
numa_node |
|
) |
| |
|
inline |
Resize agents_[numa_node]
such that it holds current + additional
elements after this call. Returns the size after
Definition at line 277 of file resource_manager.h.
◆ LoadBalance()
void bdm::ResourceManager::LoadBalance |
( |
| ) |
|
|
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.
◆ MarkEnvironmentOutOfSync()
void bdm::ResourceManager::MarkEnvironmentOutOfSync |
( |
| ) |
|
|
protected |
Adding and removing agents does not immediately reflect in the state of the environment. This function sets a flag in the envrionment such that it is aware of the changes.
Definition at line 588 of file resource_manager.cc.
◆ operator=()
◆ RebuildAgentUidMap()
void bdm::ResourceManager::RebuildAgentUidMap |
( |
| ) |
|
|
inline |
◆ RemoveAgent()
void bdm::ResourceManager::RemoveAgent |
( |
const AgentUid & |
uid | ) |
|
|
inline |
◆ RemoveAgents()
void bdm::ResourceManager::RemoveAgents |
( |
const std::vector< std::vector< AgentUid > * > & |
uids | ) |
|
◆ RemoveDiffusionGrid()
void bdm::ResourceManager::RemoveDiffusionGrid |
( |
size_t |
substance_id | ) |
|
|
inline |
◆ Reserve()
void bdm::ResourceManager::Reserve |
( |
size_t |
capacity | ) |
|
|
inline |
Reserves enough memory to hold capacity
number of agents for each numa domain.
Definition at line 265 of file resource_manager.h.
◆ ResizeAgentUidMap()
void bdm::ResourceManager::ResizeAgentUidMap |
( |
| ) |
|
|
inline |
◆ SwapAgents()
void bdm::ResourceManager::SwapAgents |
( |
std::vector< std::vector< Agent * >> * |
agents | ) |
|
◆ operator<<
◆ SimulationBackup
◆ agents_
std::vector<std::vector<Agent*> > bdm::ResourceManager::agents_ |
|
protected |
◆ agents_lb_
std::vector<std::vector<Agent*> > bdm::ResourceManager::agents_lb_ |
|
protected |
◆ diffusion_grids_
std::unordered_map<uint64_t, DiffusionGrid*> bdm::ResourceManager::diffusion_grids_ |
|
protected |
Maps a diffusion grid ID to the pointer to the diffusion grid.
Definition at line 430 of file resource_manager.h.
◆ parallel_remove_
◆ thread_info_
◆ type_index_
TypeIndex* bdm::ResourceManager::type_index_ = nullptr |
|
protected |
◆ uid_ah_map_
The documentation for this class was generated from the following files: