Configuring Execution

The CUDASimulation instance provides a range of configuration options which can be controlled directly in code, or via the command line interface. The below table details the variables available in code, and the arguments available to the command line interface.

Config Variable

Long Argument

Short Argument

Description

input_file

--in <file path>

-i <file path>

Path to a JSON/XML file to read the input state (agent/environment data). See the File Format Guide

step_log_file

--out-step <file path>

n/a

Path to a JSON/XML file to store step logging data.

exit_log_file

--out-exit <file path>

n/a

Path to a JSON/XML file to store exit logging data.

common_log_file

--out-log <file path>

n/a

Path to a JSON/XML file to store both step and exit logging data.

truncate_log_files

n/a

n/a

If true, log files will overwrite any pre-existing file with the same path/name. Default value true.

random_seed

--random <int>

-r <int>

Random seed. Default value is sample from the clock (e.g. it will change each run).

steps

--steps <int>

-s <int>

Number of simulation steps to execute. 0 will run indefinitely, or until an exit function causes the simulation to end. Default value 1.

verbose

--verbose

-v

Enable verbose simulation output to console. Default value false.

timing

--timing

-t

Output simulation timing detail to console. Default value false.

console_mode

--console

-c

Visualisation builds only, disable the visualisation. Default value false.

device_id

--device <device id>

-d <device id>

The CUDA device id of the GPU to use. Default value 0 (Note this is found within CUDASimulation::Config)

inLayerConcurrency

n/a

n/a

Enables the use of concurrency within layers. Default value true. (Note this is found within CUDASimulation::Config)

n/a

--help

-h

Print help for the command line interface and exit.

In order for the command line arguments to be processed argc and argv (Python: argv only) must be passed to initialise().

You may also wish to specify your own defaults, by setting the values prior to calling initialise():

int main(int argc, const char **argv) {

    ...

    // Create a simulation object from the model
    flamegpu::CUDASimulation simulation(model);

    // Change the default config
    simulation.SimulationConfig().random_seed = 12;

    // Initialise the model with the supplied command line parameters
    simulation.initialise(argc, argv);

    // Run the simulation
    simulation.simulate();

    ...

To configure the simulation in code the variables must be updated via the Simulation::Config and CUDASimulation::Config structures, these are accessed via SimulationConfig() and CUDAConfig() respectively on the CUDASimulation instance. Subsequently applyConfig() must be called, to implement any changes to the configuration.

// Create a simulation object from the model
flamegpu::CUDASimulation simulation(model);

// Update the configuration
simulation.SimulationConfig().steps = 100;
simulation.SimulationConfig().input_file = "input.json";
simulation.CUDAConfig().device = 1;

// Apply the updated configuration
simulation.applyConfig();

// Run the simulation
simulation.simulate();