Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$Id: History 88801 2015-03-10 14:38:27Z gcosmo $
|
||||
$Id: History 102994 2017-03-07 16:31:28Z gcosmo $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,11 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
March 7th, 2017 A.Howard (geombias-V10-03-00)
|
||||
- Added mutex locks to methods within G4IStore and G4ImportanceAlgorithm
|
||||
should fix bug#1945 (created by me) - erratic behaviour in MT-mode and
|
||||
crashing if bounds-checking was switched on (with many threads+events)
|
||||
|
||||
March 10th, 2015 G.Cosmo (geombias-V10-01-00)
|
||||
- Made G4IStore and G4WeightWindowStore singletons thread-local to avoid
|
||||
data races when accessing iterators.
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4IStore.hh 88801 2015-03-10 14:38:27Z gcosmo $
|
||||
// $Id: G4IStore.hh 102994 2017-03-07 16:31:28Z gcosmo $
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
// Class G4IStore
|
||||
@@ -144,6 +144,11 @@ private:
|
||||
mutable G4GeometryCellImportance::const_iterator fCurrentIterator;
|
||||
|
||||
static G4ThreadLocal G4IStore* fInstance;
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
static G4Mutex IStoreMutex;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ImportanceAlgorithm.hh 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
// $Id: G4ImportanceAlgorithm.hh 102994 2017-03-07 16:31:28Z gcosmo $
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
// Class G4ImportanceAlgorithm
|
||||
@@ -66,6 +66,11 @@ private:
|
||||
private:
|
||||
|
||||
mutable G4bool fWorned;
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
static G4Mutex ImportanceMutex;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4IStore.cc 88801 2015-03-10 14:38:27Z gcosmo $
|
||||
// $Id: G4IStore.cc 102994 2017-03-07 16:31:28Z gcosmo $
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
@@ -40,6 +40,10 @@
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
G4Mutex G4IStore::IStoreMutex = G4MUTEX_INITIALIZER;
|
||||
#endif
|
||||
|
||||
// ***************************************************************************
|
||||
// Static class variable: ptr to single instance of class
|
||||
// ***************************************************************************
|
||||
@@ -149,18 +153,29 @@ void G4IStore::ChangeImportance(G4double importance,
|
||||
G4double G4IStore::GetImportance(const G4VPhysicalVolume &aVolume,
|
||||
G4int aRepNum) const
|
||||
{
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MUTEXLOCK(&G4IStore::IStoreMutex);
|
||||
#endif
|
||||
SetInternalIterator(G4GeometryCell(aVolume, aRepNum));
|
||||
G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
|
||||
if (gCellIterator==fGeometryCelli.end()) {
|
||||
Error("GetImportance() - Region does not exist!");
|
||||
return 0.;
|
||||
}
|
||||
return (*fCurrentIterator).second;
|
||||
G4double importance_value = (*fCurrentIterator).second;
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MUTEXUNLOCK(&G4IStore::IStoreMutex);
|
||||
#endif
|
||||
return importance_value;
|
||||
// return (*fCurrentIterator).second;
|
||||
}
|
||||
|
||||
|
||||
G4double G4IStore::GetImportance(const G4GeometryCell &gCell) const
|
||||
{
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MUTEXLOCK(&G4IStore::IStoreMutex);
|
||||
#endif
|
||||
SetInternalIterator(gCell);
|
||||
G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
|
||||
if (gCellIterator==fGeometryCelli.end()) {
|
||||
@@ -171,16 +186,27 @@ G4double G4IStore::GetImportance(const G4GeometryCell &gCell) const
|
||||
Error(err_mess.str());
|
||||
return 0.;
|
||||
}
|
||||
return (*fCurrentIterator).second;
|
||||
G4double importance_value = (*fCurrentIterator).second;
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MUTEXUNLOCK(&G4IStore::IStoreMutex);
|
||||
#endif
|
||||
return importance_value;
|
||||
// return (*fCurrentIterator).second;
|
||||
}
|
||||
|
||||
G4bool G4IStore::IsKnown(const G4GeometryCell &gCell) const {
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MUTEXLOCK(&G4IStore::IStoreMutex);
|
||||
#endif
|
||||
G4bool inWorldKnown(IsInWorld(gCell.GetPhysicalVolume()));
|
||||
|
||||
if ( inWorldKnown ) {
|
||||
SetInternalIterator(gCell);
|
||||
inWorldKnown = (fCurrentIterator!=fGeometryCelli.end());
|
||||
}
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MUTEXUNLOCK(&G4IStore::IStoreMutex);
|
||||
#endif
|
||||
return inWorldKnown;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ImportanceAlgorithm.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
// $Id: G4ImportanceAlgorithm.cc 102994 2017-03-07 16:31:28Z gcosmo $
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
@@ -36,9 +36,14 @@
|
||||
#include "G4Types.hh"
|
||||
#include <sstream>
|
||||
#include "Randomize.hh"
|
||||
#include "G4Threading.hh"
|
||||
|
||||
#include "G4ImportanceAlgorithm.hh"
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
G4Mutex G4ImportanceAlgorithm::ImportanceMutex = G4MUTEX_INITIALIZER;
|
||||
#endif
|
||||
|
||||
G4ImportanceAlgorithm::G4ImportanceAlgorithm(): fWorned(false)
|
||||
{
|
||||
}
|
||||
@@ -52,6 +57,11 @@ G4ImportanceAlgorithm::Calculate(G4double ipre,
|
||||
G4double ipost,
|
||||
G4double init_w) const
|
||||
{
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MUTEXLOCK(&G4ImportanceAlgorithm::ImportanceMutex);
|
||||
#endif
|
||||
|
||||
G4Nsplit_Weight nw = {0,0};
|
||||
if (ipost>0.){
|
||||
if (!(ipre>0.)){
|
||||
@@ -109,6 +119,9 @@ G4ImportanceAlgorithm::Calculate(G4double ipre,
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MUTEXUNLOCK(&G4ImportanceAlgorithm::ImportanceMutex);
|
||||
#endif
|
||||
return nw;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user