fix(mpi): fix some namespaces issues with mpi

This commit is contained in:
Johann Dreo 2024-08-23 10:02:22 +02:00
commit 4bbb4a595e
8 changed files with 30 additions and 16 deletions

View file

@ -29,6 +29,7 @@ Authors:
# include "../eoFunctor.h" # include "../eoFunctor.h"
# include "../eoExceptions.h" # include "../eoExceptions.h"
# include "mpi/implMpi.h"
# include "eoMpiNode.h" # include "eoMpiNode.h"
# include "eoMpiAssignmentAlgorithm.h" # include "eoMpiAssignmentAlgorithm.h"
@ -669,7 +670,7 @@ namespace eo
timerStat.start("master_wait_for_all_responses"); timerStat.start("master_wait_for_all_responses");
while( assignmentAlgo.availableWorkers() != totalWorkers ) while( assignmentAlgo.availableWorkers() != totalWorkers )
{ {
bmpi::status status = comm.probe( bmpi::any_source, eo::mpi::Channel::Messages ); eo::mpi::status status = comm.probe( eo::mpi::any_source, eo::mpi::Channel::Messages );
int wrkRank = status.source(); int wrkRank = status.source();
that.handleResponse( wrkRank ); that.handleResponse( wrkRank );
comm.send( wrkRank, Channel::Commands, Message::Finish ); comm.send( wrkRank, Channel::Commands, Message::Finish );
@ -686,7 +687,7 @@ namespace eo
AssignmentAlgorithm& assignmentAlgo; AssignmentAlgorithm& assignmentAlgo;
Job< JobData > & that; Job< JobData > & that;
bmpi::communicator & comm; eo::mpi::communicator & comm;
}; };
/** /**
@ -713,7 +714,7 @@ namespace eo
{ {
eo::log << eo::debug << "[M" << comm.rank() << "] Waitin' for node..." << std::endl; eo::log << eo::debug << "[M" << comm.rank() << "] Waitin' for node..." << std::endl;
bmpi::status status = comm.probe( bmpi::any_source, eo::mpi::Channel::Messages ); eo::mpi::status status = comm.probe( eo::mpi::any_source, eo::mpi::Channel::Messages );
int wrkRank = status.source(); int wrkRank = status.source();
eo::log << eo::debug << "[M" << comm.rank() << "] Node " << wrkRank << " just terminated." << std::endl; eo::log << eo::debug << "[M" << comm.rank() << "] Node " << wrkRank << " just terminated." << std::endl;
@ -797,7 +798,7 @@ namespace eo
AssignmentAlgorithm& assignmentAlgo; AssignmentAlgorithm& assignmentAlgo;
int masterRank; int masterRank;
const int workerStopCondition; const int workerStopCondition;
bmpi::communicator& comm; eo::mpi::communicator& comm;
JobStore<JobData>& store; JobStore<JobData>& store;
SendTaskFunction<JobData> & sendTask; SendTaskFunction<JobData> & sendTask;

View file

@ -27,14 +27,14 @@ namespace eo
{ {
void Node::init( int argc, char** argv ) void Node::init( int argc, char** argv )
{ {
static bmpi::environment env( argc, argv ); static eo::mpi::environment env( argc, argv );
} }
bmpi::communicator& Node::comm() eo::mpi::communicator& Node::comm()
{ {
return _comm; return _comm;
} }
bmpi::communicator Node::_comm; eo::mpi::communicator Node::_comm;
} }
} }

View file

@ -23,7 +23,7 @@ Authors:
# define __MPI_NODE_H__ # define __MPI_NODE_H__
# include "implMpi.h" # include "implMpi.h"
namespace bmpi = mpi; // namespace bmpi = mpi;
namespace eo namespace eo
{ {
@ -54,10 +54,10 @@ namespace eo
/** /**
* @brief Returns the global mpi::communicator * @brief Returns the global mpi::communicator
*/ */
static bmpi::communicator& comm(); static eo::mpi::communicator& comm();
protected: protected:
static bmpi::communicator _comm; static eo::mpi::communicator _comm;
}; };
} }
} }

View file

@ -54,7 +54,7 @@ namespace eo
typedef eoUF< eoPop<EOT>&, void> ResetAlgo; typedef eoUF< eoPop<EOT>&, void> ResetAlgo;
MultiStartData( MultiStartData(
bmpi::communicator& _comm, eo::mpi::communicator& _comm,
eoAlgo<EOT>& _algo, eoAlgo<EOT>& _algo,
int _masterRank, int _masterRank,
ResetAlgo & _resetAlgo ) ResetAlgo & _resetAlgo )
@ -87,7 +87,7 @@ namespace eo
/** /**
* @brief Communicator, used to send and retrieve messages. * @brief Communicator, used to send and retrieve messages.
*/ */
bmpi::communicator& comm; eo::mpi::communicator& comm;
/** /**
* @brief Algorithm which will be performed by the worker. * @brief Algorithm which will be performed by the worker.

View file

@ -137,7 +137,7 @@ namespace eo
std::vector<EOT> tempArray; std::vector<EOT> tempArray;
int masterRank; int masterRank;
bmpi::communicator& comm; eo::mpi::communicator& comm;
}; };
/** /**

View file

@ -21,6 +21,8 @@ Authors:
*/ */
#include "implMpi.h" #include "implMpi.h"
namespace eo
{
namespace mpi namespace mpi
{ {
const int any_source = MPI_ANY_SOURCE; const int any_source = MPI_ANY_SOURCE;
@ -163,4 +165,5 @@ namespace mpi
{ {
MPI_Bcast( &value, 1, MPI_INT, root, MPI_COMM_WORLD ); MPI_Bcast( &value, 1, MPI_INT, root, MPI_COMM_WORLD );
} }
} } // namespace mpi
} // namespace eo

View file

@ -41,7 +41,8 @@ Authors:
* The entities are here shortly described, if you need further details, don't hesitate * The entities are here shortly described, if you need further details, don't hesitate
* to visit the boost URL. * to visit the boost URL.
*/ */
namespace eo
{
namespace mpi namespace mpi
{ {
/** /**
@ -83,6 +84,14 @@ namespace mpi
~environment(); ~environment();
}; };
struct MPI_Status {
int count;
int cancelled;
int MPI_SOURCE;
int MPI_TAG;
int MPI_ERROR;
};
/** /**
* @brief Wrapper class for MPI_Status * @brief Wrapper class for MPI_Status
* *
@ -318,5 +327,6 @@ namespace mpi
* @} * @}
*/ */
} // namespace mpi } // namespace mpi
} // namespace eo
# endif //__EO_IMPL_MPI_HPP__ # endif //__EO_IMPL_MPI_HPP__

View file

@ -382,7 +382,7 @@ class Experiment : public eoserial::Persistent
void run() void run()
{ {
mpi::communicator& comm = eo::mpi::Node::comm(); communicator& comm = eo::mpi::Node::comm();
// reinits every objects // reinits every objects
eo::rng.reseed( _seed ); eo::rng.reseed( _seed );
eo::rng.clearCache(); // trick for repeatable sequences of normal numbers, cf eo::rng eo::rng.clearCache(); // trick for repeatable sequences of normal numbers, cf eo::rng