KaMPIng 0.1.0
(Near) zero-overhead C++ MPI bindings.
Loading...
Searching...
No Matches
Collectives

KaMPIng's collective wrappers. More...

Functions

template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allgather (Args... args) const
 Wrapper for MPI_Allgather.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allgather_inplace (Args... args) const
 Wrapper for the in-place version of MPI_Allgather.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allgatherv (Args... args) const
 Wrapper for MPI_Allgatherv.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allreduce (Args... args) const
 Wrapper for MPI_Allreduce; which is semantically a reduction followed by a broadcast.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allreduce_inplace (Args... args) const
 Wrapper for the in-place version of Communicator::allreduce().
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allreduce_single (Args... args) const
 Wrapper for MPI_Allreduce; which is semantically a reduction followed by a broadcast.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::alltoall (Args... args) const
 Wrapper for MPI_Alltoall.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::alltoall_inplace (Args... args) const
 Wrapper for the in-place version of Communicator::alltoall.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::alltoallv (Args... args) const
 Wrapper for MPI_Alltoallv.
 
template<typename... Args>
void kamping::Communicator< DefaultContainerType, Plugins >::barrier (Args... args) const
 Perform a MPI_Barrier on this communicator.
 
template<typename recv_value_type_tparam = kamping::internal::unused_tparam, typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::bcast (Args... args) const
 Wrapper for MPI_Bcast.
 
template<typename recv_value_type_tparam = kamping::internal::unused_tparam, typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::bcast_single (Args... args) const
 Wrapper for MPI_Bcast.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::exscan (Args... args) const
 Wrapper for MPI_Exscan.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::exscan_inplace (Args... args) const
 Wrapper for the in-place version of Communicator::exscan().
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::exscan_single (Args... args) const
 Wrapper for MPI_exscan for single elements.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::gather (Args... args) const
 Wrapper for MPI_Gather.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::gatherv (Args... args) const
 Wrapper for MPI_Gatherv.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::ibarrier (Args... args) const
 Perform a non-blocking barrier synchronization on this communicator using MPI_Ibarrier. The call is associated with a kamping::Request (either allocated by KaMPIng or provided by the user). Only when the request has completed, it is guaranteed that all ranks have reached the barrier.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::reduce (Args... args) const
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::reduce_single (Args... args) const
 Wrapper for MPI_Reduce.
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scan (Args... args) const
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scan_inplace (Args... args) const
 Wrapper for the in-place version of Communicator::scan().
 
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scan_single (Args... args) const
 Wrapper for MPI_Scan for single elements.
 
template<typename recv_value_type_tparam = kamping::internal::unused_tparam, typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scatter (Args... args) const
 
template<typename recv_value_type_tparam = kamping::internal::unused_tparam, typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scatter_single (Args... args) const
 
template<typename recv_value_type_tparam = kamping::internal::unused_tparam, typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scatterv (Args... args) const
 Wrapper for MPI_Scatterv.
 

Detailed Description

KaMPIng's collective wrappers.

Function Documentation

◆ allgather()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allgather ( Args... args) const

Wrapper for MPI_Allgather.

This wrapper for MPI_Allgather collects the same amount of data from each rank to all ranks. It is semantically equivalent to performing a gather() followed by a broadcast of the collected data.

The following parameters are required:

  • kamping::send_buf() containing the data that is sent to the root. This buffer has to be the same size at each rank. See allgather_v if the amounts differ.

The following parameters are optional:

  • kamping::send_count() specifying how many elements are sent. If omitted, the size of the send buffer is used. This parameter is mandatory if kamping::send_type() is given.
  • kamping::send_type() specifying the MPI datatype to use as send type. If omitted, the MPI datatype is derived automatically based on send_buf's underlying value_type.
  • kamping::recv_count() specifying how many elements are received. If omitted, the value of send_counts will be used. This parameter is mandatory if kamping::recv_type() is given.
  • kamping::recv_buf() specifying a buffer for the output. Afterwards, this buffer will contain all data from all send buffers. This requires a size of the buffer of at least recv_counts * communicator size.
  • kamping::recv_type() specifying the MPI datatype to use as recv type. If omitted, the MPI datatype is derived automatically based on recv_buf's underlying value_type.

In-place allgather is supported by passing send_recv_buf() as parameter. This changes the requirements for the other parameters, see Communicator::allgather_inplace.

Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ allgather_inplace()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allgather_inplace ( Args... args) const

Wrapper for the in-place version of MPI_Allgather.

This variant must be called collectively by all ranks in the communicator.

The following parameters are required:

  • kamping::send_recv_buf() containing the data that is sent to the root. Opposed to the non-inplace version, this is required to already have size size() * send_recv_count and the data contributed by each rank is already at the correct location in the buffer.

The following parameters are optional:

  • kamping::send_recv_count() specifying how many elements are sent and received. If omitted, the size send_recv_buf.size() / size() is used.
  • kamping::send_recv_type() specifying the MPI datatype to use as send and recv type. If omitted, the MPI datatype is derived automatically based on send_recv_buf's underlying value_type.
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ allgatherv()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allgatherv ( Args... args) const

Wrapper for MPI_Allgatherv.

This wrapper for MPI_Allgatherv collects possibly different amounts of data from each rank to all ranks. It is semantically equivalent to performing a gatherv() followed by a broadcast of the collected data.

The following parameters are required:

The following parameters are optional but result in communication overhead if omitted:

The following parameters are optional:

  • kamping::send_count() specifying how many elements are sent. If omitted, the size of the send buffer is used. This parameter is mandatory if kamping::send_type() is given.
  • kamping::send_type() specifying the MPI datatype to use as send type. If omitted, the MPI datatype is derived automatically based on send_buf's underlying value_type.
  • kamping::recv_buf() specifying a buffer for the output. Afterwards, this buffer will contain all data from all send buffers. This requires a size of the underlying storage of at least max(recv_counts[i] + recv_displs[i]) for i in [0, communicator size).
  • kamping::recv_displs() containing the offsets of the messages in recv_buf. The recv_counts[i] elements starting at recv_buf[recv_displs[i]] will be received from rank i. If omitted, this is calculated as the exclusive prefix-sum of recv_counts.
  • kamping::recv_type() specifying the MPI datatype to use as recv type. If omitted, the MPI datatype is derived automatically based on recv_buf's underlying value_type.
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ allreduce()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allreduce ( Args... args) const

Wrapper for MPI_Allreduce; which is semantically a reduction followed by a broadcast.

This wraps MPI_Allreduce. The operation combines the elements in the input buffer provided via kamping::send_buf() and returns the combined value on all ranks.

The following parameters are required:

  • kamping::send_buf() containing the data that is sent to each rank. This buffer has to have the same size at each rank.
  • kamping::op() wrapping the operation to apply to the input. If kamping::send_recv_type() is provided explicitly, the compatibility of the type and operation has to be ensured by the user.

The following parameters are optional:

In-place allreduce is supported by providing send_recv_buf() instead of send_buf() and recv_buf(). For details on the in-place version, see Communicator::allreduce_inplace().

Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ allreduce_inplace()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allreduce_inplace ( Args... args) const

Wrapper for the in-place version of Communicator::allreduce().

This variant must be called collectively by all ranks in the communicator. It is semantically equivalent to Communicator::allreduce(), but the input buffer is used as the output buffer. This means that the input buffer is overwritten with the result of the reduction.

The following parameters are required:

The following parameters are optional:

  • kamping::send_recv_count() specifying how many elements of the send buffer take part in the reduction. If omitted, the size of send_recv_buf is used. This parameter is mandatory if kamping::send_recv_type() is given.
  • kamping::send_recv_type() specifying the MPI datatype to use as send type. If omitted, the MPI datatype is derived automatically based on send_recv_buf's underlying value_type.
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ allreduce_single()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::allreduce_single ( Args... args) const

Wrapper for MPI_Allreduce; which is semantically a reduction followed by a broadcast.

Calling allreduce_single() is a shorthand for calling allreduce() with a kamping::send_buf() of size 1. It always issues only a single MPI_Allreduce call, as no receive counts have to be exchanged.

The following parameters are required:

  • kamping::send_buf() containing the data that is sent to each rank. This buffer has to wrap a single element on each rank.
  • kamping::op() wrapping the operation to apply to the input.
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
The single output value.

◆ alltoall()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::alltoall ( Args... args) const

Wrapper for MPI_Alltoall.

This wrapper for MPI_Alltoall sends the same amount of data from each rank to each rank. The following buffers are required:

  • kamping::send_buf() containing the data that is sent to each rank. This buffer has to be the same size at each rank and divisible by the size of the communicator unless a send_count or a send_type is explicitly given as parameter. Each rank receives the same number of elements from this buffer.

The following parameters are optional:

  • kamping::send_count() specifying how many elements are sent. If omitted, the size of send buffer divided by communicator size is used. This parameter is mandatory if kamping::send_type() is given.
  • kamping::recv_count() specifying how many elements are received. If omitted, the value of send_counts will be used. This parameter is mandatory if kamping::recv_type() is given.
  • kamping::recv_buf() specifying a buffer for the output. A buffer of at least recv_count * communicator size is required.
  • kamping::send_type() specifying the MPI datatype to use as send type. If omitted, the MPI datatype is derived automatically based on send_buf's underlying value_type.
  • kamping::recv_type() specifying the MPI datatype to use as recv type. If omitted, the MPI datatype is derived automatically based on recv_buf's underlying value_type.

Inplace alltoall is supported by passing send_recv_buf as parameter. This changes the requirements for the other parameters, see Communicator::alltoall_inplace.

Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional buffers described above.
Returns
Result type wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ alltoall_inplace()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::alltoall_inplace ( Args... args) const

Wrapper for the in-place version of Communicator::alltoall.

This variant must be called collectively by all ranks in the communicator. It sends the same amount of data from each rank to each rank, using the same buffer for sending and receiving data.

The following parameteres are required:

  • kamping::send_recv_buf() containing the data that is sent to each rank and received from each rank. The size of this buffer has to be the same at each rank and divisible by the size of the communicator unless a send_recv_count or a send_recv_type is explicitly given as parameter. Each rank receives the same number of elements from this buffer.

The following parameters are optional:

  • kamping::send_recv_count() specifying how many elements are sent and received. If omitted, the size of send_recv_buf divided by communicator size is used. This parameter is mandatory if kamping::send_recv_type() is given.
  • kamping::send_recv_type() specifying the MPI datatype to use as send and recv type. If omitted, the MPI datatype is derived automatically based on send_recv_buf's underlying value_type.
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional buffers described above.
Returns
Result type wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ alltoallv()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::alltoallv ( Args... args) const

Wrapper for MPI_Alltoallv.

This wrapper for MPI_Alltoallv sends the different amounts of data from each rank to each rank. The following buffers are required:

  • kamping::send_buf() containing the data that is sent to each rank. The size of this buffer has to be at least the sum of the send_counts argument.
  • kamping::send_counts() containing the number of elements to send to each rank.

The following parameters are optional but result in communication overhead if omitted:

The following buffers are optional:

  • kamping::recv_buf() specifying a buffer for the output. Afterwards, this buffer will contain the data received as specified for send_buf. A buffer size of at least max(recv_counts[i] + recv_displs[i]) for i in [0, communicator size) elements is required.
  • kamping::send_displs() containing the offsets of the messages in send_buf. The send_counts[i] elements starting at send_buf[send_displs[i]] will be sent to rank i. If omitted, this is calculated as the exclusive prefix-sum of send_counts.
  • kamping::recv_displs() containing the offsets of the messages in recv_buf. The recv_counts[i] elements starting at recv_buf[recv_displs[i]] will be received from rank i. If omitted, this is calculated as the exclusive prefix-sum of recv_counts.
  • kamping::send_type() specifying the MPI datatype to use as send type. If omitted, the MPI datatype is derived automatically based on send_buf's underlying value_type.
  • kamping::recv_type() specifying the MPI datatype to use as recv type. If omitted, the MPI datatype is derived automatically based on recv_buf's underlying value_type.
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional buffers described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ barrier()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
void kamping::Communicator< DefaultContainerType, Plugins >::barrier ( Args... args) const

Perform a MPI_Barrier on this communicator.

Barrier takes no parameters. Any parameters passed will cause a compilation error.

The parameter pack prohibits the compiler from compiling this function when it's not used.

◆ bcast()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename recv_value_type_tparam , typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::bcast ( Args... args) const

Wrapper for MPI_Bcast.

This wrapper for MPI_Bcast sends data from the root to all other ranks.

The following buffer is required on the root rank:

  • kamping::send_recv_buf() containing the data that is sent to the other ranks. Non-root ranks must allocate and provide this buffer or provide the receive type as a template parameter to bcast() as it's used for deducing the value type. The buffer will be resized on non-root ranks according to the buffer's kamping::BufferResizePolicy.

The following parameter is optional but causes additional communication if not present.

The following parameter are optional:

  • kamping::send_recv_type() specifying the MPI datatype to use as send type on the root PE and recv type on all non-root PEs. If omitted, the MPI datatype is derived automatically based on send_recv_buf's underlying value_type.
  • kamping::root() specifying an alternative root. If not present, the default root of the Communicator is used, see root().
Template Parameters
recv_value_type_tparamThe type that is received. Only required when no kamping::send_recv_buf() is given.
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ bcast_single()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename recv_value_type_tparam , typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::bcast_single ( Args... args) const

Wrapper for MPI_Bcast.

This wrapper for MPI_Bcast sends a single value from the root to all other ranks. Calling bcast_single() is a shorthand for calling bcast(..., recv_counts(1)). It always issues only a single MPI_Bcast call, as no receive counts have to be exchanged.

The following buffer is required on the root rank:

  • kamping::send_recv_buf() containing the single value that is sent to the other ranks. Non-root ranks must either allocate and provide this buffer or provide the receive type as a template parameter to bcast_single() as it's used for deducing the value type.

The following parameter is optional:

Template Parameters
recv_value_type_tparamThe type that is received. Only required when no kamping::send_recv_buf() is given.
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional buffers described above.
Returns
The single broadcasted value.

If you expand this function to not being only a simple wrapper around bcast, you have to write more unit tests!

◆ exscan()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::exscan ( Args... args) const

Wrapper for MPI_Exscan.

exscan() wraps MPI_Exscan, which is used to perform an exclusive prefix reduction on data distributed across the calling processes. exscan() returns in the recv_buf of the process with rank $i > 0$, the reduction (calculated according to the function op) of the values in the send_bufs of processes with ranks $0, \ldots, i - 1$ (i.e. excluding i as opposed to scan()). The value of the recv_buf on rank 0 is set to the value of values_on_rank_0 if provided. If values_on_rank_0 is not provided and op is a built-in operation on the data-type used, the value on rank 0 is set to the identity of that operation. If the operation is not built-in on the data-type used and no values_on_rank_0() is provided, the contents of recv_buf on rank 0 are undefined.

The following parameters are required:

  • kamping::send_buf() containing the data for which to perform the exclusive scan. This buffer has to be the same size at each rank.
  • kamping::op() the operation to apply to the input.

The following parameters are optional:

  • kamping::recv_buf() containing a buffer for the output. A buffer size of at least send_recv_count elements is required.
  • kamping::send_recv_count() containing the number of elements to be processed in this operation. This parameter has to be the same at each rank. If omitted, the size of the send buffer will be used as send_recv_count.
  • kamping::send_recv_type() specifying the MPI datatype to use as data type in this operation. If omitted, the MPI datatype is derived automatically based on send_buf's underlying value_type. If the type is provided explicitly, the compatibility of the type and operation has to be ensured by the user.
  • kamping::values_on_rank_0() containing the value(s) that is/are returned in the recv_buf of rank 0. values_on_rank_0 must be a container of the same size as recv_buf or a single value (which will be reused for all elements of the recv_buf).

In-place exscan is supported by providing send_recv_buf() instead of send_buf() and recv_buf(). For details on the in-place version, see Communicator::exscan_inplace().

Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ exscan_inplace()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::exscan_inplace ( Args... args) const

Wrapper for the in-place version of Communicator::exscan().

This variant must be called collectively by all ranks in the communicator. It is semantically equivalent to Communicator::exscan(), but the input buffer is used as the output buffer. This means that the input buffer is overwritten with the result of the exscan.

The following parameters are required:

  • kamping::send_recv_buf() containing the data for which to perform the exclusive scan and will store the result of the scan.
  • kamping::op() wrapping the operation to apply to the input. If kamping::send_recv_type() is provided explicitly, the compatibility of the type and operation has to be ensured by the user.

The following parameters are optional:

  • kamping::send_recv_count() containing the number of elements to be processed in this operation. This parameter has to be the same at each rank. If omitted, the size of the send buffer will be used as send_recv_count.
  • kamping::send_recv_type() specifying the MPI datatype to use as data type in this operation. If omitted, the MPI datatype is derived automatically based on send_recv_buf's underlying value_type.
    • kamping::values_on_rank_0() containing the value(s) that is/are written to the output on rank 0. values_on_rank_0 must be a container of the same size as send_recv_buf or a single value (which will be reused for all elements of the recv_buf).
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ exscan_single()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::exscan_single ( Args... args) const

Wrapper for MPI_exscan for single elements.

This is functionally equivalent to exscan() but provided for uniformity with other operations (e.g. bcast_single()). exscan_single() wraps MPI_Exscan, which is used to perform an exclusive prefix reduction on data distributed across the calling processes. exscan_single() returns on the process with rank $i > 0$, the reduction (calculated according to the function op) of the values in the send_bufs of processes with ranks $0, \ldots, i - 1$ (i.e. excluding i as opposed to scan()). The result on rank 0 is set to the value of values_on_rank_0 if provided. If values_on_rank_0 is not provided and op is a built-in operation on the data-type used, the value on rank 0 is set to the identity of that operation. If the operation is not built-in on the data-type used and no values_on_rank_0() is provided, the result on rank 0 is undefined.

The following parameters are required:

  • kamping::send_buf() containing the data for which to perform the exclusive scan. This buffer has to be a single element on each rank.
  • kamping::op() the operation to apply to the input.

The following parameters are optional:

Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional buffers described above.
Returns
The single element result of the exclusive scan.

If you expand this function to not being only a simple wrapper around exscan, you have to write more unit tests!

◆ gather()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::gather ( Args... args) const

Wrapper for MPI_Gather.

This wrapper for MPI_Gather collects the same amount of data from each rank to a root.

The following arguments are required:

The following buffers are optional:

  • kamping::send_count() [on all PEs] specifying the number of elements to send to the root PE. If not given, the size of the kamping::send_buf() will be used. This parameter is mandatory if kamping::send_type() is given.
  • kamping::send_type() specifying the MPI datatype to use as send type. If omitted, the MPI datatype is derived automatically based on send_buf's underlying value_type. This parameter is ignored on non-root ranks.
  • kamping::recv_buf() containing a buffer for the output. On the root rank, the buffer will contain all data from all send buffers. At all other ranks, the buffer will not be modified and the parameter is ignored.
  • kamping::recv_count() [on root PE] specifying the number of elements to receive from each PE. On non-root ranks, this parameter is ignored. If not specified, defaults to the value of kamping::send_count() on the root. PE. In total, comm.size() * recv_counts elements will be received into the receiver buffer. This parameter is mandatory if kamping::recv_type() is given.
  • kamping::recv_type() specifying the MPI datatype to use as recv type. If omitted, the MPI datatype is derived automatically based on recv_buf's underlying value_type.
  • kamping::root() specifying an alternative root. If not present, the default root of the Communicator is used, see root().
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ gatherv()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::gatherv ( Args... args) const

Wrapper for MPI_Gatherv.

This wrapper for MPI_Gatherv collects possibly different amounts of data from each rank to a root.

The following arguments are required:

The following parameter is optional but results in communication overhead if omitted:

  • kamping::recv_counts() containing the number of elements to receive from each rank. Only the root rank uses the content of this buffer, all other ranks ignore it. However, if provided on any rank it must be provided on all ranks (possibly empty on non-root ranks). If each rank provides this parameter either as an output parameter or by passing recv_counts(kamping::ignore), then the recv_counts on root will be computed by a gather of all local send counts. This parameter is mandatory (as an in-parameter) if kamping::recv_type() is given.

The following buffers are optional:

  • kamping::send_count() [on all PEs] specifying the number of elements to send to the root rank. If not given, the size of the kamping::send_buf() will be used. This parameter is mandatory if kamping::send_type() is given.
  • kamping::recv_buf() containing a buffer for the output. Afterwards, at the root, this buffer will contain all data from all send buffers. At all other ranks, the buffer will have size 0.
  • kamping::recv_displs() containing the offsets of the messages in recv_buf. The recv_counts[i] elements starting at recv_buf[recv_displs[i]] will be received from rank i. If omitted, this is calculated as the exclusive prefix-sum of recv_counts.
  • kamping::root() specifying an alternative root. If not present, the default root of the Communicator is used, see root().
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ ibarrier()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::ibarrier ( Args... args) const

Perform a non-blocking barrier synchronization on this communicator using MPI_Ibarrier. The call is associated with a kamping::Request (either allocated by KaMPIng or provided by the user). Only when the request has completed, it is guaranteed that all ranks have reached the barrier.

The following parameters are optional:

  • kamping::request() The request object to associate this operation with. Defaults to a library allocated request object, which can be accessed via the returned result.
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional buffers described above.

◆ reduce()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::reduce ( Args... args) const
This wraps \c MPI_Reduce. The operation combines the elements in the input buffer provided via \c
kamping::send_buf() and returns the combined value on the root rank.

The following parameters are required:
- \ref kamping::send_buf() containing the data that is sent to each rank. This buffer has to be the same size at
each rank.

- \ref kamping::recv_buf() specifying a buffer for the output. This parameter is only required on the root rank.

- \ref kamping::op() wrapping the operation to apply to the input. If \ref kamping::send_recv_type() is provided,
the compatibility of the type and operation has to be ensured by the user.

The following parameters are optional:
- \ref kamping::send_recv_count() specifying how many elements of the buffer take part in the reduction.
If omitted, the size of the send buffer is used as a default. This parameter is mandatory if \ref
kamping::send_type() is given.

- \ref kamping::send_recv_type() specifying the \c MPI datatype to use as send_recv type. If omitted, the \c MPI
datatype is derived automatically based on send_buf's underlying \c value_type.

- \ref kamping::root() the root rank. If not set, the default root process of the communicator will be used.

@tparam Args Automatically deduced template parameters.
@param args All required and any number of the optional parameters described above.
@return Result object wrapping the output parameters to be returned by value.

@see \ref docs/parameter_handling.md for general information about parameter handling in KaMPIng.
<hr>
 
\ifile "/github/workspace/docs/resize_policy.dox" \iline 1 
 #### Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ reduce_single()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::reduce_single ( Args... args) const

Wrapper for MPI_Reduce.

Calling reduce_single() is a shorthand for calling reduce() with a kamping::send_buf() of size 1. It always issues only a single MPI_Reduce call, as no receive counts have to be exchanged.

The following parameters are required:

  • kamping::send_buf() containing the data that is sent to each rank. This buffer has to wrap a single element on each rank.
  • kamping::op() wrapping the operation to apply to the input.

The following parameters are optional:

  • kamping::root() the root rank. If not set, the default root process of the communicator will be used.
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional buffers described above.
Returns
Returns an std::optional object encapsulating the reduced value on the root rank and an empty std::optional object on all non-root ranks.

◆ scan()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scan ( Args... args) const
This wraps \c MPI_Scan, which is used to perform an inclusive prefix reduction on data distributed across the
calling processes. / \c scan() returns in \c recv_buf of the process with rank \c i, the reduction (calculated
according to the function op) of the values in the sendbufs of processes with ranks \f$0, ..., i\f$ (inclusive).

The following parameters are required:
- \ref kamping::send_buf() containing the data for which to perform the scan. This buffer has to be the
 same size at each rank.

- \ref kamping::op() wrapping the operation to apply to the input. If \ref kamping::send_recv_type() is provided
explicitly, the compatibility of the type and operation has to be ensured by the user.

The following parameters are optional:
- \ref kamping::recv_buf() containing a buffer for the output. A buffer size of at least `send_recv_count` elements
is required.

- \ref kamping::send_recv_count() containing the number of elements to be processed in this operation. This
parameter has to be the same at each rank. If omitted, the size of the send buffer will be used as send_recv_count.

- \ref kamping::send_recv_type() specifying the \c MPI datatype to use as data type in this operation. If omitted,
the \c MPI datatype is derived automatically based on send_buf's underlying \c value_type.

In-place scan is supported by providing `send_recv_buf()` instead of `send_buf()` and `recv_buf()`. For details
on the in-place version, see \ref Communicator::scan_inplace().

@tparam Args Automatically deduced template parameters.
@param args All required and any number of the optional parameters described above.
@return Result object wrapping the output parameters to be returned by value.

@see \ref docs/parameter_handling.md for general information about parameter handling in KaMPIng.
<hr>
 
\ifile "/github/workspace/docs/resize_policy.dox" \iline 1 
 #### Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ scan_inplace()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scan_inplace ( Args... args) const

Wrapper for the in-place version of Communicator::scan().

This variant must be called collectively by all ranks in the communicator. It is semantically equivalent to Communicator::scan(), but the input buffer is used as the output buffer. This means that the input buffer is overwritten with the result of the scan.

The following parameters are required:

The following parameters are optional:

  • kamping::send_recv_count() containing the number of elements to be processed in this operation. This parameter has to be the same at each rank. If omitted, the size of the send buffer will be used as send_recv_count.
  • kamping::send_recv_type() specifying the MPI datatype to use as data type in this operation. If omitted, the MPI datatype is derived automatically based on send_recv_buf's underlying value_type.
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ scan_single()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scan_single ( Args... args) const

Wrapper for MPI_Scan for single elements.

This is functionally equivalent to scan() but provided for uniformity with other operations (e.g. bcast_single()). scan_single() wraps MPI_Scan, which is used to perform an inclusive prefix reduction on data distributed across the calling processes. scan() returns on the process with rank $i$, the reduction (calculated according to the function op) of the values in the sendbufs of processes with ranks $0, ...,
i$ (inclusive).

The following parameters are required:

  • kamping::send_buf() containing the data for which to perform the scan. This buffer has to be a single element on each rank.
  • kamping::op() wrapping the operation to apply to the input.
Template Parameters
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional buffers described above.
Returns
The single element result of the scan.

If you expand this function to not being only a simple wrapper around scan, you have to write more unit tests!

◆ scatter()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename recv_value_type_tparam , typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scatter ( Args... args) const
This wrapper for \c MPI_Scatter distributes data on the root PE evenly across all PEs in the current
communicator.

The following parameters are mandatory on the root rank:
- kamping::send_buf() containing the data to be evenly distributed across all PEs. The size of
this buffer must be divisible by the number of PEs in the current communicator. Non-root PEs can omit a send
buffer by passing `kamping::ignore<T>` as a parameter, or `T` as a template parameter to \ref kamping::send_buf().

The following parameters are optional but incur communication overhead if omitted:
- kamping::recv_count() specifying the number of elements sent to each PE. If this parameter is omitted,
the number of elements sent to each PE is computed based on the size of the \ref kamping::send_buf() on the root
PE and broadcasted to other PEs.

The following parameters are optional:
- kamping::send_count() specifying how many elements are sent to each process.
If omitted, the size of send buffer divided by communicator size is used. This parameter is mandatory if \ref
kamping::send_type() is given.

- \ref kamping::send_type() specifying the \c MPI datatype to use as send type. If omitted, the \c MPI datatype is
derived automatically based on send_buf's underlying \c value_type. This parameter is ignored on non-root ranks.

- kamping::recv_buf() containing the received data.

- \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.

- kamping::root() specifying the rank of the root PE. If omitted, the default root PE of the communicator
is used instead.

@tparam recv_value_type_tparam The type that is received. Only required when no \ref kamping::send_buf() and no \ref
kamping::recv_buf() is given.
@tparam Args Automatically deduced template parameters.
@param args All required and any number of the optional parameters described above.
@return Result object wrapping the output parameters to be returned by value.

@see \ref docs/parameter_handling.md for general information about parameter handling in KaMPIng.
<hr>
 
\ifile "/github/workspace/docs/resize_policy.dox" \iline 1 
 #### Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.


◆ scatter_single()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename recv_value_type_tparam , typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scatter_single ( Args... args) const

Calling scatter_single() is a shorthand for calling scatter() with a kamping::send_buf() with the same size as the communicator.

The following parameters are required on the root rank:

  • kamping::send_buf() containing the data that is sent to each rank. This buffer has to have the same size as the communicator on the root rank.

The following parameters are optional:

  • kamping::root() specifying the rank of the root PE. If omitted, the default root PE of the communicator is used instead.
Template Parameters
recv_value_type_tparamThe type that is received.
ArgsAutomatically deducted template parameters.
Parameters
argsAll required and any number of the optional buffers described above.
Returns
The single output value.

◆ scatterv()

template<template< typename... > typename DefaultContainerType, template< typename, template< typename... > typename > typename... Plugins>
template<typename recv_value_type_tparam , typename... Args>
auto kamping::Communicator< DefaultContainerType, Plugins >::scatterv ( Args... args) const

Wrapper for MPI_Scatterv.

This wrapper for MPI_Scatterv distributes data on the root PE across all PEs in the current communicator.

The following parameters are mandatory on the root rank:

The following parameter can be omitted at the cost of communication overhead (1x MPI_Scatter)

The following parameter can be omitted at the cost of computational overhead:

  • kamping::send_displs() [on root PE] specifying the data displacements in the send buffer. If omitted, an exclusive prefix sum of the send_counts is used.

The following parameters are optional:

  • kamping::send_type() specifying the MPI datatype to use as send type. If omitted, the MPI datatype is derived automatically based on send_buf's underlying value_type. This parameter is ignored on non-root ranks.
  • kamping::recv_buf() [on all PEs] containing the received data. 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.
  • kamping::recv_type() specifying the MPI datatype to use as recv type. If omitted, the MPI datatype is derived automatically based on recv_buf's underlying value_type.
  • kamping::root() [on all PEs] specifying the rank of the root PE. If omitted, the default root PE of the communicator is used instead.
Template Parameters
recv_value_type_tparamThe type that is received. Only required when no kamping::send_buf() and no kamping::recv_buf() is given. ///
ArgsAutomatically deduced template parameters.
Parameters
argsAll required and any number of the optional parameters described above.
Returns
Result object wrapping the output parameters to be returned by value.
See also
docs/parameter_handling.md for general information about parameter handling in KaMPIng.

Note on Resize Policy

The underlying container/storage of an out parameter encapsulating a data buffer (e.g. recv_buf/recv_counts, etc.) will be resized according to the parameter's resize policy:

If a send_/recv_/send_recv_type parameter is provided, kamping::BufferResizePolicy::no_resize for receive buffers is required, as KaMPIng can no longer ensure a 1:1 mapping between MPI_Datatype and the underlying storage's C++ type.