1#ifndef AMREX_GPU_PARALLEL_REDUCE_H_
2#define AMREX_GPU_PARALLEL_REDUCE_H_
3#include <AMReX_Config.H>
32namespace ParallelAllReduce {
40#if defined(AMREX_USE_MPI) && defined(AMREX_USE_GPU)
57namespace ParallelReduce {
65#if defined(AMREX_USE_MPI) && defined(AMREX_USE_GPU)
70 Sum(hv.
data(),
static_cast<int>(hv.
size()), root, comm);
81 Sum(v.
data(),
static_cast<int>(v.
size()), root, comm);
86namespace ParallelDescriptor {
108 auto const n = v.
size();
114 Bcast(&n_root, std::size_t(1), root, comm);
116 "ParallelDescriptor::Bcast(Gpu::DeviceVector): receiver must be pre-allocated to the root's length");
120 if (n == 0) {
return; }
126 const bool is_root = (
MyProc(comm) == root);
131 Bcast(hv.
data(),
static_cast<std::size_t
>(n), root, comm);
142 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:654
iterator begin() noexcept
Definition AMReX_PODVector.H:680
iterator end() noexcept
Definition AMReX_PODVector.H:684
T * data() noexcept
Definition AMReX_PODVector.H:672
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:105
void Sum(Gpu::DeviceVector< T > &v, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:37
void Sum(Gpu::DeviceVector< T > &v, int root, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:62
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
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:310
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 &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:259