Geant4  10.02.p03
G4MPIscorerMerger Class Reference

#include <G4MPIscorerMerger.hh>

Collaboration diagram for G4MPIscorerMerger:

Public Member Functions

 G4MPIscorerMerger ()
 
 G4MPIscorerMerger (G4ScoringManager *mgr, G4int destination=G4MPImanager::kRANK_MASTER, G4int verbosity=0)
 
virtual ~G4MPIscorerMerger ()
 
void SetDestinationRank (G4int i)
 
void SetScoringManager (G4ScoringManager *mgr)
 
void SetVerbosity (G4int ver)
 
void Merge ()
 

Protected Member Functions

void SetupOutputBuffer (char *buff, G4int size, G4int position)
 
void DestroyBuffer ()
 
void Pack (const G4ScoringManager *)
 Pack all meshes into buffer. More...
 
void UnPackAndMerge (const G4ScoringManager *)
 
void Pack (const G4VScoringMesh *)
 Pack a single mesh. More...
 
void UnPackAndMerge (G4VScoringMesh *)
 
void Pack (const HitMap *)
 Pack a single score map. More...
 
HitMapUnPackHitMap (const G4String &detName, const G4String &colName)
 
G4int CalculatePackSize (const G4ScoringManager *) const
 
G4int CalculatePackSize (const G4VScoringMesh *) const
 
G4int CalculatePackSize (const HitMap *) const
 
void Send (const unsigned int destination)
 
void Receive (const unsigned int source)
 

Private Attributes

char * outputBuffer
 
G4int outputBufferSize
 
G4int outputBufferPosition
 
long bytesSent
 
G4bool ownsBuffer
 
G4ScoringManagerscoringManager
 
unsigned int commSize
 
unsigned int destinationRank
 
MPI::Intracomm comm
 
G4int verbose
 

Detailed Description

Definition at line 37 of file G4MPIscorerMerger.hh.

Constructor & Destructor Documentation

◆ G4MPIscorerMerger() [1/2]

G4MPIscorerMerger::G4MPIscorerMerger ( )

◆ G4MPIscorerMerger() [2/2]

G4MPIscorerMerger::G4MPIscorerMerger ( G4ScoringManager mgr,
G4int  destination = G4MPImanager::kRANK_MASTER,
G4int  verbosity = 0 
)

Definition at line 40 of file G4MPIscorerMerger.cc.

42  :
44  ownsBuffer(false),
45  scoringManager(mgr), commSize(0), destinationRank(destination),
46  verbose(verbosity)
47 {
48 }
G4ScoringManager * scoringManager
unsigned int destinationRank

◆ ~G4MPIscorerMerger()

G4MPIscorerMerger::~G4MPIscorerMerger ( )
virtual

Definition at line 50 of file G4MPIscorerMerger.cc.

50  {
51  if ( ownsBuffer ) delete[] outputBuffer;
52 }

Member Function Documentation

◆ CalculatePackSize() [1/3]

G4int G4MPIscorerMerger::CalculatePackSize ( const G4ScoringManager sm) const
protected

Definition at line 393 of file G4MPIscorerMerger.cc.

394 {
395  DMSG(3,"Calculating dimension of data to send");
396  if ( sm == nullptr ) return 0;
397  //Calcualte how much data each call to Pack* appends to the buffer
398  //e.g. sizeof(data)
399  //The number of sizeof here should match the number of calls to MPI_Pack
400 
401  //Pack(ScoringMgr)
402  G4int size = sizeof(unsigned int);
403  DMSG(3,"There are "<<sm->GetNumberOfMesh()<<" meshes.");
404  //Loop on mesh
405  for ( size_t i = 0 ; i<sm->GetNumberOfMesh() ; ++i ) {
406  size += sizeof(unsigned int);//ID
407  size += CalculatePackSize(sm->GetMesh(i));
408  }
409  return size;
410 }
size_t GetNumberOfMesh() const
#define DMSG(LVL, MSG)
G4VScoringMesh * GetMesh(G4int i) const
int G4int
Definition: G4Types.hh:78
G4int CalculatePackSize(const G4ScoringManager *) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculatePackSize() [2/3]

