#include <G4MPImanager.hh>
Definition at line 45 of file G4MPImanager.hh.
Enumerator |
---|
kTAG_G4COMMAND |
|
kTAG_G4STATUS |
|
kTAG_G4SEED |
|
kTAG_DATA |
|
kTAG_HISTO |
|
kTAG_RUN |
|
kTAG_CMDSCR |
|
Definition at line 50 of file G4MPImanager.hh.
G4MPImanager::G4MPImanager |
( |
| ) |
|
Definition at line 68 of file G4MPImanager.cc.
69 : verbose_(0), qfcout_(
false), qinitmacro_(
false), qbatchmode_(
false),
70 thread_id_(0), master_weight_(1.)
73 MPI::Init_thread(MPI::THREAD_SERIALIZED);
G4MPImanager::G4MPImanager |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 78 of file G4MPImanager.cc.
79 : verbose_(0), qfcout_(
false), qinitmacro_(
false), qbatchmode_(
false),
80 thread_id_(0), master_weight_(1.)
83 MPI::Init_thread(argc, argv, MPI::THREAD_SERIALIZED);
85 ParseArguments(argc, argv);
G4MPImanager::~G4MPImanager |
( |
| ) |
|
Definition at line 89 of file G4MPImanager.cc.
91 if( is_slave_ && qfcout_ ) fscout_.close();
97 COMM_G4COMMAND_.Free();
Definition at line 416 of file G4MPImanager.cc.
418 enum { kBUFF_SIZE = 512 };
419 static char sbuff[kBUFF_SIZE];
420 command.copy(sbuff, kBUFF_SIZE);
431 for (
G4int islave = 1; islave < size_; islave++ ) {
432 COMM_G4COMMAND_.Send(sbuff, kBUFF_SIZE, MPI::CHAR,
437 MPI::Request request= COMM_G4COMMAND_.Irecv(sbuff, kBUFF_SIZE, MPI::CHAR,
440 while(! request.Test()) {
Definition at line 460 of file G4MPImanager.cc.
462 #ifndef G4MULTITHREADED
467 G4double ntot = master_weight_ + size_ - 1.;
469 G4int nproc0 = nevent - nproc*(size_-1);
471 if ( verbose_ > 0 && is_master_ ) {
472 G4cout <<
"#events in master=" << nproc0 <<
" / "
473 <<
"#events in slave=" << nproc <<
G4endl;
476 status_-> StartTimer();
478 #ifdef G4MULTITHREADED
483 UI-> ApplyCommand(
"/run/beamOn " + str_nevt);
485 if ( is_master_ ) runManager->
BeamOn(nproc0);
486 else runManager->
BeamOn(nproc);
489 status_-> StopTimer();
492 if( verbose_ > 0 && is_master_ ) {
493 G4cout <<
"#events in master=" << nevent <<
" / "
494 <<
"#events in slave=" << nevent <<
G4endl;
496 status_-> StartTimer();
498 #ifdef G4MULTITHREADED
501 UI-> ApplyCommand(
"/run/beamOn " + str_nevt);
503 runManager->
BeamOn(nevent);
506 status_-> StopTimer();
static G4String ConvertToString(G4bool boolVal)
static G4UImanager * GetUIpointer()
G4GLOB_DLL std::ostream G4cout
static G4RunManager * GetRunManager()
void BeamOn(G4int nevent, G4bool qdivide=true)
G4bool G4MPImanager::CheckThreadStatus |
( |
| ) |
|
Definition at line 325 of file G4MPImanager.cc.
328 unsigned qstatus = 0;
331 qstatus = (thread_id_ != 0);
333 for (
G4int islave = 1; islave < size_; islave++ ) {
334 MPI::Request request = COMM_G4COMMAND_.Irecv(&buff, 1, MPI::UNSIGNED,
336 while( ! request.Test() ) {
342 buff = (thread_id_ !=0);
348 COMM_G4COMMAND_.Bcast(&buff, 1, MPI::UNSIGNED,
kRANK_MASTER);
351 if ( qstatus != 0 )
return true;
void G4MPImanager::DistributeSeeds |
( |
| ) |
|
Definition at line 287 of file G4MPImanager.cc.
289 std::vector<G4long> seed_list = seed_generator_-> GetSeedList();
290 G4Random::setTheSeed(seed_list[rank_]);
void G4MPImanager::ExecuteBeamOnThread |
( |
const G4String & |
command | ) |
|
Definition at line 385 of file G4MPImanager.cc.
391 G4cout <<
"G4MPIsession:: beamOn is still running." <<
G4endl;
396 G4int rc = pthread_create(&thread_id_, 0,
397 (
Func_t)thread_ExecuteThreadCommand,
402 "Failed to create a beamOn thread.");
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4bool CheckThreadStatus()
Definition at line 449 of file G4MPImanager.cc.
451 G4bool currentmode = qbatchmode_;
454 batchSession-> SessionStart();
456 qbatchmode_ = currentmode;
void G4MPImanager::ExecuteThreadCommand |
( |
const G4String & |
command | ) |
|
Definition at line 356 of file G4MPImanager.cc.
360 G4int rc = UI-> ApplyCommand(command);
362 G4int commandStatus = rc - (rc%100);
364 switch( commandStatus ) {
368 G4cerr <<
"illegal application state -- command refused" <<
G4endl;
371 G4cerr <<
"command refused (" << commandStatus <<
")" <<
G4endl;
377 pthread_join(thread_id_, 0);
static G4UImanager * GetUIpointer()
G4GLOB_DLL std::ostream G4cerr
const G4String & G4MPImanager::GetInitFileName |
( |
| ) |
const |
|
inline |
const G4String & G4MPImanager::GetMacroFileName |
( |
| ) |
const |
|
inline |
Definition at line 103 of file G4MPImanager.cc.
105 if ( g4mpi_ == NULL ) {
106 G4Exception(
"G4MPImanager::GetManager()",
"MPI001",
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4double G4MPImanager::GetMasterWeight |
( |
| ) |
const |
|
inline |
G4int G4MPImanager::GetRank |
( |
| ) |
const |
|
inline |
G4int G4MPImanager::GetSize |
( |
| ) |
const |
|
inline |
G4int G4MPImanager::GetVerbose |
( |
| ) |
const |
|
inline |
G4bool G4MPImanager::IsBatchMode |
( |
| ) |
const |
|
inline |
G4bool G4MPImanager::IsInitMacro |
( |
| ) |
const |
|
inline |
G4bool G4MPImanager::IsMaster |
( |
| ) |
const |
|
inline |
G4bool G4MPImanager::IsSlave |
( |
| ) |
const |
|
inline |
void G4MPImanager::JoinBeamOnThread |
( |
| ) |
|
Definition at line 532 of file G4MPImanager.cc.
535 std::cout << message << std::flush;
538 fscout_ << message << std::flush;
540 std::cout << rank_ <<
":" << message << std::flush;
Definition at line 219 of file G4MPImanager.hh.
221 master_weight_ = aweight;
223 if( aweight < 0. ) master_weight_ = 0.;
224 if( aweight > 1. ) master_weight_ = 1.;
Definition at line 317 of file G4MPImanager.cc.
319 if( rank_ == inode ) {
static void setTheSeed(long seed, int lux=3)
void G4MPImanager::SetVerbose |
( |
G4int |
iverbose | ) |
|
|
inline |
Definition at line 167 of file G4MPImanager.hh.
170 if( iverbose > 1 ) lv = 1;
171 if( iverbose < 0 ) lv = 0;
void G4MPImanager::ShowHelp |
( |
| ) |
const |
Definition at line 546 of file G4MPImanager.cc.
548 if (is_slave_ )
return;
552 G4cout <<
"<app> [options] [macro file]"
554 G4cout <<
" -h, --help show this message."
556 G4cout <<
" -v, --verbose show verbose message"
558 G4cout <<
" -i, --init=FNAME set an init macro file"
560 G4cout <<
" -o, --ofile[=FNAME] set slave output to a flie"
G4GLOB_DLL std::ostream G4cout
void G4MPImanager::ShowSeeds |
( |
| ) |
|
Definition at line 294 of file G4MPImanager.cc.
300 G4cout <<
"* rank= " << rank_
301 <<
" seed= " << G4Random::getTheSeed()
304 for (
G4int islave = 1; islave < size_; islave++ ) {
305 COMM_G4COMMAND_.Recv(&buff, 1, MPI::LONG, islave,
kTAG_G4SEED);
306 G4cout <<
"* rank= " << islave
311 buff = G4Random::getTheSeed();
G4GLOB_DLL std::ostream G4cout
void G4MPImanager::ShowStatus |
( |
| ) |
|
Definition at line 238 of file G4MPImanager.cc.
248 G4int nev = status_-> GetEventID();
249 G4int nevtp = status_-> GetNEventToBeProcessed();
250 G4double cputime = status_-> GetCPUTime();
253 for (
G4int islave = 1; islave < size_; islave++ ) {
256 status_-> UnPack(buff);
260 nev += status_-> GetEventID();
261 nevtp += status_-> GetNEventToBeProcessed();
262 cputime += status_-> GetCPUTime();
272 G4cout <<
"-------------------------------------------------------"
274 <<
"* #ranks= " << size_
275 <<
" event= " << nev <<
"/" << nevtp
276 <<
" state= " << strStatus
277 <<
" time= " << cputime <<
"s"
280 status_-> Pack(buff);
G4GLOB_DLL std::ostream G4cout
void Print(const G4String &message)
G4bool CheckThreadStatus()
void G4MPImanager::WaitBeamOn |
( |
| ) |
|
Definition at line 511 of file G4MPImanager.cc.
517 for (
G4int islave = 1; islave < size_; islave++) {
518 MPI::Request request = COMM_G4COMMAND_.Irecv(&buff, 1,
MPI::INT,
520 while(! request.Test()) {
The documentation for this class was generated from the following files:
- source/geant4.10.03.p03/examples/extended/parallel/MPI/source/include/G4MPImanager.hh
- source/geant4.10.03.p03/examples/extended/parallel/MPI/source/src/G4MPImanager.cc