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 |
---|---|---|---|
|
|
|
Path to a JSON/XML file to read the input state (agent/environment data). See the File Format Guide |
|
|
n/a |
Path to a JSON/XML file to store step logging data. |
|
|
n/a |
Path to a JSON/XML file to store exit logging data. |
|
|
n/a |
Path to a JSON/XML file to store both step and exit logging data. |
|
n/a |
n/a |
If true, log files will overwrite any pre-existing file with the same path/name. Default value true. |
|
|
|
Random seed. Default value is sample from the clock (e.g. it will change each run). |
|
|
|
Number of simulation steps to execute. 0 will run indefinitely, or until an exit function causes the simulation to end. Default value 1. |
|
|
|
Don’t print ensemble progress to console. |
|
|
|
Print config, progress and timing (-t) information to console. |
|
|
|
Output simulation timing detail to console. Default value false. |
|
|
|
Silence warnings for unknown arguments passed after this flag. |
|
|
|
Visualisation builds only, disable the visualisation. Default value false. |
|
|
|
The CUDA device id of the GPU to use. Default value 0 (Note this is found within |
|
n/a |
n/a |
Enables the use of concurrency within layers. Default value |
n/a |
|
|
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();
...
# Import sys to access argv
import sys
# Create a simulation object from the model
simulation = pyflamegpu.CUDASimulation(model)
# Change the default config
simulation.SimulationConfig().random_seed = 12;
# Initialise the model with the supplied command line parameters
simulation.initialise(sys.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_id = 1;
// Apply the updated configuration
simulation.applyConfig();
// Run the simulation
simulation.simulate();
# Create a simulation object from the model
simulation = pyflamegpu.CUDASimulation(model)
# Update the configuration
simulation.SimulationConfig().steps = 100
simulation.SimulationConfig().input_file = "input.json"
simulation.CUDAConfig().device_id = 1
# Apply the updated configuration
simulation.applyConfig()
# Run the simulation
simulation.simulate()