Import Geant4 11.3.0 source tree
This commit is contained in:
@@ -6,16 +6,31 @@ It must **not** be used as a substitute for writing good git commit messages!
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
## 2024-08-26 Gabriele Cosmo (geommng-V11-02-06)
|
||||
- G4GeometryManager: temporarily disable default parallel optimisation.
|
||||
Fixed spelling for method OptimiseInParallel(..).
|
||||
|
||||
## 2024-08-07 Gabriele Cosmo (geommng-V11-02-05)
|
||||
- Fixed broken condition for enabling voxels statistics report in
|
||||
G4GeometryManager::UndertakeOptimisation().
|
||||
- Further cleanup in G4GeometryManager for usage of static data.
|
||||
Fixed spelling on data members.
|
||||
- Access G4GeometryManager singleton through its GetInstance() in stores.
|
||||
|
||||
## 2024-08-06 Gabriele Cosmo (geommng-V11-02-04)
|
||||
- In G4GeometryManager, removed unnecessary static qualifier for some methods
|
||||
and ordered methods declarations in header.
|
||||
|
||||
## 2024-06-17 Gabriele Cosmo (geommng-V11-02-03)
|
||||
- Removed G4SmartVoxelProxy source file, as now empty.
|
||||
- Minor code cleanup/indentation.
|
||||
|
||||
## 2024-06-02 John Apostolakis (geommng-V11-02-02)
|
||||
- New capability to run voxel optimisation in threads (off by default).
|
||||
First version, parallelises only over volumes. The user must currently call
|
||||
G4GeometryManager::RequestParallelOptimisation(optimise=true, verbose) to use
|
||||
it. Set verbose=true to obtain the volumes with biggest contribution to memory
|
||||
size and CPU time for voxelisation.
|
||||
First version, parallelises only over volumes. The user can call
|
||||
RequestParallelOptimisation(optimise, verbose) from G4GeometryManager
|
||||
to turn it on/off. Set verbose=true to obtain the volumes with biggest
|
||||
contribution to memory size and CPU time for voxelisation.
|
||||
Added new method BuildOptimisationsParallel() to be called by
|
||||
G4WorkerRunManager to initialize. Added method ReportVoxelInfo() to write out
|
||||
for verification. Checked with simple and complex/large geometries.
|
||||
@@ -252,7 +267,7 @@ May 16, 2018 G.Cosmo (geommng-V10-04-05)
|
||||
compilation warnings on gcc-8.1.
|
||||
|
||||
May 11, 2018 E.Tcherniaev (geommng-V10-04-04)
|
||||
- G4AffineTransform: further optimized InverseProduct(), for the case where
|
||||
- G4AffineTransform: further optimised InverseProduct(), for the case where
|
||||
tf2 is a pure translation.
|
||||
|
||||
May 7, 2018 E.Tcherniaev (geommng-V10-04-03)
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
// - conversion of the rotation matrix to angle & axis used to get
|
||||
// a possibility to remove "friend" from the G4RotationMatrix class
|
||||
// 06.05.2018 E.Tcherniaev:
|
||||
// - optimized InverseProduct
|
||||
// - optimised InverseProduct
|
||||
// - added methods for inverse transformation: InverseTrasformPoint,
|
||||
// InverseTransformAxis, InverseNetRotation, InverseNetTranslation
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -67,8 +67,8 @@ class G4GeometryManager
|
||||
// present. Applies to just a specific subtree if a physical volume is
|
||||
// specified.
|
||||
|
||||
static G4bool IsGeometryClosed();
|
||||
// Return true/false according to state of optimised geoemtry.
|
||||
inline G4bool IsGeometryClosed() { return fIsClosed; }
|
||||
// Return true/false according to state of optimised geometry.
|
||||
|
||||
void SetWorldMaximumExtent(G4double worldExtent);
|
||||
// Set the maximum extent of the world volume. The operation is
|
||||
@@ -81,29 +81,29 @@ class G4GeometryManager
|
||||
static G4GeometryManager* GetInstanceIfExist();
|
||||
// Return ptr to singleton instance.
|
||||
|
||||
static void OptimizeInParallel(G4bool val = true);
|
||||
// Request optimization using threads (if MT is enabled & used ).
|
||||
void OptimiseInParallel(G4bool val = true);
|
||||
// Request optimisation using threads (if MT is enabled & used ).
|
||||
|
||||
void UndertakeOptimisation();
|
||||
// Method that contributes to (Voxel) optimisation until all work is done.
|
||||
// Must be called by Worker thread initialisation - not a user callable
|
||||
// method.
|
||||
|
||||
static void RequestParallelOptimisation(G4bool val = true,
|
||||
G4bool verbose = true);
|
||||
void RequestParallelOptimisation(G4bool val = true,
|
||||
G4bool verbose = true);
|
||||
// Detailed method for user to request parallel Optimisation
|
||||
// (if verbosity is required). Calling this is enough to ask for it.
|
||||
// It will be used if Geant4 is built with MT/tasks.
|
||||
|
||||
static void ChooseSequentialOptimisation(G4bool verbose = false);
|
||||
void ChooseSequentialOptimisation(G4bool verbose = false);
|
||||
// Simple way to avoid parallel optimisation.
|
||||
|
||||
static G4bool IsParallelOptimisationConfigured();
|
||||
G4bool IsParallelOptimisationConfigured();
|
||||
// Check whether parallel optimisation was requested.
|
||||
static G4bool IsParallelOptimisationFinished();
|
||||
G4bool IsParallelOptimisationFinished();
|
||||
// Report whether parallel optimisation is done.
|
||||
|
||||
~G4GeometryManager();
|
||||
~G4GeometryManager();
|
||||
// Destructor; called by G4RunManagerKernel.
|
||||
|
||||
private:
|
||||
@@ -129,32 +129,21 @@ class G4GeometryManager
|
||||
// Methods for parallel initialization
|
||||
void CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose);
|
||||
// Build vector of relevant volumes.
|
||||
G4LogicalVolume* ObtainVolumeToOptimize();
|
||||
G4LogicalVolume* ObtainVolumeToOptimise();
|
||||
|
||||
static G4ThreadLocal G4GeometryManager* fgInstance;
|
||||
static G4ThreadLocal G4bool fIsClosed;
|
||||
|
||||
static std::vector<G4LogicalVolume*> fVolumesToOptimize;
|
||||
// The list of volumes which threads need to optimize.
|
||||
static std::vector<G4LogicalVolume*>::iterator fLogVolumeIterator;
|
||||
// Iterator used by UndertakeOptimisation().
|
||||
|
||||
static std::vector<G4SmartVoxelStat> fGlobVoxelStats;
|
||||
// Statistics container shared by all workers
|
||||
|
||||
static void ConfigureParallelOptimisation(G4bool verbose);
|
||||
void ConfigureParallelOptimisation(G4bool verbose);
|
||||
// Prepare for parallel optimisation.
|
||||
|
||||
G4int ReportWorkerIsDoneOptimising(unsigned int numVolumesOptimized);
|
||||
G4int ReportWorkerIsDoneOptimising(unsigned int numVolumesOptimised);
|
||||
// Thread-safe method for worker to report it's finished its work.
|
||||
// It counts the number of workers that finished, and returns count.
|
||||
// It counts the number of volumes optimised; if all workers have
|
||||
// reported, it results in a 'Finished' state.
|
||||
|
||||
static void InformOptimisationIsFinished(G4bool verbose);
|
||||
void InformOptimisationIsFinished(G4bool verbose);
|
||||
// Returns true if all workers are finished (or all work is done).
|
||||
|
||||
static void ResetListOfVolumesToOptimise();
|
||||
void ResetListOfVolumesToOptimise();
|
||||
// Resets (empties) the list of candidate volumes for optimisation.
|
||||
// Must be called when Optimisation is finished.
|
||||
|
||||
@@ -164,26 +153,36 @@ class G4GeometryManager
|
||||
|
||||
void WaitForVoxelisationFinish(G4bool verbose = false);
|
||||
// Wait until the voxelisation is all done.
|
||||
|
||||
|
||||
private:
|
||||
|
||||
static G4ThreadLocal G4GeometryManager* fgInstance;
|
||||
G4bool fIsClosed = false;
|
||||
|
||||
static std::vector<G4LogicalVolume*> fVolumesToOptimise;
|
||||
// The list of volumes which threads need to optimise.
|
||||
static std::vector<G4LogicalVolume*>::const_iterator fLogVolumeIterator;
|
||||
// Iterator used by UndertakeOptimisation().
|
||||
|
||||
static std::vector<G4SmartVoxelStat> fGlobVoxelStats;
|
||||
// Statistics container shared by all workers
|
||||
|
||||
// Flags for parallel initialization
|
||||
// ---------------------------------
|
||||
static G4bool fVerboseParallel;
|
||||
static G4bool fParallelVoxelOptimisationRequested;
|
||||
// Flag to register it was requested.
|
||||
static G4bool fOptimizeInParallelConfigured;
|
||||
static G4bool fOptimiseInParallelConfigured;
|
||||
// Not just requested, but adopted (i.e. also in MT/tasking mode).
|
||||
static G4bool fParallelVoxelOptimisationUnderway; // It has started
|
||||
static G4bool fParallelVoxelOptimisationFinished; // It is done
|
||||
static G4bool fUsingExistingWorkers;
|
||||
// Fact: can and will use existing MT/tasks.
|
||||
static G4bool fUsingExistingWorkers; // Can and will use existing MT/tasks.
|
||||
|
||||
// Statistics for parallel Optimisation - used in 'verbose' mode
|
||||
// ------------------------------------
|
||||
static G4double fSumVoxelTime;
|
||||
static G4int fNumberThreadsReporting;
|
||||
static unsigned int fTotalNumberVolumesOptimized;
|
||||
static unsigned int fTotalNumberVolumesOptimised;
|
||||
// Counters.
|
||||
|
||||
// For Wall Clock time in parallel mode ...
|
||||
|
||||
@@ -76,18 +76,17 @@ namespace // Data structures / mutexes for parallel optimisation
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4ThreadLocal G4GeometryManager* G4GeometryManager::fgInstance = nullptr;
|
||||
G4ThreadLocal G4bool G4GeometryManager::fIsClosed = false;
|
||||
|
||||
// Static *global* class data
|
||||
G4bool G4GeometryManager::fParallelVoxelOptimisationRequested = true;
|
||||
// Records User choice - to use parallel voxel optimisation (or not)
|
||||
G4bool G4GeometryManager::fParallelVoxelOptimisationRequested = false;
|
||||
// Records User choice to use parallel voxel optimisation (or not)
|
||||
|
||||
G4bool G4GeometryManager::fOptimizeInParallelConfigured = false;
|
||||
// Configured = requested && available (ie if MT or Threads is used)
|
||||
// Value calculated during each effort to optimise
|
||||
G4bool G4GeometryManager::fOptimiseInParallelConfigured = false;
|
||||
// Configured = requested && available (ie if MT or Threads is used)
|
||||
// Value calculated during each effort to optimise
|
||||
|
||||
std::vector<G4LogicalVolume*> G4GeometryManager::fVolumesToOptimize;
|
||||
std::vector<G4LogicalVolume*>::iterator G4GeometryManager::fLogVolumeIterator;
|
||||
std::vector<G4LogicalVolume*> G4GeometryManager::fVolumesToOptimise;
|
||||
std::vector<G4LogicalVolume*>::const_iterator G4GeometryManager::fLogVolumeIterator;
|
||||
|
||||
std::vector<G4SmartVoxelStat> G4GeometryManager::fGlobVoxelStats;
|
||||
// Container for statistics
|
||||
@@ -99,7 +98,7 @@ G4bool G4GeometryManager::fParallelVoxelOptimisationFinished = false;
|
||||
G4double G4GeometryManager::fSumVoxelTime = 0.0;
|
||||
|
||||
G4int G4GeometryManager::fNumberThreadsReporting = 0;
|
||||
unsigned int G4GeometryManager::fTotalNumberVolumesOptimized = 0U;
|
||||
unsigned int G4GeometryManager::fTotalNumberVolumesOptimised = 0U;
|
||||
|
||||
// For Wall clock
|
||||
G4Timer* G4GeometryManager::fWallClockTimer = nullptr;
|
||||
@@ -168,15 +167,6 @@ void G4GeometryManager::OpenGeometry(G4VPhysicalVolume* pVolume)
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Returns status of geometry
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4bool G4GeometryManager::IsGeometryClosed()
|
||||
{
|
||||
return fIsClosed;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Returns the instance of the singleton.
|
||||
// Creates it in case it's called for the first time.
|
||||
@@ -209,7 +199,7 @@ G4GeometryManager* G4GeometryManager::GetInstanceIfExist()
|
||||
// Simplest user method to request parallel optimisation.
|
||||
// ***************************************************************************
|
||||
//
|
||||
void G4GeometryManager::OptimizeInParallel( G4bool val )
|
||||
void G4GeometryManager::OptimiseInParallel( G4bool val )
|
||||
{
|
||||
RequestParallelOptimisation(val);
|
||||
}
|
||||
@@ -247,14 +237,14 @@ G4bool G4GeometryManager::BuildOptimisations(G4bool allOpts, G4bool verbose)
|
||||
{
|
||||
G4bool finishedOptimisation = false;
|
||||
|
||||
fOptimizeInParallelConfigured = fParallelVoxelOptimisationRequested
|
||||
fOptimiseInParallelConfigured = fParallelVoxelOptimisationRequested
|
||||
&& G4Threading::IsMultithreadedApplication();
|
||||
|
||||
static unsigned int NumCallsBuildOptimisations = 0; // WORKAROUND - TODO fix
|
||||
if( fOptimizeInParallelConfigured && (NumCallsBuildOptimisations==0) )
|
||||
if( fOptimiseInParallelConfigured && (NumCallsBuildOptimisations==0) )
|
||||
{
|
||||
PrepareParallelOptimisation(allOpts, verbose);
|
||||
NumCallsBuildOptimisations++;
|
||||
++NumCallsBuildOptimisations;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -387,7 +377,7 @@ G4GeometryManager::CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose)
|
||||
|
||||
G4LogicalVolumeStore* Store = G4LogicalVolumeStore::GetInstance();
|
||||
|
||||
if( fVolumesToOptimize.size() > 0)
|
||||
if( !fVolumesToOptimise.empty() )
|
||||
{
|
||||
ResetListOfVolumesToOptimise();
|
||||
}
|
||||
@@ -402,7 +392,7 @@ G4GeometryManager::CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose)
|
||||
&& (volume->GetDaughter(0)->IsReplicated())
|
||||
&& (volume->GetDaughter(0)->GetRegularStructureId()!=1) ) )
|
||||
{
|
||||
fVolumesToOptimize.push_back(volume);
|
||||
fVolumesToOptimise.push_back(volume);
|
||||
|
||||
// For safety, must check (later) if there are any existing voxels and
|
||||
// delete before replacement:
|
||||
@@ -413,7 +403,7 @@ G4GeometryManager::CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose)
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
G4cout << "- Booking logical volume with " << volume->GetNoDaughters()
|
||||
<< " daughters and name = '" << volume->GetName() << "' "
|
||||
<< " -- for optimization (ie voxels will be built for it). " << G4endl;
|
||||
<< " -- for optimisation (ie voxels will be built for it). " << G4endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -428,9 +418,9 @@ G4GeometryManager::CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose)
|
||||
if(verbose)
|
||||
G4cout << "** G4GeometryManager::PrepareOptimisationWork: "
|
||||
<< " Number of volumes for voxelisation = "
|
||||
<< fVolumesToOptimize.size() << G4endl;
|
||||
<< fVolumesToOptimise.size() << G4endl;
|
||||
|
||||
fLogVolumeIterator = fVolumesToOptimize.begin();
|
||||
fLogVolumeIterator = fVolumesToOptimise.cbegin();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -439,13 +429,13 @@ G4GeometryManager::CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose)
|
||||
// Critical method for parallel optimisation - must be correct and fast.
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4LogicalVolume* G4GeometryManager::ObtainVolumeToOptimize()
|
||||
G4LogicalVolume* G4GeometryManager::ObtainVolumeToOptimise()
|
||||
{
|
||||
G4LogicalVolume* logVolume = nullptr;
|
||||
|
||||
G4AutoLock lock(obtainVolumeMutex);
|
||||
|
||||
if( fLogVolumeIterator != fVolumesToOptimize.end() )
|
||||
if( fLogVolumeIterator != fVolumesToOptimise.cend() )
|
||||
{
|
||||
logVolume = *fLogVolumeIterator;
|
||||
++fLogVolumeIterator;
|
||||
@@ -461,13 +451,13 @@ void G4GeometryManager::ResetListOfVolumesToOptimise()
|
||||
{
|
||||
G4AutoLock lock(obtainVolumeMutex);
|
||||
|
||||
std::vector<G4LogicalVolume*>().swap(fVolumesToOptimize);
|
||||
std::vector<G4LogicalVolume*>().swap(fVolumesToOptimise);
|
||||
// Swapping with an empty vector in order to empty it
|
||||
// without calling destructors of logical volumes.
|
||||
// Must not call clear: i.e. fVolumesToOptimize.clear();
|
||||
// Must not call clear: i.e. fVolumesToOptimise.clear();
|
||||
|
||||
assert(fVolumesToOptimize.empty());
|
||||
fLogVolumeIterator = fVolumesToOptimize.begin();
|
||||
assert(fVolumesToOptimise.empty());
|
||||
fLogVolumeIterator = fVolumesToOptimise.cbegin();
|
||||
|
||||
fGlobVoxelStats.clear();
|
||||
// Reset also the statistics of volumes -- to avoid double recording.
|
||||
@@ -508,7 +498,7 @@ void G4GeometryManager::ConfigureParallelOptimisation(G4bool verbose)
|
||||
// New effort -- reset the total time -- and number of threads reporting
|
||||
fSumVoxelTime = 0.0;
|
||||
fNumberThreadsReporting = 0;
|
||||
fTotalNumberVolumesOptimized = 0; // Number of volumes done
|
||||
fTotalNumberVolumesOptimised = 0; // Number of volumes done
|
||||
|
||||
fWallClockStarted = false; // Will need to restart it!
|
||||
}
|
||||
@@ -552,9 +542,9 @@ void G4GeometryManager::UndertakeOptimisation()
|
||||
}
|
||||
|
||||
G4Timer fetimer;
|
||||
unsigned int numVolumesOptimized = 0;
|
||||
unsigned int numVolumesOptimised = 0;
|
||||
|
||||
while( (logVolume = ObtainVolumeToOptimize()) != nullptr )
|
||||
while( (logVolume = ObtainVolumeToOptimise()) != nullptr )
|
||||
{
|
||||
if (verbose) fetimer.Start();
|
||||
|
||||
@@ -568,15 +558,14 @@ void G4GeometryManager::UndertakeOptimisation()
|
||||
|
||||
if (head != nullptr)
|
||||
{
|
||||
++numVolumesOptimized;
|
||||
++numVolumesOptimised;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4ExceptionDescription message;
|
||||
message << "VoxelHeader allocation error." << G4endl
|
||||
<< "Allocation of new VoxelHeader" << G4endl
|
||||
<< " for logical volume " << logVolume->GetName()
|
||||
<< " failed.";
|
||||
<< "for logical volume " << logVolume->GetName() << " failed.";
|
||||
G4Exception("G4GeometryManager::BuildOptimisationsParallel()",
|
||||
"GeomMgt0003", FatalException, message);
|
||||
}
|
||||
@@ -599,10 +588,10 @@ void G4GeometryManager::UndertakeOptimisation()
|
||||
G4bool allDone = false;
|
||||
G4int myCount= -1;
|
||||
|
||||
myCount = ReportWorkerIsDoneOptimising(numVolumesOptimized);
|
||||
myCount = ReportWorkerIsDoneOptimising(numVolumesOptimised);
|
||||
allDone = IsParallelOptimisationFinished();
|
||||
|
||||
if( (allDone && myCount) == G4Threading::GetNumberOfRunningWorkerThreads() )
|
||||
if( allDone && (myCount == G4Threading::GetNumberOfRunningWorkerThreads()) )
|
||||
{
|
||||
G4int badVolumes = CheckOptimisation(); // Check all voxels are created!
|
||||
if( badVolumes > 0 )
|
||||
@@ -611,8 +600,8 @@ void G4GeometryManager::UndertakeOptimisation()
|
||||
errmsg <<" Expected that all voxelisation work is done, "
|
||||
<< "but found that voxels headers are missing in "
|
||||
<< badVolumes << " volumes.";
|
||||
G4Exception("G4GeometryManager::UndertakeOptimisation",
|
||||
"GeomMng002",FatalException, errmsg);
|
||||
G4Exception("G4GeometryManager::UndertakeOptimisation()",
|
||||
"GeomMng002", FatalException, errmsg);
|
||||
}
|
||||
|
||||
// Create report
|
||||
@@ -623,15 +612,15 @@ void G4GeometryManager::UndertakeOptimisation()
|
||||
|
||||
std::ostream& report_stream = std::cout; // G4cout; does not work!
|
||||
report_stream << G4endl
|
||||
<< " G4GeometryManager::UndertakeOptimisation()"
|
||||
<< " - Timing for Voxel Optimisation" << G4endl;
|
||||
report_stream << " - Elapsed time (real) = " << std::setprecision(4)
|
||||
<< fWallClockTimer->GetRealElapsed() << " seconds (wall clock) "
|
||||
<< " , user " << fWallClockTimer->GetUserElapsed() << "seconds "
|
||||
<< " , system " << fWallClockTimer->GetSystemElapsed() << " seconds."
|
||||
<< G4endl;
|
||||
report_stream << " - Sum voxel time (real) = " << fSumVoxelTime
|
||||
<< " seconds.";
|
||||
<< "G4GeometryManager::UndertakeOptimisation"
|
||||
<< " -- Timing for Voxel Optimisation" << G4endl;
|
||||
report_stream << " - Elapsed time (real) = " << std::setprecision(4)
|
||||
<< fWallClockTimer->GetRealElapsed() << "s (wall clock)"
|
||||
<< ", user " << fWallClockTimer->GetUserElapsed() << "s"
|
||||
<< ", system " << fWallClockTimer->GetSystemElapsed() << "s."
|
||||
<< G4endl;
|
||||
report_stream << " - Sum voxel time (real) = " << fSumVoxelTime
|
||||
<< "s.";
|
||||
report_stream << std::setprecision(6) << G4endl << G4endl;
|
||||
|
||||
ReportVoxelStats( fGlobVoxelStats, fSumVoxelTime, report_stream );
|
||||
@@ -667,8 +656,9 @@ void G4GeometryManager::WaitForVoxelisationFinish(G4bool verbose)
|
||||
if( verbose )
|
||||
{
|
||||
G4AutoLock lock(outputDbgMutex);
|
||||
out_stream << G4endl << "** UndertakeOptimisation done on tid= " << tid
|
||||
<< " after waiting for " << trials << " trials." << G4endl;
|
||||
out_stream << G4endl
|
||||
<< "** UndertakeOptimisation done on tid= " << tid
|
||||
<< " after waiting for " << trials << " trials." << G4endl;
|
||||
out_stream.flush();
|
||||
}
|
||||
}
|
||||
@@ -679,13 +669,10 @@ void G4GeometryManager::WaitForVoxelisationFinish(G4bool verbose)
|
||||
//
|
||||
G4int G4GeometryManager::CheckOptimisation()
|
||||
{
|
||||
unsigned int numErrors= 0;
|
||||
for ( auto logical : fVolumesToOptimize ){
|
||||
if( logical->GetVoxelHeader() == nullptr ){
|
||||
std::cerr << "G4GeometryManager::CheckOptimisation: ERROR "
|
||||
<< " logical volume " << logical->GetName() << " has Voxel Header = " << G4endl;
|
||||
numErrors++;
|
||||
}
|
||||
unsigned int numErrors = 0;
|
||||
for ( const auto& logical : fVolumesToOptimise )
|
||||
{
|
||||
if( logical->GetVoxelHeader() == nullptr ) { ++numErrors; }
|
||||
}
|
||||
return numErrors;
|
||||
}
|
||||
@@ -701,14 +688,14 @@ G4int G4GeometryManager::CheckOptimisation()
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4int
|
||||
G4GeometryManager::ReportWorkerIsDoneOptimising(unsigned int numVolumesOptimized)
|
||||
G4GeometryManager::ReportWorkerIsDoneOptimising(unsigned int numVolumesOptimised)
|
||||
{
|
||||
// Check that all are done and, if so, signal that optimisation is finished
|
||||
G4int orderReporting;
|
||||
|
||||
G4AutoLock lock(statResultsMutex);
|
||||
orderReporting = ++fNumberThreadsReporting;
|
||||
fTotalNumberVolumesOptimized += numVolumesOptimized;
|
||||
fTotalNumberVolumesOptimised += numVolumesOptimised;
|
||||
|
||||
if (fNumberThreadsReporting == G4Threading::GetNumberOfRunningWorkerThreads())
|
||||
{
|
||||
@@ -718,26 +705,25 @@ G4GeometryManager::ReportWorkerIsDoneOptimising(unsigned int numVolumesOptimized
|
||||
return orderReporting;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// ***************************************************************************
|
||||
// Inform that all work for parallel optimisation is finished.
|
||||
// *****************************************************************************
|
||||
// ***************************************************************************
|
||||
//
|
||||
void G4GeometryManager::InformOptimisationIsFinished(G4bool verbose)
|
||||
{
|
||||
if(verbose)
|
||||
if(verbose) // G4cout does not work!
|
||||
{
|
||||
G4cout << "** G4GeometryManager: All voxel optimisation work is completed!"
|
||||
<< G4endl;
|
||||
G4cout << " Total number of volumes optimised = "
|
||||
<< fTotalNumberVolumesOptimized
|
||||
<< " of " << fVolumesToOptimize.size() << "expected" << G4endl;
|
||||
G4cout << " Number of workers reporting = "
|
||||
<< fNumberThreadsReporting
|
||||
<< " of " << G4Threading::GetNumberOfRunningWorkerThreads()
|
||||
<< "expected\n";
|
||||
std::cout << "** G4GeometryManager: All voxel optimisation work is completed!"
|
||||
<< G4endl;
|
||||
std::cout << " Total number of volumes optimised = "
|
||||
<< fTotalNumberVolumesOptimised
|
||||
<< " of " << fVolumesToOptimise.size() << " expected\n";
|
||||
std::cout << " Number of workers reporting = "
|
||||
<< fNumberThreadsReporting
|
||||
<< " of " << G4Threading::GetNumberOfRunningWorkerThreads()
|
||||
<< " expected\n";
|
||||
}
|
||||
assert ( fTotalNumberVolumesOptimized == fVolumesToOptimize.size() );
|
||||
assert ( fNumberThreadsReporting == G4Threading::GetNumberOfRunningWorkerThreads() );
|
||||
assert ( fTotalNumberVolumesOptimised == fVolumesToOptimise.size() );
|
||||
|
||||
fParallelVoxelOptimisationFinished = true;
|
||||
// fParallelVoxelOptimisationRequested = false; // Maintain request for next one!
|
||||
@@ -876,6 +862,8 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
|
||||
G4double totalCpuTime,
|
||||
std::ostream &os )
|
||||
{
|
||||
os << "--------------------------------------------------------------------------------"
|
||||
<< G4endl;
|
||||
os << "G4GeometryManager::ReportVoxelStats -- Voxel Statistics"
|
||||
<< G4endl << G4endl;
|
||||
|
||||
@@ -909,9 +897,8 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
|
||||
{
|
||||
os << "\n Voxelisation: top CPU users:" << G4endl;
|
||||
os << " Percent Total CPU System CPU Memory Volume\n"
|
||||
<< " ------- ---------- ---------- -------- ----------"
|
||||
<< G4endl;
|
||||
// 12345678901.234567890123.234567890123.234567890123k .
|
||||
<< " ------- ---------- ---------- -------- ----------"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
for(i=0; i<nPrint; ++i)
|
||||
@@ -952,9 +939,8 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
|
||||
{
|
||||
os << "\n Voxelisation: top memory users:" << G4endl;
|
||||
os << " Percent Memory Heads Nodes Pointers Total CPU Volume\n"
|
||||
<< " ------- -------- ------ ------ -------- ---------- ----------"
|
||||
<< G4endl;
|
||||
// 12345678901.2345678901k .23456789.23456789.2345678901.234567890123. .
|
||||
<< " ------- -------- ------ ------ -------- ---------- ----------"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
for(i=0; i<nPrint; ++i)
|
||||
@@ -964,32 +950,34 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
|
||||
if (totTime < 0) { totTime = 0.0; }
|
||||
|
||||
os << std::setprecision(2)
|
||||
<< std::setiosflags(std::ios::fixed|std::ios::right)
|
||||
<< std::setw(11) << G4double(memory*100)/G4double(totalMemory)
|
||||
<< std::setw(11) << memory/1024 << "k "
|
||||
<< std::setw( 9) << stats[i].GetNumberHeads()
|
||||
<< std::setw( 9) << stats[i].GetNumberNodes()
|
||||
<< std::setw(11) << stats[i].GetNumberPointers()
|
||||
<< std::setw(13) << totTime << " "
|
||||
<< std::setiosflags(std::ios::left)
|
||||
<< stats[i].GetVolume()->GetName()
|
||||
<< std::resetiosflags(std::ios::floatfield|std::ios::adjustfield)
|
||||
<< std::setprecision(6)
|
||||
<< G4endl;
|
||||
<< std::setiosflags(std::ios::fixed|std::ios::right)
|
||||
<< std::setw(11) << G4double(memory*100)/G4double(totalMemory)
|
||||
<< std::setw(11) << memory/1024 << "k "
|
||||
<< std::setw( 9) << stats[i].GetNumberHeads()
|
||||
<< std::setw( 9) << stats[i].GetNumberNodes()
|
||||
<< std::setw(11) << stats[i].GetNumberPointers()
|
||||
<< std::setw(13) << totTime << " "
|
||||
<< std::setiosflags(std::ios::left)
|
||||
<< stats[i].GetVolume()->GetName()
|
||||
<< std::resetiosflags(std::ios::floatfield|std::ios::adjustfield)
|
||||
<< std::setprecision(6)
|
||||
<< G4endl;
|
||||
}
|
||||
os << "--------------------------------------------------------------------------------"
|
||||
<< G4endl << G4endl;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Check whether parallel optimisation was requested --static (class) method.
|
||||
// Check whether parallel optimisation was requested -- static (class) data.
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4bool G4GeometryManager::IsParallelOptimisationConfigured()
|
||||
{
|
||||
return fOptimizeInParallelConfigured;
|
||||
return fOptimiseInParallelConfigured;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Report whether parallel optimisation is done -- static (class) method.
|
||||
// Report whether parallel optimisation is done -- static (class) data.
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4bool G4GeometryManager::IsParallelOptimisationFinished()
|
||||
|
||||
@@ -76,7 +76,7 @@ void G4LogicalVolumeStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the logical volume store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
|
||||
@@ -77,7 +77,7 @@ void G4PhysicalVolumeStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the physical volume store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
|
||||
@@ -79,7 +79,7 @@ void G4RegionStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the region store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
|
||||
@@ -75,7 +75,7 @@ void G4SolidStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the solid store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
|
||||
Reference in New Issue
Block a user