1#ifndef AMREX_GPU_PARALLEL_REDUCE_H_
2#define AMREX_GPU_PARALLEL_REDUCE_H_
3#include <AMReX_Config.H>
29namespace ParallelAllReduce {
37#if defined(AMREX_USE_MPI) && defined(AMREX_USE_GPU)
53namespace ParallelReduce {
61#if defined(AMREX_USE_MPI) && defined(AMREX_USE_GPU)
66 Sum(hv.
data(),
static_cast<int>(hv.
size()), root, comm);
76 Sum(v.
data(),
static_cast<int>(v.
size()), root, comm);
81namespace ParallelDescriptor {
103 auto const n = v.
size();
109 Bcast(&n_root, std::size_t(1), root, comm);
111 "ParallelDescriptor::Bcast(Gpu::DeviceVector): receiver must be pre-allocated to the root's length");
115 if (n == 0) {
return; }
121 const bool is_root = (
MyProc(comm) == root);
126 Bcast(hv.
data(),
static_cast<std::size_t
>(n), root, comm);
136 Bcast(v.
data(),
static_cast<std::size_t
>(n), root, comm);
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
Dynamically allocated vector for trivially copyable data.
Definition AMReX_PODVector.H:308
size_type size() const noexcept
Definition AMReX_PODVector.H:648
iterator begin() noexcept
Definition AMReX_PODVector.H:674
iterator end() noexcept
Definition AMReX_PODVector.H:678
T * data() noexcept
Definition AMReX_PODVector.H:666
amrex_long Long
Definition AMReX_INT.H:30
int MyProc() noexcept
Definition AMReX_ParallelDescriptor.H:128
void Bcast(Gpu::DeviceVector< T > &v, int root, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:100
void Sum(Gpu::DeviceVector< T > &v, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:34
void Sum(Gpu::DeviceVector< T > &v, int root, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:58
void copy(HostToDevice, InIter begin, InIter end, OutIter result) noexcept
A host-to-device copy routine. Note this is just a wrapper around memcpy, so it assumes contiguous st...
Definition AMReX_GpuContainers.H:128
static constexpr DeviceToHost deviceToHost
Definition AMReX_GpuContainers.H:106
static constexpr HostToDevice hostToDevice
Definition AMReX_GpuContainers.H:105
bool UseGpuAwareMpi()
Definition AMReX_ParallelDescriptor.H:113
int MPI_Comm
Definition AMReX_ccse-mpi.H:51
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:139