.. _Configuring Execution: Configuring Execution ===================== The :class:`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 `` ``-i `` Path to a JSON/XML file to read the input state (agent/environment data). See the :ref:`File Format Guide` ``step_log_file`` ``--out-step `` n/a Path to a JSON/XML file to store step logging data. ``exit_log_file`` ``--out-exit `` n/a Path to a JSON/XML file to store exit logging data. ``common_log_file`` ``--out-log `` 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 `` ``-r `` Random seed. Default value is sample from the clock (e.g. it will change each run). ``steps`` ``--steps `` ``-s `` Number of simulation steps to execute. 0 will run indefinitely, or until an exit function causes the simulation to end. Default value 1. ``quiet`` ``--quiet`` ``-q`` Don't print ensemble progress to console. ``verbose`` ``--verbose`` ``-v`` Print config, progress and timing (-t) information to console. ``timing`` ``--timing`` ``-t`` Output simulation timing detail to console. Default value false. ``unknown args`` ``--silence-unknown-args`` ``-u`` Silence warnings for unknown arguments passed after this flag. ``console_mode`` ``--console`` ``-c`` Visualisation builds only, disable the visualisation. Default value false. ``device_id`` ``--device `` ``-d `` The CUDA device id of the GPU to use. Default value 0 (Note this is found within :class:`CUDASimulation::Config`) ``inLayerConcurrency`` n/a n/a Enables the use of concurrency within layers. Default value ``true``. (Note this is found within :class:`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 :func:`initialise()`. You may also wish to specify your own defaults, by setting the values prior to calling :func:`initialise()`: .. tabs:: .. code-tab:: cpp C++ 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(); ... .. code-tab:: py Python # 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 :class:`Simulation::Config` and :class:`CUDASimulation::Config` structures, these are accessed via :func:`SimulationConfig()` and :func:`CUDAConfig()` respectively on the :class:`CUDASimulation` instance. Subsequently :func:`applyConfig()` must be called, to implement any changes to the configuration. .. tabs:: .. code-tab:: cpp C++ // 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(); .. code-tab:: py Python # 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() Related Links ------------- * User Guide: :ref:`Initial State From File` * Full API documentation for :class:`CUDASimulation` * Full API documentation for :class:`Simulation` * Full API documentation for :class:`Simulation::Config` * Full API documentation for :class:`CUDASimulation::Config`