BioDynaMo  v1.05.120-25dc9790
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  "continuum"};
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  total_steps_++;
140  Backup();
141  }
142 }
143 
144 void Scheduler::SimulateUntil(const std::function<bool()>& exit_condition) {
145  Initialize();
146  while (!exit_condition()) {
147  Execute();
148  total_steps_++;
150  }
151 }
152 
154  auto* sim = Simulation::GetActive();
155  sim->GetExecutionContext()->SetupIterationAll(sim->GetAllExecCtxts());
156 }
157 
158 uint64_t Scheduler::GetSimulatedSteps() const { return total_steps_; }
159 
161 
163 
165  // Check if operation is already in all_ops_ (could be the case when
166  // trying to reschedule a previously unscheduled operation)
167  if (std::find(all_ops_.begin(), all_ops_.end(), op) == all_ops_.end()) {
168  all_ops_.push_back(op);
169  }
170 
171  schedule_ops_.push_back(std::make_pair(op_type, op));
172 }
173 
175  // We must not unschedule a protected operation
176  if (std::find(protected_op_names_.begin(), protected_op_names_.end(),
177  op->name_) != protected_op_names_.end()) {
178  Log::Warning("Scheduler::UnscheduleOp",
179  "You tried to unschedule the protected operation ", op->name_,
180  "! This request was ignored.");
181  return;
182  }
183 
184  // Check if the requested operation is even scheduled
185  bool not_in_scheduled_ops = true;
186  ForEachOperation([&](Operation* scheduled_op) {
187  if (op == scheduled_op) {
188  not_in_scheduled_ops = false;
189  }
190  });
191 
192  if (not_in_scheduled_ops) {
193  Log::Warning("Scheduler::UnscheduleOp",
194  "You tried to unschedule the non-scheduled operation ",
195  op->name_, "! This request was ignored.");
196  return;
197  }
198 
199  unschedule_ops_.push_back(op);
200 }
201 
202 std::vector<std::string> Scheduler::GetListOfScheduledAgentOps() const {
203  std::vector<std::string> list;
204  for (auto* op : scheduled_agent_ops_) {
205  list.push_back(op->name_);
206  }
207  return list;
208 }
209 
210 std::vector<std::string> Scheduler::GetListOfScheduledStandaloneOps() const {
211  std::vector<std::string> list;
212  for (auto* op : scheduled_standalone_ops_) {
213  list.push_back(op->name_);
214  }
215  return list;
216 }
217 
218 std::vector<Operation*> Scheduler::GetOps(const std::string& name) {
219  std::vector<Operation*> ret;
220 
221  // Check if a protected op is trying to be fetched
222  if (std::find(protected_op_names_.begin(), protected_op_names_.end(), name) !=
223  protected_op_names_.end()) {
224  Log::Warning("Scheduler::GetOps", "The operation '", name,
225  "' is a protected operation. Request ignored.");
226  return ret;
227  }
228 
229  for (auto it = all_ops_.begin(); it != all_ops_.end(); ++it) {
230  if ((*it)->name_ == name) {
231  ret.push_back(*it);
232  }
233  }
234 
235  return ret;
236 }
237 
238 // -----------------------------------------------------------------------------
240  const std::vector<Functor<bool, Agent*>*>& agent_filters) {
241  agent_filters_ = agent_filters;
242 }
243 
244 // -----------------------------------------------------------------------------
245 const std::vector<Functor<bool, Agent*>*>& Scheduler::GetAgentFilters() const {
246  return agent_filters_;
247 }
248 
249 struct RunAllScheduledOps : Functor<void, Agent*, AgentHandle> {
250  explicit RunAllScheduledOps(std::vector<Operation*>& scheduled_ops)
251  : scheduled_ops_(scheduled_ops) {
253  }
254 
255  void operator()(Agent* agent, AgentHandle ah) override {
257  }
258 
260  std::vector<Operation*>& scheduled_ops_;
261 };
262 
265  if (op->frequency_ != 0 && total_steps_ % op->frequency_ == 0) {
266  Timing::Time(op->name_, [&]() { op->SetUp(); });
267  }
268  });
269 }
270 
271 void Scheduler::TearDownOps() {
272  ForEachScheduledOperation([&](Operation* op) {
273  if (op->frequency_ != 0 && total_steps_ % op->frequency_ == 0) {
274  Timing::Time(op->name_, [&]() { op->TearDown(); });
275  }
276  });
277 }
278 
279 void Scheduler::RunPreScheduledOps() const {
280  for (auto* pre_op : pre_scheduled_ops_) {
281  if (pre_op->frequency_ != 0 && total_steps_ % pre_op->frequency_ == 0) {
282  Timing::Time(pre_op->name_, [&]() { (*pre_op)(); });
283  }
284  }
285 }
286 
287 // -----------------------------------------------------------------------------
288 void Scheduler::RunAgentOps(Functor<bool, Agent*>* filter) const {
289  auto* sim = Simulation::GetActive();
290  auto* rm = sim->GetResourceManager();
291  auto* param = sim->GetParam();
292  auto batch_size = param->scheduling_batch_size;
293 
294  std::vector<Operation*> agent_ops;
295  for (auto* op : scheduled_agent_ops_) {
296  if (op->frequency_ != 0 && total_steps_ % op->frequency_ == 0 &&
297  !op->IsExcluded(filter)) {
298  agent_ops.push_back(op);
299  }
300  }
301 
302  const auto& all_exec_ctxts = sim->GetAllExecCtxts();
303  all_exec_ctxts[0]->SetupAgentOpsAll(all_exec_ctxts);
304 
305  if (param->execution_order == Param::ExecutionOrder::kForEachAgentForEachOp) {
306  RunAllScheduledOps functor(agent_ops);
307  Timing::Time("agent ops", [&]() {
308  rm->ForEachAgentParallel(batch_size, functor, filter);
309  });
310  } else {
311  for (auto* op : agent_ops) {
312  decltype(agent_ops) ops = {op};
313  RunAllScheduledOps functor(ops);
314  Timing::Time(op->name_, [&]() {
315  rm->ForEachAgentParallel(batch_size, functor, filter);
316  });
317  }
318  }
319 
320  all_exec_ctxts[0]->TearDownAgentOpsAll(all_exec_ctxts);
321 }
322 
323 // -----------------------------------------------------------------------------
324 void Scheduler::RunScheduledOps() {
325  SetUpOps();
326 
327  // Run the agent operations
328  if (agent_filters_.size() == 0) {
329  RunAgentOps(nullptr);
330  } else {
331  for (auto* filter : agent_filters_) {
332  RunAgentOps(filter);
333  }
334  }
335 
336  // Run the column-wise operations
337  for (auto* op : scheduled_standalone_ops_) {
338  if (op->frequency_ != 0 && total_steps_ % op->frequency_ == 0) {
339  Timing::Time(op->name_, [&]() { (*op)(); });
340  }
341  }
342 
343  TearDownOps();
344 }
345 
346 void Scheduler::RunPostScheduledOps() const {
347  for (auto* post_op : post_scheduled_ops_) {
348  if (post_op->frequency_ != 0 && total_steps_ % post_op->frequency_ == 0) {
349  Timing::Time(post_op->name_, [&]() { (*post_op)(); });
350  }
351  }
352 }
353 
354 void Scheduler::Execute() {
355  auto* param = Simulation::GetActive()->GetParam();
356  if (param->use_progress_bar) {
357  assert(progress_bar_ != nullptr);
358  progress_bar_->Step();
359  progress_bar_->PrintProgressBar();
360  } else if (param->show_simulation_step != 0 &&
361  total_steps_ % param->show_simulation_step == 0) {
362  std::cout << "Time step: " << total_steps_ << std::endl;
363  }
364  ScheduleOps();
365 
366  RunPreScheduledOps();
367  RunScheduledOps();
368  RunPostScheduledOps();
369 }
370 
371 void Scheduler::PrintInfo(std::ostream& out) const {
372  out << "\n" << std::string(80, '-') << "\n\n";
373  out << "Scheduler information:\n";
374  out << std::setw(80) << "frequency"
375  << "\n";
376  out << "Pre-scheduled operations:\n";
377  // pre-scheduled ops
378  for (auto* pre_op : pre_scheduled_ops_) {
379  out << std::setw(60) << pre_op->name_ << std::setw(20) << pre_op->frequency_
380  << "\n";
381  }
382  // agent-operations
383  out << "\nAgent operations:\n";
384  for (auto* op : scheduled_agent_ops_) {
385  out << std::setw(60) << op->name_ << std::setw(20) << op->frequency_
386  << "\n";
387  }
388  out << "\nStandalone operations:\n";
389  for (auto* op : scheduled_standalone_ops_) {
390  out << std::setw(60) << op->name_ << std::setw(20) << op->frequency_
391  << "\n";
392  }
393  // post-scheduled ops
394  out << "\nPost-scheduled operations:\n";
395  for (auto* post_op : post_scheduled_ops_) {
396  out << std::setw(60) << post_op->name_ << std::setw(20)
397  << post_op->frequency_ << "\n";
398  }
399  // unschedule ops
400  if (!unschedule_ops_.empty()) {
401  out << "\nUnschedule operations:\n";
402  for (auto* unschedule_op : unschedule_ops_) {
403  out << std::setw(60) << unschedule_op->name_ << std::setw(20)
404  << unschedule_op->frequency_ << "\n";
405  }
406  }
407  // schedule ops
408  if (!schedule_ops_.empty()) {
409  out << "\nSchedule operations:\n";
410  out << "(0) kSchedule, (1) kPreSchedule, (2) kPostSchedule\n";
411  for (auto schedule_op : schedule_ops_) {
412  out << "(" << schedule_op.first << ")" << std::setw(57)
413  << schedule_op.second->name_ << std::setw(20)
414  << schedule_op.second->frequency_ << "\n";
415  }
416  }
417  out << "\n" << std::string(80, '-') << "\n";
418 }
419 
420 void Scheduler::Backup() {
421  using std::chrono::duration_cast;
422  using std::chrono::seconds;
423  auto* param = Simulation::GetActive()->GetParam();
424  if (backup_->BackupEnabled() &&
425  duration_cast<seconds>(Clock::now() - last_backup_).count() >=
426  param->backup_interval) {
427  last_backup_ = Clock::now();
428  backup_->Backup(total_steps_);
429  }
430 }
431 
435 bool Scheduler::Restore(uint64_t* steps) {
436  if (backup_->RestoreEnabled() && restore_point_ > total_steps_ + *steps) {
437  total_steps_ += *steps;
438  // restore requested, but not last backup was not done during this call to
439  // Simulate. Therefore, we skip it.
440  return true;
441  } else if (backup_->RestoreEnabled() && restore_point_ > total_steps_ &&
442  restore_point_ < total_steps_ + *steps) {
443  // Restore
444  backup_->Restore();
445  *steps = total_steps_ + *steps - restore_point_;
446  total_steps_ = restore_point_;
447  }
448  return false;
449 }
450 
451 void Scheduler::UpdateSimulatedTime() {
452  simulated_time_ += Simulation::GetActive()->GetParam()->simulation_time_step;
453 }
454 
455 // TODO(lukas, ahmad) After https://trello.com/c/0D6sHCK4 has been resolved
456 // think about a better solution, because some operations are executed twice
457 // if Simulate is called with one timestep.
458 void Scheduler::Initialize(uint64_t steps) {
459  auto* sim = Simulation::GetActive();
460  auto* env = sim->GetEnvironment();
461  auto* rm = sim->GetResourceManager();
462  auto* param = sim->GetParam();
463 
464  // commit all changes
465  const auto& all_exec_ctxts = sim->GetAllExecCtxts();
466  all_exec_ctxts[0]->SetupIterationAll(all_exec_ctxts);
467 
468  if (param->bound_space != Param::BoundSpaceMode::kOpen) {
469  auto* bound_space = NewOperation("bound space");
470  rm->ForEachAgentParallel(*bound_space);
471  delete bound_space;
472  }
473 
474  // If users select the progress bar, we create the appropriate object.
475  if (param->use_progress_bar) {
476  delete progress_bar_;
477  progress_bar_ = nullptr;
478  progress_bar_ = new ProgressBar(steps);
479  progress_bar_->SetTimeUnit(param->progress_bar_time_unit);
480  }
481 
482  // Update the uid generator in case the number of threads has changed.
483  sim->GetAgentUidGenerator()->Update();
484 
485  // We force-update the environment in this function because users may apply
486  // certain operations such as shifting them in space in between two Simulate()
487  // or SimulateUntil() calls. In contrast to adding or removing agents, such
488  // an operation would not mark the environment as OutOfSync and hence the
489  // forced update at this place.
490  env->ForcedUpdate();
491  rm->ForEachContinuum([](Continuum* cm) {
492  // Create data structures, whose size depend on the env dimensions
493  cm->Initialize();
494  auto* dgrid = dynamic_cast<DiffusionGrid*>(cm);
495  if (dgrid != nullptr) {
496  // Initialize data structures with user-defined values
497  dgrid->RunInitializers();
498  }
499  });
500 
501  ScheduleOps();
502 }
503 
504 // Schedule the operations
505 void Scheduler::ScheduleOps() {
506  auto* param = Simulation::GetActive()->GetParam();
507  // Add requested operations
508  for (auto it = schedule_ops_.begin(); it != schedule_ops_.end();) {
509  auto op_type = it->first;
510  auto* op = it->second;
511 
512  // Enable GPU operation implementations (if available) if CUDA or OpenCL
513  // flags are set
514  if (param->compute_target == "cuda" &&
515  op->IsComputeTargetSupported(kCuda)) {
516  op->SelectComputeTarget(kCuda);
517  } else if (param->compute_target == "opencl" &&
518  op->IsComputeTargetSupported(kOpenCl)) {
519  op->SelectComputeTarget(kOpenCl);
520  } else {
521  op->SelectComputeTarget(kCpu);
522  }
523 
524  // Check operation type and append to corresponding list
525  switch (op_type) {
526  case kPreSchedule:
527  pre_scheduled_ops_.push_back(op);
528  break;
529  case kPostSchedule:
530  post_scheduled_ops_.push_back(op);
531  break;
532  default:
533  if (op->IsStandalone()) {
534  scheduled_standalone_ops_.push_back(op);
535  } else {
536  scheduled_agent_ops_.push_back(op);
537  }
538  }
539 
540  // Remove operation from schedule_ops_
541  it = schedule_ops_.erase(it);
542  }
543 
544  // Unschedule requested operations
545  for (auto it = unschedule_ops_.begin(); it != unschedule_ops_.end();) {
546  auto* op = *it;
547 
548  // Lists of operations that should be considered for unscheduling
549  std::vector<std::vector<Operation*>*> op_lists = {
550  &scheduled_agent_ops_, &scheduled_standalone_ops_, &pre_scheduled_ops_,
551  &post_scheduled_ops_};
552 
553  for (auto* op_list : op_lists) {
554  for (auto it2 = op_list->begin(); it2 != op_list->end(); ++it2) {
555  if (op == (*it2)) {
556  it2 = op_list->erase(it2);
557  goto LABEL;
558  }
559  }
560  }
561  LABEL:
562  it = unschedule_ops_.erase(it);
563  }
564 }
565 
566 } // 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:420
bdm::kSchedule
@ kSchedule
Definition: scheduler.h:43
adaptor.h
bdm::Scheduler::Initialize
void Initialize(uint64_t steps=0)
Definition: scheduler.cc:458
bdm::Scheduler::Execute
virtual void Execute()
Definition: scheduler.cc:354
bdm::RunAllScheduledOps::RunAllScheduledOps
RunAllScheduledOps(std::vector< Operation * > &scheduled_ops)
Definition: scheduler.cc:250
bdm::Scheduler::progress_bar_
ProgressBar * progress_bar_
Definition: scheduler.h:130
bdm::Scheduler::FinalizeInitialization
void FinalizeInitialization() const
Definition: scheduler.cc:153
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:435
bdm::kPostSchedule
@ kPostSchedule
Definition: scheduler.h:43
bdm::Scheduler::op_times_
TimingAggregator op_times_
Tracks operations' execution times.
Definition: scheduler.h:154
bdm::RunAllScheduledOps::scheduled_ops_
std::vector< Operation * > & scheduled_ops_
Definition: scheduler.cc:260
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::Scheduler::GetOpTimes
TimingAggregator * GetOpTimes()
Definition: scheduler.cc:162
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:255
bdm::kCpu
@ kCpu
Definition: operation.h:31
bdm::Scheduler::SimulateUntil
void SimulateUntil(const std::function< bool()> &exit_condition)
Definition: scheduler.cc:144
bdm::DiffusionGrid
Definition: diffusion_grid.h:90
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
bdm::Continuum
Continuum class to interface with BioDynaMo for hybrid simulations.
Definition: continuum_interface.h:52
operation_registry.h
bdm::Scheduler::GetListOfScheduledStandaloneOps
std::vector< std::string > GetListOfScheduledStandaloneOps() const
Return a list of StandAloneOperations that are scheduled.
Definition: scheduler.cc:210
simulation_backup.h
bdm::Agent
Contains code required by all agents.
Definition: agent.h:79
bdm::RunAllScheduledOps
Definition: scheduler.cc:249
bdm::Operation::frequency_
size_t frequency_
Definition: operation.h:196
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
continuum_op.h
bdm::RootAdaptor
The class that bridges the simulation code with ROOT Visualization.
Definition: adaptor.h:43
bdm::DiffusionGrid::RunInitializers
void RunInitializers()
Definition: diffusion_grid.cc:253
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:198
bdm::Continuum::Initialize
virtual void Initialize()=0
bdm::SimulationBackup::GetSimulationStepsFromBackup
size_t GetSimulationStepsFromBackup() const
Definition: simulation_backup.cc:42
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:160
bdm::Scheduler::GetAgentFilters
const std::vector< Functor< bool, Agent * > * > & GetAgentFilters() const
Definition: scheduler.cc:245
bdm::Scheduler::SetAgentFilters
void SetAgentFilters(const std::vector< Functor< bool, Agent * > * > &filters)
Definition: scheduler.cc:239
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:31
bound_space_op.h
visualization_op.h
bdm::Scheduler::UpdateSimulatedTime
void UpdateSimulatedTime()
Definition: scheduler.cc:451
log.h
bdm::Scheduler::GetListOfScheduledAgentOps
std::vector< std::string > GetListOfScheduledAgentOps() const
Return a list of AgentOperations that are scheduled.
Definition: scheduler.cc:202
bdm::RunAllScheduledOps::sim_
Simulation * sim_
Definition: scheduler.cc:259
bdm::kPreSchedule
@ kPreSchedule
Definition: scheduler.h:43
bdm::SimulationBackup::RestoreEnabled
bool RestoreEnabled() const
Definition: simulation_backup.cc:62
bdm::SimulationBackup
Definition: simulation_backup.h:33
bdm::Simulation::GetExecutionContext
ExecutionContext * GetExecutionContext()
Returns a thread local execution context.
Definition: simulation.cc:271
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:218
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
This class implements a progress bar that can be used to track the progress of a simulation.
Definition: progress_bar.h:40
bdm::Simulation::GetParam
const Param * GetParam() const
Returns the simulation parameters.
Definition: simulation.cc:254
bdm::kCuda
@ kCuda
Definition: operation.h:31
bdm::Scheduler::ScheduleOps
void ScheduleOps()
Definition: scheduler.cc:505
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:68
bdm::VisualizationOp
Definition: visualization_op.h:26
bdm::Operation
Definition: operation.h:99
bdm::Scheduler::SetUpOps
void SetUpOps()
Definition: scheduler.cc:263
bdm::Scheduler::root_visualization_
RootAdaptor * root_visualization_
Definition: scheduler.h:129
bdm::Simulation
Definition: simulation.h:50
bdm::Scheduler::ScheduleOp
void ScheduleOp(Operation *op, OpType op_type=OpType::kSchedule)
Definition: scheduler.cc:164
bdm::Scheduler::UnscheduleOp
void UnscheduleOp(Operation *op)
Definition: scheduler.cc:174
bdm::TimingAggregator
Definition: timing_aggregator.h:30
bdm::Scheduler::GetSimulatedSteps
uint64_t GetSimulatedSteps() const
This function returns the number of simulated steps (=iterations).
Definition: scheduler.cc:158
bdm::ExecutionContext::Execute
virtual void Execute(Agent *agent, AgentHandle ah, const std::vector< Operation * > &operations)=0
bdm::AgentHandle
Definition: agent_handle.h:29