G4int G4MPIscorerMerger::CalculatePackSize ( const G4VScoringMesh mesh) const
protected

Definition at line 412 of file G4MPIscorerMerger.cc.

413 {
414  DMSG(3,"Calculating size for mesh: "<<mesh);
415  //PackSingleMesh(Mesh)
416  G4int size = sizeof(unsigned int);//num maps
417  const MeshScoreMap& map = mesh->GetScoreMap();
418  for (const auto& ele : map ) {
419  //PackHitsMap
420  size += sizeof(unsigned int);//name size
421  const G4String& name = ele.first;
422  size += sizeof(char)*name.size();//name
423  size += CalculatePackSize(ele.second);
424  }
425  DMSG(3,"mesh "<<mesh<<" size: "<<size);
426  return size;
427 }
std::map< G4String, G4THitsMap< G4double > *> MeshScoreMap
MeshScoreMap GetScoreMap() const
G4String name
Definition: TRTMaterials.hh:40
#define DMSG(LVL, MSG)
int G4int
Definition: G4Types.hh:78
static const G4double ele
G4int CalculatePackSize(const G4ScoringManager *) const
Here is the call graph for this function:

◆ CalculatePackSize() [3/3]

G4int G4MPIscorerMerger::CalculatePackSize ( const HitMap map) const
protected

Definition at line 429 of file G4MPIscorerMerger.cc.

429  {
430  const G4int numEls = map->GetSize();
431  G4int size = sizeof(unsigned int);
432  size += sizeof(G4int)*numEls;
433  size += sizeof(G4double)*numEls;
434  DMSG(3,"HitMap "<<map<<" size: "<<size<<" in "<<numEls<<" elements.");
435  return size;
436 }
#define DMSG(LVL, MSG)
int G4int
Definition: G4Types.hh:78
virtual size_t GetSize() const
Definition: G4THitsMap.hh:86
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ DestroyBuffer()

void G4MPIscorerMerger::DestroyBuffer ( )
inlineprotected

Definition at line 59 of file G4MPIscorerMerger.hh.

59  {
60  delete[] outputBuffer;
61  outputBuffer = nullptr;
64  ownsBuffer = false;
65  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Merge()

void G4MPIscorerMerger::Merge ( )

Definition at line 87 of file G4MPIscorerMerger.cc.

87  {
88  DMSG(0, "G4MPIscorerMerger::Merge called");
89  const unsigned int myrank = MPI::COMM_WORLD.Get_rank();
90  commSize = MPI::COMM_WORLD.Get_size();
91  if ( commSize == 1 ) {
92  DMSG(1,"Comm world size is 1, nothing to do");
93  return;
94  }
95  comm = MPI::COMM_WORLD.Dup();
96  DestroyBuffer();
97 
98  //ANDREA:->
99 // G4cout<<"Before sending: "<<G4endl;
100 // scoringManager->GetMesh(0)->Dump();
101 // for ( int i = 0 ; i < scoringManager->GetNumberOfMesh() ; ++i ) {
102 // for ( auto e : scoringManager->GetMesh(i)->GetScoreMap() )
103 // {
104 // G4cout<<e.first<<" : "<<e.second<<G4endl;
105 // for ( auto c: *(e.second->GetMap()) ) {
106 // G4cout<<c.first<<"="<<*c.second<<G4endl;
107 //
108 // }
109 // }
110 // }
111  //ANDREA:<-
112 
113  bytesSent=0;
114  const G4double sttime = MPI::Wtime();
115 
116  //Use G4MPIutils to optimize communications between ranks
117  typedef std::function<void(unsigned int)> handler_t;
118  using std::placeholders::_1;
119  handler_t sender = std::bind(&G4MPIscorerMerger::Send , this , _1);
120  handler_t receiver = std::bind(&G4MPIscorerMerger::Receive, this, _1);
121  std::function<void(void)> barrier = std::bind(&MPI::Intracomm::Barrier,&comm);
122  G4mpi::Merge( sender , receiver , barrier , commSize , myrank );
123 
124  //OLD Style p2p communications
125  /*
126  if ( myrank != destinationRank ) {
127  DMSG(1,"Comm world size: "<<commSize<<" this rank is: "
128  <<myrank<<" sending to rank "<<destinationRank
129  <<" Number of mesh: "<< scoringManager->GetNumberOfMesh() );
130  Send(destinationRank);
131  } else {
132  DMSG(1,"Comm world size: "<<commSize<<" this rank is: "
133  <<myrank<<" receiving "
134  <<" Number of mesh: "<< scoringManager->GetNumberOfMesh() );
135  for ( unsigned int i = 0 ; i < commSize ; ++i ) {
136  if ( i != myrank ) Receive(i);
137  }
138  }
139 */
140  const G4double elapsed = MPI::Wtime() - sttime;
141  long total=0;
142  comm.Reduce(&bytesSent,&total,1,MPI::LONG,MPI::SUM,destinationRank);
143  if ( verbose > 0 && myrank == destinationRank ) {
144  //Collect from ranks how much data was sent around
145  G4cout<<"G4MPIscorerMerger::Merge() -data transfer performances: "
146  <<double(total)/1000./elapsed<<" kB/s"
147  <<" (Total Data Transfer= "<<double(total)/1000.<<" kB in "
148  <<elapsed<<" s)."<<G4endl;
149  }
150  //ANDREA:->
151 // G4cout<<"After Receiving: "<<G4endl;
152 // scoringManager->GetMesh(0)->Dump();
153 // for ( int i = 0 ; i < scoringManager->GetNumberOfMesh() ; ++i ) {
154 // for ( auto e : scoringManager->GetMesh(i)->GetScoreMap() )
155 // {
156 // G4cout<<e.first<<" : "<<e.second<<G4endl;
157 // for ( auto c: *(e.second->GetMap()) ) {
158 // G4cout<<c.first<<"="<<*c.second<<" (=2x"<<.5*(*c.second)<<")"<<G4endl;
159 //
160 // }
161 // }
162 // }
163  //ANDREA:<-
164  comm.Free();
165  DMSG(0,"G4MPIscorerMerger::Merge done.");
166 }
unsigned int destinationRank
#define DMSG(LVL, MSG)
void Merge(std::function< void(unsigned int)> senderF, std::function< void(unsigned int)> receiverF, std::function< void(void)> barrierF, unsigned int commSize, unsigned int myrank)
Definition: G4MPIutils.cc:161
MPI::Intracomm comm
void Send(const unsigned int destination)
void Receive(const unsigned int source)
G4GLOB_DLL std::ostream G4cout
G4double total(Particle const *const p1, Particle const *const p2)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Pack() [1/3]

void G4MPIscorerMerger::Pack ( const G4ScoringManager sm)
protected

Pack all meshes into buffer.

Definition at line 223 of file G4MPIscorerMerger.cc.

223  {
224  assert(sm!=nullptr);
225  if ( outputBuffer == nullptr || outputBufferPosition>=outputBufferSize) {
226  G4Exception("G4MPIscorerMerger::Pack(const G4ScoringManager*)",
227  "MPI001",FatalException,
228  "Call SetOututBuffer before trying to pack");
229  return;
230  }
231  DMSG(2,"Starting packing of meshes, # meshes: "<<sm->GetNumberOfMesh());
232  /*const*/ size_t numMeshes=sm->GetNumberOfMesh();//TODO: OLD MPI interface
233  MPI_Pack(&numMeshes,1,MPI::UNSIGNED,
236  comm);
237  for (size_t i = 0; i <numMeshes; ++i)
238  {
239  MPI_Pack(&i,1,MPI::UNSIGNED,
242  Pack(sm->GetMesh(i));
243  }
244 }
void Pack(const G4ScoringManager *)
Pack all meshes into buffer.
size_t GetNumberOfMesh() const
#define DMSG(LVL, MSG)
G4VScoringMesh * GetMesh(G4int i) const
MPI::Intracomm comm
int MPI_Pack(const void *, int, MPI_Datatype, void *, int, int *, MPI_Comm)
Definition: dummy_mpi.h:27
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Pack() [2/3]

void G4MPIscorerMerger::Pack ( const G4VScoringMesh mesh)
protected

Pack a single mesh.

Definition at line 284 of file G4MPIscorerMerger.cc.

284  {
285  assert(mesh!=nullptr);
286  assert(outputBuffer!=nullptr);
288  DMSG(3,"Packing mesh: "<<mesh);
289 
290  const MeshScoreMap& map = mesh->GetScoreMap();
291  /*const*/ size_t nummaps = map.size();//TODO: old MPI interface
292  MPI_Pack(&nummaps,1,MPI::UNSIGNED,
295  for ( const auto& ele: map ) {
296  const G4String& name = ele.first;
297  /*const*/ size_t ss = name.size();
298  MPI_Pack(&ss,1,MPI::UNSIGNED,
301 #ifdef G4MPI_USE_MPI_PACK_NOT_CONST
302  char* nn = new char[name.length()];
303  std::copy(name.begin(),name.end(),nn);
304 #else
305  const char* nn = name.c_str();
306 #endif
307  MPI_Pack(nn,ss,MPI::CHAR,
310  Pack(ele.second);
311 #ifdef G4MPI_USE_MPI_PACK_NOT_CONST
312  delete[] nn;
313 #endif
314  }
315 }
void Pack(const G4ScoringManager *)
Pack all meshes into buffer.
std::map< G4String, G4THitsMap< G4double > *> MeshScoreMap
MeshScoreMap GetScoreMap() const
G4String name
Definition: TRTMaterials.hh:40
#define DMSG(LVL, MSG)
MPI::Intracomm comm
int MPI_Pack(const void *, int, MPI_Datatype, void *, int, int *, MPI_Comm)
Definition: dummy_mpi.h:27
static const G4double ele
Here is the call graph for this function:

◆ Pack() [3/3]

void G4MPIscorerMerger::Pack ( const HitMap sm)
protected

Pack a single score map.

Definition at line 347 of file G4MPIscorerMerger.cc.

347  {
348  assert(sm!=nullptr);
349  assert(outputBuffer!=nullptr);
351  DMSG(3,"Packing hitmap: "<<sm<<" with: "<<sm->GetSize()<<" elements.");
352  /*const*/ size_t numEl = sm->GetSize();//TODO: old MPI implementation
353  MPI_Pack(&numEl,1,MPI::UNSIGNED,
356  const auto& theMap = *sm->GetMap();
357  std::vector<G4int> ids;
358  std::vector<G4double> vals;
359  std::transform(theMap.begin(),theMap.end(),std::back_inserter(ids),
360  [](decltype(*theMap.begin())& e){ return e.first;});
361  std::transform(theMap.begin(),theMap.end(),std::back_inserter(vals),
362  [](decltype(*theMap.begin())& e){ return *e.second;});
363  assert(ids.size()==vals.size()&&ids.size()==numEl);
364  MPI_Pack(ids.data(),ids.size(),MPI::INT,
367  MPI_Pack(vals.data(),vals.size(),MPI::DOUBLE,
370 }
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:68
#define DMSG(LVL, MSG)
MPI::Intracomm comm
int MPI_Pack(const void *, int, MPI_Datatype, void *, int, int *, MPI_Comm)
Definition: dummy_mpi.h:27
virtual size_t GetSize() const
Definition: G4THitsMap.hh:86
Here is the call graph for this function:

◆ Receive()

void G4MPIscorerMerger::Receive ( const unsigned int  source)
protected

Definition at line 168 of file G4MPIscorerMerger.cc.

168  {
169  DMSG(1,"Receiving scorers");
170  // DestroyBuffer();
171  DMSG(2,"Receiving from: "<<source);
172  MPI::Status status;
173  comm.Probe(source, G4MPImanager::kTAG_CMDSCR, status);
174  const G4int newbuffsize = status.Get_count(MPI::PACKED);
175  DMSG(2,"Preparing to receive buffer of size: "<<newbuffsize);
176  char* buffer = outputBuffer;
177  if ( newbuffsize > outputBufferSize ) {
178  DMSG(3,"New larger buffer expected, resize");
179  //New larger buffer incoming, recreate buffer
180  //TODO: use realloc?
181  delete[] outputBuffer;
182  buffer = new char[newbuffsize];
183  //Avoid complains from valgrind (i'm not really sure why this is needed, but, beside the
184  //small cpu penalty, we can live with that).)
185  std::fill( buffer , buffer + newbuffsize , 0 );
186  ownsBuffer = true;
187  }
188  SetupOutputBuffer(buffer,newbuffsize,0);
189  comm.Recv(buffer, newbuffsize, MPI::PACKED, source,
190  G4MPImanager::kTAG_CMDSCR, status);
191  DMSG(3,"Buffer Size: "<<outputBufferSize<< " bytes at: "<<(void*)outputBuffer);
193  DMSG(1,"Receiving of comamnd line scorers done");
194 }
G4ScoringManager * scoringManager
void UnPackAndMerge(const G4ScoringManager *)
#define DMSG(LVL, MSG)
#define buffer
Definition: xmlparse.cc:628
int G4int
Definition: G4Types.hh:78
MPI::Intracomm comm
static G4String Status(G4StepStatus stps)
void SetupOutputBuffer(char *buff, G4int size, G4int position)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Send()

void G4MPIscorerMerger::Send ( const unsigned int  destination)
protected

Definition at line 196 of file G4MPIscorerMerger.cc.

196  {
197  DMSG(1,"Sending scorers "<<this);
198  //Step 1: Setup buffer to pack/unpack data
199  const G4int newbuffsize = CalculatePackSize(scoringManager);
200  //DestroyBuffer();
201  char* buffer = outputBuffer;
202  if ( newbuffsize > outputBufferSize ) {
203  delete[] outputBuffer;
204  buffer = new char[newbuffsize];
205  //Avoid complains from valgrind (i'm not really sure why this is needed, but, beside the
206  //small cpu penalty, we can live with that).)
207  std::fill( buffer , buffer+newbuffsize,0);
208  ownsBuffer = true;
209  }
210  SetupOutputBuffer(buffer,newbuffsize,0);
211  DMSG(3,"Buffer Size: "<<newbuffsize<< " bytes at: "<<(void*)outputBuffer);
214 
215  //Version 1: p2p communication
216  comm.Send( outputBuffer , outputBufferSize , MPI::PACKED ,
217  destination , G4MPImanager::kTAG_CMDSCR);
218  bytesSent += newbuffsize;
219  //Receiver should use probe to get size of the package being sent
220  DMSG(1,"Sending done");
221 }
void Pack(const G4ScoringManager *)
Pack all meshes into buffer.
G4ScoringManager * scoringManager
#define DMSG(LVL, MSG)
#define buffer
Definition: xmlparse.cc:628
int G4int
Definition: G4Types.hh:78
MPI::Intracomm comm
G4int CalculatePackSize(const G4ScoringManager *) const
void SetupOutputBuffer(char *buff, G4int size, G4int position)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDestinationRank()

void G4MPIscorerMerger::SetDestinationRank ( G4int  i)
inline

Definition at line 46 of file G4MPIscorerMerger.hh.

46 { destinationRank = i; }
unsigned int destinationRank

◆ SetScoringManager()

void G4MPIscorerMerger::SetScoringManager ( G4ScoringManager mgr)
inline

Definition at line 47 of file G4MPIscorerMerger.hh.

47 { scoringManager = mgr; }
G4ScoringManager * scoringManager

◆ SetupOutputBuffer()

void G4MPIscorerMerger::SetupOutputBuffer ( char *  buff,
G4int  size,
G4int  position 
)
inlineprotected

Definition at line 54 of file G4MPIscorerMerger.hh.

54  {
55  outputBuffer = buff;
56  outputBufferSize=size;
58  }
#define position
Definition: xmlparse.cc:622
Here is the caller graph for this function:

◆ SetVerbosity()

void G4MPIscorerMerger::SetVerbosity ( G4int  ver)
inline

Definition at line 48 of file G4MPIscorerMerger.hh.

48 { verbose = ver; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnPackAndMerge() [1/2]

void G4MPIscorerMerger::UnPackAndMerge ( const G4ScoringManager sm)
protected

Definition at line 246 of file G4MPIscorerMerger.cc.

246  {
247  assert(sm!=nullptr);
248  if ( outputBuffer == nullptr || outputBufferPosition>=outputBufferSize) {
249  G4Exception("G4MPIscorerMerger::UnPack(const G4ScroingManager*)",
250  "MPI001",FatalException,
251  "Call SetOututBuffer before trying to un-pack");
252  return;
253  }
254  size_t numMeshes=0;
256  &numMeshes,1,MPI::UNSIGNED,comm);
257  if ( numMeshes != sm->GetNumberOfMesh() ) {
259  msg << "Number of meshes to unpack ("<<numMeshes;
260  msg <<") does not correspond to expected number ("<<sm->GetNumberOfMesh();
261  msg<<")";
262  G4Exception("G4MPIscorerMerger::UnPack(const G4ScroingManager*)",
263  "MPI001",FatalException,msg);
264  return;
265  }
266 
267  size_t meshid=0;
268  for ( size_t i = 0 ; i < numMeshes ; ++i ) {
270  &meshid,1,MPI::UNSIGNED,comm);
271  if ( meshid != i ) {
273  msg<<"Cannot unpack: expecting mesh "<<i<<" and found "<<meshid;
274  msg<<" during unpack.";
275  G4Exception("G4MPIscorerMerger::UnPack(const G4ScroingManager*)",
276  "MPI001",FatalException,msg);
277  return;
278  }
279  G4VScoringMesh* original = sm->GetMesh(i);
280  UnPackAndMerge(original);
281  }
282 }
int MPI_Unpack(const void *, int, int *, void *, int, MPI_Datatype, MPI_Comm)
Definition: dummy_mpi.h:28
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void UnPackAndMerge(const G4ScoringManager *)
size_t GetNumberOfMesh() const
G4VScoringMesh * GetMesh(G4int i) const
MPI::Intracomm comm
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnPackAndMerge() [2/2]

void G4MPIscorerMerger::UnPackAndMerge ( G4VScoringMesh inmesh)
protected

Definition at line 317 of file G4MPIscorerMerger.cc.

317  {
318  assert(outputBuffer!=nullptr);
320  assert(inmesh!=nullptr);
321  DMSG(3,"Preparing to unpack a mesh and merge into: "<<inmesh);
322  const G4String& detName = inmesh->GetWorldName();
323  size_t nummaps = 0;
325  &nummaps,1,MPI::UNSIGNED,comm);
326  for ( size_t i = 0 ; i < nummaps ; ++i ) {
327  size_t nameSize = 0;
329  &nameSize,1,MPI::UNSIGNED,comm);
330  //Create a null-terminated c-string: needed later when converting this to a G4String
331  //(Not sure: but issue reported by valgrind with the use of MPI_Unpack)
332  char* name = new char[nameSize+1];
333  std::fill(name,name+nameSize+1,0);
335  name,nameSize,MPI::CHAR,comm);
336  const G4String colname(name,nameSize);
337  delete[] name;
338  //This memory churn is very inefficient, but we cannot reuse the HitMap
339  //because we cannot change the names
340  //TODO: Evaluate change in HitMap class to allow for change of names
341  HitMap* hm = UnPackHitMap(detName,colname);
342  inmesh->Accumulate(hm);
343  delete hm;
344  }
345 }
int MPI_Unpack(const void *, int, int *, void *, int, MPI_Datatype, MPI_Comm)
Definition: dummy_mpi.h:28
G4String name
Definition: TRTMaterials.hh:40
void Accumulate(G4THitsMap< G4double > *map)
#define DMSG(LVL, MSG)
MPI::Intracomm comm
const G4String & GetWorldName() const
HitMap * UnPackHitMap(const G4String &detName, const G4String &colName)
Here is the call graph for this function:

◆ UnPackHitMap()

HitMap * G4MPIscorerMerger::UnPackHitMap ( const G4String detName,
const G4String colName 
)
protected

Definition at line 372 of file G4MPIscorerMerger.cc.

373  {
374  assert(outputBuffer!=nullptr);
376  DMSG(3,"Preparing to unpack a hit map for: "<<detName<<","<<colName);
377  size_t numEl =0 ;
379  &numEl,1,MPI::UNSIGNED,comm);
380  G4int* ids = new G4int[numEl];
382  ids,numEl,MPI::INT,comm);
383  G4double* vals = new G4double[numEl];
385  vals,numEl,MPI::DOUBLE,comm);
386  HitMap* result = new HitMap(detName,colName);
387  for ( unsigned int i = 0; i<numEl;++i) result->set(ids[i],vals[i]);
388  delete[] ids;
389  delete[] vals;
390  return result;
391 }
int MPI_Unpack(const void *, int, int *, void *, int, MPI_Datatype, MPI_Comm)
Definition: dummy_mpi.h:28
#define DMSG(LVL, MSG)
int G4int
Definition: G4Types.hh:78
MPI::Intracomm comm
G4int set(const G4int &key, T *&aHit) const
Definition: G4THitsMap.hh:165
G4THitsMap< G4double > HitMap
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bytesSent

long G4MPIscorerMerger::bytesSent
private

Definition at line 92 of file G4MPIscorerMerger.hh.

◆ comm

MPI::Intracomm G4MPIscorerMerger::comm
private

Definition at line 97 of file G4MPIscorerMerger.hh.

◆ commSize

unsigned int G4MPIscorerMerger::commSize
private

Definition at line 95 of file G4MPIscorerMerger.hh.

◆ destinationRank

unsigned int G4MPIscorerMerger::destinationRank
private

Definition at line 96 of file G4MPIscorerMerger.hh.

◆ outputBuffer

char* G4MPIscorerMerger::outputBuffer
private

Definition at line 89 of file G4MPIscorerMerger.hh.

◆ outputBufferPosition

G4int G4MPIscorerMerger::outputBufferPosition
private

Definition at line 91 of file G4MPIscorerMerger.hh.

◆ outputBufferSize

G4int G4MPIscorerMerger::outputBufferSize
private

Definition at line 90 of file G4MPIscorerMerger.hh.

◆ ownsBuffer

G4bool G4MPIscorerMerger::ownsBuffer
private

Definition at line 93 of file G4MPIscorerMerger.hh.

◆ scoringManager

G4ScoringManager* G4MPIscorerMerger::scoringManager
private

Definition at line 94 of file G4MPIscorerMerger.hh.

◆ verbose

G4int G4MPIscorerMerger::verbose
private

Definition at line 98 of file G4MPIscorerMerger.hh.


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