Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
examples
extended
parallel
MPI
source
include
G4MPImanager.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
// ********************************************************************
27
28
#ifndef G4MPI_MANAGER_H
29
#define G4MPI_MANAGER_H
30
31
#include "mpi.h"
32
#include "
globals.hh
"
33
#include <pthread.h>
34
#include <fstream>
35
36
class
G4MPImessenger
;
37
class
G4MPIsession
;
38
class
G4MPIstatus
;
39
class
G4VMPIseedGenerator
;
40
41
class
G4MPImanager
{
42
public
:
43
// MPI master rank
44
enum
{
RANK_MASTER
= 0 };
45
46
enum
{
// MPI tag
47
TAG_G4COMMAND
= 100,
48
TAG_G4STATUS
= 200,
49
TAG_G4SEED
= 300,
50
TAG_DATA
= 1000
51
};
52
53
G4MPImanager
();
54
G4MPImanager
(
int
argc,
char
** argv);
55
~G4MPImanager
();
56
57
static
G4MPImanager
*
GetManager
();
58
59
// set/get methods
60
G4MPIsession
*
GetMPIsession
()
const
;
61
62
G4int
GetVerbose
()
const
;
63
void
SetVerbose
(
G4int
iverbose);
64
65
G4int
GetSize
()
const
;
66
G4int
GetRank
()
const
;
67
68
G4bool
IsMaster
()
const
;
69
G4bool
IsSlave
()
const
;
70
71
G4bool
IsInitMacro
()
const
;
72
const
G4String
&
GetInitFileName
()
const
;
73
74
G4bool
IsBatchMode
()
const
;
75
const
G4String
&
GetMacroFileName
()
const
;
76
77
void
SetMasterWeight
(
G4double
aweight);
78
G4double
GetMasterWeight
()
const
;
79
80
G4VMPIseedGenerator
*
GetSeedGenerator
()
const
;
81
82
// MPI methods
83
G4String
BcastCommand
(
const
G4String
& command);
84
void
ShowStatus
();
85
void
ShowSeeds
();
86
void
SetSeed
(
G4int
inode,
G4long
seed);
87
void
WaitBeamOn
();
88
89
// methods for MPI environment
90
void
DistributeSeeds
();
91
void
ExecuteMacroFile
(
const
G4String
&
fname
,
G4bool
qbatch=
false
);
92
G4bool
CheckThreadStatus
();
93
void
ExecuteThreadCommand
(
const
G4String
& command);
94
void
ExecuteBeamOnThread
(
const
G4String
& command);
95
void
JoinBeamOnThread
();
96
97
void
BeamOn
(
G4int
nevent
,
G4bool
qdivide=
true
);
98
void
Print
(
const
G4String
& message);
99
100
// misc
101
void
ShowHelp
()
const
;
102
103
private
:
104
static
G4MPImanager
* theManager;
105
G4MPImessenger
* messenger;
106
G4MPIsession
* session;
107
108
G4int
verbose;
109
G4MPIstatus
* status;
// status for each node
110
111
// MPI rank
112
G4bool
isMaster;
113
G4bool
isSlave;
114
G4int
rank;
115
G4int
size;
116
117
// MPI communicator
118
MPI::Intracomm COMM_G4COMMAND;
119
120
// cout/cerr control
121
G4bool
qfcout;
122
std::ofstream fscout;
123
124
// init/macro file
125
G4bool
qinitmacro;
126
G4String
initFileName;
127
G4bool
qbatchmode;
128
G4String
macroFileName;
129
130
// internal use
131
void
Initialize();
132
void
ParseArguments(
G4int
argc,
char
** argv);
133
void
Wait(
G4int
ausec)
const
;
134
void
UpdateStatus();
135
136
// for beamOn
137
pthread_t threadID;
138
139
// seed generator
140
G4VMPIseedGenerator
* seedGenerator;
141
142
// parallel parameters
143
G4double
masterWeight;
144
};
145
146
// ====================================================================
147
inline
G4MPIsession
*
G4MPImanager::GetMPIsession
()
const
148
{
149
return
session;
150
}
151
152
inline
G4int
G4MPImanager::GetVerbose
()
const
153
{
154
return
verbose;
155
}
156
157
inline
void
G4MPImanager::SetVerbose
(
G4int
iverbose)
158
{
159
G4int
lv=iverbose;
160
if
(iverbose>1) lv=1;
161
if
(iverbose<0) lv=0;
162
163
verbose= lv;
164
return
;
165
}
166
167
inline
G4int
G4MPImanager::GetRank
()
const
168
{
169
return
rank;
170
}
171
172
inline
G4int
G4MPImanager::GetSize
()
const
173
{
174
return
size;
175
}
176
177
inline
G4bool
G4MPImanager::IsMaster
()
const
178
{
179
return
isMaster;
180
}
181
182
inline
G4bool
G4MPImanager::IsSlave
()
const
183
{
184
return
isSlave;
185
}
186
187
inline
G4bool
G4MPImanager::IsInitMacro
()
const
188
{
189
return
qinitmacro;
190
191
}
192
193
inline
const
G4String
&
G4MPImanager::GetInitFileName
()
const
194
{
195
return
initFileName;
196
197
}
198
199
inline
G4bool
G4MPImanager::IsBatchMode
()
const
200
{
201
return
qbatchmode;
202
}
203
204
inline
const
G4String
&
G4MPImanager::GetMacroFileName
()
const
205
{
206
return
macroFileName;
207
}
208
209
inline
void
G4MPImanager::SetMasterWeight
(
G4double
aweight)
210
{
211
masterWeight= aweight;
212
213
if
(aweight<0.) masterWeight= 0.;
214
if
(aweight>1.) masterWeight= 1.;
215
}
216
217
inline
G4double
G4MPImanager::GetMasterWeight
()
const
218
{
219
return
masterWeight;
220
}
221
222
inline
G4VMPIseedGenerator
*
G4MPImanager::GetSeedGenerator
()
const
223
{
224
return
seedGenerator;
225
}
226
227
#endif
Generated on Sat May 25 2013 14:32:58 for Geant4 by
1.8.4