Import Geant4 10.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2016-06-30 14:12:05 +02:00
parent a654a7ab1f
commit 4ec577e5c4
2021 changed files with 100995 additions and 78277 deletions
+2 -1
View File
@@ -17,7 +17,8 @@ task-based parallelism. <em> It should not be considered a feature-complete exam
and it present some limitations (no merging of output, no correct clean-up of
heap). </em>
It will be substantially improved in 2014. If you have interest in TBB please
It will be substantially improved in the future.
If you have interest in TBB please
refer to Geant4 Multi-threading user-forum (reachable from Geant4 website)
where updates on TBB will be communicated or contact example author at:
adotti@slac.stanford.edu.
@@ -33,7 +33,7 @@
//G4-TBB interfaces
#include "tbbUserWorkerInitialization.hh"
#include "tbbMasterRunManager.hh"
#include "SimpleTbbMasterRunManager.hh"
#include "G4Threading.hh"
#include "G4UImanager.hh"
@@ -68,10 +68,10 @@ G4ThreadFunReturnType startWork(G4ThreadFunArgType arg)
//We assume at least one /run/beamOn was executed, thus the tasklist is now filled,
//lets start TBB
try {
std::cout<<"Now spawn work and waiting"<<std::endl;
std::cout<<"Now calling 'tbb::task::spawn_work_and_wait' "<<std::endl;
tbb::task::spawn_root_and_wait( *tasks );
} catch(std::exception& e) {
std::cerr<<"Error occurred. Error test is:\""<<e.what()<<"\""<<std::endl;
std::cerr<<"Error occurred. Error info is:\""<<e.what()<<"\""<<std::endl;
}
return static_cast<G4ThreadFunReturnType>(0);
}
@@ -83,14 +83,14 @@ int main(int argc,char** argv)
// Choose the Random engine
G4Random::setTheEngine(new CLHEP::RanecuEngine);
//=== TBB engine initialization
tbb::task_scheduler_init init( G4Threading::G4GetNumberOfCores() );
tbb::task_list tasks;
unsigned int numCoresAvailable= G4Threading::G4GetNumberOfCores();
unsigned int numberOfCoresToUse= (numCoresAvailable > 1 ) ? 2 : 1 ;
//=== TBB engine initialization
tbb::task_scheduler_init init( numberOfCoresToUse );
tbb::task_list tasks;
tbbMasterRunManager* runManager = new tbbMasterRunManager;
SimpleTbbMasterRunManager* runManager = new SimpleTbbMasterRunManager;
//Set TBB specific data to run-manager, 1 event per tbb::task (e.g. Nevents == N tasks)
//Note that a /run/beamOn command will just create tasks and add them to tasks
@@ -117,14 +117,6 @@ int main(int argc,char** argv)
runManager->Initialize();
#ifdef G4VIS_USE
// Initialize visualization
G4VisManager* visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
// G4VisManager* visManager = new G4VisExecutive("Quiet");
visManager->Initialize();
#endif
// Get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();
@@ -136,17 +128,18 @@ int main(int argc,char** argv)
}
else
{ // interactive mode : define UI session
#ifdef G4UI_USE
#if 1
G4int nEvents= 50;
runManager->BeamOn(nEvents);
#else
#ifdef G4UI_USE
G4UIExecutive* ui = new G4UIExecutive(argc, argv);
#ifdef G4VIS_USE
UImanager->ApplyCommand("/control/execute init_vis.mac");
#else
UImanager->ApplyCommand("/control/execute init.mac");
#endif
UImanager->ApplyCommand("/control/execute init.mac");
if (ui->IsGUI())
UImanager->ApplyCommand("/control/execute gui.mac");
ui->SessionStart();
delete ui;
#endif
#endif
}
//END-G4
@@ -156,10 +149,6 @@ int main(int argc,char** argv)
//Wait for work to be finised
G4THREADJOIN(aThread);
#ifdef G4VIS_USE
delete visManager;
#endif
delete runManager;
return 0;
@@ -39,20 +39,20 @@
// History:
// Nov 4th, 2013 A. Dotti - First Implementation
#ifndef TBBMASTERRUNMANAGER_HH
#define TBBMASTERRUNMANAGER_HH
#ifndef SIMPLETBBMASTERRUNMANAGER_HH
#define SIMPLETBBMASTERRUNMANAGER_HH
#include "G4MTRunManager.hh"
#include <tbb/task.h>
class tbbMasterRunManager : public G4MTRunManager {
class SimpleTbbMasterRunManager : public G4MTRunManager {
public:
tbbMasterRunManager();
//Default construct, tasklist is the tbb::task_list
//where the created tasks will be added to
//nEvents is the number of events each tbb::task is
//responsible for
virtual ~tbbMasterRunManager();
SimpleTbbMasterRunManager(); // G4RunManagerKernel* existingRMK=0);
// Default constructor,
// tasklist is the tbb::task_list to which the created tasks will be added.
// nEvents is the number of events for which each tbb::task is responsible
//
virtual ~SimpleTbbMasterRunManager();
virtual void RunTermination();
void SetTaskList( tbb::task_list* tl ) { theTasks = tl; }
//Set a reference to the output task list where new tasks will
@@ -72,7 +72,8 @@ protected:
virtual void WaitForEndEventLoopWorkers() {}
virtual void ThisWorkerReady() {}
virtual void ThisWorkerEndEventLoop() {}
virtual WorkerActionRequest ThisWorkerWaitForNextAction() { return UNDEFINED; }
virtual WorkerActionRequest ThisWorkerWaitForNextAction()
{ return WorkerActionRequest::UNDEFINED; }
virtual void NewActionRequest( WorkerActionRequest /*newRequest*/ ) {}
private:
tbb::task_list* theTasks;
@@ -37,12 +37,13 @@ public:
tbbTask(G4int anId, tbb::concurrent_queue<const G4Run*>* output=0 , G4int nEvts = 1 );
virtual ~tbbTask();
tbb::task* execute();
unsigned int GetSlotId(); //
private:
G4int nEvents;
G4int thisID;
tbb::concurrent_queue<const G4Run*>* output;
G4bool beamOnCondition;
G4int m_nEvents;
G4int m_taskID;
tbb::concurrent_queue<const G4Run*>* m_output;
G4bool m_beamOnCondition;
};
#endif //TBBTASK_HH
#endif //TBBTASK_HH
@@ -29,7 +29,7 @@
// This class implements the worker model run manager for TBB based
// application.
// It is instantiated by tbbUserWorkerInitialization and used by
// tbbMasterRunManager.
// SimpleTbbMasterRunManager.
// See G4WorkerRunManager for documentation of methods relative to
// base class. Only class specific methods are documented here.
//
@@ -38,6 +38,7 @@
//
// History:
// Oct 31st, 2013 A. Dotti - First Implementation
// May 12th, 2014 J. Apostolakis - Additional methods/functionality
#ifndef TBBWORKERRUNMANAGER_HH
#define TBBWORKERRUNMANAGER_HH
@@ -29,7 +29,7 @@
// This class implements the worker model run manager for TBB based
// application.
// It is instantiated by tbbUserWorkerInitialization and used by
// tbbMasterRunManager.
// SimpleTbbMasterRunManager.
// See G4WorkerRunManager for documentation of methods relative to
// base class. Only class specific methods are documented here.
//
@@ -39,26 +39,26 @@
// History:
// Oct 31st, 2013 A. Dotti - First Implementation
#include "tbbMasterRunManager.hh"
#include "SimpleTbbMasterRunManager.hh"
#include "tbbTask.hh"
tbbMasterRunManager::tbbMasterRunManager() :
SimpleTbbMasterRunManager::SimpleTbbMasterRunManager() :
G4MTRunManager(),
theTasks(static_cast<tbb::task_list*>(0)),
nEvtsPerTask(1)
{
}
tbbMasterRunManager::~tbbMasterRunManager()
SimpleTbbMasterRunManager::~SimpleTbbMasterRunManager()
{
}
void tbbMasterRunManager::TerminateWorkers()
void SimpleTbbMasterRunManager::TerminateWorkers()
{
//For TBB based example this should be empty
}
void tbbMasterRunManager::CreateAndStartWorkers()
void SimpleTbbMasterRunManager::CreateAndStartWorkers()
{
//Instead of pthread based workers, create tbbTask
G4int ntasks = numberOfEventToBeProcessed/nEvtsPerTask;
@@ -71,14 +71,14 @@ void tbbMasterRunManager::CreateAndStartWorkers()
}
}
void tbbMasterRunManager::CreateTask(G4int id,G4int evts)
void SimpleTbbMasterRunManager::CreateTask(G4int id,G4int evts)
{
tbbTask& task = * new(tbb::task::allocate_root())
tbbTask( id , NULL , evts ); //Add output for merging
theTasks->push_back( task );
}
void tbbMasterRunManager::RunTermination()
void SimpleTbbMasterRunManager::RunTermination()
{
// Reduce results ....
G4MTRunManager::RunTermination();
@@ -42,10 +42,10 @@
tbbTask::tbbTask(G4int anId,
tbb::concurrent_queue<const G4Run*>* out,
G4int nevts)
: nEvents(nevts),
thisID(anId),
output(out),
beamOnCondition(false)
: m_nEvents(nevts),
m_taskID(anId),
m_output(out),
m_beamOnCondition(false)
{
}
@@ -177,20 +177,20 @@ tbb::task* tbbTask::execute()
G4int numSelect = masterRM->GetNumberOfSelectEvents();
if ( macroFile == "" || macroFile == " " )
{
localRM->BeamOn(nEvents,0,numSelect);
localRM->BeamOn(m_nEvents,0,numSelect);
}
else
{
localRM->BeamOn(nEvents,macroFile,numSelect);
localRM->BeamOn(m_nEvents,macroFile,numSelect);
}
//======= NEW TBB SPECIFIC ===========
//Step-5: Initialize and start run
//====================================
// bla-bla-bla-bla
// This is basically BeamOn
beamOnCondition = localRM->ConfirmBeamOnCondition();
if (beamOnCondition) {
localRM->SetNumberOfEventsToBeProcessed( nEvents );
m_beamOnCondition = localRM->ConfirmBeamOnCondition();
if (m_beamOnCondition) {
localRM->SetNumberOfEventsToBeProcessed( m_nEvents );
localRM->ConstructScoringWorlds();
localRM->RunInitialization();
//Register this G4Run in output
@@ -198,12 +198,12 @@ tbb::task* tbbTask::execute()
//G4Run or derived class. We let the kernel know this is the object
//where the output is accumulated for the tbb::tasks that run on
//this thread.
if ( output ) {}
if ( m_output ) {}
}
}
assert(localRM!=0);
if ( beamOnCondition ) {
localRM->DoEventLoop( nEvents );
if ( m_beamOnCondition ) {
localRM->DoEventLoop( m_nEvents );
//localRM->RunTermination(); //<<<< How to call this??? ANDREA TBB
}
@@ -3,6 +3,10 @@
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
add_subdirectory(B2b)
if(GEANT4_BUILD_MULTITHREADED)
add_subdirectory(B2b)
add_custom_target(tbb DEPENDS B2bTBB)
add_custom_target(g4tbb DEPENDS exampleB2bTBB)
else()
message("-- G4 Examples: tbb examples require multithreaded build, disable")
endif()
+7
View File
@@ -15,6 +15,13 @@ track of all tags.
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
23rd Fev 2016 A. Dotti (tbbex-V10-02-01)
- Removing example "granular" that is not yet ready. Use
previous tag to develop it.
22nd Feb 2016 A. Dotti (tbbex-V10-02-00)
- Compatibility porting to run-V10-02-07 tag
10th November 2013 I. Hrivnacova (tbbex-V09-06-02)
- Added README files (and moved previous README in DevelopmentStatus.txt)
- Fixed CMake build
+2 -1
View File
@@ -13,7 +13,8 @@ task-based parallelism. It should not be considered a feature-complete example
and it present some limitations (no merging of output, no correct clean-up of
heap).
It will be substantially improved in 2014. If you have interest in TBB please
It will be substantially improved in the future.
If you have interest in TBB please
refer to Geant4 Multi-threading user-forum (reachable from Geant4 website)
where updates on TBB will be communicated or contact example author at:
adotti@slac.stanford.edu.
@@ -4,7 +4,6 @@
name := ts_scorers
G4TARGET := $(name)
G4EXLIB := true
G4WORKDIR:=.
ifndef G4INSTALL
G4INSTALL = ../../..
@@ -16,5 +15,5 @@ all: lib bin
include $(G4INSTALL)/config/binmake.gmk
visclean:
rm -f g4*.prim g4*.eps g4*.wrl
rm -f .DAWN_*
rm -f g4*.prim g4*.eps g4*.wrl
rm -f .DAWN_*
@@ -14,6 +14,13 @@ track of all tags.
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
15/06/16 Gunter Folger (ThreadsafeScorers-V10-02-02)
- Correct GNUmakefile, remove setting of WORKDIR=.
15/06/16 Gunter Folger (ThreadsafeScorers-V10-02-01)
- Correct GNUmakefile,i.e. replace spaces by tab
17/11/15 J. Madsen
- Removed preprocessor checks for C++11
- Removed _HAS_ATOMICS_ preprocessor definition/conditions
File diff suppressed because it is too large Load Diff