Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MPIToolsManager Class Reference

#include <G4MPIToolsManager.hh>

Public Member Functions

 G4MPIToolsManager (const G4AnalysisManagerState &state, tools::histo::hmpi *hmpi)
 
virtual ~G4MPIToolsManager ()
 
template<typename T >
G4bool Merge (const std::vector< T * > &htVector, const std::vector< G4HnInformation * > &hnVector)
 

Detailed Description

Definition at line 43 of file G4MPIToolsManager.hh.

Constructor & Destructor Documentation

◆ G4MPIToolsManager()

G4MPIToolsManager::G4MPIToolsManager ( const G4AnalysisManagerState state,
tools::histo::hmpi *  hmpi 
)
inline

Definition at line 46 of file G4MPIToolsManager.hh.

48 : fState(state), fHmpi(hmpi) {}

◆ ~G4MPIToolsManager()

virtual G4MPIToolsManager::~G4MPIToolsManager ( )
inlinevirtual

Definition at line 49 of file G4MPIToolsManager.hh.

49{}

Member Function Documentation

◆ Merge()

template<typename T >
G4bool G4MPIToolsManager::Merge ( const std::vector< T * > &  htVector,
const std::vector< G4HnInformation * > &  hnVector 
)
inline

Definition at line 175 of file G4MPIToolsManager.hh.

177{
178 if ( ! htVector.size() ) return true;
179
180 // Get number of objects to be sent
181 G4int nofActiveT = 0;
182 if ( fState.GetIsActivation() ) {
183 // only activated histograms will be treated
184 for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
185 auto activation = hnVector[i]->GetActivation();
186 if ( activation ) ++nofActiveT;
187 }
188 } else {
189 nofActiveT = G4int(htVector.size());
190 }
191
192 if ( ! nofActiveT ) return true;
193
194 G4int commRank;
195 if ( ! fHmpi->comm_rank(commRank) ) {
196 G4ExceptionDescription description;
197 description
198 << " Failed to get MPI commander rank." << G4endl
199 << " Merging will not be performed.";
200 G4Exception("G4H1ToolsManager::Merge",
201 "Analysis_W031", JustWarning, description);
202 return false;
203 }
204
205 G4bool finalResult = true;
206
207 if ( commRank != fHmpi->rank() ) {
208
209#ifdef G4VERBOSE
210 if ( fState.GetVerboseL3() ) {
211 G4ExceptionDescription description;
212 description << "on rank " << commRank
213 << " destination rank: " << fHmpi->rank();
214 fState.GetVerboseL4()->Message("mpi send", "Hn|Pn", description);
215 }
216#endif
217
218 auto result = Send(nofActiveT, htVector, hnVector);
219
220 finalResult = result && finalResult;
221
222#ifdef G4VERBOSE
223 if ( fState.GetVerboseL1() ) {
224 G4ExceptionDescription description;
225 description << "on rank " << commRank
226 << " destination rank: " << fHmpi->rank();
227 fState.GetVerboseL1()->Message("send", "Hn|Pn", description);
228 }
229#endif
230
231 } else {
232
233#ifdef G4VERBOSE
234 if ( fState.GetVerboseL3() ) {
235 G4ExceptionDescription description;
236 description << "on rank " << commRank
237 << " destination rank: " << fHmpi->rank();
238 fState.GetVerboseL4()->Message("mpi wait_histos", "Hn|Pn", description);
239 }
240#endif
241
242 auto result = Receive(nofActiveT, htVector, hnVector);
243
244 finalResult = result && finalResult;
245
246#ifdef G4VERBOSE
247 if ( fState.GetVerboseL1() ) {
248 G4ExceptionDescription description;
249 description << "on rank " << commRank
250 << " destination rank: " << fHmpi->rank();
251 fState.GetVerboseL1()->Message("mpi wait_histos", "Hn|Pn", description);
252 }
253#endif
254 }
255 return finalResult;
256}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
const G4AnalysisVerbose * GetVerboseL3() const
const G4AnalysisVerbose * GetVerboseL1() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const

Referenced by G4ToolsAnalysisManager::MergeImpl().


The documentation for this class was generated from the following file: