Loading doc/usermanual/13_faq/07_misc.md +12 −0 Original line number Diff line number Diff line Loading @@ -44,3 +44,15 @@ charge carriers per group can be used to vary the density of lines drawn. Larger *Drift and diffusion visualization of charge carrier groups being transported through a high-resistivity CMOS silicon sensor. The plot shows the situation after an integration time of 20 nanoseconds, only charge carrier groups which reached the implant side of the sensor are drawn.* #### Why does GeometryBuilderGeant4 warn me about reduced performance with disabled multithreading? You might have see this log message: ``` Using Geant4 modules without multithreading might reduce performance when using complex geometries, please check the documentation for details ``` You might want to set `multithreading=true` and `workers=1` instead of instead of `multithreading=false` if this is allowed by the module configuration. The reason behind message this is explained more detailed in [Section 14.1](../14_additional/01_tools.md#geant4-interface). doc/usermanual/14_additional/01_tools.md +14 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,20 @@ The DepositionGeant4 module uses `MTRunManager` to be able to call the `BeamOn` benefiting from the multithreading feature while the VisualizationGeant4 module uses `RunManager` to be able to visualize the particles passage through the detectors. {{% alert title="Note" color="info" %}} The `MTRunManager` significantly reduces Geant4's run initialization time (this happens before every event in Allpix Squared) compared to Geant4's stock run managers (see [Bugzilla/Geant4 2527](https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2527) for details). It is not feasible to implement this improvement in the single-threaded `RunManager` since it directly inherits from Geant4's stock `G4RunManager`. With this run manager, the run initialization time scales with the complexity of the geometry and can - *in the worst case scenario* - take significantly more time than the actual simulation itself. Thus it is recommended to use multithreading when using Geant4 in Allpix Squared if allowed by the module configuration. Allpix Squared allows to use multithreading with only one worker as alternative to `multithreading=false`, though it is suggested to benchmark the performance for both cases to find the optimal setting for the given geometry. {{% /alert %}} ## Runge-Kutta integrator A fast Eigen-powered \[[@eigen3]\] Runge-Kutta integrator is provided as a tool to numerically solve differential equations Loading etc/unittests/test_core/test_06-11_multithreading_oneworkers.conf 0 → 100644 +17 −0 Original line number Diff line number Diff line # SPDX-FileCopyrightText: 2018-2023 CERN and the Allpix Squared authors # SPDX-License-Identifier: MIT #DESC tests the framework response in case too few workers are enabled. [Allpix] detectors_file = "detector.conf" number_of_events = 1 random_seed = 0 purge_output_directory = true deny_overwrite = true log_level = INFO multithreading = true workers = 1 #PASS (WARNING) Using multithreading with only one worker, this might be slower than multithreading=false #LABEL coverage #FAIL FATAL;ERROR etc/unittests/test_core/test_06-4_multithreading_zeroworkers.conf +1 −1 Original line number Diff line number Diff line Loading @@ -12,5 +12,5 @@ log_level = WARNING multithreading = true workers = 0 #PASS (FATAL) Error in the configuration:\nValue 0 of key 'workers' in global section is not valid: number of workers should be larger than one #PASS (FATAL) Error in the configuration:\nValue 0 of key 'workers' in global section is not valid: number of workers should be larger than zero #LABEL coverage src/core/module/ModuleManager.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -567,8 +567,10 @@ void ModuleManager::initialize() { available_hardware_concurrency -= 1u; } number_of_threads_ = global_config.get<unsigned int>("workers", std::max(available_hardware_concurrency, 1u)); if(number_of_threads_ < 2) { throw InvalidValueError(global_config, "workers", "number of workers should be larger than one"); if(number_of_threads_ < 1) { throw InvalidValueError(global_config, "workers", "number of workers should be larger than zero"); } else if(number_of_threads_ == 1) { LOG(WARNING) << "Using multithreading with only one worker, this might be slower than multithreading=false"; } if(number_of_threads_ > std::thread::hardware_concurrency()) { Loading Loading
doc/usermanual/13_faq/07_misc.md +12 −0 Original line number Diff line number Diff line Loading @@ -44,3 +44,15 @@ charge carriers per group can be used to vary the density of lines drawn. Larger *Drift and diffusion visualization of charge carrier groups being transported through a high-resistivity CMOS silicon sensor. The plot shows the situation after an integration time of 20 nanoseconds, only charge carrier groups which reached the implant side of the sensor are drawn.* #### Why does GeometryBuilderGeant4 warn me about reduced performance with disabled multithreading? You might have see this log message: ``` Using Geant4 modules without multithreading might reduce performance when using complex geometries, please check the documentation for details ``` You might want to set `multithreading=true` and `workers=1` instead of instead of `multithreading=false` if this is allowed by the module configuration. The reason behind message this is explained more detailed in [Section 14.1](../14_additional/01_tools.md#geant4-interface).
doc/usermanual/14_additional/01_tools.md +14 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,20 @@ The DepositionGeant4 module uses `MTRunManager` to be able to call the `BeamOn` benefiting from the multithreading feature while the VisualizationGeant4 module uses `RunManager` to be able to visualize the particles passage through the detectors. {{% alert title="Note" color="info" %}} The `MTRunManager` significantly reduces Geant4's run initialization time (this happens before every event in Allpix Squared) compared to Geant4's stock run managers (see [Bugzilla/Geant4 2527](https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2527) for details). It is not feasible to implement this improvement in the single-threaded `RunManager` since it directly inherits from Geant4's stock `G4RunManager`. With this run manager, the run initialization time scales with the complexity of the geometry and can - *in the worst case scenario* - take significantly more time than the actual simulation itself. Thus it is recommended to use multithreading when using Geant4 in Allpix Squared if allowed by the module configuration. Allpix Squared allows to use multithreading with only one worker as alternative to `multithreading=false`, though it is suggested to benchmark the performance for both cases to find the optimal setting for the given geometry. {{% /alert %}} ## Runge-Kutta integrator A fast Eigen-powered \[[@eigen3]\] Runge-Kutta integrator is provided as a tool to numerically solve differential equations Loading
etc/unittests/test_core/test_06-11_multithreading_oneworkers.conf 0 → 100644 +17 −0 Original line number Diff line number Diff line # SPDX-FileCopyrightText: 2018-2023 CERN and the Allpix Squared authors # SPDX-License-Identifier: MIT #DESC tests the framework response in case too few workers are enabled. [Allpix] detectors_file = "detector.conf" number_of_events = 1 random_seed = 0 purge_output_directory = true deny_overwrite = true log_level = INFO multithreading = true workers = 1 #PASS (WARNING) Using multithreading with only one worker, this might be slower than multithreading=false #LABEL coverage #FAIL FATAL;ERROR
etc/unittests/test_core/test_06-4_multithreading_zeroworkers.conf +1 −1 Original line number Diff line number Diff line Loading @@ -12,5 +12,5 @@ log_level = WARNING multithreading = true workers = 0 #PASS (FATAL) Error in the configuration:\nValue 0 of key 'workers' in global section is not valid: number of workers should be larger than one #PASS (FATAL) Error in the configuration:\nValue 0 of key 'workers' in global section is not valid: number of workers should be larger than zero #LABEL coverage
src/core/module/ModuleManager.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -567,8 +567,10 @@ void ModuleManager::initialize() { available_hardware_concurrency -= 1u; } number_of_threads_ = global_config.get<unsigned int>("workers", std::max(available_hardware_concurrency, 1u)); if(number_of_threads_ < 2) { throw InvalidValueError(global_config, "workers", "number of workers should be larger than one"); if(number_of_threads_ < 1) { throw InvalidValueError(global_config, "workers", "number of workers should be larger than zero"); } else if(number_of_threads_ == 1) { LOG(WARNING) << "Using multithreading with only one worker, this might be slower than multithreading=false"; } if(number_of_threads_ > std::thread::hardware_concurrency()) { Loading