[Gate-users] Adding G4MTRunManager Support to GATE
Alex Vergara Gil
alexvergaragil at gmail.com
Thu Mar 26 13:02:20 CET 2015
Dear All
I started this thread to unify all those enthusiast people who want to
add G4MTRunManager support into GATE. The advantages of a Multi
Threading Run Manager are obvious but I will explain it here anyway, I
will send you also my first patch and the problems I am facing.
Advantages
1. You will not depend on an external cluster software to run on a
single multi cpu PC.
2. The time you need for simulation scales linearly with the number of cpus
3. You doesn't need to merge the outputs, since this is performed automatically
4. Any other you may add
My first patch
<start of the code>
Autor: Alex Vergara Gil <alexvergaragil at gmail.com> 2015-03-25 17:13:45
Committer: Alex Vergara Gil <alexvergaragil at gmail.com> 2015-03-25 17:13:45
Padre: db6875e64d60ad1e0f2d100c496843632acb23c8 (Merge
https://github.com/OpenGATE/Gate)
Hija: 28c338cd3263108df3927db14c6975f4cdcc31b4 (Agregado el
UserActionInitialization)
Rama: partopc
Sigue-a:
Precede-a:
trying g4mtRunManager
------------------- source/general/include/GateRunManager.hh -------------------
index c4164d9..b72327b 100644
@@ -28,12 +28,19 @@
#define GateRunManager_h 1
#include "G4RunManager.hh"
+#ifdef G4MULTITHREADED
+ #include "G4MTRunManager.hh"
+#endif
#include "GateHounsfieldToMaterialsBuilder.hh"
class GateRunManagerMessenger;
class GateDetectorConstruction;
+#ifdef G4MULTITHREADED
+class GateRunManager : public G4MTRunManager
+#else
class GateRunManager : public G4RunManager
+#endif
{
public:
//! Constructor
@@ -60,8 +67,11 @@ public:
//! Return the instance of the run manager
static GateRunManager* GetRunManager()
+ #ifdef G4MULTITHREADED
+ { return dynamic_cast<GateRunManager*>(G4MTRunManager::GetRunManager()); }
+ #else
{ return dynamic_cast<GateRunManager*>(G4RunManager::GetRunManager()); }
-
+ #endif
bool GetGlobalOutputFlag() { return mGlobalOutputFlag; }
void EnableGlobalOutput(bool b) { mGlobalOutputFlag = b; }
void SetUserPhysicList(G4VUserPhysicsList * m) { mUserPhysicList = m; }
--------------------- source/general/src/GateRunManager.cc ---------------------
index 2604e47..75b3fb5 100644
@@ -8,6 +8,9 @@
#include "GateRunManager.hh"
+#ifdef G4MULTITHREADED
+ #include "G4MTRunManager.hh"
+#endif
#include "GateDetectorConstruction.hh"
#include "GateRunManagerMessenger.hh"
#include "GateHounsfieldToMaterialsBuilder.hh"
@@ -27,7 +30,11 @@
#endif
//----------------------------------------------------------------------------------------
+#ifdef G4MULTITHREADED
+GateRunManager::GateRunManager():G4MTRunManager()
+#else
GateRunManager::GateRunManager():G4RunManager()
+#endif
{
pMessenger = new GateRunManagerMessenger(this);
mHounsfieldToMaterialsBuilder = new GateHounsfieldToMaterialsBuilder();
@@ -112,7 +119,11 @@ void GateRunManager::InitializeAll()
G4ProductionCutsTable::GetProductionCutsTable()->GetHighEdgeEnergy());
// Initialization
+#ifdef G4MULTITHREADED
+ G4MTRunManager::SetUserInitialization(mUserPhysicList);
+#else
G4RunManager::SetUserInitialization(mUserPhysicList);
+#endif
//To take into account the user cuts (steplimiter and special cuts)
#if (G4VERSION_MAJOR > 9)
@@ -126,7 +137,11 @@ void GateRunManager::InitializeAll()
} // End if (mUserPhysicListName != "")
// InitializePhysics
+#ifdef G4MULTITHREADED
G4RunManager::InitializePhysics();
+#else
+ G4MTRunManager::InitializePhysics();
+#endif
// Take into account the em option set by the user (dedx bin etc)
GatePhysicsList::GetInstance()->SetEmProcessOptions();
@@ -169,7 +184,11 @@ void GateRunManager::InitGeometryOnly()
if (!geometryInitialized)
{
GateMessage("Core", 1, "Initialization of geometry" << G4endl);
+#ifdef G4MULTITHREADED
+ G4MTRunManager::InitializeGeometry();
+#else
G4RunManager::InitializeGeometry();
+#endif
}
else
{
@@ -189,7 +208,11 @@ void GateRunManager::InitGeometryOnly()
//----------------------------------------------------------------------------------------
void GateRunManager::InitPhysics()
{
+ #ifdef G4MULTITHREADED
+ G4MTRunManager::InitializePhysics();
+#else
G4RunManager::InitializePhysics();
+#endif
}
//----------------------------------------------------------------------------------------
@@ -205,7 +228,11 @@ void GateRunManager::RunInitialization()
// GateMessage("Core", 0, "Initialization of the run " << G4endl);
// Perform a regular initialisation
+ #ifdef G4MULTITHREADED
+ G4MTRunManager::RunInitialization();
+#else
G4RunManager::RunInitialization();
+#endif
// Initialization of the atom deexcitation processes
// must be done after all other initialization
</end of the code>
This patch compiles without any special warnings, however when I try
to run it it explodes with the following message
<start of message>
[G4]
[G4] *************************************************************
[G4] Geant4 version Name: geant4-10-01 [MT] (5-December-2014)
[G4] << in Multi-threaded mode >>
[G4] Copyright : Geant4 Collaboration
[G4] Reference : NIM A 506 (2003), 250-303
[G4] WWW : http://cern.ch/geant4
[G4] *************************************************************
[G4]
[G4-cerr]
-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : Run3011
issued by : G4MTRunManager::SetUserAction()
For multi-threaded version, define G4UserEventAction in
G4VUserActionInitialization.
*** Fatal Exception *** core dump ***
-------- EEEE -------- G4Exception-END --------- EEEE -------
[G4-cerr]
[G4-cerr] *** G4Exception: Aborting execution ***
Abortado (`core' generado)
</end of message>
So I wonder if some of you have ever face this situation and how to help me
Best Regards
Alex
More information about the Gate-users
mailing list