diff --git a/include/diy/mpi/communicator.hpp b/include/diy/mpi/communicator.hpp index 317e7d09..a4facaa1 100644 --- a/include/diy/mpi/communicator.hpp +++ b/include/diy/mpi/communicator.hpp @@ -62,6 +62,9 @@ namespace mpi template void send(int dest, int tag, const T& x) const { detail::send(comm_, dest, tag, x); } + template + 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 diff --git a/include/diy/mpi/point-to-point.cpp b/include/diy/mpi/point-to-point.cpp index 7696ff4b..bba84ceb 100644 --- a/include/diy/mpi/point-to-point.cpp +++ b/include/diy/mpi/point-to-point.cpp @@ -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 diff --git a/include/diy/mpi/point-to-point.hpp b/include/diy/mpi/point-to-point.hpp index b0db2d44..150d3c8f 100644 --- a/include/diy/mpi/point-to-point.hpp +++ b/include/diy/mpi/point-to-point.hpp @@ -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); @@ -37,6 +38,13 @@ namespace detail send(comm, dest, tag, address(x), count(x), datatype_of(x)); } + template + inline void ssend(DIY_MPI_Comm comm, int dest, int tag, const T& x) + { + static_assert(std::is_same::type, true_type>::value, "is_mpi_datatype::type must be true_type"); + ssend(comm, dest, tag, address(x), count(x), datatype_of(x)); + } + template status recv(DIY_MPI_Comm comm, int source, int tag, T& x) {