11#ifndef __IMPL_MPI_OP_HPP__
22#define __IMPL_MPI_OP_HPP__
33
4- #include < common/traits.hpp>
5- #include < mpi_w/message_t.hpp>
6- #include < mpi_w/mpi_types.hpp>
7-
84#include < common/execinfo.hpp>
5+ #include < common/traits.hpp>
96#include < cstddef>
107#include < limits>
118#include < math.h>
129#include < mpi.h>
10+ #include < mpi_w/impl_async.hpp>
11+ #include < mpi_w/message_t.hpp>
12+ #include < mpi_w/mpi_types.hpp>
1313#include < optional>
1414#include < span>
1515#include < stdexcept>
@@ -23,27 +23,27 @@ namespace WrapMPI
2323
2424 // SENDING
2525
26- /* *
27- * @brief Sends raw data to a destination in an unsafe manner.
28- *
29- * This function sends raw data of type `DataType` to the specified
30- * destination. It assumes the provided buffer and its size are valid
31- *
32- * @tparam DataType A type satisfying the `POD` concept.
33- * @param buf Pointer to the buffer containing data to send.
34- * @param buf_size The size of the buffer in bytes.
35- * @param dest The destination identifier for the data.
36- * @param tag Optional tag to identify the message (default is 0).
37- * @return An integer indicating success or failure of the operation.
38- *
39- * @note Use this function with caution as it performs no validation on the
40- * input.
41- */
42- template <POD_t DataType>
43- [[nodiscard]] static int _send_unsafe (DataType* buf,
44- size_t buf_size,
45- size_t dest,
46- size_t tag = 0 ) noexcept ;
26+ // / **
27+ // * @brief Sends raw data to a destination in an unsafe manner.
28+ // *
29+ // * This function sends raw data of type `DataType` to the specified
30+ // * destination. It assumes the provided buffer and its size are valid
31+ // *
32+ // * @tparam DataType A type satisfying the `POD` concept.
33+ // * @param buf Pointer to the buffer containing data to send.
34+ // * @param buf_size The size of the buffer in bytes.
35+ // * @param dest The destination identifier for the data.
36+ // * @param tag Optional tag to identify the message (default is 0).
37+ // * @return An integer indicating success or failure of the operation.
38+ // *
39+ // * @note Use this function with caution as it performs no validation on the
40+ // * input.
41+ // */
42+ // template <POD_t DataType>
43+ // [[nodiscard]] static int _send_unsafe(DataType* buf,
44+ // size_t buf_size,
45+ // size_t dest,
46+ // size_t tag = 0) noexcept;
4747
4848 /* *
4949 * @brief Sends a single instance of data to a destination.
@@ -335,13 +335,6 @@ namespace WrapMPI
335335 // **
336336 // IMPL
337337 // **
338- template <POD_t DataType>
339- static int
340- _send_unsafe (DataType* buf, size_t buf_size, size_t dest, size_t tag) noexcept
341- {
342- return MPI_Send (
343- buf, buf_size, get_type<DataType>(), dest, tag, MPI_COMM_WORLD);
344- }
345338
346339 template <POD_t DataType>
347340 DataType try_recv (size_t src, MPI_Status* status, size_t tag)
@@ -621,7 +614,10 @@ namespace WrapMPI
621614
622615 template <POD_t DataType> int send (DataType data, size_t dest, size_t tag)
623616 {
624- return _send_unsafe<DataType>(&data, 1 , dest, tag);
617+ MPI_Request req;
618+ auto res = WrapMPI::Async::_send_unsafe<DataType>(req, &data, 1 , dest, tag);
619+ WrapMPI::Async::wait (req);
620+ return res;
625621 }
626622
627623 template <POD_t DataType>
@@ -639,7 +635,12 @@ namespace WrapMPI
639635
640636 if (send_status == MPI_SUCCESS)
641637 {
642- send_status = _send_unsafe (data.data (), data.size (), dest, tag);
638+ MPI_Request req{};
639+ auto res = WrapMPI::Async::_send_unsafe<DataType>(
640+ req, data.data (), data.size (), dest, tag);
641+ WrapMPI::Async::wait (req);
642+
643+ send_status = res;
643644 }
644645
645646 return send_status;
0 commit comments