Geant4  10.00.p02
tbbMasterRunManager.cc
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 worker model run manager for TBB based
30 // application.
31 // It is instantiated by tbbUserWorkerInitialization and used by
32 // tbbMasterRunManager.
33 // See G4WorkerRunManager for documentation of methods relative to
34 // base class. Only class specific methods are documented here.
35 //
36 // Equivalent in traditional MT:
37 // G4WorkerRunManager
38 //
39 // History:
40 // Oct 31st, 2013 A. Dotti - First Implementation
41 
42 #include "tbbMasterRunManager.hh"
43 #include "tbbTask.hh"
44 
47  theTasks(static_cast<tbb::task_list*>(0)),
48  nEvtsPerTask(1)
49 {
50 }
51 
53 {
54 }
55 
57 {
58  //For TBB based example this should be empty
59 }
60 
62 {
63  //Instead of pthread based workers, create tbbTask
66  for ( G4int nt = 0 ; nt < ntasks ; ++nt )
67  {
68  G4int evts= nEvtsPerTask;
69  if ( nt == ntasks - 1 ) evts+=remn;
70  CreateTask(nt,evts);
71  }
72 }
73 
75 {
76  tbbTask& task = * new(tbb::task::allocate_root())
77  tbbTask( id , NULL , evts ); //Add output for merging
78  theTasks->push_back( task );
79 }
80 
82 {
83  // Reduce results ....
85 }
86 
virtual void TerminateWorkers()
tbb::task_list * theTasks
virtual void RunTermination()
int G4int
Definition: G4Types.hh:78
virtual void CreateTask(G4int id, G4int evts)
virtual void RunTermination()
G4int numberOfEventToBeProcessed
virtual void CreateAndStartWorkers()