Skip to content
Snippets Groups Projects
Commit 7e46647e authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'feature/mpi_wrapper_library' into 'master'

default initialize MPI_Requests

See merge request !95
parents f77f36dc 146ff281
No related branches found
No related tags found
1 merge request!95default initialize MPI_Requests
......@@ -70,7 +70,7 @@ namespace AMDiS { namespace Mpi
int size = 1;
MPI_Comm_size(comm, &size);
out.resize(size);
MPI_Request request;
MPI_Request request = MPI_REQUEST_NULL;
MPI_Iallgather(to_void_ptr(&in), 1, type_to_mpi<T>(), to_void_ptr(out.data()), 1, type_to_mpi<T>(), comm, &request);
return {request};
......@@ -82,7 +82,7 @@ namespace AMDiS { namespace Mpi
int size = 1;
MPI_Comm_size(comm, &size);
out.resize(size * N);
MPI_Request request;
MPI_Request request = MPI_REQUEST_NULL;
MPI_Iallgather(to_void_ptr(in.data()), N, type_to_mpi<T>(), to_void_ptr(out.data()), N, type_to_mpi<T>(), comm, &request);
return {request};
......
......@@ -111,7 +111,7 @@ namespace Mpi
Request isend(std::string const& str, int to, Tag tag = {}) const
{
MPI_Request request;
MPI_Request request = MPI_REQUEST_NULL;
MPI_Isend(to_void_ptr(str.data()), int(str.size()), MPI_CHAR, to, tag.value, comm_, &request);
return {request};
}
......@@ -199,7 +199,7 @@ namespace Mpi
MPI_Get_count(&status, MPI_CHAR, &size);
str.resize(size);
MPI_Request req;
MPI_Request req = MPI_REQUEST_NULL;
MPI_Irecv(&str[0], size, MPI_CHAR, status.MPI_SOURCE, status.MPI_TAG, comm, &req);
return req;
......
......@@ -34,7 +34,7 @@ void Communicator::send(std::vector<T> const& vec, int to, Tag tag) const
template <class Data, REQUIRES_(not Concepts::RawPointer<Data>)>
Request Communicator::isend(Data const& data, int to, Tag tag) const
{
MPI_Request request;
MPI_Request request = MPI_REQUEST_NULL;
MPI_Isend(to_void_ptr(&data), 1, type_to_mpi<Data>(), to, tag.value, comm_, &request);
return {request};
}
......@@ -44,7 +44,7 @@ Request Communicator::isend(Data const& data, int to, Tag tag) const
template <class Data>
Request Communicator::isend(Data const* data, std::size_t size, int to, Tag tag) const
{
MPI_Request request;
MPI_Request request = MPI_REQUEST_NULL;
MPI_Isend(to_void_ptr(data), size, type_to_mpi<Data>(), to, tag.value, comm_, &request);
return {request};
}
......@@ -53,7 +53,7 @@ Request Communicator::isend(Data const* data, std::size_t size, int to, Tag tag)
template <class T>
Request Communicator::isend(std::vector<T> const& vec, int to, Tag tag) const
{
MPI_Request request;
MPI_Request request = MPI_REQUEST_NULL;
MPI_Isend(to_void_ptr(vec.data()), int(vec.size()), type_to_mpi<T>(), to, tag.value, comm_, &request);
return {request};
}
......@@ -105,7 +105,7 @@ MPI_Status Communicator::recv(std::vector<T>& vec, int from, Tag tag) const
template <class Data, REQUIRES_(not Concepts::RawPointer<Data>)>
Request Communicator::irecv(Data& data, int from, Tag tag) const
{
MPI_Request request;
MPI_Request request = MPI_REQUEST_NULL;
MPI_Irecv(&data, 1, type_to_mpi<Data>(), from, tag.value, comm_, &request);
return {request};
}
......@@ -115,7 +115,7 @@ Request Communicator::irecv(Data& data, int from, Tag tag) const
template <class Data>
Request Communicator::irecv(Data* data, std::size_t size, int from, Tag tag) const
{
MPI_Request request;
MPI_Request request = MPI_REQUEST_NULL;
MPI_Irecv(data, size, type_to_mpi<Data>(), from, tag.value, comm_, &request);
return {request};
}
......@@ -132,7 +132,7 @@ Request Communicator::irecv(std::vector<T>& vec, int from, Tag tag) const
int min_size = std::max(size,1);
vec.resize(min_size);
MPI_Request req;
MPI_Request req = MPI_REQUEST_NULL;
MPI_Irecv(vec.data(), min_size, type_to_mpi<T>(), status.MPI_SOURCE, status.MPI_TAG, comm, &req);
return req;
},
......
......@@ -92,16 +92,16 @@ namespace AMDiS { namespace Mpi
private:
int from_ = 0; //< source rank
int tag_ = 0; //< communication tag
int from_ = 0; //< source rank
int tag_ = 0; //< communication tag
MPI_Comm comm_; //< communicator
std::function<MPI_Request(MPI_Status)> recv_; //< user receive-functor
std::function<void(MPI_Status)> finish_; //< user finalize-functor
Progress progress_ = STARTED; //< internal progress flag
MPI_Status status_{}; //< the status information, filled by MPI_Iprob and MPI_Test
MPI_Request req_{}; //< the request handler, filled by the user receive-functor \ref recv_
Progress progress_ = STARTED; //< internal progress flag
MPI_Status status_ = MPI_Status{}; //< the status information, filled by MPI_Iprob and MPI_Test
MPI_Request req_ = MPI_REQUEST_NULL; //< the request handler, filled by the user receive-functor \ref recv_
};
}} // end namespace AMDiS::Mpi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment