BioDynaMo  v1.03.61-fe34ced0
scheduler.cc
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #include "core/scheduler.h"
16 #include <chrono>
17 #include <iomanip>
18 #include <string>
19 #include <utility>
27 #include "core/param/param.h"
28 #include "core/resource_manager.h"
29 #include "core/simulation.h"
30 #include "core/simulation_backup.h"
31 #include "core/util/log.h"
33 
34 namespace bdm {
35 
37  auto* param = Simulation::GetActive()->GetParam();
38  backup_ = new SimulationBackup(param->backup_file, param->restore_file);
39  if (backup_->RestoreEnabled()) {
41  }
43 
44  // Operations are scheduled in the following order (sub categorated by their
45  // operation implementation type, so that actual order may vary)
46  std::vector<std::string> default_op_names = {
47  "update staticness", "bound space", "behavior",
48  "mechanical forces", "discretization", "propagate staticness agentop",
49  "diffusion"};
50 
51  std::vector<std::string> pre_scheduled_ops_names = {"set up iteration",
52  "propagate staticness"};
53  // We cannot put sort and balance in the list of scheduled_standalone_ops_,
54  // because numa-aware data structures would be invalidated:
55  // ```
56  // SetUpOps() <-- (1)
57  // RunScheduledOps() <-- rebalance numa domains
58  // TearDownOps() <-- indexing with AgentHandles is different than at (1)
59  // ```
60  // Also, must be done before TearDownIteration, because that introduces new
61  // agents that are not yet in the environment (which load balancing
62  // relies on)
63  std::vector<std::string> post_scheduled_ops_names = {
64  "load balancing", "tear down iteration", "update environment",
65  "visualize", "update time series"};
66 
67  protected_op_names_ = {"update staticness",
68  "discretization",
69  "distribute run displacment info",
70  "set up iteration",
71  "update environment",
72  "tear down iteration"};
73 
74  auto disabled_op_names =
76  if (!param->detect_static_agents) {
77  disabled_op_names.push_back("propagate staticness");
78  disabled_op_names.push_back("propagate staticness agentop");
79  }
80 
81  std::vector<std::vector<std::string>*> all_op_names;
82  all_op_names.push_back(&pre_scheduled_ops_names);
83  all_op_names.push_back(&default_op_names);
84  all_op_names.push_back(&post_scheduled_ops_names);
85 
86  // Remove operations listed in `Param::unschedule_default_operations` from the
87  // to-be-scheduled operations, as long as they are non-protected
88  for (auto* op_list : all_op_names) {
89  for (auto op_name_iter = op_list->begin();
90  op_name_iter != op_list->end();) {
91  if (std::find(disabled_op_names.begin(), disabled_op_names.end(),
92  *op_name_iter) != disabled_op_names.end() &&
93  std::find(protected_op_names_.begin(), protected_op_names_.end(),
94  *op_name_iter) == protected_op_names_.end()) {
95  op_name_iter = op_list->erase(op_name_iter);
96  } else {
97  op_name_iter++;
98  }
99  }
100  }
101 
102  // Schedule the default operations
103  for (auto& def_op : default_op_names) {
105  }
106 
107  for (auto& def_op : pre_scheduled_ops_names) {
109  }
110 
111  for (auto& def_op : post_scheduled_ops_names) {
113  }
114 
115  if (!GetOps("visualize").empty()) {
116  GetOps("visualize")[0]->GetImplementation<VisualizationOp>()->Initialize();
117  }
118  ScheduleOps();
119 }
120 
122  for (auto* op : all_ops_) {
123  delete op;
124  }
125  delete backup_;
126  delete root_visualization_;
127  delete progress_bar_;
128 }
129 
130 void Scheduler::Simulate(uint64_t steps) {
131  if (Restore(&steps)) {
132  return;
133  }
134 
135  Initialize(steps);
136  for (unsigned step = 0; step < steps; step++) {
137  Execute();
138 
139  total_steps_++;
141  Backup();
142  }
143 }
144 
145 void Scheduler::SimulateUntil(const std::function<bool()>& exit_condition) {
146  Initialize();
147  while (!exit_condition()) {
148  Execute();
149 
150  total_steps_++;
152  }
153 }
154 
156  auto* sim = Simulation::GetActive();
157  sim->GetExecutionContext()->SetupIterationAll(sim->GetAllExecCtxts());
158 }
159 
160 uint64_t Scheduler::GetSimulatedSteps() const { return total_steps_; }
161 
163 
165 
167  // Check if operation is already in all_ops_ (could be the case when
168  // trying to reschedule a previously unscheduled operation)
169  if (std::find(all_ops_.begin(), all_ops_.end(), op) == all_ops_.end()) {
170  all_ops_.push_back(op);
171  }
172 
173  schedule_ops_.push_back(std::make_pair(op_type, op));
174 }
175 
177  // We must not unschedule a protected operation
178  if (std::find(protected_op_names_.begin(), protected_op_names_.end(),
179  op->name_) != protected_op_names_.end()) {
180  Log::Warning("Scheduler::UnscheduleOp",
181  "You tried to unschedule the protected operation ", op->name_,
182  "! This request was ignored.");
183  return;
184  }
185 
186  // Check if the requested operation is even scheduled
187  bool not_in_scheduled_ops = true;
188  ForEachOperation([&](Operation* scheduled_op) {
189  if (op == scheduled_op) {
190  not_in_scheduled_ops = false;
191  }
192  });
193 
194  if (not_in_scheduled_ops) {
195  Log::Warning("Scheduler::UnscheduleOp",
196  "You tried to unschedule the non-scheduled operation ",
197  op->name_, "! This request was ignored.");
198  return;
199  }
200 
201  unschedule_ops_.push_back(op);
202 }
203 
204 std::vector<std::string> Scheduler::GetListOfScheduledAgentOps() const {
205  std::vector<std::string> list;
206  for (auto* op : scheduled_agent_ops_) {
207  list.push_back(op->name_);
208  }
209  return list;
210 }
211 
212 std::vector<std::string> Scheduler::GetListOfScheduledStandaloneOps() const {
213  std::vector<std::string> list;
214  for (auto* op : scheduled_standalone_ops_) {
215  list.push_back(op->name_);
216  }
217  return list;
218 }
219 
220 std::vector<Operation*> Scheduler::GetOps(const std::string& name) {
221  std::vector<Operation*> ret;
222 
223  // Check if a protected op is trying to be fetched
224  if (std::find(protected_op_names_.begin(), protected_op_names_.end(), name) !=
225  protected_op_names_.end()) {
226  Log::Warning("Scheduler::GetOps", "The operation '", name,
227  "' is a protected operation. Request ignored.");
228  return ret;
229  }
230 
231  for (auto it = all_ops_.begin(); it != all_ops_.end(); ++it) {
232  if ((*it)->name_ == name) {
233  ret.push_back(*it);
234  }
235  }
236 
237  return ret;
238 }
239 
240 // -----------------------------------------------------------------------------
242  const std::vector<Functor<bool, Agent*>*>& agent_filters) {
243  agent_filters_ = agent_filters;
244 }
245 
246 // -----------------------------------------------------------------------------
247 const std::vector<Functor<bool, Agent*>*>& Scheduler::GetAgentFilters() const {
248  return agent_filters_;
249 }
250 
251 struct RunAllScheduledOps : Functor<void, Agent*, AgentHandle> {
252  explicit RunAllScheduledOps(std::vector<Operation*>& scheduled_ops)
253  : scheduled_ops_(scheduled_ops) {
255  }
256 
257  void operator()(Agent* agent, AgentHandle ah) override {
259  }
260 
262  std::vector<Operation*>& scheduled_ops_;
263 };
264 
267  if (op->frequency_ != 0 && total_steps_ % op->frequency_ == 0) {
268  Timing::Time(op->name_, [&]() { op->SetUp(); });
269  }
270  });
271 }
272 
273 void Scheduler::TearDownOps() {
274  ForEachScheduledOperation([&](Operation* op) {
275  if (op->frequency_ != 0 && total_steps_ % op->frequency_ == 0) {
276  Timing::Time(op->name_, [&]() { op->TearDown(); });
277  }
278  });
279 }
280 
281 void Scheduler::RunPreScheduledOps() {
282  for (auto* pre_op : pre_scheduled_ops_) {
283  if (pre_op->frequency_ != 0 && total_steps_ % pre_op->frequency_ == 0) {
284  Timing::Time(pre_op->name_, [&]() { (*pre_op)(); });
285  }
286  }
287 }
288 
289 // -----------------------------------------------------------------------------
290 void Scheduler::RunAgentOps(Functor<bool, Agent*>* filter) {
291  auto* sim = Simulation::GetActive();
292  auto* rm = sim->GetResourceManager();
293  auto* param = sim->GetParam();
294  auto batch_size = param->scheduling_batch_size;
295 
296  std::vector<Operation*> agent_ops;
297  for (auto* op : scheduled_agent_ops_) {
298  if (op->frequency_ != 0 && total_steps_ % op->frequency_ == 0 &&
299  !op->IsExcluded(filter)) {
300  agent_ops.push_back(op);
301  }
302  }
303 
304  const auto& all_exec_ctxts = sim->GetAllExecCtxts();
305  all_exec_ctxts[0]->SetupAgentOpsAll(all_exec_ctxts);
306 
307  if (param->execution_order == Param::ExecutionOrder::kForEachAgentForEachOp) {
308  RunAllScheduledOps functor(agent_ops);
309  Timing::Time("agent ops", [&]() {
310  rm->ForEachAgentParallel(batch_size, functor, filter);
311  });
312  } else {
313  for (auto* op : agent_ops) {
314  decltype(agent_ops) ops = {op};
315  RunAllScheduledOps functor(ops);
316  Timing::Time(op->name_, [&]() {
317  rm->ForEachAgentParallel(batch_size, functor, filter);
318  });
319  }
320  }
321 
322  all_exec_ctxts[0]->TearDownAgentOpsAll(all_exec_ctxts);
323 }
324 
325 // -----------------------------------------------------------------------------
326 void Scheduler::RunScheduledOps() {
327  SetUpOps();
328 
329  // Run the agent operations
330  if (agent_filters_.size() == 0) {
331  RunAgentOps(nullptr);
332  } else {
333  for (auto* filter : agent_filters_) {
334  RunAgentOps(filter);
335  }
336  }
337 
338  // Run the column-wise operations
339  for (auto* op : scheduled_standalone_ops_) {
340  if (op->frequency_ != 0 && total_steps_ % op->frequency_ == 0) {
341  Timing::Time(op->name_, [&]() { (*op)(); });
342  }
343  }
344 
345  TearDownOps();
346 }
347 
348 void Scheduler::RunPostScheduledOps() {
349  for (auto* post_op : post_scheduled_ops_) {
350  if (post_op->frequency_ != 0 && total_steps_ % post_op->frequency_ == 0) {
351  Timing::Time(post_op->name_, [&]() { (*post_op)(); });
352  }
353  }
354 }
355 
356 void Scheduler::Execute() {
357  auto* param = Simulation::GetActive()->GetParam();
358  if (param->use_progress_bar) {
359  assert(progress_bar_ != nullptr);
360  progress_bar_->Step();
361  progress_bar_->PrintProgressBar();
362  } else if (param->show_simulation_step != 0 &&
363  total_steps_ % param->show_simulation_step == 0) {
364  std::cout << "Time step: " << total_steps_ << std::endl;
365  }
366  ScheduleOps();
367 
368  RunPreScheduledOps();
369  RunScheduledOps();
370  RunPostScheduledOps();
371 }
372 
373 void Scheduler::PrintInfo(std::ostream& out) {
374  out << "\n" << std::string(80, '-') << "\n\n";
375  out << "Scheduler information:\n";
376  out << std::setw(80) << "frequency"
377  << "\n";
378  out << "Pre-scheduled operations:\n";
379  // pre-scheduled ops
380  for (auto* pre_op : pre_scheduled_ops_) {
381  out << std::setw(60) << pre_op->name_ << std::setw(20) << pre_op->frequency_
382  << "\n";
383  }
384  // agent-operations
385  out << "\nAgent operations:\n";
386  for (auto* op : scheduled_agent_ops_) {
387  out << std::setw(60) << op->name_ << std::setw(20) << op->frequency_
388  << "\n";
389  }
390  out << "\nStandalone operations:\n";
391  for (auto* op : scheduled_standalone_ops_) {
392  out << std::setw(60) << op->name_ << std::setw(20) << op->frequency_
393  << "\n";
394  }
395  // post-scheduled ops
396  out << "\nPost-scheduled operations:\n";
397  for (auto* post_op : post_scheduled_ops_) {
398  out << std::setw(60) << post_op->name_ << std::setw(20)
399  << post_op->frequency_ << "\n";
400  }
401 
402  out << "\n" << std::string(80, '-') << "\n";
403 }
404 
405 void Scheduler::Backup() {
406  using std::chrono::duration_cast;
407  using std::chrono::seconds;
408  auto* param = Simulation::GetActive()->GetParam();
409  if (backup_->BackupEnabled() &&
410  duration_cast<seconds>(Clock::now() - last_backup_).count() >=
411  param->backup_interval) {
412  last_backup_ = Clock::now();
413  backup_->Backup(total_steps_);
414  }
415 }
416 
420 bool Scheduler::Restore(uint64_t* steps) {
421  if (backup_->RestoreEnabled() && restore_point_ > total_steps_ + *steps) {
422  total_steps_ += *steps;
423  // restore requested, but not last backup was not done during this call to
424  // Simualte. Therefore, we skip it.
425  return true;
426  } else if (backup_->RestoreEnabled() && restore_point_ > total_steps_ &&
427  restore_point_ < total_steps_ + *steps) {
428  // Restore
429  backup_->Restore();
430  *steps = total_steps_ + *steps - restore_point_;
431  total_steps_ = restore_point_;
432  }
433  return false;
434 }
435 
436 void Scheduler::UpdateSimulatedTime() {
437  simulated_time_ += Simulation::GetActive()->GetParam()->simulation_time_step;
438 }
439 
440 // TODO(lukas, ahmad) After https://trello.com/c/0D6sHCK4 has been resolved
441 // think about a better solution, because some operations are executed twice
442 // if Simulate is called with one timestep.
443 void Scheduler::Initialize(uint64_t steps) {
444  auto* sim = Simulation::GetActive();
445  auto* env = sim->GetEnvironment();
446  auto* rm = sim->GetResourceManager();
447  auto* param = sim->GetParam();
448 
449  // commit all changes
450  const auto& all_exec_ctxts = sim->GetAllExecCtxts();
451  all_exec_ctxts[0]->SetupIterationAll(all_exec_ctxts);
452 
453  if (param->bound_space != Param::BoundSpaceMode::kOpen) {
454  auto* bound_space = NewOperation("bound space");
455  rm->ForEachAgentParallel(*bound_space);
456  delete bound_space;
457  }
458 
459  // If users select the progress bar, we create the appropriate object.
460  if (param->use_progress_bar) {
461  delete progress_bar_;
462  progress_bar_ = nullptr;
463  progress_bar_ = new ProgressBar(steps);
464  }
465 
466  // Update the uid generator in case the number of threads has changed.
467  sim->GetAgentUidGenerator()->Update();
468 
469  // We force-update the environment in this function because users may apply
470  // certain operations such as shifting them in space in between two Simulate()
471  // or SimulateUntil() calls. In contrast to adding or removing agents, such
472  // an operation would not mark the environment as OutOfSync and hence the
473  // forced update at this place.
474  env->ForcedUpdate();
475  rm->ForEachDiffusionGrid([&](DiffusionGrid* dgrid) {
476  // Create data structures, whose size depend on the env dimensions
477  dgrid->Initialize();
478  // Initialize data structures with user-defined values
479  dgrid->RunInitializers();
480  });
481 
482  ScheduleOps();
483 }
484 
485 // Schedule the operations
486 void Scheduler::ScheduleOps() {
487  auto* param = Simulation::GetActive()->GetParam();
488  // Add requested operations
489  for (auto it = schedule_ops_.begin(); it != schedule_ops_.end();) {
490  auto op_type = it->first;
491  auto* op = it->second;
492 
493  // Enable GPU operation implementations (if available) if CUDA or OpenCL
494  // flags are set
495  if (param->compute_target == "cuda" &&
496  op->IsComputeTargetSupported(kCuda)) {
497  op->SelectComputeTarget(kCuda);
498  } else if (param->compute_target == "opencl" &&
499  op->IsComputeTargetSupported(kOpenCl)) {
500  op->SelectComputeTarget(kOpenCl);
501  } else {
502  op->SelectComputeTarget(kCpu);
503  }
504 
505  // Check operation type and append to corresponding list
506  switch (op_type) {
507  case kPreSchedule:
508  pre_scheduled_ops_.push_back(op);
509  break;
510  case kPostSchedule:
511  post_scheduled_ops_.push_back(op);
512  break;
513  default:
514  if (op->IsStandalone()) {
515  scheduled_standalone_ops_.push_back(op);
516  } else {
517  scheduled_agent_ops_.push_back(op);
518  }
519  }
520 
521  // Remove operation from schedule_ops_
522  it = schedule_ops_.erase(it);
523  }
524 
525  // Unschedule requested operations
526  for (auto it = unschedule_ops_.begin(); it != unschedule_ops_.end();) {
527  auto* op = *it;
528 
529  // Lists of operations that should be considered for unscheduling
530  std::vector<std::vector<Operation*>*> op_lists = {
531  &scheduled_agent_ops_, &scheduled_standalone_ops_, &pre_scheduled_ops_,
532  &post_scheduled_ops_};
533 
534  for (auto* op_list : op_lists) {
535  for (auto it2 = op_list->begin(); it2 != op_list->end(); ++it2) {
536  if (op == (*it2)) {
537  it2 = op_list->erase(it2);
538  goto LABEL;
539  }
540  }
541  }
542  LABEL:
543  it = unschedule_ops_.erase(it);
544  }
545 }
546 
547 } // namespace bdm
in_place_exec_ctxt.h
bdm::Scheduler::Backup
void Backup()
Backup the simulation. Backup interval based on Param::backup_interval
Definition: scheduler.cc:405
bdm::kSchedule
@ kSchedule
Definition: scheduler.h:43
adaptor.h
bdm::Scheduler::Initialize
void Initialize(uint64_t steps=0)
Definition: scheduler.cc:443
bdm::Scheduler::Execute
virtual void Execute()
Definition: scheduler.cc:356
bdm::RunAllScheduledOps::RunAllScheduledOps
RunAllScheduledOps(std::vector< Operation * > &scheduled_ops)
Definition: scheduler.cc:252
bdm::Scheduler::progress_bar_
ProgressBar * progress_bar_
Definition: scheduler.h:130
op_timer.h
bdm::Scheduler::ForEachOperation
void ForEachOperation(Lambda lambda)
Runs a lambda for each operation that is executed in the Execute() call.
Definition: scheduler.h:194
bdm
Definition: agent.cc:39
bdm::Scheduler::Restore
bool Restore(uint64_t *steps)
Definition: scheduler.cc:420
bdm::kPostSchedule
@ kPostSchedule
Definition: scheduler.h:43
bdm::Scheduler::op_times_
TimingAggregator op_times_
Tracks operations' execution times.
Definition: scheduler.h:154
diffusion_op.h
bdm::RunAllScheduledOps::scheduled_ops_
std::vector< Operation * > & scheduled_ops_
Definition: scheduler.cc:262
bdm::Scheduler::protected_op_names_
std::vector< std::string > protected_op_names_
List of operations that cannot be affected by the user.
Definition: scheduler.h:146
bdm::Scheduler::~Scheduler
virtual ~Scheduler()
Definition: scheduler.cc:121
bdm::DiffusionGrid::Initialize
virtual void Initialize()
Definition: diffusion_grid.cc:23
bdm::Scheduler::GetOpTimes
TimingAggregator * GetOpTimes()
Definition: scheduler.cc:164
bdm::Scheduler::restore_point_
uint64_t restore_point_
Definition: scheduler.h:127
bdm::real_t
double real_t
Definition: real_t.h:21
scheduler.h
bdm::Scheduler::scheduled_agent_ops_
std::vector< Operation * > scheduled_agent_ops_
List of operations will be executed on all agents.
Definition: scheduler.h:144
bdm::RunAllScheduledOps::operator()
void operator()(Agent *agent, AgentHandle ah) override
Definition: scheduler.cc:257
bdm::kCpu
@ kCpu
Definition: operation.h:30
bdm::SimulationBackup::GetSimulationStepsFromBackup
size_t GetSimulationStepsFromBackup()
Definition: simulation_backup.cc:42
bdm::Scheduler::SimulateUntil
void SimulateUntil(const std::function< bool()> &exit_condition)
Definition: scheduler.cc:145
bdm::DiffusionGrid
Definition: diffusion_grid.h:32
bdm::Scheduler::unschedule_ops_
std::vector< Operation * > unschedule_ops_
List of operations that are to be removed in the upcoming timestep.
Definition: scheduler.h:140
bdm::Scheduler::backup_
SimulationBackup * backup_
Definition: scheduler.h:126
operation_registry.h
bdm::Scheduler::GetListOfScheduledStandaloneOps
std::vector< std::string > GetListOfScheduledStandaloneOps() const
Return a list of StandAloneOperations that are scheduled.
Definition: scheduler.cc:212
simulation_backup.h
bdm::SimulationBackup::RestoreEnabled
bool RestoreEnabled()
Definition: simulation_backup.cc:62
bdm::Agent
Contains code required by all agents.
Definition: agent.h:79
bdm::RunAllScheduledOps
Definition: scheduler.cc:251
bdm::Operation::frequency_
size_t frequency_
Definition: operation.h:195
bdm::Functor
Definition: functor.h:24
bdm::Log::Warning
static void Warning(const std::string &location, const Args &... parts)
Prints warning message.
Definition: log.h:67
bdm::OpType
OpType
Definition: scheduler.h:43
bdm::RootAdaptor
The class that bridges the simulation code with ROOT Visualization.
Definition: adaptor.h:43
bdm::DiffusionGrid::RunInitializers
void RunInitializers()
Initialize the diffusion grid according to the initialization functions.
Definition: diffusion_grid.cc:190
bdm::Param::unschedule_default_operations
std::vector< std::string > unschedule_default_operations
Definition: param.h:99
bdm::Scheduler::scheduled_standalone_ops_
std::vector< Operation * > scheduled_standalone_ops_
List of operations will be executed as a stand-alone operation.
Definition: scheduler.h:142
bdm::Scheduler::ForEachScheduledOperation
void ForEachScheduledOperation(Lambda lambda)
Runs a lambda for each scheduled operation.
Definition: scheduler.h:187
bdm::Operation::name_
std::string name_
Operation name / unique identifier.
Definition: operation.h:197
bdm::Scheduler::Simulate
void Simulate(uint64_t steps)
Simulate steps number of iterations.
Definition: scheduler.cc:130
bdm::Scheduler::GetSimulatedTime
real_t GetSimulatedTime() const
Definition: scheduler.cc:162
bdm::Scheduler::GetAgentFilters
const std::vector< Functor< bool, Agent * > * > & GetAgentFilters() const
Definition: scheduler.cc:247
bdm::Scheduler::SetAgentFilters
void SetAgentFilters(const std::vector< Functor< bool, Agent * > * > &filters)
Definition: scheduler.cc:241
bdm::Scheduler::Scheduler
Scheduler()
Definition: scheduler.cc:36
bdm::Scheduler::all_ops_
std::vector< Operation * > all_ops_
Definition: scheduler.h:136
bdm::kOpenCl
@ kOpenCl
Definition: operation.h:30
bound_space_op.h
visualization_op.h
bdm::Scheduler::UpdateSimulatedTime
void UpdateSimulatedTime()
Definition: scheduler.cc:436
log.h
bdm::Scheduler::GetListOfScheduledAgentOps
std::vector< std::string > GetListOfScheduledAgentOps() const
Return a list of AgentOperations that are scheduled.
Definition: scheduler.cc:204
bdm::RunAllScheduledOps::sim_
Simulation * sim_
Definition: scheduler.cc:261
bdm::kPreSchedule
@ kPreSchedule
Definition: scheduler.h:43
bdm::SimulationBackup
Definition: simulation_backup.h:33
bdm::Simulation::GetExecutionContext
ExecutionContext * GetExecutionContext()
Returns a thread local execution context.
Definition: simulation.cc:288
bdm::Scheduler::agent_filters_
std::vector< Functor< bool, Agent * > * > agent_filters_
Definition: scheduler.h:159
bdm::Scheduler::GetOps
std::vector< Operation * > GetOps(const std::string &name)
Definition: scheduler.cc:220
bdm::NewOperation
Operation * NewOperation(const std::string &name)
A convenient function to get a new operation from the registry by its name.
Definition: operation_registry.h:85
mechanical_forces_op.h
simulation.h
bdm::ProgressBar
Definition: progress_bar.h:23
bdm::Simulation::GetParam
const Param * GetParam() const
Returns the simulation parameters.
Definition: simulation.cc:271
bdm::kCuda
@ kCuda
Definition: operation.h:30
bdm::Scheduler::ScheduleOps
void ScheduleOps()
Definition: scheduler.cc:486
bdm::Scheduler::total_steps_
uint64_t total_steps_
Definition: scheduler.h:115
bdm::Scheduler::simulated_time_
real_t simulated_time_
Definition: scheduler.h:116
bdm::Scheduler::schedule_ops_
std::vector< std::pair< OpType, Operation * > > schedule_ops_
List of operations that are to be added in the upcoming timestep.
Definition: scheduler.h:138
resource_manager.h
param.h
bdm::Simulation::GetActive
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
Definition: simulation.cc:67
bdm::VisualizationOp
Definition: visualization_op.h:26
bdm::Operation
Definition: operation.h:98
bdm::Scheduler::SetUpOps
void SetUpOps()
Definition: scheduler.cc:265
bdm::Scheduler::root_visualization_
RootAdaptor * root_visualization_
Definition: scheduler.h:129
bdm::Scheduler::FinalizeInitialization
void FinalizeInitialization()
Definition: scheduler.cc:155
bdm::Simulation
Definition: simulation.h:50
bdm::Scheduler::ScheduleOp
void ScheduleOp(Operation *op, OpType op_type=OpType::kSchedule)
Definition: scheduler.cc:166
bdm::Scheduler::UnscheduleOp
void UnscheduleOp(Operation *op)
Definition: scheduler.cc:176
bdm::TimingAggregator
Definition: timing_aggregator.h:30
bdm::Scheduler::GetSimulatedSteps
uint64_t GetSimulatedSteps() const
This function returns the numer of simulated steps (=iterations).
Definition: scheduler.cc:160
bdm::ExecutionContext::Execute
virtual void Execute(Agent *agent, AgentHandle ah, const std::vector< Operation * > &operations)=0
bdm::AgentHandle
Definition: agent_handle.h:29