Commit f4e3273e authored by Enrico Bothmann's avatar Enrico Bothmann Committed by Johannes Krause

Replace C++ MPI bindings with C MPI bindings

The C++ MPI bindings have been deprecated a long time ago and are e.g.
not enabled per default in OpenMPI 4 (or even present, since I found the
open-mpi configure flag to be defunct for me). Custom wrapper functions
are now defined in My_MPI class.
parent dd42d720
......@@ -473,7 +473,7 @@ void Histogram::Output(const std::string name)
void Histogram::MPISync()
{
#ifdef USING__MPI
int size=MPI::COMM_WORLD.Get_size();
int size=mpi->Size();
if (size>1) {
int cn=m_depth*m_nbin+2;
double *values = new double[cn];
......@@ -481,7 +481,7 @@ void Histogram::MPISync()
for (int i(0);i<m_nbin;++i) values[j*m_nbin+i]=m_mvalues[j][i];
values[cn-2]=m_mfills;
values[cn-1]=m_mpsfills;
mpi->MPIComm()->Allreduce(MPI_IN_PLACE,values,cn,MPI::DOUBLE,MPI::SUM);
mpi->Allreduce(values,cn,MPI_DOUBLE,MPI_SUM);
for (int j(0);j<m_depth;++j)
for (int i(0);i<m_nbin;++i) m_mvalues[j][i]=values[j*m_nbin+i];
m_mfills=values[cn-2];
......
......@@ -165,7 +165,7 @@ bool ATOOLS::Random::ReadInStatus(const std::string &path)
void ATOOLS::Random::ReadInStatus(const char * filename)
{
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_size()>1) return;
if (mpi->Size()>1) return;
#endif
if (p_external!=NULL) return;
// check what type of data is in target file
......@@ -202,7 +202,7 @@ size_t ATOOLS::Random::ReadInStatus
{
if (activeGenerator==4) { ReadInStatus4(myinstream,idx); }
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_size()>1) return std::string::npos;
if (mpi->Size()>1) return std::string::npos;
#endif
size_t count;
while (!myinstream.eof()) {
......
......@@ -189,7 +189,7 @@ std::ostream &Message::Out()
{
#ifdef USING__MPI
if (!m_mpimode &&
MPI::COMM_WORLD.Get_rank()) return m_devnull;
mpi->Rank()) return m_devnull;
#endif
return m_output;
}
......@@ -198,7 +198,7 @@ std::ostream &Message::Error()
{
#ifdef USING__MPI
if (!m_mpimode &&
MPI::COMM_WORLD.Get_rank()) return m_devnull;
mpi->Rank()) return m_devnull;
#endif
if (m_level >= 0) return m_output;
return m_devnull;
......@@ -208,7 +208,7 @@ std::ostream &Message::Events()
{
#ifdef USING__MPI
if (!m_mpimode &&
MPI::COMM_WORLD.Get_rank()) return m_devnull;
mpi->Rank()) return m_devnull;
#endif
if (m_level & 1) return m_output;
return m_devnull;
......@@ -218,7 +218,7 @@ std::ostream &Message::Info()
{
#ifdef USING__MPI
if (!m_mpimode &&
MPI::COMM_WORLD.Get_rank()) return m_devnull;
mpi->Rank()) return m_devnull;
#endif
if (m_level & 2) return m_output;
return m_devnull;
......@@ -228,7 +228,7 @@ std::ostream &Message::Tracking()
{
#ifdef USING__MPI
if (!m_mpimode &&
MPI::COMM_WORLD.Get_rank()) return m_devnull;
mpi->Rank()) return m_devnull;
#endif
if (m_level & 4) return m_output;
return m_devnull;
......@@ -238,7 +238,7 @@ std::ostream &Message::Debugging()
{
#ifdef USING__MPI
if (!m_mpimode &&
MPI::COMM_WORLD.Get_rank()) return m_devnull;
mpi->Rank()) return m_devnull;
#endif
if (m_level & 8) return m_output;
return m_devnull;
......@@ -248,7 +248,7 @@ std::ostream &Message::IODebugging()
{
#ifdef USING__MPI
if (!m_mpimode &&
MPI::COMM_WORLD.Get_rank()) return m_devnull;
mpi->Rank()) return m_devnull;
#endif
if (m_level & 32) return m_output;
return m_devnull;
......
......@@ -66,15 +66,15 @@ bool My_File<FileType>::OpenDB(std::string file)
{
std::string path(file);
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()) {
if (mpi->Rank()) {
s_ziparchives[path]=ZipArchive_Ref(NULL,std::vector<std::string>());
int size;
MPI::COMM_WORLD.Bcast(&size,1,MPI_INT,0);
mpi->Bcast(&size,1,MPI_INT,0);
for (int i=0;i<size;++i) {
int length;
MPI::COMM_WORLD.Bcast(&length,1,MPI_INT,0);
mpi->Bcast(&length,1,MPI_INT,0);
char *message = new char[length+1];
MPI::COMM_WORLD.Bcast(message,length+1,MPI_CHAR,0);
mpi->Bcast(message,length+1,MPI_CHAR,0);
std::string name, content;
for (int p=0;p<length;++p)
if (message[p]=='\n') {
......@@ -98,7 +98,7 @@ bool My_File<FileType>::OpenDB(std::string file)
const std::vector<ZipEntry> &entries=zf->getEntries();
int size=entries.size();
#ifdef USING__MPI
MPI::COMM_WORLD.Bcast(&size,1,MPI_INT,0);
mpi->Bcast(&size,1,MPI_INT,0);
#endif
for(std::vector<ZipEntry>::const_iterator
it=entries.begin();it!=entries.end();++it) {
......@@ -109,8 +109,8 @@ bool My_File<FileType>::OpenDB(std::string file)
#ifdef USING__MPI
int length(name.length()+content.length()+1);
content=name+'\n'+content;
MPI::COMM_WORLD.Bcast(&length,1,MPI_INT,0);
MPI::COMM_WORLD.Bcast(&content[0],length+1,MPI_CHAR,0);
mpi->Bcast(&length,1,MPI_INT,0);
mpi->Bcast(&content[0],length+1,MPI_CHAR,0);
#endif
}
return true;
......@@ -219,12 +219,12 @@ bool My_File<FileType>::Open()
}
else {
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()) {
if (mpi->Rank()) {
int fsize;
MPI::COMM_WORLD.Bcast(&fsize,1,MPI_INT,0);
mpi->Bcast(&fsize,1,MPI_INT,0);
if (fsize<0) return false;
char *content = new char[fsize+1];
MPI::COMM_WORLD.Bcast(content,fsize+1,MPI_CHAR,0);
mpi->Bcast(content,fsize+1,MPI_CHAR,0);
(*p_stream)<<content<<"\n";
delete [] content;
}
......@@ -234,7 +234,7 @@ bool My_File<FileType>::Open()
int fsize(infile.good()?1:-1);
if (fsize<0) {
#ifdef USING__MPI
MPI::COMM_WORLD.Bcast(&fsize,1,MPI_INT,0);
mpi->Bcast(&fsize,1,MPI_INT,0);
#endif
return false;
}
......@@ -243,8 +243,8 @@ bool My_File<FileType>::Open()
#ifdef USING__MPI
std::string content(p_stream->str());
fsize=content.length();
MPI::COMM_WORLD.Bcast(&fsize,1,MPI_INT,0);
MPI::COMM_WORLD.Bcast(&content[0],fsize+1,MPI_CHAR,0);
mpi->Bcast(&fsize,1,MPI_INT,0);
mpi->Bcast(&content[0],fsize+1,MPI_CHAR,0);
}
#endif
}
......@@ -271,7 +271,7 @@ bool My_File<FileType>::Close()
return false;
auto os = dynamic_cast<std::ofstream*>(p_file.get());
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()==0)
if (mpi->Rank()==0)
#endif
if (os) {
bool indb(false);
......
#include "ATOOLS/Org/My_MPI.H"
#include "ATOOLS/Org/Run_Parameter.H"
#include "ATOOLS/Org/Shell_Tools.H"
#include "ATOOLS/Org/Message.H"
#include <csignal>
#include <cstddef>
#include <cstring>
#include <unistd.h>
using namespace ATOOLS;
My_MPI *ATOOLS::mpi(NULL);
My_MPI* ATOOLS::mpi {nullptr};
My_MPI::My_MPI()
{
#ifdef USING__MPI
p_comm=&MPI::COMM_WORLD;
m_comm = MPI_COMM_WORLD;
#endif
}
My_MPI::~My_MPI()
{
}
void My_MPI::SetUpSendRecv()
void My_MPI::PrintRankInfo()
{
#ifdef USING__MPI
int size=MPI::COMM_WORLD.Get_size();
if (size>1) {
msg_Info()<<METHOD<<"(): Running on "<<size<<" ranks."<<std::endl;
}
const auto size = Size();
if (size > 1)
msg_Info() << METHOD << "(): Running on " << size << " ranks." << std::endl;
#endif
}
void ATOOLS::Abort(const int mode)
{
#ifdef USING__MPI
MPI::COMM_WORLD.Abort(1+mode);
MPI_Abort(MPI_COMM_WORLD, 1 + mode);
#else
if (mode) kill(getpid(),9);
if (mode)
kill(getpid(), 9);
abort();
#endif
#endif
}
......@@ -2,9 +2,11 @@
#define ATOOLS__Org__My_MPI_H
#include "ATOOLS/Org/CXXFLAGS.H"
#ifdef USING__MPI
#include "mpi.h"
#endif
#ifdef USING__Threading
#include <pthread.h>
inline int pthread_cond_signal
......@@ -22,29 +24,56 @@ inline int pthread_cond_signal
namespace ATOOLS {
class My_MPI {
private:
public:
My_MPI();
void PrintRankInfo();
#ifdef USING__MPI
MPI::Intracomm *p_comm;
#endif
void SetMPIRecv(std::vector<int> r);
void Barrier() {
MPI_Barrier(m_comm);
}
public:
int Rank() {
int rank;
MPI_Comm_rank(m_comm, &rank);
return rank;
}
My_MPI();
int Size() {
int size;
MPI_Comm_size(m_comm, &size);
return size;
}
void Bcast(void* buffer, int count, MPI_Datatype type, int root=0) {
MPI_Bcast(buffer, count, type, root, m_comm);
}
~My_MPI();
void Allreduce(void* buffer, int count, MPI_Datatype type, MPI_Op op) {
MPI_Allreduce(MPI_IN_PLACE, buffer, count, type, op, m_comm);
}
void SetUpSendRecv();
void Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype) {
MPI_Allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype,
m_comm);
}
#endif
private:
#ifdef USING__MPI
inline MPI::Intracomm *MPIComm() { return p_comm; }
MPI_Comm m_comm;
#endif
};// end of class My_MPI
extern My_MPI *mpi;
extern My_MPI* mpi;
void Abort(const int mode=0);
......
......@@ -307,7 +307,7 @@ void Run_Parameter::Init()
}
#ifdef USING__MPI
int rank=MPI::COMM_WORLD.Get_rank();
int rank=mpi->Rank();
if (s["MPI_SEED_MODE"].Get<int>()==0) {
msg_Info()<<METHOD<<"(): Seed mode '*'\n";
for (int i(0);i<4;++i)
......@@ -418,7 +418,7 @@ void Run_Parameter::Gen::WriteCitationInfo()
*f<<"%% You have used the following configuration:\n";
PrintGitVersion(*f,1,"%% ");
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()==0)
if (mpi->Rank()==0)
#endif
std::cout<<std::string(72,'-')<<"\n"
<<om::bold<<"Please cite the publications listed in '"
......
......@@ -34,8 +34,8 @@ bool ATOOLS::MakeDir(std::string path,const bool create_tree,
#ifndef USING__MPI
int exists(!mkdir(path.c_str(),mode));
#else
int exists(MPI::COMM_WORLD.Get_rank()?0:!mkdir(path.c_str(),mode));
MPI::COMM_WORLD.Bcast(&exists,1,MPI_INT,0);
int exists(mpi->Rank()?0:!mkdir(path.c_str(),mode));
mpi->Bcast(&exists,1,MPI_INT,0);
#endif
return exists;
}
......@@ -54,8 +54,8 @@ bool ATOOLS::MakeDir(std::string path,const bool create_tree,
#ifndef USING__MPI
int result(mkdir(piece.c_str(),mode));
#else
int result(MPI::COMM_WORLD.Get_rank()?0:mkdir(piece.c_str(),mode));
MPI::COMM_WORLD.Bcast(&result,1,MPI_INT,0);
int result(mpi->Rank()?0:mkdir(piece.c_str(),mode));
mpi->Bcast(&result,1,MPI_INT,0);
#endif
if (result!=0) {
if (errno==EEXIST) {
......@@ -84,8 +84,8 @@ bool ATOOLS::ChMod(const std::string &file,const mode_t mode)
#ifndef USING__MPI
int result(chmod(file.c_str(),mode));
#else
int result(MPI::COMM_WORLD.Get_rank()?0:chmod(file.c_str(),mode));
MPI::COMM_WORLD.Bcast(&result,1,MPI_INT,0);
int result(mpi->Rank()?0:chmod(file.c_str(),mode));
mpi->Bcast(&result,1,MPI_INT,0);
#endif
if (result!=0) {
#ifdef DEBUG__Shell_Tools
......@@ -103,20 +103,20 @@ bool ATOOLS::Copy(const std::string &oldname,
{
int mode(0);
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()==0) {
if (mpi->Rank()==0) {
#endif
struct stat fst;
stat(oldname.c_str(),&fst);
mode=fst.st_mode;
#ifdef USING__MPI
}
MPI::COMM_WORLD.Bcast(&mode,1,MPI_INT,0);
mpi->Bcast(&mode,1,MPI_INT,0);
#endif
if ((mode&S_IFMT)==S_IFDIR) {
if (!MakeDir(newname,mode)) return false;
int stat=true;
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()==0) {
if (mpi->Rank()==0) {
#endif
struct dirent **entries;
int n(scandir(oldname.c_str(),&entries,NULL,NULL));
......@@ -130,14 +130,14 @@ bool ATOOLS::Copy(const std::string &oldname,
if (n>=0) free(entries);
#ifdef USING__MPI
}
MPI::COMM_WORLD.Bcast(&stat,1,MPI_INT,0);
mpi->Bcast(&stat,1,MPI_INT,0);
#endif
return stat;
}
if (!FileExists(oldname)) return false;
int stat=false;
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()==0) {
if (mpi->Rank()==0) {
#endif
std::ifstream oldfile(oldname.c_str());
std::ofstream newfile(newname.c_str());
......@@ -145,7 +145,7 @@ bool ATOOLS::Copy(const std::string &oldname,
stat=chmod(newname.c_str(),mode)==0;
#ifdef USING__MPI
}
MPI::COMM_WORLD.Bcast(&stat,1,MPI_INT,0);
mpi->Bcast(&stat,1,MPI_INT,0);
#endif
return stat;
}
......@@ -189,14 +189,14 @@ bool ATOOLS::FileExists(const std::string &file,const int mode)
if (mode) return false;
int exists(false);
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()==0) {
if (mpi->Rank()==0) {
#endif
struct stat fst;
if (stat(file.c_str(),&fst)!=-1)
exists=(fst.st_mode&S_IFMT)==S_IFREG;
#ifdef USING__MPI
}
MPI::COMM_WORLD.Bcast(&exists,1,MPI_INT,0);
mpi->Bcast(&exists,1,MPI_INT,0);
#endif
return exists;
}
......@@ -205,14 +205,14 @@ bool ATOOLS::DirectoryExists(const std::string &dir)
{
int exists(false);
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()==0) {
if (mpi->Rank()==0) {
#endif
struct stat fst;
if (stat(dir.c_str(),&fst)!=-1)
exists=(fst.st_mode&S_IFMT)==S_IFDIR;
#ifdef USING__MPI
}
MPI::COMM_WORLD.Bcast(&exists,1,MPI_INT,0);
mpi->Bcast(&exists,1,MPI_INT,0);
#endif
return exists;
}
......@@ -221,9 +221,9 @@ bool ATOOLS::Remove(const std::string &file,
const bool rec)
{
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()) {
if (mpi->Rank()) {
int success;
MPI::COMM_WORLD.Bcast(&success,1,MPI_INT,0);
mpi->Bcast(&success,1,MPI_INT,0);
return success;
}
#endif
......@@ -231,7 +231,7 @@ bool ATOOLS::Remove(const std::string &file,
if (stat(file.c_str(),&fst)==-1) {
int success(false);
#ifdef USING__MPI
MPI::COMM_WORLD.Bcast(&success,1,MPI_INT,0);
mpi->Bcast(&success,1,MPI_INT,0);
#endif
return success;
}
......@@ -249,13 +249,13 @@ bool ATOOLS::Remove(const std::string &file,
int success(false);
if (stat) success=(rmdir(file.c_str())==0);
#ifdef USING__MPI
MPI::COMM_WORLD.Bcast(&success,1,MPI_INT,0);
mpi->Bcast(&success,1,MPI_INT,0);
#endif
return success;
}
int success(unlink(file.c_str())==0);
#ifdef USING__MPI
MPI::COMM_WORLD.Bcast(&success,1,MPI_INT,0);
mpi->Bcast(&success,1,MPI_INT,0);
#endif
return success;
}
......
......@@ -194,7 +194,7 @@ bool Analysis_Handler::WriteOut()
if (rpa->gen.BatchMode()&1) m_write=false;
if (!m_write) return true;
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()==0)
if (mpi->Rank()==0)
#endif
if (OutputPath()[OutputPath().length()-1]=='/') {
if (!MakeDir(OutputPath())) {
......@@ -214,7 +214,7 @@ bool Analysis_Handler::WriteOut()
bool Analysis_Handler::Finish()
{
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()==0)
if (mpi->Rank()==0)
#endif
if (OutputPath()[OutputPath().length()-1]=='/') {
if (!MakeDir(OutputPath())) {
......
......@@ -416,18 +416,18 @@ void Primitive_Analysis::FinishAnalysis(const std::string & resdir,int mode)
{
if (m_usedb) mode=1;
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_size()>1) {
int rank=MPI::COMM_WORLD.Get_rank();
if (mpi->Size()>1) {
int rank=mpi->Rank();
std::string local, global;
for (Analysis_List::iterator ait(m_subanalyses.begin());
ait!=m_subanalyses.end();++ait)
local+="||"+ait->first+"|"+ToString(ait->second->m_mode);
int sz(local.length());
mpi->MPIComm()->Allreduce(MPI_IN_PLACE,&sz,1,MPI::INT,MPI::MAX);
mpi->Allreduce(&sz,1,MPI_INT,MPI_MAX);
if (sz) {
local.resize(sz,' ');
global.resize(MPI::COMM_WORLD.Get_size()*sz,' ');
mpi->MPIComm()->Allgather(&local[0],sz,MPI::CHAR,&global[0],sz,MPI::CHAR);
global.resize(mpi->Size()*sz,' ');
mpi->Allgather(&local[0],sz,MPI_CHAR,&global[0],sz,MPI_CHAR);
std::swap<PL_Container>(p_partner->m_pls,p_partner->m_slp);
for (size_t pos(global.find("||"));pos!=std::string::npos;) {
global=global.substr(pos+2);
......@@ -441,7 +441,7 @@ void Primitive_Analysis::FinishAnalysis(const std::string & resdir,int mode)
std::swap<PL_Container>(p_partner->m_pls,p_partner->m_slp);
}
}
if (MPI::COMM_WORLD.Get_rank()==0)
if (mpi->Rank()==0)
#endif
{
if (m_usedb) {
......
......@@ -45,7 +45,7 @@ using namespace libzippp;
int main(int argc,char **argv)
{
#ifdef USING__MPI
MPI::Init(argc,argv);
MPI_Init(&argc, &argv);
#endif
ATOOLS::exh = new Terminator_Object_Handler();
ATOOLS::msg = new Message();
......@@ -253,7 +253,7 @@ int main(int argc,char **argv)
delete ATOOLS::msg;
delete ATOOLS::exh;
#ifdef USING__MPI
MPI::Finalize();
MPI_Finalize();
#endif
return 0;
}
......
......@@ -44,7 +44,7 @@ Output_HepMC2_Genevent::Output_HepMC2_Genevent(const Output_Arguments &args) :
m_ext += ".gz";
#endif
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_size()>1) {
if (mpi->Size()>1) {
m_basename+="_"+rpa->gen.Variable("RNG_SEED");
}
#endif
......
......@@ -45,7 +45,7 @@ Output_HepMC2_Short::Output_HepMC2_Short(const Output_Arguments &args) :
m_ext += ".gz";
#endif
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_size()>1) {
if (mpi->Size()>1) {
m_basename+="_"+rpa->gen.Variable("RNG_SEED");
}
#endif
......
......@@ -32,7 +32,7 @@ Output_HepMC3_Genevent::Output_HepMC3_Genevent(const Output_Arguments &args) :
= Settings::GetMainSettings()["HEPMC3_IO_TYPE"].SetDefault(0).Get<int>();
int precision = Settings::GetMainSettings()["HEPMC3_OUTPUT_PRECISION"].SetDefault(12).Get<int>();
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_size()>1) {
if (mpi->Size()>1) {
m_basename+="_"+rpa->gen.Variable("RNG_SEED");
}
#endif
......
......@@ -137,7 +137,7 @@ bool OpenLoops_Interface::Initialize(MODEL::Model_Base* const model,
SetParameter("install_path", s_olprefix.c_str());
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_size()>1) SetParameter("splash","0");
if (mpi->Size()>1) SetParameter("splash","0");
#endif
// set remaining OL parameters specified by user
......
......@@ -196,13 +196,13 @@ Rivet_Interface::Rivet_Interface(const std::string &outpath,
if (m_outpath[m_outpath.size()-1]=='/')
m_outpath=m_outpath.substr(0,m_outpath.size()-1);
#ifdef USING__MPI
if (MPI::COMM_WORLD.Get_rank()==0) {
if (mpi->Rank()==0) {
#endif
if (m_outpath.rfind('/')!=std::string::npos)
MakeDir(m_outpath.substr(0,m_outpath.rfind('/')));
#ifdef USING__MPI
}
if (MPI::COMM_WORLD.Get_size()>1) {
if (mpi->Size()>1) {
m_outpath.insert(m_outpath.length(),"_"+rpa->gen.Variable("RNG_SEED"));
}
#endif
......
......@@ -41,7 +41,7 @@ Output_RootNtuple::Output_RootNtuple
m_idcnt=0;
m_avsize=s["ROOTNTUPLE_AVSIZE"].Get<int>();
#ifdef USING__MPI
int size=MPI::COMM_WORLD.Get_size();
int size=mpi->Size();
if (m_exact) m_avsize=Max((size_t)1,m_avsize/size);
#endif
m_total=0;
......@@ -113,7 +113,7 @@ void Output_RootNtuple::Header()
{
#ifdef USING__ROOT
#ifdef USING__MPI
int rank=MPI::COMM_WORLD.Get_rank();
int rank=mpi->Rank();
if (rank) return;
#endif
p_f=new TFile((m_basename+m_ext).c_str(),"recreate");
......@@ -407,22 +407,22 @@ void Output_RootNtuple::MPISync()
{
#ifdef USING__MPI
static int s_offset=11;
int size=MPI::COMM_WORLD.Get_size();
int size=mpi->Size();
if (size>1) {
int rank=MPI::COMM_WORLD.Get_rank();
int rank=mpi->Rank();
double vals[6];
if (rank==0) {
m_evtlist.resize(m_cnt2);
m_flavlist.resize(m_fcnt);
m_momlist.resize(m_fcnt);
for (int tag=1;tag<size;++tag) {
MPI::COMM_WORLD.Recv(&vals,6,MPI::DOUBLE,MPI::ANY_SOURCE,s_offset*size+tag);
MPI_COMM_WORLD.Recv(&vals,6,MPI_DOUBLE,MPI_ANY_SOURCE,s_offset*size+tag);
std::vector<rntuple_evt2> evts((int)vals[0]);
std::vector<int> flavs((int)vals[3]);
std::vector<Vec4D> moms((int)vals[3]);
MPI::COMM_WORLD.Recv(&evts.front(),(int)vals[0],MPI_rntuple_evt2,MPI::ANY_SOURCE,(s_offset+1)*size+tag);
MPI::COMM_WORLD.Recv(&flavs.front(),(int)vals[3],MPI::INT,MPI::ANY_SOURCE,(s_offset+2)*size+tag);
MPI::COMM_WORLD.Recv(&moms.front(),(int)vals[3],MPI_Vec4D,MPI::ANY_SOURCE,(s_offset+3)*size+tag);
MPI_COMM_WORLD.Recv(&evts.front(),(int)vals[0],MPI_rntuple_evt2,MPI_ANY_SOURCE,(s_offset+1)*size+tag);
MPI_COMM_WORLD.Recv(&flavs.front(),(int)vals[3],MPI_INT,MPI_ANY_SOURCE,(s_offset+2)*size+tag);
MPI_COMM_WORLD.Recv(&moms.front(),(int)vals[3],MPI_Vec4D,MPI_ANY_SOURCE,(s_offset+3)*size+tag);
m_evtlist.insert(m_evtlist.end(),evts.begin(),evts.end());
m_flavlist.insert(m_flavlist.end(),flavs.begin(),flavs.end());
m_momlist.insert(m_momlist.end(),moms.begin(),moms.end());
......@@ -453,10 +453,10 @@ void Output_RootNtuple::MPISync()
vals[3]=m_fcnt;
vals[4]=m_fsq;
vals[5]=m_sum;
MPI::COMM_WORLD.Send(&vals,6,MPI::DOUBLE,0,s_offset*size+rank);
MPI::COMM_WORLD.Send(&m_evtlist.front(),(int)vals[0],MPI_rntuple_evt2,0,(s_offset+1)*size+rank);
MPI::COMM_WORLD.Send(&m_flavlist.front(),(int)vals[3],MPI::INT,0,(s_offset+2)*size+rank);
MPI::COMM_WORLD.Send(&m_momlist.front(),(int)vals[3],MPI_Vec4D,0,(s_offset+3)*size+rank);
MPI_COMM_WORLD.Send(&vals,6,MPI_DOUBLE,0,s_offset*size+rank);
MPI_COMM_WORLD.Send(&m_evtlist.front(),(int)vals[0],MPI_rntuple_evt2,0,(s_offset+1)*size+rank);
MPI_COMM_WORLD.Send(&m_flavlist.front(),(int)vals[3],MPI_INT,0,(s_offset+2)*size+rank);
MPI_COMM_WORLD.Send(&m_momlist.front(),(int)vals[3],MPI_Vec4D,0,(s_offset+3)*size+rank);
m_cnt2=m_cnt3=m_fcnt=m_evt=0;
m_sum=m_fsq=0.0;
}
......
......@@ -143,8 +143,8 @@ RootNtuple_Reader::RootNtuple_Reader(const Input_Arguments &args,int exact,int f
size_t i(ToType<size_t>(range.substr(0,spos)));
size_t e(ToType<size_t>(range.substr(spos+1)));
#ifdef USING__MPI
int size=MPI::COMM_WORLD.Get_size();
int rank=MPI::COMM_WORLD.Get_rank();
int size=mpi->Size();
int rank=mpi->Rank();
int le=e, nact=size, values[2];
if (size>1) {
if (rank==0) {
......@@ -157,18 +157,18 @@ RootNtuple_Reader::RootNtuple_Reader(const Input_Arguments &args,int exact,int f
values[0]=i+tag*inc;
values[1]=i+(tag+1)*inc-1;
if (tag==nact-1) values[1]=le;
MPI::COMM_WORLD.Send(&values,2,MPI::INT,tag,tag);
MPI::COMM_WORLD.Recv(&values,2,MPI::INT,MPI::ANY_SOURCE,size+tag);