From f6c59c9c2f0c05f626d13ebf8b708a2349fc21cd Mon Sep 17 00:00:00 2001 From: Matthew Shepherd Date: Wed, 2 Sep 2026 18:21:36 -0400 Subject: [PATCH 1/2] add comments to explain differences in standard and MPI implementations regarding loadMC() --- AmpTools/IUAmpTools/NormIntInterface.h | 3 +-- AmpTools/IUAmpToolsMPI/AmpToolsInterfaceMPI.cc | 2 ++ AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc | 9 ++------- AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.h | 2 -- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/AmpTools/IUAmpTools/NormIntInterface.h b/AmpTools/IUAmpTools/NormIntInterface.h index d702f155..7ddb1a24 100644 --- a/AmpTools/IUAmpTools/NormIntInterface.h +++ b/AmpTools/IUAmpTools/NormIntInterface.h @@ -91,8 +91,7 @@ class NormIntInterface void invalidateTerms(); - // needs different implementations in MPI so make virtual - virtual void loadMC() const; + void loadMC() const; #endif diff --git a/AmpTools/IUAmpToolsMPI/AmpToolsInterfaceMPI.cc b/AmpTools/IUAmpToolsMPI/AmpToolsInterfaceMPI.cc index 91ee339c..28f69543 100644 --- a/AmpTools/IUAmpToolsMPI/AmpToolsInterfaceMPI.cc +++ b/AmpTools/IUAmpToolsMPI/AmpToolsInterfaceMPI.cc @@ -123,6 +123,8 @@ AmpToolsInterfaceMPI::AmpToolsInterfaceMPI(ConfigurationInfo* configurationInfo) NormIntInterface* normInt = NULL; if (genMCRdr && accMCRdr && intenMan && !(reaction->normIntFileInput())){ normInt = new NormIntInterfaceMPI(genMCRdr, accMCRdr, *intenMan); + // no need to call loadMC() here because the constructor of + // NormIntInterfaceMPI calls it through setupMPI() m_normIntMap[reactionName] = normInt; if (reaction->normIntFile() == "") report( WARNING, kModule ) << "no name given to NormInt file for reaction " diff --git a/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc b/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc index a998f1b5..121d6a81 100644 --- a/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc +++ b/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc @@ -130,6 +130,8 @@ NormIntInterfaceMPI::setupMPI() // load the MC into CPU memory on the follower nodes -- this is effectively // a copy from the DataReaderMPI cache to the AmpVecs structure + // and it is only run on the followers to avoid large memory + // usage on the lead node loadMC(); long int thisEvents; @@ -202,10 +204,3 @@ NormIntInterfaceMPI::sumIntegrals( IntType type ) const delete[] result; } -void -NormIntInterfaceMPI::loadMC() const -{ - // avoids large memory allocations on the lead node - if( !m_isLeader ) NormIntInterface::loadMC(); -} - diff --git a/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.h b/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.h index 3f450586..7abb9f0c 100644 --- a/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.h +++ b/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.h @@ -58,8 +58,6 @@ class NormIntInterfaceMPI : public NormIntInterface complex< double > normInt( string amp, string conjAmp, bool forceUseCache = false ) const; void forceCacheUpdate( bool normIntOnly = false ) const; - void loadMC() const; - private: void setupMPI(); From a74ec291a905b0ffdae5fd441c74f6d7d35672f3 Mon Sep 17 00:00:00 2001 From: Matthew Shepherd Date: Wed, 2 Sep 2026 19:21:12 -0400 Subject: [PATCH 2/2] introduce virtual loadMC to allow MPI implementation to avoid MC loads on the lead process --- AmpTools/IUAmpTools/NormIntInterface.h | 2 +- AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc | 8 ++++++++ AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.h | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/AmpTools/IUAmpTools/NormIntInterface.h b/AmpTools/IUAmpTools/NormIntInterface.h index 7ddb1a24..07e028d0 100644 --- a/AmpTools/IUAmpTools/NormIntInterface.h +++ b/AmpTools/IUAmpTools/NormIntInterface.h @@ -91,7 +91,7 @@ class NormIntInterface void invalidateTerms(); - void loadMC() const; + virtual void loadMC() const; #endif diff --git a/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc b/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc index 121d6a81..70a9b911 100644 --- a/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc +++ b/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.cc @@ -204,3 +204,11 @@ NormIntInterfaceMPI::sumIntegrals( IntType type ) const delete[] result; } +void +NormIntInterfaceMPI::loadMC() const{ + + // do not load MC on the leader node + // only the followers need the MC + if( !m_isLeader ) NormIntInterface::loadMC(); +} + diff --git a/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.h b/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.h index 7abb9f0c..067c047f 100644 --- a/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.h +++ b/AmpTools/IUAmpToolsMPI/NormIntInterfaceMPI.h @@ -58,6 +58,8 @@ class NormIntInterfaceMPI : public NormIntInterface complex< double > normInt( string amp, string conjAmp, bool forceUseCache = false ) const; void forceCacheUpdate( bool normIntOnly = false ) const; + void loadMC() const; + private: void setupMPI();