diff --git a/include/kamping/communicator.hpp b/include/kamping/communicator.hpp index 624fc8f0f..c649b6b01 100644 --- a/include/kamping/communicator.hpp +++ b/include/kamping/communicator.hpp @@ -464,6 +464,9 @@ class Communicator : public Plugins auto recv_single(Args... args) const; + template + auto irecv(Args... args) const; + template auto alltoall(Args... args) const; diff --git a/include/kamping/p2p/irecv.hpp b/include/kamping/p2p/irecv.hpp new file mode 100644 index 000000000..d8e9ed92c --- /dev/null +++ b/include/kamping/p2p/irecv.hpp @@ -0,0 +1,180 @@ +// This file is part of KaMPIng. +// +// Copyright 2024 The KaMPIng Authors +// +// KaMPIng is free software : you can redistribute it and/or modify it under the +// terms of the GNU Lesser General Public License as published by the Free +// Software Foundation, either version 3 of the License, or (at your option) any +// later version. KaMPIng is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +// for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with KaMPIng. If not, see . + +#pragma once + +#include +#include + +#include +#include + +#include "kamping/communicator.hpp" +#include "kamping/data_buffer.hpp" +#include "kamping/error_handling.hpp" +#include "kamping/implementation_helpers.hpp" +#include "kamping/mpi_datatype.hpp" +#include "kamping/named_parameter_check.hpp" +#include "kamping/named_parameter_selection.hpp" +#include "kamping/named_parameter_types.hpp" +#include "kamping/named_parameters.hpp" +#include "kamping/p2p/helpers.hpp" +#include "kamping/p2p/probe.hpp" +#include "kamping/parameter_objects.hpp" +#include "kamping/request.hpp" +#include "kamping/result.hpp" +#include "kamping/status.hpp" + +/// @brief Wrapper for \c MPI_Recv. +/// +/// This wraps \c MPI_Irecv. This operation performs a standard non-blocking receive. +/// If the \ref kamping::recv_counts() parameter is not specified, this first performs a (blocking) probe, followed by a +/// (non-blocking) receive of the probed message with the probed message size. +/// The call is associated with a \ref kamping::Request (either allocated by KaMPIng or provided by the user). Before +/// accessing the result the user has to complete the request. +/// +/// The following parameters are optional: +/// - \ref kamping::recv_buf() the buffer to receive the message into. The buffer will be resized according to the +/// buffer's kamping::BufferResizePolicy. If this is kamping::BufferResizePolicy::no_resize, the buffer's underlying +/// storage must be large enough to hold all received elements. If \ref kamping::recv_type() is given the resize policy +/// has to be BufferResizePolicy::no_resize. If no \ref kamping::recv_buf() is provided, the \c value_type of the recv +/// buffer has to be passed as a template parameter to \c recv(). +/// +/// - \ref kamping::tag() recv message with this tag. Defaults to receiving for an arbitrary tag, i.e. \c +/// tag(tags::any). +/// +/// - \ref kamping::source() receive a message sent from this source rank. Defaults to probing for an arbitrary source, +/// i.e. \c source(rank::any). +/// +// - \ref kamping::recv_type() specifying the \c MPI datatype to use as recv type. If omitted, the \c MPI datatype is +/// derived automatically based on recv_buf's underlying \c value_type. +/// +/// - \ref kamping::request() The request object to associate this operation with. Defaults to a library allocated +/// request object, which can be access via the returned result. +/// +/// The following parameter is optional, but leads to an additional call to \c MPI_Probe if not present: +/// - \ref kamping::recv_count() the number of elements to receive. Will be probed before receiving if not given. +/// Keep in mind that this introduces an additional blocking operation call. +/// +/// +/// @tparam recv_value_type_tparam The type that is received. Only required when no \ref kamping::recv_buf() is given. +/// @tparam Args Automatically deducted template parameters. +/// @param args All required and any number of the optional buffers described +/// above. +template