Class AbstractSimRunner

Nested Relationships

Nested Types

Inheritance Relationships

Derived Types

Class Documentation

class AbstractSimRunner

Common interface and implementation shared between SimRunner and MPISimRunner

Subclassed by flamegpu::detail::MPISimRunner, flamegpu::detail::SimRunner

Public Functions

AbstractSimRunner(const std::shared_ptr<const ModelData> _model, std::atomic<unsigned int> &_err_ct, std::atomic<unsigned int> &_next_run, const RunPlanVector &_plans, std::shared_ptr<const StepLoggingConfig> _step_log_config, std::shared_ptr<const LoggingConfig> _exit_log_config, int _device_id, unsigned int _runner_id, flamegpu::Verbosity _verbosity, std::map<unsigned int, RunLog> &run_logs, std::queue<unsigned int> &log_export_queue, std::mutex &log_export_queue_mutex, std::condition_variable &log_export_queue_cdn, std::vector<ErrorDetail> &err_detail, unsigned int _total_runners, bool _isSWIG)

Constructor, creates and initialises the underlying thread

Parameters:
  • _model – A copy of the ModelDescription hierarchy for the RunPlanVector, this is used to create the CUDASimulation instances.

  • _err_ct – Reference to an atomic integer for tracking how many errors have occurred

  • _next_run – Atomic counter for safely selecting the next run plan to execute across multiple threads

  • _plans – The vector of run plans to be executed by the ensemble

  • _step_log_config – The config of which data should be logged each step

  • _exit_log_config – The config of which data should be logged at run exit

  • _device_id – The GPU that all runs should execute on

  • _runner_id – A unique index assigned to the runner

  • _verbosity – Verbosity level (Verbosity::Quiet, Verbosity::Default, Verbosity::Verbose)

  • run_logs – Reference to the vector to store generate run logs

  • log_export_queue – The queue of logs to exported to disk

  • log_export_queue_mutex – This mutex must be locked to access log_export_queue

  • log_export_queue_cdn – The condition is notified every time a log has been added to the queue

  • err_detail – Structure to store error details on fast failure for main thread rethrow

  • _total_runners – Total number of runners executing

  • _isSWIG – Flag denoting whether it’s a Python build of FLAMEGPU

inline virtual ~AbstractSimRunner()

Virtual class requires polymorphic destructor

virtual void main() = 0

Subclass implementation of SimRunner

void join()

Blocking call which if thread->joinable() triggers thread->join()

Protected Functions

void runSimulation(int plan_id)

Create and execute the simulation for the RunPlan within plans of given index

Throws:

Exceptions – during sim execution may be raised, these should be caught and handled by the caller

Protected Attributes

std::thread thread

The thread which the SimRunner executes on

const std::shared_ptr<const ModelData> model

Each sim runner takes it’s own clone of model description hierarchy, so it can manipulate environment without conflict

const int device_id

CUDA Device index of runner

const unsigned int runner_id

Per instance unique runner id

const unsigned int total_runners

Total number of runners executing This is used to calculate the progress on job completion

const flamegpu::Verbosity verbosity

Flag for whether to print progress

std::atomic<unsigned int> &err_ct

Reference to an atomic integer for tracking how many errors have occurred

std::atomic<unsigned int> &next_run

Atomic counter for safely selecting the next run plan to execute across multiple threads This is used differently by each class of runner

const RunPlanVector &plans

Reference to the vector of run configurations to be executed

const std::shared_ptr<const StepLoggingConfig> step_log_config

Config specifying which data to log per step

const std::shared_ptr<const LoggingConfig> exit_log_config

Config specifying which data to log at run exit

std::map<unsigned int, RunLog> &run_logs

Reference to the map to store generated run logs

std::queue<unsigned int> &log_export_queue

The queue of logs to exported to disk

std::mutex &log_export_queue_mutex

This mutex must be locked to access log_export_queue

std::condition_variable &log_export_queue_cdn

The condition is notified every time a log has been added to the queue

std::vector<ErrorDetail> &err_detail

Error details will be stored here

const bool isSWIG

If true, the model is using SWIG Python interface

Friends

friend class flamegpu::CUDAEnsemble
struct ErrorDetail

Public Members

unsigned int run_id
unsigned int device_id
unsigned int runner_id
char exception_string[1024]