Import Geant4 10.7.0.beta source tree
This commit is contained in:
@@ -24,117 +24,127 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
#include "G4UserWorkerThreadInitialization.hh"
|
||||
#include "G4WorkerThread.hh"
|
||||
#include "G4WorkerRunManager.hh"
|
||||
#include "G4MTRunManagerKernel.hh"
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
#include "G4MTRunManagerKernel.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4WorkerRunManager.hh"
|
||||
#include "G4WorkerThread.hh"
|
||||
#include <sstream>
|
||||
|
||||
//Will need this for TPMalloc
|
||||
// Will need this for TPMalloc
|
||||
//#ifdef G4MULTITHREADED
|
||||
//#define TPMALLOCDEFINESTUB
|
||||
//#include "tpmalloc/tpmallocstub.h"
|
||||
//#endif
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
G4Thread* G4UserWorkerThreadInitialization::CreateAndStartWorker(G4WorkerThread* wTC)
|
||||
G4Thread* G4UserWorkerThreadInitialization::CreateAndStartWorker(
|
||||
G4WorkerThread* wTC)
|
||||
{
|
||||
//Note: this method is called by G4MTRunManager, here we are still sequential
|
||||
//Create a new thread/worker structure
|
||||
G4Thread* worker = new G4Thread;
|
||||
G4THREADCREATE(worker, &G4MTRunManagerKernel::StartThread, wTC );
|
||||
return worker;
|
||||
// Note: this method is called by G4MTRunManager, here we are still sequential
|
||||
// Create a new thread/worker structure
|
||||
G4Thread* worker = new G4Thread;
|
||||
G4THREADCREATE(worker, &G4MTRunManagerKernel::StartThread, wTC);
|
||||
return worker;
|
||||
}
|
||||
#else
|
||||
G4Thread* G4UserWorkerThreadInitialization::CreateAndStartWorker(G4WorkerThread*)
|
||||
G4Thread* G4UserWorkerThreadInitialization::CreateAndStartWorker(
|
||||
G4WorkerThread*)
|
||||
{
|
||||
return new G4Thread;
|
||||
return new G4Thread;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Avoid compilation warning in sequential
|
||||
// Avoid compilation warning in sequential
|
||||
#ifdef G4MULTITHREADED
|
||||
void G4UserWorkerThreadInitialization::JoinWorker(G4Thread* aThread)
|
||||
{
|
||||
G4THREADJOIN(*aThread);
|
||||
G4THREADJOIN(*aThread);
|
||||
}
|
||||
#else
|
||||
void G4UserWorkerThreadInitialization::JoinWorker(G4Thread*)
|
||||
{
|
||||
}
|
||||
void G4UserWorkerThreadInitialization::JoinWorker(G4Thread*) {}
|
||||
#endif
|
||||
|
||||
G4UserWorkerThreadInitialization::G4UserWorkerThreadInitialization()
|
||||
{;}
|
||||
G4UserWorkerThreadInitialization::G4UserWorkerThreadInitialization() { ; }
|
||||
|
||||
G4UserWorkerThreadInitialization::~G4UserWorkerThreadInitialization()
|
||||
{;}
|
||||
G4UserWorkerThreadInitialization::~G4UserWorkerThreadInitialization() { ; }
|
||||
|
||||
namespace {
|
||||
G4Mutex rngCreateMutex = G4MUTEX_INITIALIZER;
|
||||
namespace
|
||||
{
|
||||
G4Mutex rngCreateMutex = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
#include "globals.hh"
|
||||
void G4UserWorkerThreadInitialization::SetupRNGEngine(const CLHEP::HepRandomEngine* aNewRNG) const
|
||||
void G4UserWorkerThreadInitialization::SetupRNGEngine(
|
||||
const CLHEP::HepRandomEngine* aNewRNG) const
|
||||
{
|
||||
G4AutoLock l(&rngCreateMutex);
|
||||
//No default available, let's create the instance of random stuff
|
||||
//A Call to this just forces the creation to defaults
|
||||
G4Random::getTheEngine();
|
||||
//Poor man's solution to check which RNG Engine is used in master thread
|
||||
CLHEP::HepRandomEngine* retRNG= 0;
|
||||
G4AutoLock l(&rngCreateMutex);
|
||||
// No default available, let's create the instance of random stuff
|
||||
// A Call to this just forces the creation to defaults
|
||||
G4Random::getTheEngine();
|
||||
// Poor man's solution to check which RNG Engine is used in master thread
|
||||
CLHEP::HepRandomEngine* retRNG = 0;
|
||||
|
||||
// Need to make these calls thread safe
|
||||
if ( dynamic_cast<const CLHEP::HepJamesRandom*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::HepJamesRandom;
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::MixMaxRng;
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::RanecuEngine;
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG) ) {
|
||||
const CLHEP::Ranlux64Engine* theRNG = dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG);
|
||||
retRNG= new CLHEP::Ranlux64Engine(123,theRNG->getLuxury());
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::MTwistEngine;
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::DualRand*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::DualRand;
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG) ) {
|
||||
const CLHEP::RanluxEngine* theRNG = dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG);
|
||||
retRNG= new CLHEP::RanluxEngine(123,theRNG->getLuxury());
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::RanshiEngine;
|
||||
}
|
||||
|
||||
if( retRNG != 0 ) {
|
||||
G4Random::setTheEngine( retRNG );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Does a new method, such as aNewRng->newEngine() exist to clone it ?
|
||||
G4ExceptionDescription msg;
|
||||
msg<< " Unknown type of RNG Engine - " << G4endl
|
||||
<< " Can cope only with HepJamesRandom, MixMaxRng, Ranecu, Ranlux64,"
|
||||
<< " MTwistEngine, DualRand, Ranlux or Ranshi."
|
||||
<< G4endl
|
||||
<< " Cannot clone this type of RNG engine, as required for this thread" << G4endl
|
||||
<< " Aborting " << G4endl;
|
||||
G4Exception("G4UserWorkerInitializition::SetupRNGEngine()",
|
||||
"Run0122",FatalException,msg);
|
||||
}
|
||||
// Need to make these calls thread safe
|
||||
if(dynamic_cast<const CLHEP::HepJamesRandom*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::HepJamesRandom;
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::MixMaxRng;
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::RanecuEngine;
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG))
|
||||
{
|
||||
const CLHEP::Ranlux64Engine* theRNG =
|
||||
dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG);
|
||||
retRNG = new CLHEP::Ranlux64Engine(123, theRNG->getLuxury());
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::MTwistEngine;
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::DualRand*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::DualRand;
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG))
|
||||
{
|
||||
const CLHEP::RanluxEngine* theRNG =
|
||||
dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG);
|
||||
retRNG = new CLHEP::RanluxEngine(123, theRNG->getLuxury());
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::RanshiEngine;
|
||||
}
|
||||
|
||||
if(retRNG != 0)
|
||||
{
|
||||
G4Random::setTheEngine(retRNG);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Does a new method, such as aNewRng->newEngine() exist to clone it ?
|
||||
G4ExceptionDescription msg;
|
||||
msg << " Unknown type of RNG Engine - " << G4endl
|
||||
<< " Can cope only with HepJamesRandom, MixMaxRng, Ranecu, Ranlux64,"
|
||||
<< " MTwistEngine, DualRand, Ranlux or Ranshi." << G4endl
|
||||
<< " Cannot clone this type of RNG engine, as required for this thread"
|
||||
<< G4endl << " Aborting " << G4endl;
|
||||
G4Exception("G4UserWorkerInitializition::SetupRNGEngine()", "Run0122",
|
||||
FatalException, msg);
|
||||
}
|
||||
}
|
||||
|
||||
G4WorkerRunManager* G4UserWorkerThreadInitialization::CreateWorkerRunManager() const
|
||||
G4WorkerRunManager* G4UserWorkerThreadInitialization::CreateWorkerRunManager()
|
||||
const
|
||||
{
|
||||
return new G4WorkerRunManager();
|
||||
return new G4WorkerRunManager();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user