44static void fail(
const std::string& _prefix,
const std::string& _name,
45 const std::set<std::string>& _opts,
G4int _num)
48 msg << _prefix <<
": \"" << _name <<
"\". "
49 <<
"Must be one of: ";
51 for (
const auto& itr : _opts)
52 ss <<
", \"" << itr <<
"\"";
53 msg << ss.str().substr(2);
54 auto mnum = std::string(
"RunManagerFactory000") + std::to_string(_num);
70 std::string rm_type =
GetName(_type);
76 fail_if_unavail =
true;
85 "Overriding G4RunManager type...");
89 if (force_rm.length() > 0) {
90 rm_type = std::move(force_rm);
91 fail_if_unavail =
true;
93 else if (rm_type.empty()) {
102 if (opts.find(rm_type) == opts.end()) {
103 if (fail_if_unavail) {
104 fail(
"Run manager type is not available", rm_type, opts, 1);
120#if defined(G4MULTITHREADED)
125#if defined(G4MULTITHREADED)
130#if defined(G4MULTITHREADED) && defined(GEANT4_USE_TBB)
135#if defined(G4MULTITHREADED)
136#if defined(GEANT4_USE_TBB)
158 if (rm ==
nullptr) fail(
"Failure creating run manager",
GetName(_type),
GetOptions(), 2);
163 master_run_manager = rm;
164 mt_master_run_manager = mtrm;
165 master_run_manager_kernel = rm->
kernel;
175#if defined(G4MULTITHREADED)
186 static auto _instance = []() {
187 std::set<std::string> options = {
"Serial"};
188#if defined(G4MULTITHREADED)
189 options.insert({
"MT",
"Tasking"});
190# if defined(GEANT4_USE_TBB)
191 options.insert(
"TBB");
193 options.insert(
"SubEvt");
205 static const auto opts = std::regex::icase;
251#if !defined(G4MULTITHREADED)
256 if (master_run_manager !=
nullptr)
return master_run_manager;
261 if (mt_rm !=
nullptr)
return mt_rm;
273#if defined(G4MULTITHREADED)
275 if (mt_master_run_manager !=
nullptr)
return mt_master_run_manager;
280 if (task_rm !=
nullptr)
return task_rm;
292#if !defined(G4MULTITHREADED)
297 if (master_run_manager_kernel !=
nullptr)
return master_run_manager_kernel;
302 if (mt_rm !=
nullptr)
return mt_rm->kernel;
_Tp G4GetEnv(const std::string &env_id, _Tp _default=_Tp())
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
PTL::VUserTaskQueue G4VUserTaskQueue
void SetNumberOfThreads(G4int n) override
static G4MTRunManager * GetMasterRunManager()
static G4RunManager * CreateRunManager(G4RunManagerType _type=G4RunManagerType::Default, G4VUserTaskQueue *_queue=nullptr, G4bool fail_if_unavail=true, G4int nthreads=0)
static G4RunManager * GetMasterRunManager()
static G4MTRunManager * GetMTMasterRunManager()
static std::set< std::string > GetOptions()
static std::string GetName(G4RunManagerType)
static std::string GetDefault()
static G4RunManagerType GetType(const std::string &)
static G4RunManagerKernel * GetMasterRunManagerKernel()
G4RunManagerKernel * kernel
static G4RunManager * GetRunManager()
static G4TaskRunManager * GetMasterRunManager()
G4bool IsMultithreadedApplication()
void G4ConsumeParameters(_Args &&...)