Core¶
Point-to-point¶
Send¶
Warning
This is not a blocking operation despite being named like MPI_Send
.
-
template<KokkosView SendView, KokkosExecutionSpace ExecSpace = Kokkos::DefaultExecutionSpace, CommunicationSpace CommSpace = DefaultCommunicationSpace>
auto send(Handle<ExecSpace, CommSpace> &h, SendView &sv, int dest) -> Req<CommSpace>¶ Initiates a non-blocking send operation.
- Template Parameters:
SendView – The type of the Kokkos view to send.
ExecSpace – The execution space to use. Defaults to
Kokkos::DefaultExecutionSpace
.CommSpace – The communication backend to use. Defaults to
DefaultCommunicationSpace
.
- Parameters:
h – A handle to the execution space and transport mechanism.
sv – The Kokkos view to send.
dest – The destination rank.
- Returns:
A request object of type
Req<CommSpace>
representing the non-blocking send operation.
-
template<KokkosView SendView, KokkosExecutionSpace ExecSpace = Kokkos::DefaultExecutionSpace, CommunicationSpace CommSpace = DefaultCommunicationSpace>
auto send(SendView &sv, int dest) -> Req<CommSpace>¶ Initiates a non-blocking send operation using a default handle.
- Template Parameters:
SendView – The type of the Kokkos view to send.
ExecSpace – The execution space to use. Defaults to
Kokkos::DefaultExecutionSpace
.CommSpace – The communication backend to use. Defaults to
DefaultCommunicationSpace
.
- Parameters:
sv – The Kokkos view to send.
dest – The destination rank.
- Returns:
A request object of type
Req<CommSpace>
representing the non-blocking send operation.
Example usage:
#include "KokkosComm/KokkosComm.hpp"
// Define the execution space and transport
using ExecSpace = Kokkos::DefaultExecutionSpace;
using CommSpace = DefaultCommunicationSpace;
// Create a Kokkos view
Kokkos::View<double*> data("data", 100);
// Fill the view with some data
Kokkos::parallel_for("fill_data", Kokkos::RangePolicy<ExecSpace>(0, 100), KOKKOS_LAMBDA(int i) {
data(i) = static_cast<double>(i);
});
// Destination rank
int dest = 1;
// Create a handle
KokkosComm::Handle<> handle; // Same as Handle<Execspace, CommSpace>
// Initiate a non-blocking send with a handle
auto req1 = send(handle, data, dest);
// Initiate a non-blocking send with a default handle
auto req2 = send(data, dest);
// Wait for the requests to complete (assuming a wait function exists)
KokkosComm::wait(req1);
KokkosComm::wait(req2);
Receive¶
Warning
This is not a blocking operation despite being named like MPI_Recv
.
-
template<KokkosView RecvView, KokkosExecutionSpace ExecSpace = Kokkos::DefaultExecutionSpace, CommunicationSpace CommSpace = DefaultCommunicationSpace>
auto recv(Handle<ExecSpace, CommSpace> &h, RecvView &sv, int dest) -> Req<CommSpace>¶ Initiates a non-blocking receive operation.
- Template Parameters:
RecvView – The type of the Kokkos view for receiving data.
ExecSpace – The execution space where the operation will be performed. Defaults to
Kokkos::DefaultExecutionSpace
.CommSpace – The communication backend to use. Defaults to
DefaultCommunicationSpace
.
- Parameters:
h – A handle to the execution space and transport mechanism.
rv – The Kokkos view where the received data will be stored.
src – The source rank from which to receive data.
- Returns:
A request object of type
Req<CommSpace>
representing the non-blocking receive operation.
This function initiates a non-blocking receive operation using the specified execution space and transport mechanism. The data will be received into the provided view from the specified source rank and message tag. The function returns a request object that can be used to check the status of the receive operation or to wait for its completion.
-
template<KokkosView RecvView, KokkosExecutionSpace ExecSpace = Kokkos::DefaultExecutionSpace, CommunicationSpace CommSpace = DefaultCommunicationSpace>
auto recv(RecvView &sv, int dest) -> Req<CommSpace>¶ Initiates a non-blocking receive operation using a default handle.
- Template Parameters:
RecvView – The type of the Kokkos view for receiving data.
ExecSpace – The execution space where the operation will be performed. Defaults to Kokkos::DefaultExecutionSpace.
CommSpace – The communication backend to use. Defaults to
DefaultCommunicationSpace
.
- Parameters:
rv – The Kokkos view where the received data will be stored.
src – The source rank from which to receive data.
- Returns:
A request object of type
Req<CommSpace>
representing the non-blocking receive operation.
Example usage:
#include "KokkosComm/KokkosComm.hpp"
// Define the execution space and transport
using ExecSpace = Kokkos::DefaultExecutionSpace;
using CommSpace = DefaultCommunicationSpace;
// Source rank
int src = 1;
// Create a handle
KokkosComm::Handle<> handle; // Same as Handle<Execspace, CommSpace>
// Allocate a view to receive the data
Kokkos::View<double*> data("recv_view", 100);
// Initiate a non-blocking receive with a handle
auto req1 = recv(handle, data, src);
// Initiate a non-blocking receive with a default handle
auto req2 = recv(data, src);
// Wait for the requests to complete (assuming a wait function exists)
KokkosComm::wait(req1);
KokkosComm::wait(req2);
Collectives¶
-
template<KokkosExecutionSpace ExecSpace = Kokkos::DefaultExecutionSpace, CommunicationSpace CommSpace = DefaultCommunicationSpace>
auto barrier(Handle<ExecSpace, CommSpace> &&h) -> void¶ A function to create a barrier using the given execution space and transport handle.
- Template Parameters:
ExecSpace – The execution space where the operation will be performed. Defaults to
Kokkos::DefaultExecutionSpace
.CommSpace – The communication backend to use. Defaults to
DefaultCommunicationSpace
.
- Parameters:
h – A handle of type
Handle<ExecSpace, CommSpace>
to be forwarded to the barrier implementation.