16 return (
string(
"mpi error: ") +
string(runtime_error::what())).c_str();
21 char err_str[MPI_MAX_ERROR_STRING];
23 int err = MPI_Error_string(err_code, err_str, &err_len);
25 return MPIError(
"MPI Error: " +
string(err_str, err_len) +
" (code=" + to_string(err_code) +
")");
40 MPI_Comm_size(this->comm, &(this->
_size));
41 MPI_Comm_rank(this->comm, &(this->
_rank));
43 char buff[MPI_MAX_OBJECT_NAME];
44 int err = MPI_Comm_get_name(this->comm, buff, &len);
47 this->
_name = string(
"world");
49 this->
_name = string(buff, len);
52 shared_ptr<MPIStatus>
status = make_shared<MPIStatus>();
54 this->status->set_comm(
this);
88 ML_CLOG(DEBUG,
"Controller",
"set converged for rank " << this->
comm->
rank() <<
" to "
89 <<
"'" << boolalpha << converged <<
"'");
90 this->converged.at(this->
comm->
rank()) = converged;
91 assert(this->converged.at(this->comm->rank()) == converged);
108 if (
mpi->
size() == 1) {
return; }
114 ML_CLOG(DEBUG,
"Controller",
"sending converged status to rank " << dest_rank
115 <<
" with tag " << tag <<
": "
117 int err = MPI_Send(&iconverged, 1, MPI_INT, dest_rank, tag,
mpi->
comm);
119 ML_CLOG(DEBUG,
"Controller",
"sent converged status");
125 if (
mpi->
size() == 1) {
return; }
126 if (
mpi->
rank() == 0) {
return; }
129 ML_CLOG(DEBUG,
"Controller",
"skipping status recieve as previous is stored as converged");
136 ML_CLOG(DEBUG,
"Controller",
"receiving converged status from rank " << src_rank
138 int err = MPI_Recv(&iconverged, 1, MPI_INT, src_rank, tag,
mpi->
comm, &stat);
140 ML_CLOG(DEBUG,
"Controller",
"received converged status from rank " << src_rank
141 <<
" with tag "<< tag <<
": "
152 if ( mpi_status.MPI_TAG == MPI_ANY_TAG
153 && mpi_status.MPI_SOURCE == MPI_ANY_SOURCE
154 && mpi_status.MPI_ERROR == MPI_SUCCESS) {
155 os <<
"MPI_Status(empty)";
157 char err_str[MPI_MAX_ERROR_STRING];
159 int err = MPI_Error_string(mpi_status.MPI_ERROR, err_str, &err_len);
161 os <<
"MPI_Status(source=" << to_string(mpi_status.MPI_SOURCE) <<
", "
162 <<
"tag=" << to_string(mpi_status.MPI_TAG) <<
", "
163 <<
"error=" << string(err_str, err_len) <<
")";
virtual void clear() override
Resetting status.
virtual void set_comm(ICommunicator *comm)
Set new communicator to use.
#define ML_CLOG(level, logger_id, x)
same as CLOG(level, logger, x) from easylogging++
virtual void set_comm(MPI_Comm comm)
static const int CONVERGED
virtual void recv(int tag) override
MPIError(const string &msg="")
#define UNUSED(expr)
Denoting unused function parameters for omitting compiler warnings.
virtual void post(int tag) override
Abstract interface for communicators.
virtual void set_converged(bool converged) override
sets a new converged state.
MAKE_LOGGABLE(MPI_Status, mpi_status, os)
static MPIError from_code(const int err_code)
virtual bool get_converged(int rank) override
Retreive converged state for specific processor.
static void check_mpi_error(const int err_code)
checks MPI error code
virtual void send(int tag) override
shared_ptr< IStatus > status
static const int NOT_CONVERGED
static MPI_Status MPI_Status_factory()
creates and initializes a new empty MPI_Status object
virtual const char * what() const