Skip to content

Concurrent Operation

For parameter sweeps involving a large number of simulation tasks, executing them sequentially can be very time-consuming. tricys supports concurrent operation (parallel computing) to fully utilize your computer's multiple CPU cores, significantly reducing the total simulation time.

1. How to Enable Concurrency

Enabling concurrency is very simple. Just set the concurrent flag to true in the simulation section of your configuration file.

{
    "paths": {
        ...
    },
    "simulation": {
        "model_name": "example_model.Cycle",
        ...
        "concurrent": true,
        "max_workers": 4
    },
    "simulation_parameters": {
        "blanket.TBR": "linspace:1:1.5:10"
    }
}

2. Configuration Details

2.1. simulation.concurrent

  • Description: Whether to enable concurrent operation.
  • Type: Boolean (true or false).
  • Default: false.
  • How it works: When set to true, tricys will start a process pool and distribute the simulation tasks (e.g., each run in a parameter sweep) to different processes for parallel execution.

2.2. simulation.max_workers

  • Description: Controls the maximum number of processes (or "workers") used for concurrent execution.
  • Type: Integer (optional).
  • Default: If this parameter is not specified, tricys will default to using all available CPU cores on your machine.
  • Recommendations:
    • For compute-intensive tasks, it is recommended to set this value to no more than the number of physical cores on your machine for optimal performance.
    • If you encounter memory shortage issues during the simulation, you can try lowering the value of max_workers, as each process loads the model independently and consumes a certain amount of memory.

In the example above, "concurrent": true and "max_workers": 4 mean that tricys will create a process pool with 4 worker processes to handle the 10 simulation tasks generated by the parameter sweep in parallel.

Applicable Scenarios

Concurrent operation is not only applicable to standard parameter sweeps but also to Co-Simulation and Automated Analysis workflows, comprehensively improving the execution efficiency of tricys.