Geant4_10
tbbMasterRunManager.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // Class description:
28 //
29 // This class implements the master model run manager for TBB bases
30 // application.
31 // It is instantiated by user main (or equivalent function) instead
32 // of G4[MT]RunManager. It controls the creation of tbb::tasks.
33 // See G4MTRunManager for documentation of methods relative to base
34 // class. Only class specific methods are documented here.
35 //
36 // Equivalent in traditional MT:
37 // G4MTRunManager
38 //
39 // History:
40 // Nov 4th, 2013 A. Dotti - First Implementation
41 
42 #ifndef TBBMASTERRUNMANAGER_HH
43 #define TBBMASTERRUNMANAGER_HH
44 
45 #include "G4MTRunManager.hh"
46 #include <tbb/task.h>
47 
49 public:
51  //Default construct, tasklist is the tbb::task_list
52  //where the created tasks will be added to
53  //nEvents is the number of events each tbb::task is
54  //responsible for
55  virtual ~tbbMasterRunManager();
56  virtual void RunTermination();
57  void SetTaskList( tbb::task_list* tl ) { theTasks = tl; }
58  //Set a reference to the output task list where new tasks will
59  //be added to
60  void SetNumberEventsPerTask( G4int nt ) { nEvtsPerTask = nt; }
61  //Specify number of events that each simulation task is responsible
62  //for
63 protected:
64  virtual void CreateAndStartWorkers();
65  virtual void TerminateWorkers();
66  virtual void CreateTask(G4int id,G4int evts);
67  //Creates a concrete tbb::task with index id
68  //responsible for evts events
69 protected:
70  //Barriers mechanism for TBB is non existing
71  virtual void WaitForReadyWorkers() {}
72  virtual void WaitForEndEventLoopWorkers() {}
73  virtual void ThisWorkerReady() {}
74  virtual void ThisWorkerEndEventLoop() {}
76  virtual void NewActionRequest( WorkerActionRequest /*newRequest*/ ) {}
77 private:
78  tbb::task_list* theTasks;
79  G4int nEvtsPerTask;
80 };
81 
82 #endif //TBBMASTERRUNMANAGER_HH
virtual void WaitForEndEventLoopWorkers()
virtual void TerminateWorkers()
void SetNumberEventsPerTask(G4int nt)
int G4int
Definition: G4Types.hh:78
virtual void WaitForReadyWorkers()
virtual WorkerActionRequest ThisWorkerWaitForNextAction()
virtual void ThisWorkerEndEventLoop()
virtual void ThisWorkerReady()
TTree * nt
Definition: plotHisto.C:21
virtual void NewActionRequest(WorkerActionRequest)
virtual void CreateTask(G4int id, G4int evts)
virtual void RunTermination()
void SetTaskList(tbb::task_list *tl)
virtual void CreateAndStartWorkers()