Import Geant4 11.0.0.beta source tree
This commit is contained in:
+20
-1
@@ -16,7 +16,26 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
Jan 25th, 2021 Makoto Asai (tasking-V10-06-14)
|
||||
June 6th, 2021 Jonathan Madsen (tasking-V10-07-05)
|
||||
- Check for valid threadPool pointer in
|
||||
G4TaskRunManager::RequestWorkersProcessCommandsStack()
|
||||
(causes seg-fault when ui/viz inited but run not inited)
|
||||
|
||||
May 24th, 2021 Jonathan Madsen (tasking-V10-07-04)
|
||||
- Update to PTL v2.0.0 (shared_ptr usage) included some minor API
|
||||
changes to direct async usage
|
||||
|
||||
May 17th, 2021 Jonathan Madsen (tasking-V10-07-03)
|
||||
- Fixes to TBB task-group usage
|
||||
|
||||
Apr 21st, 2021 Jonathan Madsen (tasking-V10-07-02)
|
||||
- Fix for G4FORCENUMBEROFTHREADS env lookup
|
||||
|
||||
Mar 30th, 2021 Makoto Asai (tasking-V10-07-01)
|
||||
- G4RunManagerFactory : Set default run manager type to Tasking for
|
||||
release 11.0.
|
||||
|
||||
Jan 25th, 2021 Makoto Asai (tasking-V10-07-00)
|
||||
- G4WorkerTaskRunManager.cc : Correct the way to count the number of events
|
||||
processed in a worker thread. This correction also fixes a rare crash due to
|
||||
accessing to the seed vector more than necessary.
|
||||
|
||||
@@ -68,6 +68,7 @@ class G4TaskRunManager
|
||||
, public PTL::TaskRunManager
|
||||
{
|
||||
friend class G4RunManagerFactory;
|
||||
|
||||
public:
|
||||
// the profiler aliases are only used when compiled with GEANT4_USE_TIMEMORY
|
||||
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
|
||||
@@ -75,7 +76,6 @@ class G4TaskRunManager
|
||||
public:
|
||||
using InitializeSeedsCallback = std::function<G4bool(G4int, G4int&, G4int&)>;
|
||||
using RunTaskGroup = G4TaskGroup<void>;
|
||||
using RunTaskGroupTBB = G4TBBTaskGroup<void>;
|
||||
|
||||
public:
|
||||
// Parameters:
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// Class Description:
|
||||
//
|
||||
// This file creates an abstract base class for the grouping the thread-pool
|
||||
// tasking system into independently joinable units
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// Author: Jonathan Madsen (May 28th 2020)
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "PTL/VTaskGroup.hh"
|
||||
|
||||
using G4VTaskGroup = PTL::VTaskGroup;
|
||||
@@ -32,7 +32,6 @@ GEANT4_DEFINE_MODULE(NAME G4tasking
|
||||
G4ThreadData.hh
|
||||
G4ThreadPool.hh
|
||||
G4VTask.hh
|
||||
G4VTaskGroup.hh
|
||||
G4TaskManager.hh
|
||||
G4UserTaskQueue.hh
|
||||
G4VUserTaskQueue.hh
|
||||
|
||||
@@ -172,8 +172,8 @@ std::string G4RunManagerFactory::GetDefault()
|
||||
{
|
||||
#if defined(G4MULTITHREADED)
|
||||
// For version 10.7, default is set to MT
|
||||
// return "Tasking";
|
||||
return "MT";
|
||||
// return "MT";
|
||||
return "Tasking";
|
||||
#else
|
||||
return "Serial";
|
||||
#endif
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "G4WorkerThread.hh"
|
||||
#include "G4UserTaskQueue.hh"
|
||||
#include "G4TiMemory.hh"
|
||||
#include "G4ThreadLocalSingleton.hh"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@@ -87,7 +88,7 @@ G4TaskRunManager::G4TaskRunManager(G4VUserTaskQueue* task_queue, G4bool useTBB,
|
||||
taskQueue = task_queue;
|
||||
|
||||
// override default of 2 from G4MTRunManager
|
||||
nworkers = std::thread::hardware_concurrency();
|
||||
nworkers = G4Threading::G4GetNumberOfCores();
|
||||
fMasterRM = this;
|
||||
MTkernel = static_cast<G4TaskRunManagerKernel*>(kernel);
|
||||
|
||||
@@ -115,13 +116,13 @@ G4TaskRunManager::G4TaskRunManager(G4VUserTaskQueue* task_queue, G4bool useTBB,
|
||||
//------------------------------------------------------------------------//
|
||||
// handle threading
|
||||
//------------------------------------------------------------------------//
|
||||
G4String _nthread_env = G4GetEnv<G4String>("G4FORCENUMBEROFTHREADS", "max");
|
||||
G4String _nthread_env = G4GetEnv<G4String>("G4FORCENUMBEROFTHREADS", "");
|
||||
for(auto& itr : _nthread_env)
|
||||
itr = tolower(itr);
|
||||
|
||||
if(_nthread_env == "max")
|
||||
forcedNwokers = G4Threading::G4GetNumberOfCores();
|
||||
else
|
||||
else if(!_nthread_env.empty())
|
||||
{
|
||||
std::stringstream ss;
|
||||
G4int _nthread_val = -1;
|
||||
@@ -166,15 +167,23 @@ G4TaskRunManager::G4TaskRunManager(G4bool useTBB)
|
||||
|
||||
G4TaskRunManager::~G4TaskRunManager()
|
||||
{
|
||||
if(workTaskGroup)
|
||||
{
|
||||
workTaskGroup->join();
|
||||
delete workTaskGroup;
|
||||
}
|
||||
// finalize profiler before shutting down the threads
|
||||
G4Profiler::Finalize();
|
||||
|
||||
// terminate all the workers
|
||||
G4TaskRunManager::TerminateWorkers();
|
||||
|
||||
// trigger all G4AutoDelete instances
|
||||
G4ThreadLocalSingleton<void>::Clear();
|
||||
|
||||
// delete the task-group
|
||||
delete workTaskGroup;
|
||||
workTaskGroup = nullptr;
|
||||
|
||||
// destroy the thread-pool
|
||||
if(threadPool)
|
||||
threadPool->destroy_threadpool();
|
||||
|
||||
PTL::TaskRunManager::Terminate();
|
||||
}
|
||||
|
||||
@@ -269,19 +278,18 @@ void G4TaskRunManager::InitializeThreadPool()
|
||||
PTL::TaskRunManager::Initialize(nworkers);
|
||||
|
||||
// create the joiners
|
||||
if(threadPool->using_tbb())
|
||||
if(threadPool->is_tbb_threadpool())
|
||||
{
|
||||
G4cout << "G4TaskRunManager :: Using TBB..." << G4endl;
|
||||
if(!workTaskGroup)
|
||||
workTaskGroup = new RunTaskGroupTBB(threadPool);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "G4TaskRunManager :: Using G4ThreadPool..." << G4endl;
|
||||
if(!workTaskGroup)
|
||||
workTaskGroup = new RunTaskGroup(threadPool);
|
||||
}
|
||||
|
||||
if(!workTaskGroup)
|
||||
workTaskGroup = new RunTaskGroup(threadPool);
|
||||
|
||||
G4cout << ss.str() << "\n" << G4endl;
|
||||
}
|
||||
|
||||
@@ -314,11 +322,14 @@ void G4TaskRunManager::ComputeNumberOfTasks()
|
||||
: 1;
|
||||
|
||||
if(eventModuloDef > 0)
|
||||
{ eventModulo = eventModuloDef; }
|
||||
{
|
||||
eventModulo = eventModuloDef;
|
||||
}
|
||||
else
|
||||
{
|
||||
eventModulo = G4int(std::sqrt(G4double(numberOfEventToBeProcessed)));
|
||||
if(eventModulo < 1) eventModulo = 1;
|
||||
if(eventModulo < 1)
|
||||
eventModulo = 1;
|
||||
}
|
||||
if(eventModulo > nEvtsPerTask)
|
||||
{
|
||||
@@ -326,8 +337,9 @@ void G4TaskRunManager::ComputeNumberOfTasks()
|
||||
eventModulo = nEvtsPerTask;
|
||||
|
||||
G4ExceptionDescription msgd;
|
||||
msgd << "Event modulo is reduced to " << eventModulo << " (was "
|
||||
<< oldMod << ")" << " to distribute events to all threads.";
|
||||
msgd << "Event modulo is reduced to " << eventModulo << " (was " << oldMod
|
||||
<< ")"
|
||||
<< " to distribute events to all threads.";
|
||||
G4Exception("G4TaskRunManager::InitializeEventLoop()", "Run10035",
|
||||
JustWarning, msgd);
|
||||
}
|
||||
@@ -773,7 +785,8 @@ void G4TaskRunManager::RequestWorkersProcessCommandsStack()
|
||||
}
|
||||
};
|
||||
|
||||
threadPool->execute_on_all_threads(process_commands_stack);
|
||||
if(threadPool)
|
||||
threadPool->execute_on_all_threads(process_commands_stack);
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
|
||||
@@ -137,8 +137,8 @@ void G4TaskRunManagerKernel::InitializeWorker()
|
||||
if(G4MTRunManager::GetMasterThreadId() == G4ThisThread::get_id())
|
||||
{
|
||||
G4TaskManager* taskManager = mrm->GetTaskManager();
|
||||
std::future<void> _fut = taskManager->async(InitializeWorker);
|
||||
_fut.wait();
|
||||
auto _fut = taskManager->async(InitializeWorker);
|
||||
_fut->wait();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ void G4TaskRunManagerKernel::ExecuteWorkerInit()
|
||||
G4TaskManager* taskManager =
|
||||
G4TaskRunManager::GetMasterRunManager()->GetTaskManager();
|
||||
auto _fut = taskManager->async(ExecuteWorkerInit);
|
||||
return _fut.get();
|
||||
return _fut->get();
|
||||
}
|
||||
|
||||
// this check is for TBB as there is not a way to run an initialization
|
||||
@@ -261,7 +261,7 @@ void G4TaskRunManagerKernel::ExecuteWorkerTask()
|
||||
G4TaskManager* taskManager =
|
||||
G4TaskRunManager::GetMasterRunManager()->GetTaskManager();
|
||||
auto _fut = taskManager->async(ExecuteWorkerTask);
|
||||
return _fut.get();
|
||||
return _fut->get();
|
||||
}
|
||||
|
||||
// this check is for TBB as there is not a way to run an initialization
|
||||
|
||||
@@ -223,9 +223,11 @@ void G4WorkerTaskRunManager::DoEventLoop(G4int n_event, const char* macroFile,
|
||||
if(eventLoopOnGoing)
|
||||
{
|
||||
TerminateOneEvent();
|
||||
if(runAborted) eventLoopOnGoing = false;
|
||||
if(runAborted)
|
||||
eventLoopOnGoing = false;
|
||||
}
|
||||
if(!eventLoopOnGoing) break;
|
||||
if(!eventLoopOnGoing)
|
||||
break;
|
||||
}
|
||||
|
||||
// TerminateEventLoop();
|
||||
|
||||
Reference in New Issue
Block a user