Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -19,6 +19,9 @@ include $(G4INSTALL)/config/architecture.gmk
|
||||
ifdef G4FPE_DEBUG
|
||||
CPPFLAGS += -DG4FPE_DEBUG
|
||||
endif
|
||||
ifdef G4BT_DEBUG
|
||||
CPPFLAGS += -DG4BT_DEBUG
|
||||
endif
|
||||
|
||||
CPPFLAGS += -DG4RUN_ALLOC_EXPORT
|
||||
CPPFLAGS += \
|
||||
|
||||
+53
-14
@@ -16,19 +16,58 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
June 17th Gunter Folger, included in run-V10-06-07
|
||||
- Fixes for windows.
|
||||
- G4MTRunManager:
|
||||
- inline static functions split into declaration and definition:
|
||||
GetMasterThreadId(), GetMasterScoringManager(), GetMasterWorlds(),
|
||||
addWorld(), SetSeedOncePerCommunication(), SetSeedOncePerCommunication()
|
||||
- add GetMasterTheadId()
|
||||
- G4RunManager:
|
||||
- impot/export static fGeometryHasBeenDestroyed using G4RUN_DLL, add
|
||||
include for rundef.hh
|
||||
|
||||
|
||||
June 4th, 2020 J.Madsen (run-V10-06-07)
|
||||
November 21, 2020 Gabriele Cosmo (run-V10-06-19)
|
||||
- Fixed compilation warnings in G4RunManager.
|
||||
|
||||
November 18, 2020 Jonathan Madsen (run-V10-06-18)
|
||||
- Added G4Profiler support.
|
||||
- Removed TIMEMORY_AUTO_TIMER.
|
||||
|
||||
November 17, 2020 G.Cosmo (run-V10-06-17)
|
||||
- Protect activation of G4BackTrace within G4BT_DEBUG flag in
|
||||
G4RunManagerKernel.
|
||||
|
||||
November 16, 2020 G.Cosmo (run-V10-06-16)
|
||||
- Fixed typos in printed-out text. Addressing problem report #2285.
|
||||
|
||||
October 20th, 2020 Jonathan Madsen (run-V10-06-15)
|
||||
- Run-managers are friends of G4RunManagerFactory.
|
||||
|
||||
October 20th, 2020 Jonathan Madsen (run-V10-06-14)
|
||||
- Added activation of G4Backtrace to G4RunManagerKernel.
|
||||
|
||||
October 9th, 2020 Makoto Asai (run-V10-06-13)
|
||||
- Added protection for Windows on G4RunManager::GetRunManager()->rndmSaveThisEvent().
|
||||
|
||||
October 5th, 2020 Makoto Asai (run-V10-06-12)
|
||||
- Fix the issue of G4RunManager::GetRunManager()->rndmSaveThisEvent() not working
|
||||
in multithreaded mode. Addresses to Bug Report #2278.
|
||||
|
||||
September 29th, 2020 Anna Zaborowska (run-V10-06-11)
|
||||
- Bug fix for bug #2276: /random/setSeeds parses arguments to int instead of long
|
||||
|
||||
September 27th Vladimir Ivanchenko (run-V10-06-10)
|
||||
- G4VModularPhysicsList - fixed typos in printouts
|
||||
|
||||
September 21st Jonathan Madsen (run-V10-06-09)
|
||||
- Added checks for currentRun before calling routines with currentRun
|
||||
- G4MTRunManager:
|
||||
- added banner similar to G4TaskRunManager at CreateAndStartWorkers
|
||||
- moved master scoring-manager, master worlds, fMasterRM from private to protected
|
||||
|
||||
June 30th Gabriele Cosmo (run-V10-06-08)
|
||||
- Added dummy virtual methods Get/SetNumberOfThreads() in G4RunManager to
|
||||
allow dispatching to inheriting MT/Tasking classes.
|
||||
|
||||
June 17th Gunter Folger (run-V10-06-07)
|
||||
- Fixes for Windows DLLs. In G4MTRunManager: split inline static functions into
|
||||
declaration and definition: GetMasterThreadId(), GetMasterScoringManager(),
|
||||
GetMasterWorlds(), addWorld(), SetSeedOncePerCommunication(),
|
||||
SetSeedOncePerCommunication(); added GetMasterTheadId().
|
||||
In G4RunManager: import/export static 'fGeometryHasBeenDestroyed' using
|
||||
G4RUN_DLL, and include for rundefs.hh
|
||||
|
||||
June 4th, 2020 J.Madsen
|
||||
- Minor class access changes in G4MTRunManager to enable inheritance
|
||||
for G4TaskRunManager
|
||||
June 17th Gunter Folger, included in the above tag
|
||||
@@ -53,7 +92,7 @@ April 9th, 2020 M.Asai (run-V10-06-02)
|
||||
option for the new "probe" scoring mesh.
|
||||
|
||||
February 18th, 2020 V.Ivanchenko (run-V10-06-01)
|
||||
- G4RunManager - does not call G4ParticleTable for Messenger
|
||||
- G4RunManager - does not call G4ParticleTable for Messenger
|
||||
deletion
|
||||
|
||||
December 9th, 2019 B. Morgan (run-V10-06-00)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "G4RNGHelper.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Threading.hh"
|
||||
#include "G4Profiler.hh"
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
@@ -45,11 +46,18 @@ class G4MTRunManagerKernel;
|
||||
class G4ScoringManager;
|
||||
class G4UserWorkerInitialization;
|
||||
class G4UserWorkerThreadInitialization;
|
||||
class G4RunManagerFactory;
|
||||
|
||||
// TODO: Split random number storage from this class
|
||||
|
||||
class G4MTRunManager : public G4RunManager
|
||||
{
|
||||
friend class G4RunManagerFactory;
|
||||
|
||||
public:
|
||||
// the profiler aliases are only used when compiled with GEANT4_USE_TIMEMORY
|
||||
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
|
||||
|
||||
public:
|
||||
G4MTRunManager();
|
||||
virtual ~G4MTRunManager();
|
||||
@@ -100,6 +108,8 @@ class G4MTRunManager : public G4RunManager
|
||||
// Adds one seed to the list of seeds
|
||||
virtual void PrepareCommandsStack();
|
||||
virtual void StoreRNGStatus(const G4String& filenamePrefix);
|
||||
virtual void rndmSaveThisRun();
|
||||
virtual void rndmSaveThisEvent();
|
||||
virtual void CreateAndStartWorkers();
|
||||
// Creates worker threads and signal to start
|
||||
public:
|
||||
@@ -175,12 +185,14 @@ class G4MTRunManager : public G4RunManager
|
||||
return masterRNGEngine;
|
||||
}
|
||||
|
||||
private:
|
||||
protected:
|
||||
// Handling of master thread scoring worlds, access to it is needed by workers
|
||||
static G4ScoringManager* masterScM;
|
||||
static masterWorlds_t masterWorlds;
|
||||
G4MTRUN_DLL static G4ScoringManager* masterScM;
|
||||
G4MTRUN_DLL static masterWorlds_t masterWorlds;
|
||||
// Singleton implementing master thread behavior
|
||||
static G4MTRunManager* fMasterRM;
|
||||
G4MTRUN_DLL static G4MTRunManager* fMasterRM;
|
||||
|
||||
private:
|
||||
G4MTRunManagerKernel* MTkernel;
|
||||
|
||||
public: // with description
|
||||
|
||||
@@ -30,7 +30,10 @@
|
||||
#define G4Run_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4Profiler.hh"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class G4Event;
|
||||
class G4HCtable;
|
||||
class G4DCtable;
|
||||
@@ -44,6 +47,9 @@ class G4DCtable;
|
||||
|
||||
class G4Run
|
||||
{
|
||||
public:
|
||||
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
|
||||
|
||||
public:
|
||||
G4Run();
|
||||
virtual ~G4Run();
|
||||
|
||||
@@ -131,12 +131,20 @@ class G4PrimaryTransformer;
|
||||
#include "G4Event.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4RunManagerKernel.hh"
|
||||
#include "G4Profiler.hh"
|
||||
#include "globals.hh"
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
|
||||
class G4RunManagerFactory;
|
||||
|
||||
class G4RunManager
|
||||
{
|
||||
friend class G4RunManagerFactory;
|
||||
public:
|
||||
// the profiler aliases are only used when compiled with GEANT4_USE_TIMEMORY
|
||||
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
|
||||
|
||||
public: // with description
|
||||
static G4RunManager* GetRunManager();
|
||||
// Static method which returns the singleton pointer of G4RunManager or
|
||||
@@ -265,6 +273,17 @@ class G4RunManager
|
||||
// G4VPersistentManager
|
||||
// class is defined.
|
||||
|
||||
virtual void ConfigureProfilers(const std::vector<std::string>& args = {});
|
||||
// This method configures the global fallback query and label generators
|
||||
|
||||
void ConfigureProfilers(int argc, char** argv);
|
||||
// calls the above virtual method
|
||||
|
||||
virtual void SetNumberOfThreads(G4int) {}
|
||||
virtual G4int GetNumberOfThreads() const { return 1; }
|
||||
// Dummy methods to dispatch generic inheritance calls from G4RunManager
|
||||
// base class.
|
||||
|
||||
public: // with description
|
||||
//////////////////////////////////////////////////////void UpdateRegion();
|
||||
// Update region list.
|
||||
@@ -690,6 +709,9 @@ class G4RunManager
|
||||
{
|
||||
geometryDirectlyUpdated = val;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<ProfilerConfig> masterRunProfiler;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -219,7 +219,7 @@ class G4VUserPhysicsList
|
||||
|
||||
// Store PhysicsTable together with both material and cut value
|
||||
// information in files under the specified directory.
|
||||
// (return true if files are sucessfully created)
|
||||
// (return true if files are successfully created)
|
||||
G4bool StorePhysicsTable(const G4String& directory = ".");
|
||||
|
||||
// Return true if "Retrieve" flag is ON.
|
||||
|
||||
@@ -46,6 +46,9 @@ class G4WorkerRunManagerKernel;
|
||||
|
||||
class G4WorkerRunManager : public G4RunManager
|
||||
{
|
||||
public:
|
||||
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
|
||||
|
||||
public:
|
||||
static G4WorkerRunManager* GetWorkerRunManager();
|
||||
static G4WorkerRunManagerKernel* GetWorkerRunManagerKernel();
|
||||
@@ -76,6 +79,8 @@ class G4WorkerRunManager : public G4RunManager
|
||||
protected:
|
||||
virtual void ConstructScoringWorlds();
|
||||
virtual void StoreRNGStatus(const G4String& filenamePrefix);
|
||||
virtual void rndmSaveThisRun();
|
||||
virtual void rndmSaveThisEvent();
|
||||
virtual void MergePartialResults();
|
||||
// This method will merge (reduce) the results of this run into the
|
||||
// global run
|
||||
@@ -115,6 +120,9 @@ class G4WorkerRunManager : public G4RunManager
|
||||
G4SeedsQueue seedsQueue;
|
||||
G4bool readStatusFromFile;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ProfilerConfig> workerRunProfiler;
|
||||
|
||||
public:
|
||||
virtual void RestoreRndmEachEvent(G4bool flag) { readStatusFromFile = flag; }
|
||||
};
|
||||
|
||||
@@ -47,4 +47,14 @@
|
||||
# define G4RUN_DLL
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && defined(G4LIB_BUILD_DLL)
|
||||
# if defined G4RUN_ALLOC_EXPORT
|
||||
# define G4MTRUN_DLL __declspec(dllexport)
|
||||
# else
|
||||
# define G4MTRUN_DLL __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define G4MTRUN_DLL
|
||||
#endif
|
||||
|
||||
#endif /* G4RUNDEFS_HH */
|
||||
|
||||
@@ -16,12 +16,12 @@ geant4_define_module(NAME G4run
|
||||
G4MatScanMessenger.hh
|
||||
G4MaterialScanner.hh
|
||||
G4PhysicsListHelper.hh
|
||||
G4PhysicsListOrderingParameter.hh
|
||||
G4PhysicsListOrderingParameter.hh
|
||||
G4PhysicsListWorkspace.hh
|
||||
G4Run.hh
|
||||
G4RunManager.hh
|
||||
G4MTRunManager.hh
|
||||
G4WorkerRunManager.hh
|
||||
G4MTRunManager.hh
|
||||
G4WorkerRunManager.hh
|
||||
G4RunManagerKernel.hh
|
||||
G4MTRunManagerKernel.hh
|
||||
G4WorkerRunManagerKernel.hh
|
||||
@@ -42,7 +42,7 @@ geant4_define_module(NAME G4run
|
||||
G4WorkerThread.hh
|
||||
G4VUPLSplitter.hh
|
||||
rundefs.hh
|
||||
G4RNGHelper.hh
|
||||
G4RNGHelper.hh
|
||||
G4PhysicsBuilderInterface.hh
|
||||
SOURCES
|
||||
G4AdjointPrimaryGeneratorAction.cc
|
||||
@@ -52,13 +52,13 @@ geant4_define_module(NAME G4run
|
||||
G4MSSteppingAction.cc
|
||||
G4MatScanMessenger.cc
|
||||
G4MaterialScanner.cc
|
||||
G4PhysicsListHelper.cc
|
||||
G4PhysicsListOrderingParamater.cc
|
||||
G4PhysicsListHelper.cc
|
||||
G4PhysicsListOrderingParamater.cc
|
||||
G4PhysicsListWorkspace.cc
|
||||
G4Run.cc
|
||||
G4RunManager.cc
|
||||
G4MTRunManager.cc
|
||||
G4WorkerRunManager.cc
|
||||
G4MTRunManager.cc
|
||||
G4WorkerRunManager.cc
|
||||
G4RunManagerKernel.cc
|
||||
G4MTRunManagerKernel.cc
|
||||
G4WorkerRunManagerKernel.cc
|
||||
@@ -76,7 +76,7 @@ geant4_define_module(NAME G4run
|
||||
G4VPhysicsConstructor.cc
|
||||
G4VUserPhysicsList.cc
|
||||
G4VUserPrimaryGeneratorAction.cc
|
||||
G4WorkerThread.cc
|
||||
G4WorkerThread.cc
|
||||
G4RNGHelper.cc
|
||||
GRANULAR_DEPENDENCIES
|
||||
G4cuts
|
||||
@@ -122,3 +122,6 @@ geant4_define_module(NAME G4run
|
||||
)
|
||||
|
||||
# List any source specific properties here
|
||||
if(GEANT4_BUILD_BUILTIN_BACKTRACE)
|
||||
geant4_module_compile_definitions(G4run PRIVATE G4BT_DEBUG)
|
||||
endif()
|
||||
|
||||
@@ -137,7 +137,7 @@ G4MTRunManager::G4MTRunManager()
|
||||
G4ExceptionDescription msg1;
|
||||
msg1 << "There are " << numberOfStaticAllocators
|
||||
<< " static G4Allocator objects detected.\n"
|
||||
<< "In multi-threaded mode, all G4Allocator objects must be dynamicly "
|
||||
<< "In multi-threaded mode, all G4Allocator objects must be dynamically "
|
||||
"instantiated.";
|
||||
G4Exception("G4MTRunManager::G4MTRunManager", "Run1035", FatalException,
|
||||
msg1);
|
||||
@@ -209,6 +209,41 @@ void G4MTRunManager::StoreRNGStatus(const G4String& fn)
|
||||
G4Random::saveEngineStatus(os.str().c_str());
|
||||
}
|
||||
|
||||
void G4MTRunManager::rndmSaveThisRun()
|
||||
{
|
||||
G4int runNumber = 0;
|
||||
if(currentRun) runNumber = currentRun->GetRunID();
|
||||
if(!storeRandomNumberStatus)
|
||||
{
|
||||
G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
|
||||
<< " Random number status was not stored prior to this run."
|
||||
<< G4endl << "/random/setSavingFlag command must be issued. "
|
||||
<< "Command ignored." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
G4String fileIn = randomNumberStatusDir + "G4Worker_currentRun.rndm";
|
||||
|
||||
std::ostringstream os;
|
||||
os << "run" << runNumber << ".rndm" << '\0';
|
||||
G4String fileOut = randomNumberStatusDir + os.str();
|
||||
|
||||
#ifdef WIN32
|
||||
G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
|
||||
#else
|
||||
G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
|
||||
#endif
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
|
||||
if(verboseLevel > 0)
|
||||
{ G4cout << fileIn << " is copied to " << fileOut << G4endl; }
|
||||
}
|
||||
|
||||
void G4MTRunManager::rndmSaveThisEvent()
|
||||
{
|
||||
G4Exception("G4MTRunManager::rndmSaveThisEvent","RUN_RNDM001",
|
||||
FatalException,"This method shall not be invoked !!");
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetNumberOfThreads(G4int n)
|
||||
{
|
||||
if(threads.size() != 0)
|
||||
@@ -284,6 +319,22 @@ void G4MTRunManager::CreateAndStartWorkers()
|
||||
// number of threads: threads area created once
|
||||
if(threads.size() == 0)
|
||||
{
|
||||
{
|
||||
// for consistency with G4TaskRunManager
|
||||
std::stringstream msg;
|
||||
msg << "--> G4MTRunManager::CreateAndStartWorkers() --> "
|
||||
<< "Initializing workers...";
|
||||
|
||||
std::stringstream ss;
|
||||
ss.fill('=');
|
||||
ss << std::setw(msg.str().length()) << "";
|
||||
G4cout << "\n"
|
||||
<< ss.str() << "\n"
|
||||
<< msg.str() << "\n"
|
||||
<< ss.str() << "\n"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
for(G4int nw = 0; nw < nworkers; ++nw)
|
||||
{
|
||||
// Create a new worker and remember it
|
||||
@@ -302,7 +353,6 @@ void G4MTRunManager::CreateAndStartWorkers()
|
||||
void G4MTRunManager::InitializeEventLoop(G4int n_event, const char* macroFile,
|
||||
G4int n_select)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
MTkernel->SetUpDecayChannels();
|
||||
numberOfEventToBeProcessed = n_event;
|
||||
numberOfEventProcessed = 0;
|
||||
@@ -617,6 +667,8 @@ void G4MTRunManager::TerminateWorkers()
|
||||
RequestWorkersProcessCommandsStack();
|
||||
// Ask workers to exit
|
||||
NewActionRequest(WorkerActionRequest::ENDWORKER);
|
||||
// finalize profiler before shutting down the threads
|
||||
G4Profiler::Finalize();
|
||||
// Now join threads.
|
||||
#ifdef G4MULTITHREADED // protect here to prevent warning in compilation
|
||||
while(!threads.empty())
|
||||
|
||||
@@ -330,7 +330,7 @@ void G4PhysicsListHelper::ReadOrdingParameterTable()
|
||||
}
|
||||
#endif
|
||||
G4Exception("G4PhysicsListHelper::ReadOrdingParameterTable", "Run0105",
|
||||
JustWarning, "Fail to open ordering paramter table ");
|
||||
JustWarning, "Fail to open ordering parameter table ");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -540,7 +540,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
|
||||
G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
|
||||
<< particle->GetParticleName() << " with type/subtype =" << pType
|
||||
<< "/" << pSubType
|
||||
<< " is not reigstered in OrdingParameterTable " << G4endl;
|
||||
<< " is not registered in OrdingParameterTable " << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4Exception("G4PhysicsListHelper::RegisterProcess", "Run0109",
|
||||
@@ -629,7 +629,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
|
||||
G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
|
||||
<< particle->GetParticleName() << " with type/subtype =" << pType
|
||||
<< "/" << pSubType
|
||||
<< " is sucessfully registered with ordering parameters " << ord[0]
|
||||
<< " is successfully registered with ordering parameters " << ord[0]
|
||||
<< ":" << ord[1] << ":" << ord[2] << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
+224
-25
@@ -61,6 +61,8 @@
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4TiMemory.hh"
|
||||
#include "G4Profiler.hh"
|
||||
#include <sstream>
|
||||
|
||||
using namespace CLHEP;
|
||||
@@ -230,10 +232,13 @@ G4RunManager::G4RunManager(RMType rmType)
|
||||
G4Random::saveFullState(oss);
|
||||
randomNumberStatusForThisRun = oss.str();
|
||||
randomNumberStatusForThisEvent = oss.str();
|
||||
ConfigureProfilers();
|
||||
}
|
||||
|
||||
G4RunManager::~G4RunManager()
|
||||
{
|
||||
// finalize profiler before shutting down the threads
|
||||
G4Profiler::Finalize();
|
||||
G4StateManager* pStateManager = G4StateManager::GetStateManager();
|
||||
// set the application state to the quite state
|
||||
if(pStateManager->GetCurrentState() != G4State_Quit)
|
||||
@@ -320,7 +325,6 @@ void G4RunManager::DeleteUserInitializations()
|
||||
|
||||
void G4RunManager::BeamOn(G4int n_event, const char* macroFile, G4int n_select)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
if(n_event <= 0)
|
||||
{
|
||||
fakeRun = true;
|
||||
@@ -381,7 +385,6 @@ void G4RunManager::RunInitialization()
|
||||
if(!(kernel->RunInitialization(fakeRun)))
|
||||
return;
|
||||
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
runAborted = false;
|
||||
numberOfEventProcessed = 0;
|
||||
|
||||
@@ -435,6 +438,10 @@ void G4RunManager::RunInitialization()
|
||||
if(userRunAction)
|
||||
userRunAction->BeginOfRunAction(currentRun);
|
||||
|
||||
#if defined(GEANT4_USE_TIMEMORY)
|
||||
masterRunProfiler.reset(new ProfilerConfig(currentRun));
|
||||
#endif
|
||||
|
||||
if(isScoreNtupleWriter)
|
||||
{
|
||||
G4VScoreNtupleWriter::Instance()->OpenFile();
|
||||
@@ -456,7 +463,6 @@ void G4RunManager::RunInitialization()
|
||||
void G4RunManager::DoEventLoop(G4int n_event, const char* macroFile,
|
||||
G4int n_select)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
InitializeEventLoop(n_event, macroFile, n_select);
|
||||
|
||||
// Event loop
|
||||
@@ -500,7 +506,6 @@ void G4RunManager::InitializeEventLoop(G4int n_event, const char* macroFile,
|
||||
|
||||
void G4RunManager::ProcessOneEvent(G4int i_event)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
currentEvent = GenerateEvent(i_event);
|
||||
eventManager->ProcessOneEvent(currentEvent);
|
||||
AnalyzeEvent(currentEvent);
|
||||
@@ -511,7 +516,6 @@ void G4RunManager::ProcessOneEvent(G4int i_event)
|
||||
|
||||
void G4RunManager::TerminateOneEvent()
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
StackPreviousEvent(currentEvent);
|
||||
currentEvent = 0;
|
||||
numberOfEventProcessed++;
|
||||
@@ -543,7 +547,6 @@ void G4RunManager::TerminateEventLoop()
|
||||
|
||||
G4Event* G4RunManager::GenerateEvent(G4int i_event)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
if(!userPrimaryGeneratorAction)
|
||||
{
|
||||
G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
|
||||
@@ -584,7 +587,6 @@ G4Event* G4RunManager::GenerateEvent(G4int i_event)
|
||||
|
||||
void G4RunManager::StoreRNGStatus(const G4String& fnpref)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
G4String fileN = randomNumberStatusDir + fnpref + ".rndm";
|
||||
G4Random::saveEngineStatus(fileN);
|
||||
}
|
||||
@@ -602,17 +604,25 @@ void G4RunManager::RunTermination()
|
||||
{
|
||||
if(!fakeRun)
|
||||
{
|
||||
#if defined(GEANT4_USE_TIMEMORY)
|
||||
masterRunProfiler.reset();
|
||||
#endif
|
||||
CleanUpUnnecessaryEvents(0);
|
||||
if(userRunAction)
|
||||
userRunAction->EndOfRunAction(currentRun);
|
||||
G4VPersistencyManager* fPersM =
|
||||
G4VPersistencyManager::GetPersistencyManager();
|
||||
if(fPersM)
|
||||
fPersM->Store(currentRun);
|
||||
// write & close analysis output
|
||||
if(isScoreNtupleWriter)
|
||||
// tasking occasionally will call this function even
|
||||
// if there was not a current run
|
||||
if(currentRun)
|
||||
{
|
||||
G4VScoreNtupleWriter::Instance()->Write();
|
||||
if(userRunAction)
|
||||
userRunAction->EndOfRunAction(currentRun);
|
||||
G4VPersistencyManager* fPersM =
|
||||
G4VPersistencyManager::GetPersistencyManager();
|
||||
if(fPersM)
|
||||
fPersM->Store(currentRun);
|
||||
// write & close analysis output
|
||||
if(isScoreNtupleWriter)
|
||||
{
|
||||
G4VScoreNtupleWriter::Instance()->Write();
|
||||
}
|
||||
}
|
||||
runIDCounter++;
|
||||
}
|
||||
@@ -824,13 +834,13 @@ void G4RunManager::DefineWorldVolume(G4VPhysicalVolume* worldVol,
|
||||
void G4RunManager::rndmSaveThisRun()
|
||||
{
|
||||
G4int runNumber = 0;
|
||||
if(currentRun)
|
||||
runNumber = currentRun->GetRunID();
|
||||
if(currentRun) runNumber = currentRun->GetRunID();
|
||||
if(!storeRandomNumberStatus)
|
||||
{
|
||||
G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
|
||||
<< " Random number status was not stored prior to this run."
|
||||
<< G4endl << "Command ignored." << G4endl;
|
||||
<< G4endl << "/random/setSavingFlag command must be issued. "
|
||||
<< "Command ignored." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -840,23 +850,37 @@ void G4RunManager::rndmSaveThisRun()
|
||||
os << "run" << runNumber << ".rndm" << '\0';
|
||||
G4String fileOut = randomNumberStatusDir + os.str();
|
||||
|
||||
#ifdef WIN32
|
||||
G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
|
||||
#else
|
||||
G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
|
||||
#endif
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
|
||||
if(verboseLevel > 0)
|
||||
G4cout << "currentRun.rndm is copied to file: " << fileOut << G4endl;
|
||||
{ G4cout << fileIn << " is copied to " << fileOut << G4endl; }
|
||||
}
|
||||
|
||||
void G4RunManager::rndmSaveThisEvent()
|
||||
{
|
||||
if(!storeRandomNumberStatus || currentEvent == 0)
|
||||
if(currentEvent == 0)
|
||||
{
|
||||
G4cerr
|
||||
<< "Warning from G4RunManager::rndmSaveThisEvent():"
|
||||
<< " there is no currentEvent or its RandomEngineStatus is not available."
|
||||
<< " there is no currentEvent available."
|
||||
<< G4endl << "Command ignored." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!storeRandomNumberStatus)
|
||||
{
|
||||
G4cerr
|
||||
<< "Warning from G4RunManager::rndmSaveThisEvent():"
|
||||
<< " Random number engine status is not available."
|
||||
<< G4endl << "/random/setSavingFlag command must be issued "
|
||||
<< "prior to the start of the run. Command ignored." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
G4String fileIn = randomNumberStatusDir + "currentEvent.rndm";
|
||||
|
||||
std::ostringstream os;
|
||||
@@ -864,10 +888,14 @@ void G4RunManager::rndmSaveThisEvent()
|
||||
<< ".rndm" << '\0';
|
||||
G4String fileOut = randomNumberStatusDir + os.str();
|
||||
|
||||
#ifdef WIN32
|
||||
G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
|
||||
#else
|
||||
G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
|
||||
#endif
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
|
||||
if(verboseLevel > 0)
|
||||
G4cout << "currentEvent.rndm is copied to file: " << fileOut << G4endl;
|
||||
{ G4cout << fileIn << " is copied to " << fileOut << G4endl; }
|
||||
}
|
||||
|
||||
void G4RunManager::RestoreRandomNumberStatus(const G4String& fileN)
|
||||
@@ -924,7 +952,6 @@ void G4RunManager::ConstructScoringWorlds()
|
||||
if(nPar < 1)
|
||||
return;
|
||||
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
G4ParticleTable::G4PTblDicIterator* theParticleIterator =
|
||||
G4ParticleTable::GetParticleTable()->GetIterator();
|
||||
for(G4int iw = 0; iw < nPar; iw++)
|
||||
@@ -1002,7 +1029,6 @@ void G4RunManager::UpdateScoring()
|
||||
if(nPar < 1)
|
||||
return;
|
||||
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
G4HCofThisEvent* HCE = currentEvent->GetHCofThisEvent();
|
||||
if(!HCE)
|
||||
return;
|
||||
@@ -1201,3 +1227,176 @@ void G4RunManager::ReinitializeGeometry(G4bool destroyFirst, G4bool prop)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
void G4RunManager::ConfigureProfilers(int argc, char** argv)
|
||||
{
|
||||
std::vector<std::string> _args;
|
||||
for(int i = 0; i < argc; ++i)
|
||||
_args.push_back(argv[i]);
|
||||
ConfigureProfilers(_args);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
void G4RunManager::ConfigureProfilers(const std::vector<std::string>& args)
|
||||
{
|
||||
#ifdef GEANT4_USE_TIMEMORY
|
||||
// parse command line if arguments were passed
|
||||
G4Profiler::Configure(args);
|
||||
#else
|
||||
G4ConsumeParameters(args);
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
#if !defined(GEANT4_USE_TIMEMORY)
|
||||
# define TIMEMORY_WEAK_PREFIX
|
||||
# define TIMEMORY_WEAK_POSTFIX
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// this allows the default setup to be overridden by linking
|
||||
// in an custom extern C function into the application
|
||||
TIMEMORY_WEAK_PREFIX
|
||||
void G4RunProfilerInit(void) TIMEMORY_WEAK_POSTFIX;
|
||||
|
||||
extern void G4ProfilerInit(void);
|
||||
|
||||
// this gets executed when the library gets loaded
|
||||
void G4RunProfilerInit(void)
|
||||
{
|
||||
#ifdef GEANT4_USE_TIMEMORY
|
||||
G4ProfilerInit();
|
||||
|
||||
// guard against re-initialization
|
||||
static bool _once = false;
|
||||
if(_once)
|
||||
return;
|
||||
_once = true;
|
||||
|
||||
puts(">>> G4RunProfilerInit <<<");
|
||||
|
||||
using RunProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
|
||||
using EventProfilerConfig = G4ProfilerConfig<G4ProfileType::Event>;
|
||||
using TrackProfilerConfig = G4ProfilerConfig<G4ProfileType::Track>;
|
||||
using StepProfilerConfig = G4ProfilerConfig<G4ProfileType::Step>;
|
||||
using UserProfilerConfig = G4ProfilerConfig<G4ProfileType::User>;
|
||||
|
||||
//
|
||||
// these are the default functions for evaluating whether
|
||||
// to start profiling
|
||||
//
|
||||
RunProfilerConfig::GetFallbackQueryFunctor() = [](const G4Run* _run) {
|
||||
return G4Profiler::GetEnabled(G4ProfileType::Run) && _run;
|
||||
};
|
||||
|
||||
EventProfilerConfig::GetFallbackQueryFunctor() = [](const G4Event* _event) {
|
||||
return G4Profiler::GetEnabled(G4ProfileType::Event) && _event;
|
||||
};
|
||||
|
||||
TrackProfilerConfig::GetFallbackQueryFunctor() = [](const G4Track* _track) {
|
||||
return G4Profiler::GetEnabled(G4ProfileType::Track) && _track &&
|
||||
_track->GetDynamicParticle();
|
||||
};
|
||||
|
||||
StepProfilerConfig::GetFallbackQueryFunctor() = [](const G4Step* _step) {
|
||||
return G4Profiler::GetEnabled(G4ProfileType::Step) && _step &&
|
||||
_step->GetTrack();
|
||||
};
|
||||
|
||||
UserProfilerConfig::GetFallbackQueryFunctor() =
|
||||
[](const std::string& _user) {
|
||||
return G4Profiler::GetEnabled(G4ProfileType::User) && !_user.empty();
|
||||
};
|
||||
|
||||
//
|
||||
// these are the default functions which encode the profiling label.
|
||||
// Will not be called unless the query returned true
|
||||
//
|
||||
RunProfilerConfig::GetFallbackLabelFunctor() = [](const G4Run* _run) {
|
||||
return TIMEMORY_JOIN('/', "G4Run", _run->GetRunID());
|
||||
};
|
||||
|
||||
EventProfilerConfig::GetFallbackLabelFunctor() =
|
||||
[](const G4Event* _event) -> std::string {
|
||||
if(G4Profiler::GetPerEvent())
|
||||
return TIMEMORY_JOIN('/', "G4Event", _event->GetEventID());
|
||||
else
|
||||
return "G4Event";
|
||||
};
|
||||
|
||||
TrackProfilerConfig::GetFallbackLabelFunctor() = [](const G4Track* _track) {
|
||||
auto pdef = _track->GetDynamicParticle()->GetParticleDefinition();
|
||||
return TIMEMORY_JOIN('/', "G4Track", pdef->GetParticleName());
|
||||
};
|
||||
|
||||
StepProfilerConfig::GetFallbackLabelFunctor() = [](const G4Step* _step) {
|
||||
auto pdef = _step->GetTrack()->GetParticleDefinition();
|
||||
return TIMEMORY_JOIN('/', "G4Step", pdef->GetParticleName());
|
||||
};
|
||||
|
||||
UserProfilerConfig::GetFallbackLabelFunctor() =
|
||||
[](const std::string& _user) { return _user; };
|
||||
|
||||
using RunTool = typename RunProfilerConfig::type;
|
||||
using EventTool = typename EventProfilerConfig::type;
|
||||
using TrackTool = typename TrackProfilerConfig::type;
|
||||
using StepTool = typename StepProfilerConfig::type;
|
||||
using UserTool = typename UserProfilerConfig::type;
|
||||
|
||||
RunProfilerConfig::GetFallbackToolFunctor() =
|
||||
[](const std::string& _label) { return new RunTool{ _label }; };
|
||||
|
||||
EventProfilerConfig::GetFallbackToolFunctor() =
|
||||
[](const std::string& _label) { return new EventTool{ _label }; };
|
||||
|
||||
TrackProfilerConfig::GetFallbackToolFunctor() =
|
||||
[](const std::string& _label) {
|
||||
return new TrackTool(_label, tim::scope::config(tim::scope::flat{}));
|
||||
};
|
||||
|
||||
StepProfilerConfig::GetFallbackToolFunctor() =
|
||||
[](const std::string& _label) {
|
||||
return new StepTool(_label, tim::scope::config(tim::scope::flat{}));
|
||||
};
|
||||
|
||||
UserProfilerConfig::GetFallbackToolFunctor() =
|
||||
[](const std::string& _label) { return new UserTool(_label); };
|
||||
|
||||
auto comps = "wall_clock, cpu_clock, cpu_util, peak_rss";
|
||||
auto run_env_comps =
|
||||
tim::get_env<std::string>("G4PROFILE_RUN_COMPONENTS", comps);
|
||||
auto event_env_comps =
|
||||
tim::get_env<std::string>("G4PROFILE_EVENT_COMPONENTS", comps);
|
||||
auto track_env_comps =
|
||||
tim::get_env<std::string>("G4PROFILE_TRACK_COMPONENTS", comps);
|
||||
auto step_env_comps =
|
||||
tim::get_env<std::string>("G4PROFILE_STEP_COMPONENTS", comps);
|
||||
auto user_env_comps =
|
||||
tim::get_env<std::string>("G4PROFILE_USER_COMPONENTS", comps);
|
||||
|
||||
tim::configure<G4RunProfiler>(run_env_comps);
|
||||
tim::configure<G4EventProfiler>(event_env_comps);
|
||||
tim::configure<G4TrackProfiler>(track_env_comps);
|
||||
tim::configure<G4StepProfiler>(step_env_comps);
|
||||
tim::configure<G4UserProfiler>(user_env_comps);
|
||||
#endif
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
#ifdef GEANT4_USE_TIMEMORY
|
||||
namespace
|
||||
{
|
||||
static bool profiler_is_initialized = (G4RunProfilerInit(), true);
|
||||
}
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
@@ -64,6 +64,10 @@
|
||||
#include "G4AutoLock.hh"
|
||||
#include "G4RNGHelper.hh"
|
||||
|
||||
#ifdef G4BT_DEBUG
|
||||
#include "G4Backtrace.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4FPE_DEBUG
|
||||
# include "G4FPEDetection.hh"
|
||||
#endif
|
||||
@@ -96,6 +100,19 @@ G4RunManagerKernel::G4RunManagerKernel()
|
||||
#ifdef G4FPE_DEBUG
|
||||
InvalidOperationDetection();
|
||||
#endif
|
||||
|
||||
#ifdef G4BT_DEBUG
|
||||
auto _signals = G4GetEnv<std::string>("G4BACKTRACE", "");
|
||||
if(_signals.empty())
|
||||
{
|
||||
G4Backtrace::Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Backtrace::Enable(_signals);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4AllocatorList* allocList = G4AllocatorList::GetAllocatorListIfExist();
|
||||
if(allocList)
|
||||
numberOfStaticAllocators = allocList->Size();
|
||||
@@ -197,6 +214,18 @@ G4RunManagerKernel::G4RunManagerKernel(RMKType rmkType)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef G4BT_DEBUG
|
||||
auto _signals = G4GetEnv<std::string>("G4BACKTRACE", "");
|
||||
if(_signals.empty())
|
||||
{
|
||||
G4Backtrace::Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Backtrace::Enable(_signals);
|
||||
}
|
||||
#endif
|
||||
|
||||
defaultExceptionHandler = new G4ExceptionHandler();
|
||||
if(fRunManagerKernel)
|
||||
{
|
||||
@@ -760,7 +789,6 @@ void G4RunManagerKernel::InitializePhysics()
|
||||
|
||||
G4bool G4RunManagerKernel::RunInitialization(G4bool fakeRun)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4ApplicationState currentState = stateManager->GetCurrentState();
|
||||
|
||||
@@ -894,7 +922,6 @@ void G4RunManagerKernel::BuildPhysicsTables(G4bool fakeRun)
|
||||
if(G4ProductionCutsTable::GetProductionCutsTable()->IsModified() ||
|
||||
physicsNeedsToBeReBuilt)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
#ifdef G4MULTITHREADED
|
||||
if(runManagerKernelType == masterRMK)
|
||||
{
|
||||
|
||||
@@ -617,7 +617,7 @@ void G4RunMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
G4String vl;
|
||||
while(!(vl = next()).isNull())
|
||||
{
|
||||
seeds[idx] = (long) (StoI(vl));
|
||||
seeds[idx] = StoL(vl);
|
||||
idx++;
|
||||
}
|
||||
if(idx < 2)
|
||||
|
||||
@@ -45,9 +45,6 @@ G4VMPLManager G4VModularPhysicsList::G4VMPLsubInstanceManager;
|
||||
|
||||
void G4VMPLData::initialize() { physicsVector = new G4PhysConstVectorData(); }
|
||||
|
||||
// G4ThreadLocal G4VModularPhysicsList::G4PhysConstVector*
|
||||
// G4VModularPhysicsList::physicsVector = 0;
|
||||
|
||||
G4VModularPhysicsList::G4VModularPhysicsList()
|
||||
: G4VUserPhysicsList()
|
||||
, verboseLevel(0)
|
||||
@@ -177,7 +174,7 @@ void G4VModularPhysicsList::RegisterPhysics(G4VPhysicsConstructor* fPhysics)
|
||||
if(verboseLevel > 1)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::RegisterPhysics: " << pName
|
||||
<< "with type : " << pType << " is added" << G4endl;
|
||||
<< " with type : " << pType << " is added" << G4endl;
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
@@ -199,7 +196,7 @@ void G4VModularPhysicsList::RegisterPhysics(G4VPhysicsConstructor* fPhysics)
|
||||
<< "a physics with given type already exists " << G4endl;
|
||||
G4cout << " Type = " << pType << " : "
|
||||
<< " existing physics is " << (*itr)->GetPhysicsName() << G4endl;
|
||||
G4cout << pName << " can not be registered " << G4endl;
|
||||
G4cout << " New " << pName << " can not be registered " << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4String comment = "Duplicate type for ";
|
||||
@@ -237,7 +234,7 @@ void G4VModularPhysicsList::ReplacePhysics(G4VPhysicsConstructor* fPhysics)
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::ReplacePhysics: " << pName
|
||||
<< "with type : " << pType << " is added" << G4endl;
|
||||
<< " with type : " << pType << " is added" << G4endl;
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
@@ -262,8 +259,8 @@ void G4VModularPhysicsList::ReplacePhysics(G4VPhysicsConstructor* fPhysics)
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::ReplacePhysics: "
|
||||
<< (*itr)->GetPhysicsName() << "with type : " << pType
|
||||
<< " is replaces with " << pName << G4endl;
|
||||
<< (*itr)->GetPhysicsName() << " with type : " << pType
|
||||
<< " is replaced with " << pName << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -296,7 +293,7 @@ void G4VModularPhysicsList::RemovePhysics(G4int pType)
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
|
||||
<< " is removed" << G4endl;
|
||||
<< " is removed" << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4MT_physicsVector->erase(itr);
|
||||
@@ -329,7 +326,7 @@ void G4VModularPhysicsList::RemovePhysics(G4VPhysicsConstructor* fPhysics)
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
|
||||
<< " is removed" << G4endl;
|
||||
<< " is removed" << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4MT_physicsVector->erase(itr);
|
||||
@@ -361,7 +358,7 @@ void G4VModularPhysicsList::RemovePhysics(const G4String& name)
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
|
||||
<< " is removed" << G4endl;
|
||||
<< " is removed" << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4MT_physicsVector->erase(itr);
|
||||
|
||||
@@ -174,7 +174,6 @@ void G4WorkerRunManager::InitializeGeometry()
|
||||
|
||||
void G4WorkerRunManager::RunInitialization()
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
#ifdef G4MULTITHREADED
|
||||
if(!visIsSetUp)
|
||||
{
|
||||
@@ -250,6 +249,10 @@ void G4WorkerRunManager::RunInitialization()
|
||||
if(userRunAction)
|
||||
userRunAction->BeginOfRunAction(currentRun);
|
||||
|
||||
#if defined(GEANT4_USE_TIMEMORY)
|
||||
workerRunProfiler.reset(new ProfilerConfig(currentRun));
|
||||
#endif
|
||||
|
||||
if(isScoreNtupleWriter)
|
||||
{
|
||||
G4VScoreNtupleWriter::Instance()->OpenFile();
|
||||
@@ -274,7 +277,6 @@ void G4WorkerRunManager::RunInitialization()
|
||||
void G4WorkerRunManager::DoEventLoop(G4int n_event, const char* macroFile,
|
||||
G4int n_select)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
if(!userPrimaryGeneratorAction)
|
||||
{
|
||||
G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
|
||||
@@ -324,7 +326,6 @@ void G4WorkerRunManager::DoEventLoop(G4int n_event, const char* macroFile,
|
||||
|
||||
void G4WorkerRunManager::ProcessOneEvent(G4int i_event)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
currentEvent = GenerateEvent(i_event);
|
||||
if(eventLoopOnGoing)
|
||||
{
|
||||
@@ -338,7 +339,6 @@ void G4WorkerRunManager::ProcessOneEvent(G4int i_event)
|
||||
|
||||
G4Event* G4WorkerRunManager::GenerateEvent(G4int i_event)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
G4Event* anEvent = new G4Event(i_event);
|
||||
long s1 = 0;
|
||||
long s2 = 0;
|
||||
@@ -487,6 +487,9 @@ void G4WorkerRunManager::RunTermination()
|
||||
{
|
||||
if(!fakeRun)
|
||||
{
|
||||
#if defined(GEANT4_USE_TIMEMORY)
|
||||
workerRunProfiler.reset();
|
||||
#endif
|
||||
MergePartialResults();
|
||||
|
||||
// Call a user hook: note this is before the next barrier
|
||||
@@ -725,9 +728,81 @@ void G4WorkerRunManager::StoreRNGStatus(const G4String& fn)
|
||||
G4Random::saveEngineStatus(os.str().c_str());
|
||||
}
|
||||
|
||||
void G4WorkerRunManager::rndmSaveThisRun()
|
||||
{
|
||||
G4int runNumber = 0;
|
||||
if(currentRun) runNumber = currentRun->GetRunID();
|
||||
if(!storeRandomNumberStatus)
|
||||
{
|
||||
G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
|
||||
<< " Random number status was not stored prior to this run."
|
||||
<< G4endl << "/random/setSavingFlag command must be issued. "
|
||||
<< "Command ignored." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::ostringstream oos;
|
||||
oos << "G4Worker" << workerContext->GetThreadId()
|
||||
<< "_" << "currentRun.rndm" << "\0";
|
||||
G4String fileIn = randomNumberStatusDir + oos.str();
|
||||
|
||||
std::ostringstream os;
|
||||
os << "run" << runNumber << ".rndm" << '\0';
|
||||
G4String fileOut = randomNumberStatusDir + os.str();
|
||||
|
||||
#ifdef WIN32
|
||||
G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
|
||||
#else
|
||||
G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
|
||||
#endif
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
|
||||
if(verboseLevel > 0)
|
||||
{ G4cout << fileIn << " is copied to " << fileOut << G4endl; }
|
||||
}
|
||||
|
||||
void G4WorkerRunManager::rndmSaveThisEvent()
|
||||
{
|
||||
if(currentEvent == 0)
|
||||
{
|
||||
G4cerr
|
||||
<< "Warning from G4RunManager::rndmSaveThisEvent():"
|
||||
<< " there is no currentEvent available."
|
||||
<< G4endl << "Command ignored." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!storeRandomNumberStatus)
|
||||
{
|
||||
G4cerr
|
||||
<< "Warning from G4RunManager::rndmSaveThisEvent():"
|
||||
<< " Random number engine status is not available."
|
||||
<< G4endl << "/random/setSavingFlag command must be issued "
|
||||
<< "prior to the start of the run. Command ignored." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::ostringstream oos;
|
||||
oos << "G4Worker" << workerContext->GetThreadId()
|
||||
<< "_" << "currentEvent.rndm" << "\0";
|
||||
G4String fileIn = randomNumberStatusDir + oos.str();
|
||||
|
||||
std::ostringstream os;
|
||||
os << "run" << currentRun->GetRunID() << "evt" << currentEvent->GetEventID()
|
||||
<< ".rndm" << '\0';
|
||||
G4String fileOut = randomNumberStatusDir + os.str();
|
||||
|
||||
#ifdef WIN32
|
||||
G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
|
||||
#else
|
||||
G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
|
||||
#endif
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
|
||||
if(verboseLevel > 0)
|
||||
{ G4cout << fileIn << " is copied to " << fileOut << G4endl; }
|
||||
}
|
||||
|
||||
void G4WorkerRunManager::DoWork()
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
G4MTRunManager* mrm = G4MTRunManager::GetMasterRunManager();
|
||||
G4MTRunManager::WorkerActionRequest nextAction =
|
||||
mrm->ThisWorkerWaitForNextAction();
|
||||
|
||||
Reference in New Issue
Block a user