Unverified Commit 1800fa6d authored by Stephan Lachnit's avatar Stephan Lachnit
Browse files

ModuleManager: allow multithreading with one worker

parent 02017068
Loading
Loading
Loading
Loading
+18 −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 (INFO) Using multithreading with only one worker, this might be slower than multithreading=false
#LABEL coverage
#FAIL ERROR
#FAIL FATAL
+1 −1
Original line number Diff line number Diff line
@@ -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
+4 −2
Original line number Diff line number Diff line
@@ -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()) {