32 #ifndef G4MPIToolsManager_h
33 #define G4MPIToolsManager_h 1
39 #include <tools/impi_world>
40 #include <tools/histo/hmpi>
48 tools::histo::hmpi* hmpi)
56 const std::vector<G4HnInformation*>& hnVector);
61 const std::vector<T*>& htVector,
62 const std::vector<G4HnInformation*>& hnVector);
66 const std::vector<T*>& htVector,
67 const std::vector<G4HnInformation*>& hnVector);
79 const std::vector<T*>& htVector,
80 const std::vector<G4HnInformation*>& hnVector)
86 fHmpi->beg_send(nofActiveT);
89 for (
G4int i=0; i<
G4int(htVector.size()); ++i ) {
91 auto info = hnVector[i];
95 auto ht = htVector[i];
97 finalResult =
result && finalResult;
103 description <<
" Rank: " <<
fHmpi->rank() <<
" : can't send histos.";
113 template <
typename T>
115 const std::vector<T*>& htVector,
116 const std::vector<G4HnInformation*>& hnVector)
123 <<
" Failed to get MPI commander size." <<
G4endl
124 <<
" Merging will not be performed.";
131 for (
G4int srank = 0; srank < commSize; ++srank) {
134 if ( srank ==
fHmpi->rank() )
continue;
138 using class_pointer = std::pair<std::string,void*>;
139 std::vector<class_pointer> hs;
140 if ( !
fHmpi->wait_histos(srank, hs) ) {
142 description <<
" wait_histos from " << srank <<
" : failed.";
149 if (
G4int(hs.size()) != nofActiveT ) {
151 description <<
" srank: " << srank <<
" : got " << hs.size() <<
" objects, "
152 <<
"while " << nofActiveT <<
" were exepected." <<
G4endl;
160 for (
G4int i=0; i<
G4int(htVector.size()); ++i ) {
162 auto info = hnVector[i];
165 auto ht = htVector[i];
166 auto newHt =
static_cast<T*
>(hs[counter++].second);
175 template <
typename T>
177 const std::vector<G4HnInformation*>& hnVector)
179 if ( ! htVector.size() )
return true;
182 G4int nofActiveT = 0;
185 for (
G4int i=0; i<
G4int(htVector.size()); ++i ) {
186 auto activation = hnVector[i]->GetActivation();
187 if ( activation ) ++nofActiveT;
190 nofActiveT =
G4int(htVector.size());
193 if ( ! nofActiveT )
return true;
196 if ( !
fHmpi->comm_rank(commRank) ) {
199 <<
" Failed to get MPI commander rank." <<
G4endl
200 <<
" Merging will not be performed.";
206 G4bool finalResult =
true;
208 if ( commRank !=
fHmpi->rank() ) {
213 description <<
"on rank " << commRank
214 <<
" destination rank: " <<
fHmpi->rank();
219 auto result =
Send(nofActiveT, htVector, hnVector);
221 finalResult =
result && finalResult;
226 description <<
"on rank " << commRank
227 <<
" destination rank: " <<
fHmpi->rank();
237 description <<
"on rank " << commRank
238 <<
" destination rank: " <<
fHmpi->rank();
245 finalResult =
result && finalResult;
250 description <<
"on rank " << commRank
251 <<
" destination rank: " <<
fHmpi->rank();
const XML_Char XML_Encoding * info
std::ostringstream G4ExceptionDescription
G4bool GetIsActivation() const
const G4AnalysisVerbose * GetVerboseL4() const
const G4AnalysisVerbose * GetVerboseL3() const
G4double G4ParticleHPJENDLHEData::G4double result
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisVerbose * GetVerboseL1() const