1#ifndef AMREX_NONLOCAL_BC_H_
2#define AMREX_NONLOCAL_BC_H_
3#include <AMReX_Config.H>
16template <
typename T,
typename... Args>
17using Inverse_t =
decltype(std::declval<T>().Inverse(std::declval<Args>()...));
25template <
class IndexMap>
27 :
Conjunction<IsCallableR<Dim3, IndexMap&, const Dim3&>,
28 HasInverseMemFn<const IndexMap&>> {};
37template <
class IndexMap>
63 int iv[3]{i.x, i.y, i.z};
65 for (
int d = 0; d < AMREX_SPACEDIM; ++d) {
68 return Dim3{.x = iv_new[0], .y = iv_new[1], .z = iv_new[2]};
78 int iv_new[3]{i.x, i.y, i.z};
80 for (
int d = 0; d < AMREX_SPACEDIM; ++d) {
84 return Dim3{.x = iv[0], .y = iv[1], .z = iv[2]};
93 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
112template <
typename DTOS>
130template <
typename DTOS>
139 for (
int d = 0; d < AMREX_SPACEDIM; ++d) {
140 smallEnd[d] = std::min(mapped_smallEnd[d], mapped_bigEnd[d]);
141 bigEnd[d] = std::max(mapped_smallEnd[d], mapped_bigEnd[d]);
143 return Box{smallEnd, bigEnd, box.
ixType()};
155template <
typename DTOS>
161 Box srcbox =
Image([&dtos](
Dim3 d) {
return dtos(d); }, box);
179template <
typename DTOS>
180requires (HasInverseMemFn<DTOS>::value)
184 return Apply([&dtos](
Dim3 i) {
return dtos.Inverse(i); }, iv);
196template <
typename DTOS>
201 return Image([&dtos](
Dim3 i) {
return dtos.Inverse(i); }, box);
213template <
typename DTOS>
218 return Image([&dtos](
auto&& i) {
return dtos.Inverse(i); }, box);
222static_assert(IsIndexMapping<MultiBlockIndexMapping>(),
223 "MultiBlockIndexMapping is expected to satisfy IndexMapping");
242 template <
typename DTOS>
243 requires (IsIndexMapping<DTOS>::value)
245 const IntVect& ngrow, DTOS
const& dtos);
250 template <
typename DTOS>
281 template <
typename DTOS>
296template <
typename P, BaseFabType FAB>
299 IsCallableR<typename FAB::value_type, P, Array4<const typename FAB::value_type>, Dim3, int>,
300 IsCallableR<typename FAB::value_type, P, Array4<const typename FAB::value_type>, Dim3, int, Dim3>>
305 template <
typename Proj,
typename T>
307 T call_projection (Proj
const& proj,
Array4<T const> const& src,
Dim3 const& src_index,
int comp,
308 Dim3 const& dst_index)
noexcept
311 return proj(src, src_index, comp, dst_index);
314 return proj(src, src_index, comp);
333 template <
typename T>
335 noexcept(noexcept(array(i.
x, i.
y, i.
z, comp))) {
336 return array(i.
x, i.
y, i.
z, comp);
344static_assert(
sizeof(Identity) == 1 );
345static_assert(std::is_trivially_default_constructible_v<Identity> );
346static_assert(std::is_trivially_copy_assignable_v<Identity> );
347static_assert(std::is_trivially_copy_constructible_v<Identity> );
348static_assert(IsIndexMapping<Identity>() );
349static_assert(IsFabProjection<Identity, FArrayBox>() );
365 "Base needs to be a callable function: (Array4<const T>, Dim3, i) -> auto.");
368 "Map needs to be a callable function: int -> int.");
373 template <
typename T>
376 noexcept(
noexcept(
base(array, i,
map(comp))))
378 return base(array, i,
map(comp));
382static_assert(std::is_trivially_copy_assignable<MapComponents<Identity>>() );
383static_assert(std::is_trivially_copy_constructible<MapComponents<Identity>>() );
384static_assert(IsFabProjection<MapComponents<Identity>,
FArrayBox>() );
395 static_assert(CompI >= 0 && CompJ >= 0,
"CompI >= 0 && CompJ >= 0");
401 const int map[2] = {CompI, CompJ};
402 return i == CompI || i == CompJ ? map[std::size_t(i == CompI)] : i;
407 static_assert(CompI >= 0,
"CompI >= 0");
411 const int map[2] = {CompI,
J};
412 return i == CompI || i ==
J ? map[std::size_t(i == CompI)] : i;
417 static_assert(CompJ >= 0,
"CompJ >= 0");
421 const int map[2] = {
I, CompJ};
422 return i ==
I || i == CompJ ? map[std::size_t(i ==
I)] : i;
430 const int map[2] = {
I,
J};
431 return i ==
I || i ==
J ? map[std::size_t(i ==
I)] : i;
439static_assert(
sizeof(SwapComponents<0, 1>) == 1 );
441static_assert(
sizeof(SwapComponents<0, -1>) ==
sizeof(
int) );
442static_assert(
sizeof(SwapComponents<-1, 1>) ==
sizeof(
int) );
443static_assert(std::is_trivially_default_constructible<MapComponents<Identity, SwapComponents<0, 1>>>() );
444static_assert(std::is_trivially_copy_assignable<MapComponents<Identity, SwapComponents<0, 1>>>() );
445static_assert(std::is_trivially_copy_constructible<MapComponents<Identity, SwapComponents<0, 1>>>() );
446static_assert(IsFabProjection<MapComponents<Identity, SwapComponents<0, 1>>,
FArrayBox>() );
489 std::uint64_t
id = std::numeric_limits<std::uint64_t>::max();
496 int n_components, std::size_t object_size, std::size_t align);
527 int n_components, std::size_t object_size, std::size_t block_size,
557template <
typename... Args>
560template <
typename... Args>
563template <
typename... Args>
566template <
typename... Args>
569template <
typename... Args>
573#if defined(AMREX_USE_CUDA) && defined(_WIN32)
574template <
typename DP, BaseFabType FAB>
struct IsDataPacking : std::true_type {};
576template <
typename DP, BaseFabType FAB>
579 IsDetected<LocalCopy_t, DP&, FabArray<FAB>&, const FabArray<FAB>&, const FabArrayBase::CopyComTagsContainer&>
581 ,IsDetected<PrepareSendBuffers_t, DP&, FabArray<FAB>&, const FabArray<FAB>&, CommData&, const FabArrayBase::MapOfCopyComTagContainers&>,
582 IsDetected<PrepareRecvBuffers_t, DP&, FabArray<FAB>&, const FabArray<FAB>&, CommData&, const FabArrayBase::MapOfCopyComTagContainers&>,
583 IsDetected<PackSendBuffers_t, DP&, const FabArray<FAB>&, CommData&>,
584 IsDetected<UnpackRecvBuffers_t, DP&, FabArray<FAB>&, CommData&>
589template <BaseFabType FAB,
class DTOS = Identity,
class Proj = Identity>
594 Proj
const& proj = Proj{})
noexcept;
597template <BaseFabType FAB,
class DTOS = Identity,
class Proj = Identity>
598requires (IsCallableR<Dim3, DTOS, Dim3>::value && IsFabProjection<Proj, FAB>::value)
603 DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{})
noexcept;
607template <BaseFabType FAB,
class DTOS = Identity,
class Proj = Identity>
608requires (IsCallableR<Dim3, DTOS, Dim3>::value && IsFabProjection<Proj, FAB>::value)
612 Proj
const& proj = Proj{})
noexcept;
615template <BaseFabType FAB,
class DTOS = Identity,
class Proj = Identity>
616requires (IsCallableR<Dim3, DTOS, Dim3>::value && IsFabProjection<Proj, FAB>::value)
622 DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{});
640template <BaseFabType FAB>
659template <BaseFabType FAB>
664 using T =
typename FAB::value_type;
670template <BaseFabType FAB>
675 using T =
typename FAB::value_type;
681template <BaseFabType FAB>
698template <BaseFabType FAB>
715static_assert(IsDataPacking<PackComponents, FArrayBox>(),
716 "PackComponents is expected to satisfy the concept DataPacking.");
725template <
typename DTOS = Identity,
typename FabProj = Identity>
729 : PackComponents(components),
dtos(std::move(dtos_)),
proj(std::move(proj_)) {}
739template <BaseFabType FAB,
typename DTOS,
typename FabProj>
749 "NonLocalBC: src_component must be 0 unless the projection is Identity");
764template <BaseFabType FAB,
typename DTOS,
typename FabProj>
774 "NonLocalBC: src_component must be 0 unless the projection is Identity");
788static_assert(IsDataPacking<ApplyDtosAndProjectionOnReciever<>,
FArrayBox>(),
789 "ApplyDtosAndProjectionOnReciever<> is expected to satisfy the DataPacking concept.");
818template <BaseFabType FAB,
typename DataPacking>
819requires (IsDataPacking<DataPacking, FAB>::value)
875template <BaseFabType FAB,
typename DataPacking>
910template <BaseFabType FAB,
typename DataPacking>
911requires (IsDataPacking<DataPacking, FAB>::value)
930 amrex::Abort(
"NonLocalPC::ParallelCopy_finish failed with wrong message size");
962template <BaseFabType FAB,
typename DataPacking>
963requires (IsDataPacking<DataPacking, FAB>::value)
1002template <BaseFabType FAB,
typename DataPacking>
1003requires (IsDataPacking<DataPacking, FAB>::value)
1009 if (dest.
empty()) {
return; }
1014 MPI_Comm_size(comm, &nprocs_comm);
1015 if (nprocs_comm > 1)
1018 CommHandler& handler = cached ? *cached : local_handler;
1025 if (handler.
send.
id == std::numeric_limits<std::uint64_t>::max()) {
1037 if (!snd_tags.empty()) {
1049 if (!rcv_tags.empty()) {
1071template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1076 int srccomp,
int destcomp,
int numcomp,
1077 DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{},
1080 PackComponents components{};
1081 components.dest_component = destcomp;
1082 components.src_component = srccomp;
1083 components.n_components = numcomp;
1098template <BaseFabType FAB,
typename DataPacking>
1103 std::size_t block_size,
CommHandler* cached =
nullptr,
1106 if (dest.
empty()) {
return; }
1111 MPI_Comm_size(comm, &nprocs_comm);
1112 if (nprocs_comm > 1)
1114 using T =
typename FAB::value_type;
1117 CommHandler& handler = cached ? *cached : local_handler;
1123 if (handler.
send.
id == std::numeric_limits<std::uint64_t>::max()) {
1125 sizeof(T), block_size, comm);
1127 sizeof(T), block_size, comm);
1133 if (!snd_tags.empty()) {
1143 if (!rcv_tags.empty()) {
1164template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1169 int srccomp,
int destcomp,
int numcomp,
1170 DTOS
const& dtos, Proj
const& proj,
1171 std::size_t block_size,
CommHandler* cached =
nullptr,
1205template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1211 PackComponents components{};
1212 components.dest_component = destcomp.
i;
1213 components.src_component = srccomp.
i;
1214 components.n_components = numcomp.
n;
1215#if defined(__GNUC__) && !defined(__clang__)
1216#pragma GCC diagnostic push
1217#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
1222#if defined(__GNUC__) && !defined(__clang__)
1223#pragma GCC diagnostic pop
1250template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1254 int srccomp,
int destcomp,
int numcomp, DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{})
1256 ParallelCopy(dest, src, cmd, SrcComp(srccomp), DestComp(destcomp), NumComps(numcomp), dtos, proj);
1289template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1293 DestComp destcomp,
NumComps numcomp,
const IntVect& ngrow, DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{})
1296 ParallelCopy(dest, src, cmd, srccomp, destcomp, numcomp, dtos, proj);
1330template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1334 int destcomp,
int numcomp,
const IntVect& ngrow, DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{})
1336 return ParallelCopy(dest, destbox, src, SrcComp(srccomp), DestComp(destcomp), NumComps(numcomp), ngrow, dtos, proj);
1344template <BaseFabType FAB>
1348template <BaseFabType FAB>
1355template <BaseFabType FAB>
1359template <BaseFabType FAB>
1367template <BaseFabType FAB>
1371template <BaseFabType FAB>
1412template <BaseFabType FAB,
typename DTOS,
typename Proj = Identity>
1417 int scomp,
int ncomp, DTOS
const& dtos,
1418 Proj
const& proj = Proj{});
1456template <BaseFabType FAB,
typename DTOS,
typename Proj = Identity>
1461 int scomp,
int ncomp, DTOS
const& dtos,
1462 Proj
const& proj = Proj{});
1496template <BaseFabType FAB,
typename DTOS,
typename Proj = Identity>
1500 int scomp,
int ncomp, DTOS
const& dtos, Proj
const& proj = Proj{})
1521template <BaseFabType FAB,
typename DTOS>
1522requires (IsCallableR<Dim3,DTOS,Dim3>::value)
1524FabArrayBase::CommMetaData
1526 Geometry const& geom, DTOS
const& dtos);
1537 using NonLocalBC::SphThetaPhiRIndexMapping;
1538 using NonLocalBC::SphThetaPhiRComponentMapping;
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:593
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:123
Floating-point specialization of BaseFab plus FAB I/O helpers.
Distributed container of FAB objects plus copy and fill utilities.
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Reference-counted collection of Boxes.
Definition AMReX_BoxArray.H:681
__host__ __device__ const IntVectND< dim > & bigEnd() const &noexcept
Return the inclusive upper bound of the box.
Definition AMReX_Box.H:136
__host__ __device__ IndexTypeND< dim > ixType() const noexcept
Return the indexing type.
Definition AMReX_Box.H:148
__host__ __device__ BoxND & setType(const IndexTypeND< dim > &t) noexcept
Set indexing type.
Definition AMReX_Box.H:534
__host__ __device__ const IntVectND< dim > & smallEnd() const &noexcept
Return the inclusive lower bound of the box.
Definition AMReX_Box.H:124
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:55
A Fortran Array of REALs.
Definition AMReX_FArrayBox.H:237
Base class for FabArray.
Definition AMReX_FabArrayBase.H:47
CopyComTag::CopyComTagsContainer CopyComTagsContainer
Definition AMReX_FabArrayBase.H:236
CopyComTag::MapOfCopyComTagContainers MapOfCopyComTagContainers
Definition AMReX_FabArrayBase.H:237
bool empty() const noexcept
Definition AMReX_FabArrayBase.H:94
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:383
static void pack_send_buffer_gpu(FabArray< FAB > const &src, int scomp, int ncomp, Vector< char * > const &send_data, Vector< std::size_t > const &send_size, Vector< const CopyComTagsContainer * > const &send_cctc, std::uint64_t id)
static void pack_send_buffer_cpu(FabArray< FAB > const &src, int scomp, int ncomp, Vector< char * > const &send_data, Vector< std::size_t > const &send_size, Vector< const CopyComTagsContainer * > const &send_cctc)
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:87
__host__ __device__ constexpr Dim3 dim3() const noexcept
Definition AMReX_IntVect.H:269
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
ArrayND< T, 4, true > Array4
Convenient alias for a 4D ArrayND with three spatial dimensions plus a component dimension.
Definition AMReX_Array4.H:1352
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:88
Definition AMReX_NonLocalBC.cpp:53
void AcquireCommBuffer(CommData &comm)
Allocate the_data of a prepared CommData again after ReleaseCommBuffer.
Definition AMReX_NonLocalBC.cpp:244
IntVect Apply(DTOS const &dtos, const IntVect &iv)
Applies the Dim3 to Dim3 mapping onto IntVects.
Definition AMReX_NonLocalBC.H:115
void Rotate90(FabArray< FAB > &mf, int scomp, int ncomp, IntVect const &nghost, Box const &domain)
decltype(PrepareRecvBuffers(std::declval< Args >()...)) PrepareRecvBuffers_t
Definition AMReX_NonLocalBC.H:561
void ReleaseCommBuffer(CommData &comm)
Free the_data of a prepared CommData, keeping the rest of the meta-data.
Definition AMReX_NonLocalBC.cpp:238
FabArrayBase::CommMetaData makeFillBoundaryMetaData(FabArray< FAB > &mf, IntVect const &nghost, Geometry const &geom, DTOS const &dtos)
Make metadata for FillBoundary.
void unpack_recv_buffer_cpu(FabArray< FAB > &mf, int dcomp, int ncomp, Vector< char * > const &recv_data, Vector< std::size_t > const &recv_size, Vector< FabArrayBase::CopyComTagsContainer const * > const &recv_cctc, DTOS const &dtos=DTOS{}, Proj const &proj=Proj{}) noexcept
void Alltoallv(CommData const &send, CommData &recv, MPI_Comm comm)
Exchange all send buffers for all recv buffers with one MPI_Alltoallv.
Definition AMReX_NonLocalBC.cpp:284
IntVect ApplyInverse(DTOS const &dtos, const IntVect &iv)
Applies the Dim3 to Dim3 invserse mapping onto IntVects.
Definition AMReX_NonLocalBC.H:182
void PrepareCommBuffers(CommData &comm, const FabArrayBase::MapOfCopyComTagContainers &cctc, int n_components, std::size_t object_size, std::size_t align)
Fill all class member variables of comm but the request and the stats vector.
Definition AMReX_NonLocalBC.cpp:57
Box InverseImage(DTOS const &dtos, const Box &box)
Applies the inverse Dim3 to Dim3 mapping onto Boxes without changing the index type.
Definition AMReX_NonLocalBC.H:199
void PackSendBuffers(const PackComponents &components, const FabArray< FAB > &src, CommData &send)
Serializes FAB data without any knowledge of a DTOS nor a projection.
Definition AMReX_NonLocalBC.H:683
decltype(std::declval< T >().Inverse(std::declval< Args >()...)) Inverse_t
Return type of an InverseImage class member function.
Definition AMReX_NonLocalBC.H:17
CommHandler FillBoundary_nowait(FabArray< FAB > &mf, const FabArrayBase::CommMetaData &cmd, int scomp, int ncomp, DTOS const &dtos, Proj const &proj=Proj{})
Start communication to fill boundary.
void Alltoall(CommData const &send, CommData &recv, std::size_t block_size, MPI_Comm comm)
Exchange uniform blocks of block_size bytes with one MPI_Alltoall.
Definition AMReX_NonLocalBC.cpp:260
decltype(PrepareSendBuffers(std::declval< Args >()...)) PrepareSendBuffers_t
Definition AMReX_NonLocalBC.H:558
void ParallelCopy_finish(FabArray< FAB > &dest, CommHandler handler, const FabArrayBase::CommMetaData &cmd, const DataPacking &data_packing)
Definition AMReX_NonLocalBC.H:914
void Rotate180(FabArray< FAB > &mf, int scomp, int ncomp, IntVect const &nghost, Box const &domain)
void PrepareAlltoallvCounts(CommData &comm, MPI_Comm c)
Fill comm.counts and comm.displs for MPI_Alltoallv on communicator c.
Definition AMReX_NonLocalBC.cpp:171
void LocalCopy(const PackComponents &components, FabArray< FAB > &dest, const FabArray< FAB > &src, const FabArrayBase::CopyComTagsContainer &local_tags)
Dispatch local copies to the default behaviour that knows no DTOS nor projection.
Definition AMReX_NonLocalBC.H:642
static constexpr SwapComponents< CompI, CompJ > swap_indices
Definition AMReX_NonLocalBC.H:437
void PostSends(CommData &send, int mpi_tag)
Initiate all sends with MPI_Isend calls associated with tag mpi_tag.
Definition AMReX_NonLocalBC.cpp:135
void local_copy_cpu(FabArray< FAB > &dest, const FabArray< FAB > &src, int dcomp, int scomp, int ncomp, FabArrayBase::CopyComTagsContainer const &local_tags, DTOS const &dtos=DTOS{}, Proj const &proj=Proj{}) noexcept
void PostRecvs(CommData &recv, int mpi_tag)
Initiate all recvieves with MPI_Irecv calls associated with tag mpi_tag.
Definition AMReX_NonLocalBC.cpp:119
SwapComponents<-1, -1 > DynamicSwapComponents
Definition AMReX_NonLocalBC.H:435
void FillBoundary_finish(CommHandler handler, FabArray< FAB > &mf, const FabArrayBase::CommMetaData &cmd, int scomp, int ncomp, DTOS const &dtos, Proj const &proj=Proj{})
Finish communication started by FillBoundary_nowait.
void FillPolar(FabArray< FAB > &mf, int scomp, int ncomp, IntVect const &nghost, Box const &domain)
void FillBoundary(FabArray< FAB > &mf, const FabArrayBase::CommMetaData &cmd, int scomp, int ncomp, DTOS const &dtos, Proj const &proj=Proj{})
Fill ghost cells for FabArray/MultiFab.
Definition AMReX_NonLocalBC.H:1499
void UnpackRecvBuffers(const PackComponents &components, FabArray< FAB > &dest, const CommData &recv)
De-serializes FAB data without any knowledge of a DTOS nor a projection.
Definition AMReX_NonLocalBC.H:700
static constexpr struct amrex::NonLocalBC::DoLocalCopy do_local_copy
decltype(LocalCopy(std::declval< Args >()...)) LocalCopy_t
Definition AMReX_NonLocalBC.H:570
void local_copy_gpu(FabArray< FAB > &dest, const FabArray< FAB > &src, int dcomp, int scomp, int ncomp, FabArrayBase::CopyComTagsContainer const &local_tags, DTOS const &dtos=DTOS{}, Proj const &proj=Proj{}) noexcept
template MultiBlockCommMetaData ParallelCopy(FabArray< FArrayBox > &dest, const Box &destbox, const FabArray< FArrayBox > &src, int destcomp, int srccomp, int numcomp, const IntVect &ngrow, MultiBlockIndexMapping const &, Identity const &)
CommHandler ParallelCopy_nowait(NoLocalCopy, FabArray< FAB > &dest, const FabArray< FAB > &src, const FabArrayBase::CommMetaData &cmd, const DataPacking &data_packing)
Definition AMReX_NonLocalBC.H:822
static constexpr Identity identity
Definition AMReX_NonLocalBC.H:342
decltype(PackSendBuffers(std::declval< Args >()...)) PackSendBuffers_t
Definition AMReX_NonLocalBC.H:564
Box Image(DTOS const &dtos, const Box &box)
Applies the Dim3 to Dim3 mapping onto Boxes but does not change the index type.
Definition AMReX_NonLocalBC.H:133
decltype(UnpackRecvBuffers(std::declval< Args >()...)) UnpackRecvBuffers_t
Definition AMReX_NonLocalBC.H:567
void PrepareRecvBuffers(const PackComponents &components, FabArray< FAB > &dest, const FabArray< FAB > &src, CommData &comm, const FabArrayBase::MapOfCopyComTagContainers &cctc)
Calls PrepareComBuffers.
Definition AMReX_NonLocalBC.H:672
void ParallelCopy_alltoallv(FabArray< FAB > &dest, const FabArray< FAB > &src, const FabArrayBase::CommMetaData &cmd, const DataPacking &data_packing, CommHandler *cached=nullptr, MPI_Comm comm=MPI_COMM_NULL)
ParallelCopy that exchanges all messages with a single MPI_Alltoallv.
Definition AMReX_NonLocalBC.H:1005
static constexpr struct amrex::NonLocalBC::NoLocalCopy no_local_copy
void PrepareSendBuffers(const PackComponents &components, FabArray< FAB > &dest, const FabArray< FAB > &src, CommData &comm, const FabArrayBase::MapOfCopyComTagContainers &cctc)
Calls PrepareComBuffers.
Definition AMReX_NonLocalBC.H:661
void unpack_recv_buffer_gpu(FabArray< FAB > &mf, int scomp, int ncomp, Vector< char * > const &recv_data, Vector< std::size_t > const &recv_size, Vector< FabArrayBase::CopyComTagsContainer const * > const &recv_cctc, DTOS const &dtos=DTOS{}, Proj const &proj=Proj{})
void ParallelCopy_alltoall(FabArray< FAB > &dest, const FabArray< FAB > &src, const FabArrayBase::CommMetaData &cmd, const DataPacking &data_packing, std::size_t block_size, CommHandler *cached=nullptr, MPI_Comm comm=MPI_COMM_NULL)
ParallelCopy that exchanges uniform blocks with a single MPI_Alltoall.
Definition AMReX_NonLocalBC.H:1101
void PrepareCommBuffersUniform(CommData &comm, const FabArrayBase::MapOfCopyComTagContainers &cctc, int n_components, std::size_t object_size, std::size_t block_size, MPI_Comm c)
Like PrepareCommBuffers, but every process in communicator c gets a block of block_size bytes in the ...
Definition AMReX_NonLocalBC.cpp:185
void TranslateRanks(CommData &comm, MPI_Comm c)
Fill comm.comm_rank with the ranks of comm.rank (global ranks) in communicator c.
Definition AMReX_NonLocalBC.cpp:151
MPI_Comm CommunicatorSub() noexcept
sub-communicator for current frame
Definition AMReX_ParallelContext.H:70
int NProcsSub() noexcept
number of ranks in current frame
Definition AMReX_ParallelContext.H:74
void Waitall(Vector< MPI_Request > &, Vector< MPI_Status > &)
Definition AMReX_ParallelDescriptor.cpp:1312
int SeqNum() noexcept
Returns sequential message sequence numbers, usually used as tags for send/recv.
Definition AMReX_ParallelDescriptor.H:678
int MPI_Comm
Definition AMReX_ccse-mpi.H:51
static constexpr int MPI_COMM_NULL
Definition AMReX_ccse-mpi.H:59
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:273
std::unique_ptr< char, TheFaArenaDeleter > TheFaArenaPointer
Definition AMReX_FabArray.H:118
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
@ y
Definition AMReX_Orientation.H:14
@ x
Definition AMReX_Orientation.H:14
@ z
Definition AMReX_Orientation.H:14
IndexTypeND< 3 > IndexType
IndexType is an alias for amrex::IndexTypeND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:41
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:239
const int[]
Definition AMReX_BLProfiler.cpp:1665
std::is_same< Expected, Detected_t< Op, Args... > > IsDetectedExact
Definition AMReX_TypeTraits.H:186
This class stores both recv and send buffers with an associated MPI tag.
Definition AMReX_NonLocalBC.H:546
Logical traits let us combine multiple type requirements.
Definition AMReX_TypeTraits.H:232
Destination-component descriptor.
Definition AMReX_BaseFab.H:105
int i
Definition AMReX_BaseFab.H:108
A simple struct holding 3 int values for a 3D index.
Definition AMReX_Dim3.H:24
int x
Definition AMReX_Dim3.H:24
int z
Definition AMReX_Dim3.H:24
int y
Definition AMReX_Dim3.H:24
Definition AMReX_TypeTraits.H:238
Test if a given type T is callable with arguments of type Args...
Definition AMReX_TypeTraits.H:214
Test if a given type T is callable with arguments of type Args...
Definition AMReX_TypeTraits.H:208
This class specializes behaviour on local copies and unpacking receive buffers.
Definition AMReX_NonLocalBC.H:726
constexpr ApplyDtosAndProjectionOnReciever()=default
constexpr ApplyDtosAndProjectionOnReciever(const PackComponents &components, DTOS dtos_=DTOS{}, FabProj proj_=FabProj{})
Definition AMReX_NonLocalBC.H:728
FabProj proj
Definition AMReX_NonLocalBC.H:732
DTOS dtos
Definition AMReX_NonLocalBC.H:731
This class holds data buffers for either immediate MPI send or recv calls.
Definition AMReX_NonLocalBC.H:464
Vector< std::size_t > size
The size in bytes for each data transaction.
Definition AMReX_NonLocalBC.H:475
Vector< char * > data
Pointers to the_data that can be used for each single data transaction.
Definition AMReX_NonLocalBC.H:471
Vector< const FabArrayBase::CopyComTagsContainer * > cctc
For each request the copy comm tags for the corresponding data FABs.
Definition AMReX_NonLocalBC.H:481
std::size_t total_bytes
Size of the_data in bytes, so that it can be released and reacquired.
Definition AMReX_NonLocalBC.H:488
Vector< MPI_Status > stats
For each request the corresponding MPI_status, used for debugging.
Definition AMReX_NonLocalBC.H:479
Vector< MPI_Request > request
The associated MPI_Request for each data transaction.
Definition AMReX_NonLocalBC.H:477
TheFaArenaPointer the_data
Holds 'em all in one data pointer.
Definition AMReX_NonLocalBC.H:467
std::uint64_t id
Definition AMReX_NonLocalBC.H:489
Vector< int > rank
Stores MPI ranks. For recvs it is the 'from' rank and for sends it is the 'to' rank.
Definition AMReX_NonLocalBC.H:469
Vector< int > displs
Definition AMReX_NonLocalBC.H:486
Vector< std::size_t > offset
All offsets of data in the_data.
Definition AMReX_NonLocalBC.H:473
Vector< int > counts
size and offset per rank of that communicator, as MPI_Alltoallv wants them.
Definition AMReX_NonLocalBC.H:485
Vector< int > comm_rank
rank translated into the communicator used by Alltoall and Alltoallv.
Definition AMReX_NonLocalBC.H:483
This class stores both recv and send buffers with an associated MPI tag.
Definition AMReX_NonLocalBC.H:546
CommData send
Definition AMReX_NonLocalBC.H:550
int mpi_tag
Definition AMReX_NonLocalBC.H:548
CommData recv
Definition AMReX_NonLocalBC.H:549
Definition AMReX_NonLocalBC.H:795
Type trait that tests if T has an InverseImage class member function.
Definition AMReX_NonLocalBC.H:21
This class acts as a default no-op operator.
Definition AMReX_NonLocalBC.H:326
constexpr Dim3 operator()(Dim3 i) const noexcept
The identity function for Dim3.
Definition AMReX_NonLocalBC.H:328
constexpr T operator()(Array4< const T > array, Dim3 i, int comp=0) const noexcept(noexcept(array(i.x, i.y, i.z, comp)))
Definition AMReX_NonLocalBC.H:334
constexpr int operator()(int i) const noexcept
The identity for int.
Definition AMReX_NonLocalBC.H:340
static constexpr Dim3 Inverse(Dim3 i) noexcept
The identity function for Dim3.
Definition AMReX_NonLocalBC.H:330
This type trait tests if a given type DP satisfies the DataPacking concept for type FAB.
Definition AMReX_NonLocalBC.H:586
This type trait tests if a type P is a projection for FAB.
Definition AMReX_NonLocalBC.H:301
Tests if a given type IndexMap is usable as an index mapping between two index based coordinate syste...
Definition AMReX_NonLocalBC.H:28
Type trait for index mappings that are monotone in each component over the whole index space,...
Definition AMReX_NonLocalBC.H:38
This class takes a projection and a component map and combines them to form a new projection.
Definition AMReX_NonLocalBC.H:363
Base base
Definition AMReX_NonLocalBC.H:370
Map map
Definition AMReX_NonLocalBC.H:371
constexpr decltype(auto) operator()(Array4< const T > array, Dim3 i, int comp) const noexcept(noexcept(base(array, i, map(comp))))
Definition AMReX_NonLocalBC.H:375
This struct describes an affine index transformation for two coordinate systems.
Definition AMReX_NonLocalBC.H:48
IndexType operator()(IndexType it) const noexcept
Definition AMReX_NonLocalBC.H:87
IntVect sign
A vector of 1 and -1 describing the orientation in each component.
Definition AMReX_NonLocalBC.H:54
__host__ __device__ Dim3 operator()(Dim3 i) const noexcept
Applies this mapping on the index from destination space and returns an index in the source space.
Definition AMReX_NonLocalBC.H:62
__host__ __device__ Dim3 Inverse(Dim3 i) const noexcept
The inverse function is given by rearringing all above terms.
Definition AMReX_NonLocalBC.H:77
IntVect offset
The offset in the source index space.
Definition AMReX_NonLocalBC.H:52
IntVect permutation
This vector needs to be a valid permutation.
Definition AMReX_NonLocalBC.H:50
IndexType Inverse(IndexType it) const noexcept
Definition AMReX_NonLocalBC.H:91
Definition AMReX_NonLocalBC.H:794
Contains information about which components take part of the data transaction.
Definition AMReX_NonLocalBC.H:633
int dest_component
Definition AMReX_NonLocalBC.H:634
int src_component
Definition AMReX_NonLocalBC.H:635
int n_components
Definition AMReX_NonLocalBC.H:636
int J
Definition AMReX_NonLocalBC.H:428
int I
Definition AMReX_NonLocalBC.H:427
constexpr int operator()(int i) const noexcept
Definition AMReX_NonLocalBC.H:429
constexpr int operator()(int i) const noexcept
Definition AMReX_NonLocalBC.H:420
int I
Definition AMReX_NonLocalBC.H:419
constexpr int operator()(int i) const noexcept
Definition AMReX_NonLocalBC.H:410
int J
Definition AMReX_NonLocalBC.H:409
This is a permutation where only two components are swapped.
Definition AMReX_NonLocalBC.H:394
constexpr int operator()(int i) const noexcept
Swaps indices CompI and CompJ.
Definition AMReX_NonLocalBC.H:400
Number-of-components descriptor.
Definition AMReX_BaseFab.H:112
int n
Definition AMReX_BaseFab.H:115
Source-component descriptor.
Definition AMReX_BaseFab.H:98
int i
Definition AMReX_BaseFab.H:101