Commit 7765fcdd authored by Praetorius, Simon's avatar Praetorius, Simon

changed type-traits since problems with bullxmpi

parent eec6b175
......@@ -43,77 +43,77 @@ namespace mpi14
public:
// send mpi datatype
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
void send(Data const& data, int to, int tag = 0) const;
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, void>
send(Data const& data, int to, int tag = 0) const;
// send array of mpi datatypes
template <class T,
REQUIRES( is_mpi_type<T>::value )>
void send(T const* data, std::size_t size, int to, int tag = 0) const;
template <class T>
std::enable_if_t<is_mpi_type<T>::value, void>
send(T const* data, std::size_t size, int to, int tag = 0) const;
template <class T, std::size_t N,
REQUIRES( is_mpi_type<T>::value )>
void send(T const (&data)[N], int to, int tag = 0) const
template <class T, std::size_t N>
std::enable_if_t<is_mpi_type<T>::value, void>
send(T const (&data)[N], int to, int tag = 0) const
{
send(data, N, to, tag);
send(to_void_ptr(data), N, to, tag);
}
template <class T, std::size_t N,
REQUIRES( is_mpi_type<T>::value )>
void send(std::array<T,N> const& array, int to, int tag = 0) const
template <class T, std::size_t N>
std::enable_if_t<is_mpi_type<T>::value, void>
send(std::array<T,N> const& array, int to, int tag = 0) const
{
send(array.data(), N, to, tag);
send(to_void_ptr(array.data()), N, to, tag);
}
template <class T,
REQUIRES( is_mpi_type<T>::value )>
void send(std::vector<T> const& vec, int to, int tag = 0) const;
template <class T>
std::enable_if_t<is_mpi_type<T>::value, void>
send(std::vector<T> const& vec, int to, int tag = 0) const;
void send(std::string const& str, int to, int tag = 0) const
{
MPI_Send(str.data(), int(str.size()), MPI_CHAR, to, tag, comm_);
MPI_Send(to_void_ptr(str.data()), int(str.size()), MPI_CHAR, to, tag, comm_);
}
// send complex datatype:
// 1. create a binary representation of data, store it in a buffer
// 2. send size of buffer (with MPI_Ibsend)
// 3. send buffer
template <class Data,
REQUIRES( !is_mpi_type<Data>::value )>
void send(Data const& data, int to, int tag = 0) const;
template <class Data>
std::enable_if_t<!is_mpi_type<Data>::value, void>
send(Data const& data, int to, int tag = 0) const;
// -------------------------------------------------------------------------------------
// send mpi datatype (non-blocking)
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request isend(Data const& data, int to, int tag = 0) const;
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
isend(Data const& data, int to, int tag = 0) const;
// send mpi datatype (non-blocking, buffered)
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request ibsend(Data const& data, int to, int tag = 0) const;
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
ibsend(Data const& data, int to, int tag = 0) const;
// send array of mpi datatypes (non-blocking)
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request isend(Data const* data, std::size_t size, int to, int tag = 0) const;
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
isend(Data const* data, std::size_t size, int to, int tag = 0) const;
// send array of mpi datatypes (non-blocking, buffered)
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request ibsend(Data const* data, std::size_t size, int to, int tag = 0) const;
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
ibsend(Data const* data, std::size_t size, int to, int tag = 0) const;
template <class T,
REQUIRES( is_mpi_type<T>::value )>
Request isend(std::vector<T> const& vec, int to, int tag = 0) const;
template <class T>
std::enable_if_t<is_mpi_type<T>::value, Request>
isend(std::vector<T> const& vec, int to, int tag = 0) const;
Request isend(std::string const& str, int to, int tag = 0) const
{
MPI_Request request;
MPI_Isend(str.data(), int(str.size()), MPI_CHAR, to, tag, comm_, &request);
MPI_Isend(to_void_ptr(str.data()), int(str.size()), MPI_CHAR, to, tag, comm_, &request);
return {request};
}
......@@ -122,39 +122,39 @@ namespace mpi14
// 1. create a binary representation of data, store it in a buffer
// 2. send size of buffer (with MPI_Ibsend)
// 3. send buffer (with MPI_Ibsend)
template <class Data,
REQUIRES( !is_mpi_type<Data>::value )>
Request isend(Data const& data, int to, int tag = 0) const;
template <class Data>
std::enable_if_t<!is_mpi_type<Data>::value, Request>
isend(Data const& data, int to, int tag = 0) const;
// -------------------------------------------------------------------------------------
// receive mpi datatype
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
MPI_Status recv(Data& data, int from, int tag = 0) const;
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, MPI_Status>
recv(Data& data, int from, int tag = 0) const;
// receive array of mpi datatypes
template <class T,
REQUIRES( is_mpi_type<T>::value )>
MPI_Status recv(T* data, std::size_t size, int from, int tag = 0) const;
template <class T>
std::enable_if_t<is_mpi_type<T>::value, MPI_Status>
recv(T* data, std::size_t size, int from, int tag = 0) const;
template <class T, std::size_t N,
REQUIRES( is_mpi_type<T>::value )>
MPI_Status recv(T (&data)[N], int from, int tag = 0) const
template <class T, std::size_t N>
std::enable_if_t<is_mpi_type<T>::value, MPI_Status>
recv(T (&data)[N], int from, int tag = 0) const
{
return recv(data, N, from, tag);
}
template <class T, std::size_t N,
REQUIRES( is_mpi_type<T>::value )>
MPI_Status recv(std::array<T,N>& data, int from, int tag = 0) const
template <class T, std::size_t N>
std::enable_if_t<is_mpi_type<T>::value, MPI_Status>
recv(std::array<T,N>& data, int from, int tag = 0) const
{
return recv(data.data(), N, from, tag);
}
template <class T,
REQUIRES( is_mpi_type<T>::value )>
MPI_Status recv(std::vector<T>& data, int from, int tag = 0) const;
template <class T>
std::enable_if_t<is_mpi_type<T>::value, MPI_Status>
recv(std::vector<T>& data, int from, int tag = 0) const;
MPI_Status recv(std::string& str, int from, int tag = 0) const
{
......@@ -170,29 +170,29 @@ namespace mpi14
}
// receive complex datatype
template <class Data,
REQUIRES( !is_mpi_type<Data>::value )>
MPI_Status recv(Data& data, int from, int tag = 0) const;
template <class Data>
std::enable_if_t<!is_mpi_type<Data>::value, MPI_Status>
recv(Data& data, int from, int tag = 0) const;
// -------------------------------------------------------------------------------------
// receive mpi datatype
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request irecv(Data& data, int from, int tag = 0) const;
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
irecv(Data& data, int from, int tag = 0) const;
// receive array of mpi datatypes
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request irecv(Data* data, std::size_t size, int from, int tag = 0) const;
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
irecv(Data* data, std::size_t size, int from, int tag = 0) const;
// receive vector of mpi datatypes
// 1. until message received, call MPI_Iprobe to retrieve status and size of message
// 2. resize data-vector
// 3. receive data into vector
template <class T,
REQUIRES( is_mpi_type<T>::value )>
Request irecv(std::vector<T>& vec, int from, int tag = 0) const;
template <class T>
std::enable_if_t<is_mpi_type<T>::value, Request>
irecv(std::vector<T>& vec, int from, int tag = 0) const;
Request irecv(std::string& str, int from, int tag = 0) const
{
......@@ -206,9 +206,9 @@ namespace mpi14
// receive complex datatype asynchronousely
// Wait for data, by calling Future::test() or Future::wait().
template <class Data,
REQUIRES( !is_mpi_type<Data>::value )>
Request irecv(Data& data, int from, int tag = 0) const;
template <class Data>
std::enable_if_t<!is_mpi_type<Data>::value, Request>
irecv(Data& data, int from, int tag = 0) const;
protected:
......
......@@ -90,5 +90,11 @@ namespace mpi14
template <class T>
MPI_Op op_to_mpi() { return aux::op_to_mpi<T>::value(); };
template <class T>
void* to_void_ptr(T* ptr) { return ptr; }
template <class T>
void* to_void_ptr(T const* ptr) { return const_cast<T*>(ptr); }
} // end namespace mpi14
......@@ -3,28 +3,28 @@
namespace mpi14 {
// send mpi datatype
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
void Communicator::send(Data const& data, int to, int tag) const
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, void>
Communicator::send(Data const& data, int to, int tag) const
{
MPI_Send(&data, 1, type_to_mpi<Data>(), to, tag, comm_);
MPI_Send(to_void_ptr(&data), 1, type_to_mpi<Data>(), to, tag, comm_);
}
// send array of mpi datatypes
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
void Communicator::send(Data const* data, std::size_t size, int to, int tag) const
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, void>
Communicator::send(Data const* data, std::size_t size, int to, int tag) const
{
MPI_Send(data, int(size), type_to_mpi<Data>(), to, tag, comm_);
MPI_Send(to_void_ptr(data), int(size), type_to_mpi<Data>(), to, tag, comm_);
}
template <class T,
REQUIRES( is_mpi_type<T>::value )>
void Communicator::send(std::vector<T> const& vec, int to, int tag) const
template <class T>
std::enable_if_t<is_mpi_type<T>::value, void>
Communicator::send(std::vector<T> const& vec, int to, int tag) const
{
MPI_Send(vec.data(), int(vec.size()), type_to_mpi<T>(), to, tag, comm_);
MPI_Send(to_void_ptr(vec.data()), int(vec.size()), type_to_mpi<T>(), to, tag, comm_);
}
......@@ -32,67 +32,67 @@ void Communicator::send(std::vector<T> const& vec, int to, int tag) const
// 1. create a binary representation of data, store it in a buffer
// 2. send size of buffer (with MPI_Ibsend)
// 3. send buffer
template <class Data,
REQUIRES( !is_mpi_type<Data>::value )>
void Communicator::send(Data const& data, int to, int tag) const
template <class Data>
std::enable_if_t<!is_mpi_type<Data>::value, void>
Communicator::send(Data const& data, int to, int tag) const
{
auto buffer = serialization::store(data);
MPI_Send(buffer.data(), int(buffer.size()), MPI_BYTE, to, tag, comm_);
MPI_Send(to_void_ptr(buffer.data()), int(buffer.size()), MPI_BYTE, to, tag, comm_);
}
// -------------------------------------------------------------------------------------
// send mpi datatype (non-blocking)
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request Communicator::isend(Data const& data, int to, int tag) const
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
Communicator::isend(Data const& data, int to, int tag) const
{
MPI_Request request;
MPI_Isend(&data, 1, type_to_mpi<Data>(), to, tag, comm_, &request);
MPI_Isend(to_void_ptr(&data), 1, type_to_mpi<Data>(), to, tag, comm_, &request);
return {request};
}
// send mpi datatype (non-blocking, buffered)
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request Communicator::ibsend(Data const& data, int to, int tag) const
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
Communicator::ibsend(Data const& data, int to, int tag) const
{
MPI_Request request;
MPI_Ibsend(&data, 1, type_to_mpi<Data>(), to, tag, comm_, &request);
MPI_Ibsend(to_void_ptr(&data), 1, type_to_mpi<Data>(), to, tag, comm_, &request);
return {request};
}
// send array of mpi datatypes (non-blocking)
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request Communicator::isend(Data const* data, std::size_t size, int to, int tag) const
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
Communicator::isend(Data const* data, std::size_t size, int to, int tag) const
{
MPI_Request request;
MPI_Isend(data, size, type_to_mpi<Data>(), to, tag, comm_, &request);
MPI_Isend(to_void_ptr(data), size, type_to_mpi<Data>(), to, tag, comm_, &request);
return {request};
}
// send array of mpi datatypes (non-blocking, buffered)
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request Communicator::ibsend(Data const* data, std::size_t size, int to, int tag) const
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
Communicator::ibsend(Data const* data, std::size_t size, int to, int tag) const
{
MPI_Request request;
MPI_Ibsend(data, size, type_to_mpi<Data>(), to, tag, comm_, &request);
MPI_Ibsend(to_void_ptr(data), size, type_to_mpi<Data>(), to, tag, comm_, &request);
return {request};
}
template <class T,
REQUIRES( is_mpi_type<T>::value )>
Request Communicator::isend(std::vector<T> const& vec, int to, int tag) const
template <class T>
std::enable_if_t<is_mpi_type<T>::value, Request>
Communicator::isend(std::vector<T> const& vec, int to, int tag) const
{
MPI_Request request;
MPI_Isend(vec.data(), int(vec.size()), type_to_mpi<T>(), to, tag, comm_, &request);
MPI_Isend(to_void_ptr(vec.data()), int(vec.size()), type_to_mpi<T>(), to, tag, comm_, &request);
return {request};
}
......@@ -101,9 +101,9 @@ Request Communicator::isend(std::vector<T> const& vec, int to, int tag) const
// 1. create a binary representation of data, store it in a buffer
// 2. send size of buffer (with MPI_Ibsend)
// 3. send buffer (with MPI_Ibsend)
template <class Data,
REQUIRES( !is_mpi_type<Data>::value )>
Request Communicator::isend(Data const& data, int to, int tag) const
template <class Data>
std::enable_if_t<!is_mpi_type<Data>::value, Request>
Communicator::isend(Data const& data, int to, int tag) const
{
check_buffers();
buffers_.emplace_back(MPI_Request{}, serialization::store(data));
......@@ -111,16 +111,16 @@ Request Communicator::isend(Data const& data, int to, int tag) const
auto& request = buffers_.back().first;
auto const& buffer = buffers_.back().second;
MPI_Isend(buffer.data(), int(buffer.size()), MPI_BYTE, to, tag, comm_, &request);
MPI_Isend(to_void_ptr(buffer.data()), int(buffer.size()), MPI_BYTE, to, tag, comm_, &request);
return {request};
}
// -------------------------------------------------------------------------------------
// receive mpi datatype
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
MPI_Status Communicator::recv(Data& data, int from, int tag) const
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, MPI_Status>
Communicator::recv(Data& data, int from, int tag) const
{
MPI_Status status;
MPI_Recv(&data, 1, type_to_mpi<Data>(), from, tag, comm_, &status);
......@@ -129,9 +129,9 @@ MPI_Status Communicator::recv(Data& data, int from, int tag) const
// receive array of mpi datatypes
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
MPI_Status Communicator::recv(Data* data, std::size_t size, int from, int tag) const
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, MPI_Status>
Communicator::recv(Data* data, std::size_t size, int from, int tag) const
{
MPI_Status status;
MPI_Recv(data, size, type_to_mpi<Data>(), from, tag, comm_, &status);
......@@ -140,9 +140,9 @@ MPI_Status Communicator::recv(Data* data, std::size_t size, int from, int tag) c
// receive array of mpi datatypes
template <class T,
REQUIRES( is_mpi_type<T>::value )>
MPI_Status Communicator::recv(std::vector<T>& vec, int from, int tag) const
template <class T>
std::enable_if_t<is_mpi_type<T>::value, MPI_Status>
Communicator::recv(std::vector<T>& vec, int from, int tag) const
{
MPI_Status status;
MPI_Probe(from, tag, comm_, &status);
......@@ -157,9 +157,9 @@ MPI_Status Communicator::recv(std::vector<T>& vec, int from, int tag) const
// receive complex datatype
template <class Data,
REQUIRES( !is_mpi_type<Data>::value )>
MPI_Status Communicator::recv(Data& data, int from, int tag) const
template <class Data>
std::enable_if_t<!is_mpi_type<Data>::value, MPI_Status>
Communicator::recv(Data& data, int from, int tag) const
{
MPI_Status status;
int size = -1;
......@@ -178,9 +178,9 @@ MPI_Status Communicator::recv(Data& data, int from, int tag) const
// -------------------------------------------------------------------------------------
// receive mpi datatype
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request Communicator::irecv(Data& data, int from, int tag) const
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
Communicator::irecv(Data& data, int from, int tag) const
{
MPI_Request request;
MPI_Irecv(&data, 1, type_to_mpi<Data>(), from, tag, comm_, &request);
......@@ -189,9 +189,9 @@ Request Communicator::irecv(Data& data, int from, int tag) const
// receive array of mpi datatypes
template <class Data,
REQUIRES( is_mpi_type<Data>::value )>
Request Communicator::irecv(Data* data, std::size_t size, int from, int tag) const
template <class Data>
std::enable_if_t<is_mpi_type<Data>::value, Request>
Communicator::irecv(Data* data, std::size_t size, int from, int tag) const
{
MPI_Request request;
MPI_Irecv(data, size, type_to_mpi<Data>(), from, tag, comm_, &request);
......@@ -199,9 +199,9 @@ Request Communicator::irecv(Data* data, std::size_t size, int from, int tag) con
}
template <class T,
REQUIRES( is_mpi_type<T>::value )>
Request Communicator::irecv(std::vector<T>& vec, int from, int tag) const
template <class T>
std::enable_if_t<is_mpi_type<T>::value, Request>
Communicator::irecv(std::vector<T>& vec, int from, int tag) const
{
return {RecvDynamicSize(type_to_mpi<T>(),from,tag,comm_,
[from,tag,comm=comm_,&vec](int size)
......@@ -212,9 +212,9 @@ Request Communicator::irecv(std::vector<T>& vec, int from, int tag) const
}
template <class Data,
REQUIRES( !is_mpi_type<Data>::value )>
Request Communicator::irecv(Data& data, int from, int tag) const
template <class Data>
std::enable_if_t<!is_mpi_type<Data>::value, Request>
Communicator::irecv(Data& data, int from, int tag) const
{
return {RecvDynamicSize(MPI_BYTE,from,tag,comm_,
[from,tag,comm=comm_,&data](int size)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment