Skip to content

Commit

Permalink
Add mpi::communicator::ssend()
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzv committed Dec 20, 2023
1 parent 7cda7ee commit 72643ee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/diy/mpi/communicator.hpp
Expand Up @@ -62,6 +62,9 @@ namespace mpi
template<class T>
void send(int dest, int tag, const T& x) const { detail::send(comm_, dest, tag, x); }

template<class T>
void ssend(int dest, int tag, const T& x) const { detail::ssend(comm_, dest, tag, x); }

//! Receive `x` from `dest` using `tag` (blocking).
//! If `T` is an `std::vector<...>`, `recv` will resize it to fit exactly the sent number of values.
template<class T>
Expand Down
10 changes: 10 additions & 0 deletions include/diy/mpi/point-to-point.cpp
Expand Up @@ -31,6 +31,16 @@ void send(DIY_MPI_Comm comm, int dest, int tag, const void* data, int count, con
#endif
}

void ssend(DIY_MPI_Comm comm, int dest, int tag, const void* data, int count, const datatype& type)
{
#if DIY_HAS_MPI
MPI_Ssend(data, count, mpi_cast(type.handle), dest, tag, mpi_cast(comm));
#else
(void) comm; (void) dest; (void) tag; (void) data; (void) count; (void) type;
DIY_UNSUPPORTED_MPI_CALL(MPI_Ssend);
#endif
}

status probe(DIY_MPI_Comm comm, int source, int tag)
{
#if DIY_HAS_MPI
Expand Down
8 changes: 8 additions & 0 deletions include/diy/mpi/point-to-point.hpp
Expand Up @@ -24,6 +24,7 @@ DIY_MPI_EXPORT extern const int any_tag;
namespace detail
{
DIY_MPI_EXPORT_FUNCTION void send(DIY_MPI_Comm comm, int dest, int tag, const void* data, int count, const datatype& type);
DIY_MPI_EXPORT_FUNCTION void ssend(DIY_MPI_Comm comm, int dest, int tag, const void* data, int count, const datatype& type);
DIY_MPI_EXPORT_FUNCTION request isend(DIY_MPI_Comm comm, int dest, int tag, const void* data, int count, const datatype& type);
DIY_MPI_EXPORT_FUNCTION request issend(DIY_MPI_Comm comm, int dest, int tag, const void* data, int count, const datatype& type);
DIY_MPI_EXPORT_FUNCTION status probe(DIY_MPI_Comm comm, int source, int tag);
Expand All @@ -37,6 +38,13 @@ namespace detail
send(comm, dest, tag, address(x), count(x), datatype_of(x));
}

template <class T>
inline void ssend(DIY_MPI_Comm comm, int dest, int tag, const T& x)
{
static_assert(std::is_same<typename is_mpi_datatype<T>::type, true_type>::value, "is_mpi_datatype<T>::type must be true_type");
ssend(comm, dest, tag, address(x), count(x), datatype_of(x));
}

template <class T>
status recv(DIY_MPI_Comm comm, int source, int tag, T& x)
{
Expand Down

0 comments on commit 72643ee

Please sign in to comment.