Loading...
Searching...
No Matches
G4VUserMPIrunMerger.hh
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//
26#ifndef G4MPIRUNMERGER_HH
27#define G4MPIRUNMERGER_HH
28#include "G4Run.hh"
29#include <mpi.h>
30#include "G4MPImanager.hh"
31
33public:
35 G4VUserMPIrunMerger( const G4Run* aRun ,
36 G4int destination = G4MPImanager::kRANK_MASTER ,
37 G4int verbosity = 0);
39 void SetRun( G4Run* r ) { run = r; }
40 void SetDestinationRank( G4int i ) { destinationRank = i; }
41 void SetVerbosity( G4int ver ) { verbose = ver; }
42
43 virtual void Merge();
44
45protected:
46 virtual void Pack() = 0;
47 virtual G4Run* UnPack() = 0;
48
49 void InputUserData( /*const*/ void* input_data ,const MPI::Datatype& dt, int count) {
50 input_userdata.push_back( const_registered_data{input_data,dt,count} );
51 }
52 void OutputUserData( void* input_data ,const MPI::Datatype& dt, int count) {
53 output_userdata.push_back( registered_data{input_data,dt,count} );
54 }
55
56 // void GetUserData(void* output_data,const MPI::Datatype& dt, int count);
57
58 void SetupOutputBuffer(char* buff, G4int size, G4int position) {
59 outputBuffer = buff;
62 }
64 delete[] outputBuffer;
65 outputBuffer = nullptr;
68 ownsBuffer = false;
69 }
70
71 G4int GetPosition() const { return outputBufferPosition; }
72 char* GetBuffer() const { return outputBuffer; }
73 G4int GetBufferSize() const { return outputBufferSize; }
74
75 void Send(const unsigned int destination);
76 void Receive(const unsigned int source);
77private:
81 G4bool ownsBuffer;
82 unsigned int destinationRank;
84 unsigned int commSize;
85 MPI::Intracomm COMM_G4COMMAND_;
86 G4int verbose;
88
89 //Input data to send (read-only)
93 //const_registered_data(const_registered_data&&) = default;
94 //const_registered_data& operator=(const_registered_data&&) = default;
95 /*const*/ void* p_data;
96 /*const*/ MPI::Datatype dt;
97 /*const*/ int count;
98 };
99 std::vector<const_registered_data> input_userdata;
100
101 //Output data
105 void* p_data;
106 /*const*/ MPI::Datatype dt;
107 /*const*/ int count;
108 };
109 std::vector<registered_data> output_userdata;
110
111};
112
113
114#endif //G4MPIRUNMERGER_HH
115
MPI manager class.
void OutputUserData(void *input_data, const MPI::Datatype &dt, int count)
void SetDestinationRank(G4int i)
virtual void Pack()=0
void SetVerbosity(G4int ver)
void Send(const unsigned int destination)
std::vector< const_registered_data > input_userdata
std::vector< registered_data > output_userdata
virtual G4Run * UnPack()=0
MPI::Intracomm COMM_G4COMMAND_
void InputUserData(void *input_data, const MPI::Datatype &dt, int count)
void SetupOutputBuffer(char *buff, G4int size, G4int position)
void Receive(const unsigned int source)
const_registered_data & operator=(const const_registered_data &)=default
const_registered_data(const const_registered_data &)=default
registered_data(const registered_data &)=default
registered_data & operator=(const registered_data &)=default

Applications | User Support | Publications | Collaboration