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&>> {};
53 int iv[3]{i.x, i.y, i.z};
55 for (
int d = 0; d < AMREX_SPACEDIM; ++d) {
58 return Dim3{.x = iv_new[0], .y = iv_new[1], .z = iv_new[2]};
68 int iv_new[3]{i.x, i.y, i.z};
70 for (
int d = 0; d < AMREX_SPACEDIM; ++d) {
74 return Dim3{.x = iv[0], .y = iv[1], .z = iv[2]};
83 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
102template <
typename DTOS>
120template <
typename DTOS>
129 for (
int d = 0; d < AMREX_SPACEDIM; ++d) {
130 smallEnd[d] = std::min(mapped_smallEnd[d], mapped_bigEnd[d]);
131 bigEnd[d] = std::max(mapped_smallEnd[d], mapped_bigEnd[d]);
133 return Box{smallEnd, bigEnd, box.
ixType()};
145template <
typename DTOS>
151 Box srcbox =
Image([&dtos](
Dim3 d) {
return dtos(d); }, box);
169template <
typename DTOS>
170requires (HasInverseMemFn<DTOS>::value)
174 return Apply([&dtos](
Dim3 i) {
return dtos.Inverse(i); }, iv);
186template <
typename DTOS>
191 return Image([&dtos](
Dim3 i) {
return dtos.Inverse(i); }, box);
203template <
typename DTOS>
208 return Image([&dtos](
auto&& i) {
return dtos.Inverse(i); }, box);
212static_assert(IsIndexMapping<MultiBlockIndexMapping>(),
213 "MultiBlockIndexMapping is expected to satisfy IndexMapping");
229 template <
typename DTOS>
230 requires (IsIndexMapping<DTOS>::value)
232 const IntVect& ngrow, DTOS
const& dtos);
237 template <
typename DTOS>
267 template <
typename DTOS>
279template <
typename P, BaseFabType FAB>
281 :
IsCallableR<typename FAB::value_type, P, Array4<const typename FAB::value_type>, Dim3, int>
298 template <
typename T>
300 noexcept(noexcept(array(i.
x, i.
y, i.
z, comp))) {
301 return array(i.
x, i.
y, i.
z, comp);
309static_assert(
sizeof(Identity) == 1 );
310static_assert(std::is_trivially_default_constructible_v<Identity> );
311static_assert(std::is_trivially_copy_assignable_v<Identity> );
312static_assert(std::is_trivially_copy_constructible_v<Identity> );
313static_assert(IsIndexMapping<Identity>() );
314static_assert(IsFabProjection<Identity, FArrayBox>() );
327 "Base needs to be a callable function: (Array4<const T>, Dim3, i) -> auto.");
330 "Map needs to be a callable function: int -> int.");
335 template <
typename T>
338 noexcept(
noexcept(
base(array, i,
map(comp))))
340 return base(array, i,
map(comp));
344static_assert(std::is_trivially_copy_assignable<MapComponents<Identity>>() );
345static_assert(std::is_trivially_copy_constructible<MapComponents<Identity>>() );
346static_assert(IsFabProjection<MapComponents<Identity>,
FArrayBox>() );
357 static_assert(CompI >= 0 && CompJ >= 0,
"CompI >= 0 && CompJ >= 0");
363 const int map[2] = {CompI, CompJ};
364 return i == CompI || i == CompJ ? map[std::size_t(i == CompI)] : i;
369 static_assert(CompI >= 0,
"CompI >= 0");
373 const int map[2] = {CompI,
J};
374 return i == CompI || i ==
J ? map[std::size_t(i == CompI)] : i;
379 static_assert(CompJ >= 0,
"CompJ >= 0");
383 const int map[2] = {
I, CompJ};
384 return i ==
I || i == CompJ ? map[std::size_t(i ==
I)] : i;
392 const int map[2] = {
I,
J};
393 return i ==
I || i ==
J ? map[std::size_t(i ==
I)] : i;
401static_assert(
sizeof(SwapComponents<0, 1>) == 1 );
403static_assert(
sizeof(SwapComponents<0, -1>) ==
sizeof(
int) );
404static_assert(
sizeof(SwapComponents<-1, 1>) ==
sizeof(
int) );
405static_assert(std::is_trivially_default_constructible<MapComponents<Identity, SwapComponents<0, 1>>>() );
406static_assert(std::is_trivially_copy_assignable<MapComponents<Identity, SwapComponents<0, 1>>>() );
407static_assert(std::is_trivially_copy_constructible<MapComponents<Identity, SwapComponents<0, 1>>>() );
408static_assert(IsFabProjection<MapComponents<Identity, SwapComponents<0, 1>>,
FArrayBox>() );
451 std::uint64_t
id = std::numeric_limits<std::uint64_t>::max();
458 int n_components, std::size_t object_size, std::size_t align);
489 int n_components, std::size_t object_size, std::size_t block_size,
519template <
typename... Args>
522template <
typename... Args>
525template <
typename... Args>
528template <
typename... Args>
531template <
typename... Args>
535#if defined(AMREX_USE_CUDA) && defined(_WIN32)
536template <
typename DP, BaseFabType FAB>
struct IsDataPacking : std::true_type {};
538template <
typename DP, BaseFabType FAB>
541 IsDetected<LocalCopy_t, DP&, FabArray<FAB>&, const FabArray<FAB>&, const FabArrayBase::CopyComTagsContainer&>
543 ,IsDetected<PrepareSendBuffers_t, DP&, FabArray<FAB>&, const FabArray<FAB>&, CommData&, const FabArrayBase::MapOfCopyComTagContainers&>,
544 IsDetected<PrepareRecvBuffers_t, DP&, FabArray<FAB>&, const FabArray<FAB>&, CommData&, const FabArrayBase::MapOfCopyComTagContainers&>,
545 IsDetected<PackSendBuffers_t, DP&, const FabArray<FAB>&, CommData&>,
546 IsDetected<UnpackRecvBuffers_t, DP&, FabArray<FAB>&, CommData&>
551template <BaseFabType FAB,
class DTOS = Identity,
class Proj = Identity>
556 Proj
const& proj = Proj{})
noexcept;
559template <BaseFabType FAB,
class DTOS = Identity,
class Proj = Identity>
560requires (IsCallableR<Dim3, DTOS, Dim3>::value && IsFabProjection<Proj, FAB>::value)
565 DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{})
noexcept;
569template <BaseFabType FAB,
class DTOS = Identity,
class Proj = Identity>
570requires (IsCallableR<Dim3, DTOS, Dim3>::value && IsFabProjection<Proj, FAB>::value)
574 Proj
const& proj = Proj{})
noexcept;
577template <BaseFabType FAB,
class DTOS = Identity,
class Proj = Identity>
578requires (IsCallableR<Dim3, DTOS, Dim3>::value && IsFabProjection<Proj, FAB>::value)
584 DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{});
602template <BaseFabType FAB>
621template <BaseFabType FAB>
626 using T =
typename FAB::value_type;
632template <BaseFabType FAB>
637 using T =
typename FAB::value_type;
643template <BaseFabType FAB>
660template <BaseFabType FAB>
677static_assert(IsDataPacking<PackComponents, FArrayBox>(),
678 "PackComponents is expected to satisfy the concept DataPacking.");
686template <
typename DTOS = Identity,
typename FabProj = Identity>
690 : PackComponents(components),
dtos(std::move(dtos_)),
proj(std::move(proj_)) {}
700template <BaseFabType FAB,
typename DTOS,
typename FabProj>
720template <BaseFabType FAB,
typename DTOS,
typename FabProj>
740static_assert(IsDataPacking<ApplyDtosAndProjectionOnReciever<>,
FArrayBox>(),
741 "ApplyDtosAndProjectionOnReciever<> is expected to satisfy the DataPacking concept.");
770template <BaseFabType FAB,
typename DataPacking>
771requires (IsDataPacking<DataPacking, FAB>::value)
827template <BaseFabType FAB,
typename DataPacking>
862template <BaseFabType FAB,
typename DataPacking>
863requires (IsDataPacking<DataPacking, FAB>::value)
882 amrex::Abort(
"NonLocalPC::ParallelCopy_finish failed with wrong message size");
914template <BaseFabType FAB,
typename DataPacking>
915requires (IsDataPacking<DataPacking, FAB>::value)
954template <BaseFabType FAB,
typename DataPacking>
955requires (IsDataPacking<DataPacking, FAB>::value)
961 if (dest.
empty()) {
return; }
966 MPI_Comm_size(comm, &nprocs_comm);
970 CommHandler& handler = cached ? *cached : local_handler;
977 if (handler.
send.
id == std::numeric_limits<std::uint64_t>::max()) {
989 if (!snd_tags.empty()) {
1001 if (!rcv_tags.empty()) {
1023template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1028 int srccomp,
int destcomp,
int numcomp,
1029 DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{},
1032 PackComponents components{};
1033 components.dest_component = destcomp;
1034 components.src_component = srccomp;
1035 components.n_components = numcomp;
1050template <BaseFabType FAB,
typename DataPacking>
1055 std::size_t block_size,
CommHandler* cached =
nullptr,
1058 if (dest.
empty()) {
return; }
1063 MPI_Comm_size(comm, &nprocs_comm);
1064 if (nprocs_comm > 1)
1066 using T =
typename FAB::value_type;
1069 CommHandler& handler = cached ? *cached : local_handler;
1075 if (handler.
send.
id == std::numeric_limits<std::uint64_t>::max()) {
1077 sizeof(T), block_size, comm);
1079 sizeof(T), block_size, comm);
1085 if (!snd_tags.empty()) {
1095 if (!rcv_tags.empty()) {
1116template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1121 int srccomp,
int destcomp,
int numcomp,
1122 DTOS
const& dtos, Proj
const& proj,
1123 std::size_t block_size,
CommHandler* cached =
nullptr,
1156template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1162 PackComponents components{};
1163 components.dest_component = destcomp.
i;
1164 components.src_component = srccomp.
i;
1165 components.n_components = numcomp.
n;
1166#if defined(__GNUC__) && !defined(__clang__)
1167#pragma GCC diagnostic push
1168#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
1173#if defined(__GNUC__) && !defined(__clang__)
1174#pragma GCC diagnostic pop
1200template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1204 int srccomp,
int destcomp,
int numcomp, DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{})
1206 ParallelCopy(dest, src, cmd, SrcComp(srccomp), DestComp(destcomp), NumComps(numcomp), dtos, proj);
1238template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1242 DestComp destcomp,
NumComps numcomp,
const IntVect& ngrow, DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{})
1245 ParallelCopy(dest, src, cmd, srccomp, destcomp, numcomp, dtos, proj);
1278template <BaseFabType FAB,
typename DTOS = Identity,
typename Proj = Identity>
1282 int destcomp,
int numcomp,
const IntVect& ngrow, DTOS
const& dtos = DTOS{}, Proj
const& proj = Proj{})
1284 return ParallelCopy(dest, destbox, src, SrcComp(srccomp), DestComp(destcomp), NumComps(numcomp), ngrow, dtos, proj);
1292template <BaseFabType FAB>
1296template <BaseFabType FAB>
1303template <BaseFabType FAB>
1307template <BaseFabType FAB>
1315template <BaseFabType FAB>
1319template <BaseFabType FAB>
1359template <BaseFabType FAB,
typename DTOS,
typename Proj = Identity>
1364 int scomp,
int ncomp, DTOS
const& dtos,
1365 Proj
const& proj = Proj{});
1402template <BaseFabType FAB,
typename DTOS,
typename Proj = Identity>
1407 int scomp,
int ncomp, DTOS
const& dtos,
1408 Proj
const& proj = Proj{});
1441template <BaseFabType FAB,
typename DTOS,
typename Proj = Identity>
1445 int scomp,
int ncomp, DTOS
const& dtos, Proj
const& proj = Proj{})
1466template <BaseFabType FAB,
typename DTOS>
1467requires (IsCallableR<Dim3,DTOS,Dim3>::value)
1469FabArrayBase::CommMetaData
1471 Geometry const& geom, DTOS
const& dtos);
1482 using NonLocalBC::SphThetaPhiRIndexMapping;
1483 using NonLocalBC::SphThetaPhiRComponentMapping;
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:593
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
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:51
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:356
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:262
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:1340
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:88
Definition AMReX_NonLocalBC.cpp:41
void AcquireCommBuffer(CommData &comm)
Allocate the_data of a prepared CommData again after ReleaseCommBuffer.
Definition AMReX_NonLocalBC.cpp:232
IntVect Apply(DTOS const &dtos, const IntVect &iv)
Applies the Dim3 to Dim3 mapping onto IntVects.
Definition AMReX_NonLocalBC.H:105
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:523
void ReleaseCommBuffer(CommData &comm)
Free the_data of a prepared CommData, keeping the rest of the meta-data.
Definition AMReX_NonLocalBC.cpp:226
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:272
IntVect ApplyInverse(DTOS const &dtos, const IntVect &iv)
Applies the Dim3 to Dim3 invserse mapping onto IntVects.
Definition AMReX_NonLocalBC.H:172
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:45
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:189
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:645
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:248
decltype(PrepareSendBuffers(std::declval< Args >()...)) PrepareSendBuffers_t
Definition AMReX_NonLocalBC.H:520
void ParallelCopy_finish(FabArray< FAB > &dest, CommHandler handler, const FabArrayBase::CommMetaData &cmd, const DataPacking &data_packing)
Definition AMReX_NonLocalBC.H:866
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:159
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:604
static constexpr SwapComponents< CompI, CompJ > swap_indices
Definition AMReX_NonLocalBC.H:399
void PostSends(CommData &send, int mpi_tag)
Initiate all sends with MPI_Isend calls associated with tag mpi_tag.
Definition AMReX_NonLocalBC.cpp:123
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:107
SwapComponents<-1, -1 > DynamicSwapComponents
Definition AMReX_NonLocalBC.H:397
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:1444
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:662
static constexpr struct amrex::NonLocalBC::DoLocalCopy do_local_copy
decltype(LocalCopy(std::declval< Args >()...)) LocalCopy_t
Definition AMReX_NonLocalBC.H:532
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:774
static constexpr Identity identity
Definition AMReX_NonLocalBC.H:307
decltype(PackSendBuffers(std::declval< Args >()...)) PackSendBuffers_t
Definition AMReX_NonLocalBC.H:526
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:123
decltype(UnpackRecvBuffers(std::declval< Args >()...)) UnpackRecvBuffers_t
Definition AMReX_NonLocalBC.H:529
void PrepareRecvBuffers(const PackComponents &components, FabArray< FAB > &dest, const FabArray< FAB > &src, CommData &comm, const FabArrayBase::MapOfCopyComTagContainers &cctc)
Calls PrepareComBuffers.
Definition AMReX_NonLocalBC.H:634
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:957
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:623
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:1053
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:173
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:139
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:244
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:508
Logical traits let us combine multiple type requirements.
Definition AMReX_TypeTraits.H:232
Destination-component descriptor.
Definition AMReX_BaseFab.H:107
int i
Definition AMReX_BaseFab.H:110
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
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:687
constexpr ApplyDtosAndProjectionOnReciever()=default
constexpr ApplyDtosAndProjectionOnReciever(const PackComponents &components, DTOS dtos_=DTOS{}, FabProj proj_=FabProj{})
Definition AMReX_NonLocalBC.H:689
FabProj proj
Definition AMReX_NonLocalBC.H:693
DTOS dtos
Definition AMReX_NonLocalBC.H:692
This class holds data buffers for either immediate MPI send or recv calls.
Definition AMReX_NonLocalBC.H:426
Vector< std::size_t > size
The size in bytes for each data transaction.
Definition AMReX_NonLocalBC.H:437
Vector< char * > data
Pointers to the_data that can be used for each single data transaction.
Definition AMReX_NonLocalBC.H:433
Vector< const FabArrayBase::CopyComTagsContainer * > cctc
For each request the copy comm tags for the corresponding data FABs.
Definition AMReX_NonLocalBC.H:443
std::size_t total_bytes
Size of the_data in bytes, so that it can be released and reacquired.
Definition AMReX_NonLocalBC.H:450
Vector< MPI_Status > stats
For each request the corresponding MPI_status, used for debugging.
Definition AMReX_NonLocalBC.H:441
Vector< MPI_Request > request
The associated MPI_Request for each data transaction.
Definition AMReX_NonLocalBC.H:439
TheFaArenaPointer the_data
Holds 'em all in one data pointer.
Definition AMReX_NonLocalBC.H:429
std::uint64_t id
Definition AMReX_NonLocalBC.H:451
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:431
Vector< int > displs
Definition AMReX_NonLocalBC.H:448
Vector< std::size_t > offset
All offsets of data in the_data.
Definition AMReX_NonLocalBC.H:435
Vector< int > counts
size and offset per rank of that communicator, as MPI_Alltoallv wants them.
Definition AMReX_NonLocalBC.H:447
Vector< int > comm_rank
rank translated into the communicator used by Alltoall and Alltoallv.
Definition AMReX_NonLocalBC.H:445
This class stores both recv and send buffers with an associated MPI tag.
Definition AMReX_NonLocalBC.H:508
CommData send
Definition AMReX_NonLocalBC.H:512
int mpi_tag
Definition AMReX_NonLocalBC.H:510
CommData recv
Definition AMReX_NonLocalBC.H:511
Definition AMReX_NonLocalBC.H:747
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:291
constexpr Dim3 operator()(Dim3 i) const noexcept
The identity function for Dim3.
Definition AMReX_NonLocalBC.H:293
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:299
constexpr int operator()(int i) const noexcept
The identity for int.
Definition AMReX_NonLocalBC.H:305
static constexpr Dim3 Inverse(Dim3 i) noexcept
The identity function for Dim3.
Definition AMReX_NonLocalBC.H:295
This type trait tests if a given type DP satisfies the DataPacking concept for type FAB.
Definition AMReX_NonLocalBC.H:548
This type trait tests if a type P is a projection for FAB.
Definition AMReX_NonLocalBC.H:282
Tests if a given type IndexMap is usable as an index mapping between two index based coordinate syste...
Definition AMReX_NonLocalBC.H:28
This class takes a projection and a component map and combines them to form a new projection.
Definition AMReX_NonLocalBC.H:325
Base base
Definition AMReX_NonLocalBC.H:332
Map map
Definition AMReX_NonLocalBC.H:333
constexpr decltype(auto) operator()(Array4< const T > array, Dim3 i, int comp) const noexcept(noexcept(base(array, i, map(comp))))
Definition AMReX_NonLocalBC.H:337
This struct describes an affine index transformation for two coordinate systems.
Definition AMReX_NonLocalBC.H:38
IndexType operator()(IndexType it) const noexcept
Definition AMReX_NonLocalBC.H:77
IntVect sign
A vector of 1 and -1 describing the orientation in each component.
Definition AMReX_NonLocalBC.H:44
__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:52
__host__ __device__ Dim3 Inverse(Dim3 i) const noexcept
The inverse function is given by rearringing all above terms.
Definition AMReX_NonLocalBC.H:67
IntVect offset
The offset in the source index space.
Definition AMReX_NonLocalBC.H:42
IntVect permutation
This vector needs to be a valid permutation.
Definition AMReX_NonLocalBC.H:40
IndexType Inverse(IndexType it) const noexcept
Definition AMReX_NonLocalBC.H:81
Definition AMReX_NonLocalBC.H:746
Contains information about which components take part of the data transaction.
Definition AMReX_NonLocalBC.H:595
int dest_component
Definition AMReX_NonLocalBC.H:596
int src_component
Definition AMReX_NonLocalBC.H:597
int n_components
Definition AMReX_NonLocalBC.H:598
int J
Definition AMReX_NonLocalBC.H:390
int I
Definition AMReX_NonLocalBC.H:389
constexpr int operator()(int i) const noexcept
Definition AMReX_NonLocalBC.H:391
constexpr int operator()(int i) const noexcept
Definition AMReX_NonLocalBC.H:382
int I
Definition AMReX_NonLocalBC.H:381
constexpr int operator()(int i) const noexcept
Definition AMReX_NonLocalBC.H:372
int J
Definition AMReX_NonLocalBC.H:371
This is a permutation where only two components are swapped.
Definition AMReX_NonLocalBC.H:356
constexpr int operator()(int i) const noexcept
Swaps indices CompI and CompJ.
Definition AMReX_NonLocalBC.H:362
Number-of-components descriptor.
Definition AMReX_BaseFab.H:114
int n
Definition AMReX_BaseFab.H:117
Source-component descriptor.
Definition AMReX_BaseFab.H:100
int i
Definition AMReX_BaseFab.H:103