Tpetra parallel linear algebra  Version of the Day
Classes | Namespaces | Functions
Tpetra_Details_iallreduce.hpp File Reference

Declaration of Tpetra::Details::iallreduce. More...

#include "TpetraCore_config.h"
#include "Teuchos_EReductionType.hpp"
#include "Kokkos_Core.hpp"
#include <memory>
#include <stdexcept>
#include <type_traits>
#include <functional>

Go to the source code of this file.

Classes

class  Tpetra::Details::CommRequest
 Base class for the request (more or less a future) representing a pending nonblocking MPI operation. More...
 
class  Tpetra::Details::Impl::DeferredActionCommRequest
 Part of the Work-around for not having MPI >= 3. More...
 
class  Tpetra::Details::Impl::IallreduceCommRequest< PacketType, SendLayoutType, SendDeviceType, RecvLayoutType, RecvDeviceType, rank >
 Object representing a pending Tpetra::Details::iallreduce operation. More...
 
class  Tpetra::Details::Impl::IallreduceCommRequest< PacketType, SendLayoutType, SendDeviceType, RecvLayoutType, RecvDeviceType, 1 >
 Partial pecialization for rank-1 send and receive buffers. More...
 
class  Tpetra::Details::Impl::IallreduceCommRequest< PacketType, SendLayoutType, SendDeviceType, RecvLayoutType, RecvDeviceType, 0 >
 Partial pecialization for rank-0 (single-value) send and receive buffers. More...
 
struct  Tpetra::Details::Impl::Iallreduce< PacketType, SendLayoutType, SendDeviceType, RecvLayoutType, RecvDeviceType, rank >
 Implementation of Tpetra::Details::iallreduce. More...
 
struct  Tpetra::Details::Impl::Iallreduce< PacketType, SendLayoutType, SendDeviceType, RecvLayoutType, RecvDeviceType, 1 >
 Partial specialization of Iallreduce for rank-1 send and receive buffers. More...
 
struct  Tpetra::Details::Impl::Iallreduce< PacketType, SendLayoutType, SendDeviceType, RecvLayoutType, RecvDeviceType, 0 >
 Partial specialization of Iallreduce for rank-0 send and receive buffers. More...
 

Namespaces

 Tpetra
 Namespace Tpetra contains the class and methods constituting the Tpetra library.
 
 Tpetra::Details
 Namespace for Tpetra implementation details.
 

Functions

std::shared_ptr< CommRequest > Tpetra::Details::Impl::emptyCommRequest ()
 Return an "empty" comm request (waiting on it does nothing). More...
 
template<class PacketType , class SendLayoutType , class SendDeviceType , class RecvLayoutType , class RecvDeviceType >
std::shared_ptr< CommRequest > Tpetra::Details::Impl::wrapIallreduceCommRequest (const std::shared_ptr< CommRequest > &req, const ::Kokkos::View< const PacketType *, SendLayoutType, SendDeviceType > &sendbuf, const ::Kokkos::View< PacketType *, RecvLayoutType, RecvDeviceType > &recvbuf)
 Function for wrapping the CommRequest to be returned from Tpetra::Details::iallreduce; overload for rank-1 send and receive buffers. More...
 
template<class PacketType , class SendLayoutType , class SendDeviceType , class RecvLayoutType , class RecvDeviceType >
std::shared_ptr< CommRequest > Tpetra::Details::Impl::wrapIallreduceCommRequest (const std::shared_ptr< CommRequest > &req, const ::Kokkos::View< const PacketType, SendLayoutType, SendDeviceType > &sendbuf, const ::Kokkos::View< PacketType, RecvLayoutType, RecvDeviceType > &recvbuf)
 Function for wrapping the CommRequest to be returned from Tpetra::Details::iallreduce; overload for rank-0 send and receive buffers. More...
 
template<class Packet >
std::shared_ptr< CommRequest > Tpetra::Details::Impl::iallreduceRaw (const Packet sendbuf[], Packet recvbuf[], const int count, const ::Teuchos::EReductionType op, const ::Teuchos::Comm< int > &comm)
 Second lowest-level implementation of Tpetra::Details::iallreduce (see bottom of this header file). More...
 
template<class InputViewType , class OutputViewType >
std::shared_ptr< CommRequest > Tpetra::Details::iallreduce (const InputViewType &sendbuf, const OutputViewType &recvbuf, const ::Teuchos::EReductionType op, const ::Teuchos::Comm< int > &comm)
 Nonblocking all-reduce, for either rank-1 or rank-0 Kokkos::View objects. More...
 

Detailed Description

Declaration of Tpetra::Details::iallreduce.

Warning
This file and its contents are implementation details of Tpetra. Users must not rely on them.

Tpetra::Details::iallreduce wraps MPI_Iallreduce. That is the only thing in this file upon which Tpetra developers should rely. Tpetra developers should not rely on anything else in this file. Users may not rely on anything in this file!

If you want to find the only thing in this file that you are supposed to use, search for "SKIP DOWN TO HERE" (no quotes). "You" only refers to Tpetra developers. Users, this file is not for you!

