Skip to content
Snippets Groups Projects
Commit 207b8989 authored by Ivana Hrivnacova's avatar Ivana Hrivnacova
Browse files

Modifications in vmc for multi-threading:

Making TVirtualMC and TVirtualMCApplication instances thread local;
behind #if defined(__linux__) && !defined(__CINT__)


git-svn-id: http://root.cern.ch/svn/root/trunk@43453 27541ba8-7e3a-0410-8455-c3a389f83636
parent bb4c49e0
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,10 @@ ...@@ -32,6 +32,10 @@
#include "TString.h" #include "TString.h"
#include "TError.h" #include "TError.h"
#if defined(__linux__) && !defined(__CINT__)
#include <pthread.h>
#endif
class TLorentzVector; class TLorentzVector;
class TGeoHMatrix; class TGeoHMatrix;
class TArrayI; class TArrayI;
...@@ -479,7 +483,7 @@ public: ...@@ -479,7 +483,7 @@ public:
virtual Bool_t DefineParticle(Int_t pdg, const char* name, virtual Bool_t DefineParticle(Int_t pdg, const char* name,
TMCParticleType mcType, TMCParticleType mcType,
Double_t mass, Double_t charge, Double_t lifetime) = 0; Double_t mass, Double_t charge, Double_t lifetime) = 0;
// Set a user defined particle // Set a user defined particle
// Function is ignored if particle with specified pdg // Function is ignored if particle with specified pdg
// already exists and error report is printed. // already exists and error report is printed.
...@@ -797,7 +801,10 @@ public: ...@@ -797,7 +801,10 @@ public:
// Initialize MC // Initialize MC
virtual void Init() = 0; virtual void Init() = 0;
// Initialize MC physics // Initialize MC in a multi-threaded application
virtual void InitMT(Int_t threadRank);
// Initialize MC physics
virtual void BuildPhysics() = 0; virtual void BuildPhysics() = 0;
// Process one event // Process one event
...@@ -860,7 +867,11 @@ private: ...@@ -860,7 +867,11 @@ private:
TVirtualMC(const TVirtualMC &mc); TVirtualMC(const TVirtualMC &mc);
TVirtualMC & operator=(const TVirtualMC &); TVirtualMC & operator=(const TVirtualMC &);
static TVirtualMC* fgMC; // Monte Carlo singleton instance #if defined(__linux__) && !defined(__CINT__)
static __thread TVirtualMC* fgMC; // Monte Carlo singleton instance
#else
static TVirtualMC* fgMC; // Monte Carlo singleton instance
#endif
TVirtualMCStack* fStack; //! Particles stack TVirtualMCStack* fStack; //! Particles stack
TVirtualMCDecayer* fDecayer; //! External decayer TVirtualMCDecayer* fDecayer; //! External decayer
...@@ -889,7 +900,16 @@ inline Bool_t TVirtualMC::GetMaterial(Int_t /*imat*/, TString& /*name*/, ...@@ -889,7 +900,16 @@ inline Bool_t TVirtualMC::GetMaterial(Int_t /*imat*/, TString& /*name*/,
return kFALSE; return kFALSE;
} }
R__EXTERN TVirtualMC *gMC; inline void TVirtualMC::InitMT(Int_t /*threadRank*/) {
// Initialize MC in a multi-threaded application
Warning("InitMT(Int_t threadRank)", "New function - not yet implemented.");
}
#if defined(__linux__) && !defined(__CINT__)
R__EXTERN __thread TVirtualMC *gMC;
#else
R__EXTERN TVirtualMC *gMC;
#endif
#endif //ROOT_TVirtualMC #endif //ROOT_TVirtualMC
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
#include "TMath.h" #include "TMath.h"
#endif #endif
#if defined(__linux__) && !defined(__CINT__)
#include <pthread.h>
#endif
class TVirtualMCApplication : public TNamed { class TVirtualMCApplication : public TNamed {
public: public:
...@@ -101,7 +105,11 @@ public: ...@@ -101,7 +105,11 @@ public:
private: private:
// static data members // static data members
static TVirtualMCApplication* fgInstance; // singleton instance #if defined(__linux__) && !defined(__CINT__)
static __thread TVirtualMCApplication* fgInstance; // singleton instance
#else
static TVirtualMCApplication* fgInstance; // singleton instance
#endif
ClassDef(TVirtualMCApplication,1) //Interface to MonteCarlo application ClassDef(TVirtualMCApplication,1) //Interface to MonteCarlo application
}; };
......
...@@ -26,8 +26,13 @@ ...@@ -26,8 +26,13 @@
ClassImp(TVirtualMC) ClassImp(TVirtualMC)
#if defined(__linux__) && !defined(__CINT__)
__thread TVirtualMC* TVirtualMC::fgMC=0;
__thread TVirtualMC* gMC;
#else
TVirtualMC* TVirtualMC::fgMC=0; TVirtualMC* TVirtualMC::fgMC=0;
TVirtualMC* gMC; TVirtualMC* gMC;
#endif
//_____________________________________________________________________________ //_____________________________________________________________________________
TVirtualMC::TVirtualMC(const char *name, const char *title, TVirtualMC::TVirtualMC(const char *name, const char *title,
......
...@@ -20,7 +20,11 @@ ...@@ -20,7 +20,11 @@
ClassImp(TVirtualMCApplication) ClassImp(TVirtualMCApplication)
#if defined(__linux__) && !defined(__CINT__)
__thread TVirtualMCApplication* TVirtualMCApplication::fgInstance = 0;
#else
TVirtualMCApplication* TVirtualMCApplication::fgInstance = 0; TVirtualMCApplication* TVirtualMCApplication::fgInstance = 0;
#endif
//_____________________________________________________________________________ //_____________________________________________________________________________
TVirtualMCApplication::TVirtualMCApplication(const char *name, TVirtualMCApplication::TVirtualMCApplication(const char *name,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment