Import Geant4 10.6.0 source tree
This commit is contained in:
@@ -52,9 +52,7 @@ class G4RootMpiAnalysisManager : public G4RootAnalysisManager
|
||||
// MPI
|
||||
void SetMpiNtupleMerging(tools::impi* impi,
|
||||
G4int mpiRank, G4int mpiSize,
|
||||
G4int nofReducedNtupleFiles = 0,
|
||||
G4bool rowWise = false,
|
||||
unsigned int basketSize = fgkDefaultBasketSize);
|
||||
G4int nofReducedNtupleFiles = 0);
|
||||
|
||||
protected:
|
||||
// virtual methods from base class
|
||||
|
||||
@@ -46,7 +46,8 @@ class G4RootMpiNtupleManager : public G4RootNtupleManager
|
||||
friend class G4RootMpiMainNtupleManager;
|
||||
|
||||
public:
|
||||
G4RootMpiNtupleManager(const G4AnalysisManagerState& state, G4bool rowWise,
|
||||
G4RootMpiNtupleManager(const G4AnalysisManagerState& state,
|
||||
G4bool rowWise, G4bool rowMode,
|
||||
tools::impi* impi, G4int mpiSize);
|
||||
virtual ~G4RootMpiNtupleManager();
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class G4RootMpiPNtupleManager : public G4BaseNtupleManager
|
||||
friend class G4RootNtupleManager;
|
||||
|
||||
public:
|
||||
explicit G4RootMpiPNtupleManager(const G4AnalysisManagerState& state, G4bool rowWise,
|
||||
explicit G4RootMpiPNtupleManager(const G4AnalysisManagerState& state,
|
||||
tools::impi* impi, G4int mpiRank, G4int destinationRank);
|
||||
~G4RootMpiPNtupleManager();
|
||||
|
||||
@@ -143,7 +143,6 @@ class G4RootMpiPNtupleManager : public G4BaseNtupleManager
|
||||
tools::wroot::directory* fNtupleDirectory;
|
||||
std::vector<G4RootMpiPNtupleDescription*> fNtupleDescriptionVector;
|
||||
std::vector<tools::wroot::impi_ntuple*> fNtupleVector;
|
||||
G4bool fRowWise;
|
||||
tools::impi* fImpi;
|
||||
G4int fMpiRank;
|
||||
G4int fDestinationRank;
|
||||
|
||||
@@ -34,7 +34,9 @@
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootMpiAnalysisManager::G4RootMpiAnalysisManager(G4bool isMaster)
|
||||
: G4RootAnalysisManager(isMaster)
|
||||
: G4RootAnalysisManager(isMaster),
|
||||
fMpiNtupleMergeMode(G4MpiNtupleMergeMode::kNone),
|
||||
fMpiSlaveNtupleManager(nullptr)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -57,14 +59,16 @@ void G4RootMpiAnalysisManager::CreateMpiNtupleManagers(
|
||||
switch ( fMpiNtupleMergeMode )
|
||||
{
|
||||
case G4MpiNtupleMergeMode::kNone:
|
||||
fNtupleManager = new G4RootNtupleManager(fState, 0, fNtupleRowWise);
|
||||
fNtupleManager
|
||||
= new G4RootNtupleManager(fState, 0, fNtupleRowWise, fNtupleRowMode);
|
||||
fNtupleManager->SetFileManager(fFileManager);
|
||||
SetNtupleManager(fNtupleManager);
|
||||
break;
|
||||
|
||||
case G4MpiNtupleMergeMode::kMain: {
|
||||
fNtupleManager
|
||||
= new G4RootMpiNtupleManager(fState, fNtupleRowWise, impi, mpiSize);
|
||||
= new G4RootMpiNtupleManager(fState, fNtupleRowWise, fNtupleRowMode,
|
||||
impi, mpiSize);
|
||||
fNtupleManager->SetFileManager(fFileManager);
|
||||
SetNtupleManager(fNtupleManager);
|
||||
break;
|
||||
@@ -73,7 +77,7 @@ void G4RootMpiAnalysisManager::CreateMpiNtupleManagers(
|
||||
case G4MpiNtupleMergeMode::kSlave: {
|
||||
auto destinationRank = mpiSize;
|
||||
fMpiSlaveNtupleManager
|
||||
= new G4RootMpiPNtupleManager(fState, fNtupleRowWise, impi, mpiRank, destinationRank);
|
||||
= new G4RootMpiPNtupleManager(fState, impi, mpiRank, destinationRank);
|
||||
SetNtupleManager(fMpiSlaveNtupleManager);
|
||||
break;
|
||||
}
|
||||
@@ -144,24 +148,16 @@ void G4RootMpiAnalysisManager::SetMpiNtupleMergingMode(
|
||||
//_____________________________________________________________________________
|
||||
void G4RootMpiAnalysisManager::SetMpiNtupleMerging(tools::impi* impi,
|
||||
G4int mpiRank, G4int mpiSize,
|
||||
G4int nofNtupleFiles,
|
||||
G4bool rowWise,
|
||||
unsigned int basketSize)
|
||||
G4int nofNtupleFiles)
|
||||
{
|
||||
// G4cout << "SetMpiNtupleMerging: "
|
||||
// << impi << ", "
|
||||
// << mpiRank << ","
|
||||
// << mpiSize << ","
|
||||
// << nofNtupleFiles << ","
|
||||
// << rowWise << ","
|
||||
// << basketSize << G4endl;
|
||||
// << nofNtupleFiles << G4endl;
|
||||
|
||||
// fImpi = impi;
|
||||
|
||||
// Keep basketSize in file manager
|
||||
fFileManager->SetBasketSize(basketSize);
|
||||
fNtupleRowWise = rowWise;
|
||||
|
||||
// Set ntuple merging mode
|
||||
SetMpiNtupleMergingMode(mpiRank, mpiSize, nofNtupleFiles);
|
||||
|
||||
@@ -330,5 +326,3 @@ G4bool G4RootMpiAnalysisManager::Reset()
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,9 +43,10 @@ const int kTAG_NTUPLE = 1004; // This constant is defined in G4MPImanager
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootMpiNtupleManager::G4RootMpiNtupleManager(
|
||||
const G4AnalysisManagerState& state, G4bool rowWise,
|
||||
const G4AnalysisManagerState& state,
|
||||
G4bool rowWise, G4bool rowMode,
|
||||
tools::impi* impi, G4int mpiSize)
|
||||
: G4RootNtupleManager(state, 0, rowWise),
|
||||
: G4RootNtupleManager(state, 0, rowWise, rowMode),
|
||||
fImpi(impi),
|
||||
fSlaveRanks(),
|
||||
fMainRank(0)
|
||||
@@ -82,6 +83,7 @@ G4bool G4RootMpiNtupleManager::Send(G4int id, tools::wroot::ntuple* ntuple)
|
||||
|
||||
auto ntupleFile = fFileManager->GetNtupleFile(id);
|
||||
tools::uint32 basketSize = fFileManager->GetBasketSize();
|
||||
unsigned int basketEntries = fFileManager->GetBasketEntries();
|
||||
|
||||
for ( auto slaveRank : fSlaveRanks ) {
|
||||
G4cout << "Going to send main ntuple data to slave rank " << slaveRank << G4endl;
|
||||
@@ -92,6 +94,11 @@ G4bool G4RootMpiNtupleManager::Send(G4int id, tools::wroot::ntuple* ntuple)
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! fImpi->bpack(fRowWise) ) {
|
||||
G4cerr << "bpack(fRowWise) failed."<< G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! fImpi->bpack(ntupleFile->byte_swap())) {
|
||||
G4cerr << "bpack(byte_swap) failed." << G4endl;
|
||||
return false;
|
||||
@@ -110,12 +117,20 @@ G4bool G4RootMpiNtupleManager::Send(G4int id, tools::wroot::ntuple* ntuple)
|
||||
|
||||
if ( fRowWise ) {
|
||||
if ( ! fImpi->pack(basketSize) ) {
|
||||
G4cerr << "pack(basket_sizes) failed." << G4endl;
|
||||
G4cerr << "pack(basketSize) failed." << G4endl;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ( ! fImpi->bpack(fRowMode) ) {
|
||||
G4cerr << "bpack(fRowMode) failed." << G4endl;
|
||||
return false;
|
||||
}
|
||||
if ( ! fImpi->vpack(basketSizes) ) {
|
||||
G4cerr << "vpack(basket_sizes) failed." << G4endl;
|
||||
G4cerr << "vpack(basketSizes) failed." << G4endl;
|
||||
return false;
|
||||
}
|
||||
if ( ! fImpi->pack(basketEntries) ) {
|
||||
G4cerr << "pack(basketEntries) failed." << G4endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -159,7 +174,7 @@ G4bool G4RootMpiNtupleManager::WaitBuffer()
|
||||
// Receive the pntuple data from the slave ranks
|
||||
// For the time being only one ntuple
|
||||
|
||||
G4cout << "G4RootMpiNtupleManager::WaitBuffer" << G4endl;
|
||||
// G4cout << "G4RootMpiNtupleManager::WaitBuffer" << G4endl;
|
||||
|
||||
unsigned long numberOfEndFill = 0;
|
||||
|
||||
@@ -178,15 +193,15 @@ G4bool G4RootMpiNtupleManager::WaitBuffer()
|
||||
|
||||
tools::uint32 protocol;
|
||||
if ( ! fImpi->unpack(protocol)) {
|
||||
G4cerr << "sunpack(protocol) failed."<< G4endl;
|
||||
G4cerr << "unpack(protocol) failed."<< G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( protocol == tools::wroot::mpi_protocol_basket() ) {
|
||||
|
||||
// G4cout << "G4RootMpiNtupleManager::WaitBuffer got protocol_basket" << G4endl;
|
||||
// G4cout << "G4RootMpiNtupleManager::WaitBuffer got protocol_basket" << G4endl;
|
||||
|
||||
// get ntuple Id
|
||||
// get ntuple Id
|
||||
tools::uint32 ntupleId;
|
||||
if ( ! fImpi->unpack(ntupleId) ) {
|
||||
G4cerr << "unpack(ntuple_id) failed."<< std::endl;
|
||||
@@ -207,6 +222,32 @@ G4bool G4RootMpiNtupleManager::WaitBuffer()
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else if ( protocol == tools::wroot::mpi_protocol_baskets() ) {
|
||||
//column_wise and row_mode only.
|
||||
|
||||
// G4cout << "G4RootMpiNtupleManager::WaitBuffer got protocol_baskets" << G4endl;
|
||||
|
||||
// get ntuple Id
|
||||
tools::uint32 ntupleId;
|
||||
if ( ! fImpi->unpack(ntupleId) ) {
|
||||
G4cerr << "unpack(ntuple_id) failed."<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ntupleId >= fNtupleVector.size() ) {
|
||||
std::cerr << "!!! unknown ntupleId " << ntupleId << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Main ntuple
|
||||
auto mainNtuple = fNtupleVector[ntupleId];
|
||||
|
||||
// add basket to main ntuple
|
||||
if ( ! mainNtuple->mpi_add_baskets(*fImpi)) {
|
||||
std::cerr << "mainNtuple->mpi_add_baskets() failed." << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else if ( protocol==tools::wroot::mpi_protocol_end_fill() ) {
|
||||
|
||||
// G4cout << "G4RootMpiNtupleManager::WaitBuffer got protocol_end_fill" << G4endl;
|
||||
@@ -286,4 +327,3 @@ G4bool G4RootMpiNtupleManager::Merge()
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +39,10 @@ const int kTAG_NTUPLE = 1004; // This constant is defined in G4MPImanager
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootMpiPNtupleManager::G4RootMpiPNtupleManager(
|
||||
const G4AnalysisManagerState& state, G4bool rowWise,
|
||||
const G4AnalysisManagerState& state,
|
||||
tools::impi* impi, G4int mpiRank, G4int destinationRank)
|
||||
: G4BaseNtupleManager(state),
|
||||
fNtupleVector(),
|
||||
fRowWise(rowWise),
|
||||
fImpi(impi),
|
||||
fMpiRank(mpiRank),
|
||||
fDestinationRank(destinationRank)
|
||||
@@ -129,11 +128,14 @@ void G4RootMpiPNtupleManager::CreateNtuple(G4RootMpiPNtupleDescription* ntupleDe
|
||||
G4cout << "After wait_buffer with " << fImpi << G4endl;
|
||||
|
||||
tools::uint32 mainNtupleId;
|
||||
bool rowWise;
|
||||
bool byteSwap;
|
||||
unsigned int compression;
|
||||
tools::wroot::seek seekDirectory;
|
||||
tools::uint32 basketSize;
|
||||
bool rowMode;
|
||||
std::vector<tools::uint32> basketSizes;
|
||||
unsigned int basketEntries;
|
||||
|
||||
if ( ! fImpi->unpack(mainNtupleId) ) {
|
||||
G4cerr << "bunpack(byteSwap) failed."<< G4endl;
|
||||
@@ -141,6 +143,12 @@ void G4RootMpiPNtupleManager::CreateNtuple(G4RootMpiPNtupleDescription* ntupleDe
|
||||
}
|
||||
// G4cout << "unpack 1" << G4endl;
|
||||
|
||||
if ( ! fImpi->bunpack(rowWise) ) {
|
||||
G4cerr << "bunpack(rowWise) failed."<< G4endl;
|
||||
return;
|
||||
}
|
||||
// G4cout << "unpack 1/2" << G4endl;
|
||||
|
||||
if ( ! fImpi->bunpack(byteSwap) ) {
|
||||
G4cerr << "bunpack(byteSwap) failed."<< G4endl;
|
||||
return;
|
||||
@@ -159,16 +167,24 @@ void G4RootMpiPNtupleManager::CreateNtuple(G4RootMpiPNtupleDescription* ntupleDe
|
||||
}
|
||||
// G4cout << "unpack 4" << G4endl;
|
||||
|
||||
if(fRowWise) {
|
||||
if (rowWise) {
|
||||
if ( ! fImpi->unpack(basketSize) ) {
|
||||
G4cerr << "unpack(basketSize) failed."<< G4endl;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if ( ! fImpi->bunpack(rowMode) ) {
|
||||
G4cerr << "bpack(rowMode) failed." << G4endl;
|
||||
return;
|
||||
}
|
||||
if ( ! fImpi->vunpack(basketSizes) ) {
|
||||
G4cerr << "vunpack(basketSizes) failed."<< G4endl;
|
||||
return;
|
||||
}
|
||||
if( ! fImpi->unpack(basketEntries) ) {
|
||||
G4cerr << "unpack(basketEntries) failed." << G4endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// G4cout << "unpack 5" << G4endl;
|
||||
|
||||
@@ -182,7 +198,7 @@ void G4RootMpiPNtupleManager::CreateNtuple(G4RootMpiPNtupleDescription* ntupleDe
|
||||
// << G4endl;
|
||||
|
||||
// Create MPI pntuple
|
||||
if ( fRowWise ) {
|
||||
if ( rowWise ) {
|
||||
tools::wroot::mpi_ntuple_row_wise* ntuple
|
||||
= new tools::wroot::mpi_ntuple_row_wise(
|
||||
mainNtupleId, G4cout, byteSwap, compression, seekDirectory,
|
||||
@@ -193,7 +209,8 @@ void G4RootMpiPNtupleManager::CreateNtuple(G4RootMpiPNtupleDescription* ntupleDe
|
||||
tools::wroot::mpi_ntuple_column_wise* ntuple
|
||||
= new tools::wroot::mpi_ntuple_column_wise(
|
||||
mainNtupleId, G4cout, byteSwap, compression, seekDirectory,
|
||||
basketSizes, ntupleDescription->fNtupleBooking, verbose);
|
||||
basketSizes, ntupleDescription->fNtupleBooking,
|
||||
rowMode, basketEntries, verbose);
|
||||
ntupleDescription->fNtuple = ntuple;
|
||||
ntupleDescription->fBasePNtuple = ntuple;
|
||||
}
|
||||
@@ -522,4 +539,3 @@ unsigned int G4RootMpiPNtupleManager::GetBasketSize() const
|
||||
|
||||
return fFileManager->GetBasketSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class G4MPIntupleMerger
|
||||
{
|
||||
public:
|
||||
G4MPIntupleMerger(G4int nofReducedNtupleFiles = 0,
|
||||
G4bool rowWise = false);
|
||||
G4bool rowWise = false, G4bool rowMode = true);
|
||||
~G4MPIntupleMerger();
|
||||
|
||||
private:
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
|
||||
G4MPIntupleMerger::G4MPIntupleMerger(G4int nofReducedNtupleFiles,
|
||||
G4bool rowWise)
|
||||
G4bool rowWise, G4bool rowMode)
|
||||
{
|
||||
// Configure MPI using G4MPImanager
|
||||
|
||||
@@ -59,7 +59,8 @@ G4MPIntupleMerger::G4MPIntupleMerger(G4int nofReducedNtupleFiles,
|
||||
fWrmpi = new tools::mpi::wrmpi(G4cout, *comm);
|
||||
|
||||
analysisManager->SetMpiNtupleMerging(
|
||||
fWrmpi, mpiRank, mpiSize, nofReducedNtupleFiles, rowWise);
|
||||
fWrmpi, mpiRank, mpiSize, nofReducedNtupleFiles);
|
||||
analysisManager->SetNtupleRowWise(rowWise, rowMode);
|
||||
|
||||
// G4cout << "End configure ntuple MPI merging" << G4endl;
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ void G4MPIscorerMerger::Pack(const G4VScoringMesh* mesh) {
|
||||
assert(outputBufferPosition<=outputBufferSize);
|
||||
DMSG(3,"Packing mesh: "<<mesh);
|
||||
|
||||
const MeshScoreMap& map = mesh->GetScoreMap();
|
||||
auto map = mesh->GetScoreMap();
|
||||
/*const*/ size_t nummaps = map.size();//TODO: old MPI interface
|
||||
MPI_Pack(&nummaps,1,MPI::UNSIGNED,
|
||||
outputBuffer,outputBufferSize,
|
||||
@@ -496,7 +496,7 @@ G4int G4MPIscorerMerger::CalculatePackSize(const G4VScoringMesh* mesh) const
|
||||
DMSG(3,"Calculating size for mesh: "<<mesh);
|
||||
//PackSingleMesh(Mesh)
|
||||
G4int size = sizeof(unsigned int);//num maps
|
||||
const MeshScoreMap& map = mesh->GetScoreMap();
|
||||
auto map = mesh->GetScoreMap();
|
||||
for (const auto& ele : map ) {
|
||||
//PackHitsMap
|
||||
size += sizeof(unsigned int);//name size
|
||||
|
||||
Reference in New Issue
Block a user