Definition in file Tpetra_Details_iallreduce.hpp.

Function Documentation

◆ emptyCommRequest()

std::shared_ptr< CommRequest > Tpetra::Details::Impl::emptyCommRequest ( )

Return an "empty" comm request (waiting on it does nothing).

Definition at line 171 of file Tpetra_Details_iallreduce.cpp.

◆ wrapIallreduceCommRequest() [1/2]

template<class PacketType , class SendLayoutType , class SendDeviceType , class RecvLayoutType , class RecvDeviceType >
std::shared_ptr<CommRequest> Tpetra::Details::Impl::wrapIallreduceCommRequest ( const std::shared_ptr< CommRequest > &  req,
const ::Kokkos::View< const PacketType *, SendLayoutType, SendDeviceType > &  sendbuf,
const ::Kokkos::View< PacketType *, RecvLayoutType, RecvDeviceType > &  recvbuf 
)

Function for wrapping the CommRequest to be returned from Tpetra::Details::iallreduce; overload for rank-1 send and receive buffers.

The object returned from this function keeps the send and receive buffers. Since ::Kokkos::View reference-counts, this ensures that the buffers will not be deallocated until the iallreduce completes. The buffer references get cleared on wait() or cancel().

Parameters
req[in] Pointer to CommRequest from Tpetra::Details::iallreduce.
sendbuf[in] Send buffer for Tpetra::Details::iallreduce.
recvbuf[in] Receive buffer for Tpetra::Details::iallreduce. This is an input argument, because this function itself does not modify the contents of the receive buffer; it just keeps a reference to it.
Returns
Pointer to wrapped CommRequest.
Template Parameters
PacketTypeType of each entry of the send and receive buffers.
SendLayoutTypearray_layout of the send buffer. Must be Kokkos::LayoutLeft or Kokkos::LayoutRight.
SendDeviceTypeKokkos::Device specialization used by the send buffer.
RecvLayoutTypearray_layout of the receive buffer. Must be Kokkos::LayoutLeft or Kokkos::LayoutRight.
RecvDeviceTypeKokkos::Device specialization used by the receive buffer. It's OK for this to differ from SendDeviceType. We assume that MPI implementations can handle this. (This is a reasonable assumption with CUDA-enabled MPI implementations.)

Definition at line 482 of file Tpetra_Details_iallreduce.hpp.

◆ wrapIallreduceCommRequest() [2/2]

template<class PacketType , class SendLayoutType , class SendDeviceType , class RecvLayoutType , class RecvDeviceType >
std::shared_ptr<CommRequest> Tpetra::Details::Impl::wrapIallreduceCommRequest ( const std::shared_ptr< CommRequest > &  req,
const ::Kokkos::View< const PacketType, SendLayoutType, SendDeviceType > &  sendbuf,
const ::Kokkos::View< PacketType, RecvLayoutType, RecvDeviceType > &  recvbuf 
)

Function for wrapping the CommRequest to be returned from Tpetra::Details::iallreduce; overload for rank-0 send and receive buffers.

The object returned from this function keeps the send and receive buffers. Since ::Kokkos::View reference-counts, this ensures that the buffers will not be deallocated until the iallreduce completes. The buffer references get cleared on wait() or cancel().

Parameters
req[in] Pointer to CommRequest from Tpetra::Details::iallreduce.
sendbuf[in] Send buffer for Tpetra::Details::iallreduce.
recvbuf[in] Receive buffer for Tpetra::Details::iallreduce. This is an input argument, because this function itself does not modify the contents of the receive buffer; it just keeps a reference to it.
Returns
Pointer to wrapped CommRequest.
Template Parameters
PacketTypeType of each entry of the send and receive buffers.
SendLayoutTypearray_layout of the send buffer. Must be Kokkos::LayoutLeft or Kokkos::LayoutRight.
SendDeviceTypeKokkos::Device specialization used by the send buffer.
RecvLayoutTypearray_layout of the receive buffer. Must be Kokkos::LayoutLeft or Kokkos::LayoutRight.
RecvDeviceTypeKokkos::Device specialization used by the receive buffer. It's OK for this to differ from SendDeviceType. We assume that MPI implementations can handle this. (This is a reasonable assumption with CUDA-enabled MPI implementations.)

Definition at line 541 of file Tpetra_Details_iallreduce.hpp.

◆ iallreduceRaw()

template<class Packet >
std::shared_ptr<CommRequest> Tpetra::Details::Impl::iallreduceRaw ( const Packet  sendbuf[],
Packet  recvbuf[],
const int  count,
const ::Teuchos::EReductionType  op,
const ::Teuchos::Comm< int > &  comm 
)

Second lowest-level implementation of Tpetra::Details::iallreduce (see bottom of this header file).

Template Parameters
PacketType of each entry of the send and receive buffer.

This doesn't need to know about the Kokkos "Device" type, because we assume that MPI implementations can read CUDA device memory, host memory, or indeed from any memory space.

Definition at line 595 of file Tpetra_Details_iallreduce.hpp.