Loading...
Searching...
No Matches
G4MPIstatus.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/// @file G4MPIstatus.cc
26/// @brief status of MPI application
27
28#include "G4ApplicationState.hh"
29#include "G4MPIstatus.hh"
30
31// --------------------------------------------------------------------------
33 : rank_(0), run_id_(0), nevent_to_be_processed_(0), event_id_(0),
34 cputime_(0.), g4state_(G4State_Quit)
35{
36 timer_ = new G4Timer;
37}
38
39// --------------------------------------------------------------------------
41{
42 delete timer_;
43}
44
45// --------------------------------------------------------------------------
47{
48 timer_-> Start();
49}
50
51// --------------------------------------------------------------------------
53{
54 timer_-> Stop();
55}
56
57// --------------------------------------------------------------------------
58void G4MPIstatus::SetStatus(G4int arank, G4int runid, G4int noe, G4int evtid,
59 G4ApplicationState state)
60{
61 rank_ = arank;
62 run_id_ = runid;
64 event_id_ = evtid;
65 g4state_ = state;
66 if ( timer_-> IsValid() ) cputime_= timer_-> GetRealElapsed();
67 else cputime_ = 0.;
68}
69
70// --------------------------------------------------------------------------
71void G4MPIstatus::Pack(G4int* data) const
72{
73 data[0] = rank_;
74 data[1] = run_id_;
76 data[3] = event_id_;
77 data[4] = g4state_;
78
79 G4double* ddata = (G4double*)(data+5);
80 ddata[0] = cputime_;
81}
82
83// --------------------------------------------------------------------------
84void G4MPIstatus::UnPack(G4int* data)
85{
86 rank_ = data[0];
87 run_id_ = data[1];
89 event_id_ = data[3];
90 g4state_ = (G4ApplicationState)data[4];
91
92 G4double* ddata = (G4double*)(data+5);
93 cputime_ = ddata[0];
94}
95
96// --------------------------------------------------------------------------
98{
99 // * rank= 001 run= 10002 event= 00001 / 100000 state= Idle"
100 G4cout << "* rank= " << rank_
101 << " run= " << run_id_
102 << " event= " << event_id_ << " / " << nevent_to_be_processed_
103 << " state= " << GetStateString(g4state_)
104 << " time= " << cputime_ << "s"
105 << G4endl;
106}
107
108// --------------------------------------------------------------------------
109G4String G4MPIstatus::GetStateString(G4ApplicationState astate) const
110{
111 G4String sname;
112
113 switch(astate) {
114 case G4State_PreInit:
115 sname = "PreInit";
116 break;
117 case G4State_Init:
118 sname = "Init";
119 break;
120 case G4State_Idle:
121 sname = "Idle";
122 break;
123 case G4State_GeomClosed:
124 sname = "GeomClosed";
125 break;
126 case G4State_EventProc:
127 sname = "EventProc";
128 break;
129 case G4State_Quit:
130 sname = "Quit";
131 break;
132 case G4State_Abort:
133 sname = "Abort";
134 break;
135 default:
136 sname = "Unknown";
137 break;
138 }
139
140 return sname;
141}
status of MPI application
void StartTimer()
void Pack(G4int *data) const
void UnPack(G4int *data)
G4Timer * timer_
void Print() const
void StopTimer()
void SetStatus(G4int arank, G4int runid, G4int noe, G4int evtid, G4ApplicationState state)
G4double cputime_
G4String GetStateString(G4ApplicationState astate) const
G4ApplicationState g4state_
G4int nevent_to_be_processed_
G4int event_id_

Applications | User Support | Publications | Collaboration