Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_NonLocalBCImpl.H
Go to the documentation of this file.
1#ifndef AMREX_NONLOCAL_BC_H_
2#include "AMReX_NonLocalBC.H"
3#endif
4
5#ifndef AMREX_NONLOCAL_BC_IMPL_H_
6#define AMREX_NONLOCAL_BC_IMPL_H_
7#include <AMReX_Config.H>
8#include <AMReX_TypeTraits.H>
9
10#include <algorithm>
11
12namespace amrex::NonLocalBC {
13struct Rotate90ClockWise {
15 IntVect operator() (IntVect const& iv) const noexcept {
16 return IntVect{AMREX_D_DECL(iv[1], -1-iv[0], iv[2])};
17 }
18
20 Dim3 operator() (Dim3 const& a) const noexcept {
21 return Dim3{.x = a.y, .y = -1-a.x, .z = a.z};
22 }
23
24 Box operator() (Box const& box) const noexcept {
25 return Box(operator()(IntVect{AMREX_D_DECL(box.bigEnd (0),
26 box.smallEnd(1),
27 box.smallEnd(2))}),
28 operator()(IntVect{AMREX_D_DECL(box.smallEnd(0),
29 box.bigEnd (1),
30 box.bigEnd (2))}));
31 }
32};
33
34struct Rotate90CounterClockWise {
36 IntVect operator() (IntVect const& iv) const noexcept {
37 return IntVect{AMREX_D_DECL(-1-iv[1], iv[0], iv[2])};
38 }
39
41 Dim3 operator() (Dim3 const& a) const noexcept {
42 return Dim3{.x = -1-a.y, .y = a.x, .z = a.z};
43 }
44
45 Box operator() (Box const& box) const noexcept {
46 return Box(operator()(IntVect{AMREX_D_DECL(box.smallEnd(0),
47 box.bigEnd (1),
48 box.smallEnd(2))}),
49 operator()(IntVect{AMREX_D_DECL(box.bigEnd (0),
50 box.smallEnd(1),
51 box.bigEnd (2))}));
52 }
53};
54
55struct Rotate90DstToSrc
56{
58 Dim3 operator() (Dim3 const& a) const noexcept {
59 if (a.x < 0 && a.y < 0) { // lo-x/lo-y corner: 180 degree rotation
60 return Dim3{.x = -1-a.x, .y = -1-a.y, .z = a.z};
61 } else if (a.x < 0) {
62 return Rotate90ClockWise()(a);
63 } else {
64 return Rotate90CounterClockWise()(a);
65 }
66 }
67};
68
69struct Rotate180Fn {
70 int Ly;
71
73 IntVect operator() (IntVect const& iv) const noexcept {
74 return IntVect{AMREX_D_DECL(-1-iv[0], Ly-1-iv[1], iv[2])};
75 }
76
78 Dim3 operator() (Dim3 const& a) const noexcept {
79 return Dim3{.x = -1-a.x, .y = Ly-1-a.y, .z = a.z};
80 }
81
82 Box operator() (Box const& box) const noexcept {
83 return Box(operator()(IntVect{AMREX_D_DECL(box.bigEnd (0),
84 box.bigEnd (1),
85 box.smallEnd(2))}),
86 operator()(IntVect{AMREX_D_DECL(box.smallEnd(0),
87 box.smallEnd(1),
88 box.bigEnd (2))}));
89 }
90};
91
92struct PolarFn {
93 int Lx, Ly;
94
95 [[nodiscard]] AMREX_GPU_HOST_DEVICE
96 int i_index (int i) const noexcept {
97 return (i < Lx/2) ? -1-i : 2*Lx-1-i;
98 }
99
100 [[nodiscard]] AMREX_GPU_HOST_DEVICE
101 int j_index (int j) const noexcept {
102 return (j < Ly/2) ? j+Ly/2 : j-Ly/2;
103 }
104
105 [[nodiscard]] AMREX_GPU_HOST_DEVICE
106 IntVect operator() (IntVect const& iv) const noexcept {
107 return IntVect{AMREX_D_DECL(i_index(iv[0]), j_index(iv[1]), iv[2])};
108 }
109
110 [[nodiscard]] AMREX_GPU_HOST_DEVICE
111 Dim3 operator() (Dim3 const& a) const noexcept {
112 return Dim3{.x = i_index(a.x), .y = j_index(a.y), .z = a.z};
113 }
114
115 [[nodiscard]] Box operator() (Box const& box) const noexcept {
116 return Box(operator()(IntVect{AMREX_D_DECL(box.bigEnd (0),
117 box.smallEnd(1),
118 box.smallEnd(2))}),
119 operator()(IntVect{AMREX_D_DECL(box.smallEnd(0),
120 box.bigEnd (1),
121 box.bigEnd (2))}));
122 }
123};
124
125struct PolarFn2 { // for the x-y corners
126 int Lx, Ly;
127
128 [[nodiscard]] AMREX_GPU_HOST_DEVICE
129 int i_index (int i) const noexcept {
130 return (i < Lx/2) ? -1-i : 2*Lx-1-i;
131 }
132
133 [[nodiscard]] AMREX_GPU_HOST_DEVICE
134 int j_index (int j) const noexcept {
135 if (j < 0) { // NOLINT
136 return j+Ly/2;
137 } else if (j >= Ly) { // NOLINT
138 return j-Ly/2;
139 } else if (j < Ly/2) {
140 return j-Ly/2;
141 } else {
142 return j+Ly/2;
143 }
144 }
145
146 [[nodiscard]] AMREX_GPU_HOST_DEVICE
147 IntVect operator() (IntVect const& iv) const noexcept {
148 return IntVect{AMREX_D_DECL(i_index(iv[0]), j_index(iv[1]), iv[2])};
149 }
150
151 [[nodiscard]] AMREX_GPU_HOST_DEVICE
152 Dim3 operator() (Dim3 const& a) const noexcept {
153 return Dim3{.x = i_index(a.x), .y = j_index(a.y), .z = a.z};
154 }
155
156 [[nodiscard]] Box operator() (Box const& box) const noexcept {
157 return Box(operator()(IntVect{AMREX_D_DECL(box.bigEnd (0),
158 box.smallEnd(1),
159 box.smallEnd(2))}),
160 operator()(IntVect{AMREX_D_DECL(box.smallEnd(0),
161 box.bigEnd (1),
162 box.bigEnd (2))}));
163 }
164};
165
189template <BaseFabType FAB, class DTOS, class Proj>
190requires (IsCallableR<Dim3, DTOS, Dim3>::value && IsFabProjection<Proj, FAB>::value)
191void
192local_copy_cpu (FabArray<FAB>& dest, const FabArray<FAB>& src, int dcomp, int scomp, int ncomp,
193 FabArrayBase::CopyComTagsContainer const& local_tags, DTOS const& dtos, Proj const& proj) noexcept
194{
195 const auto N_locs = static_cast<int>(local_tags.size());
196 if (N_locs == 0) { return; }
197#ifdef AMREX_USE_OMP
198#pragma omp parallel for
199#endif
200 for (int itag = 0; itag < N_locs; ++itag) {
201 const auto& tag = local_tags[itag];
202 auto const& sfab = src.const_array(tag.srcIndex);
203 auto const& dfab = dest.array (tag.dstIndex);
204 amrex::LoopConcurrentOnCpu(tag.dbox, ncomp, [=] (int i, int j, int k, int n) noexcept
205 {
206 Dim3 const di{.x = i, .y = j, .z = k};
207 auto const si = dtos(di);
208 dfab(i,j,k,dcomp+n) = detail::call_projection(proj, sfab, si, scomp+n, di);
209 });
210 }
211}
212
218template <BaseFabType FAB, class DTOS, class Proj>
219requires (IsCallableR<Dim3, DTOS, Dim3>::value && IsFabProjection<Proj, FAB>::value)
220void
221unpack_recv_buffer_cpu (FabArray<FAB>& mf, int dcomp, int ncomp, Vector<char*> const& recv_data,
222 Vector<std::size_t> const& recv_size,
223 Vector<FabArrayBase::CopyComTagsContainer const*> const& recv_cctc,
224 DTOS const& dtos, Proj const& proj) noexcept
225{
226 amrex::ignore_unused(recv_size);
227
228 const auto N_rcvs = static_cast<int>(recv_cctc.size());
229 if (N_rcvs == 0) { return; }
230
231 using T = typename FAB::value_type;
232#ifdef AMREX_USE_OMP
233 if (omp_get_max_threads() > 1) {
234 // Threads share tags, not neighbor ranks, which are often fewer than threads.
235 Vector<std::pair<const char*,FabArrayBase::CopyComTag const*>> tags;
236 for (int ircv = 0; ircv < N_rcvs; ++ircv) {
237 const char* dptr = recv_data[ircv];
238 for (auto const& tag : *recv_cctc[ircv]) {
239 tags.emplace_back(dptr, &tag);
240 dptr += tag.sbox.numPts() * ncomp * sizeof(T);
241 AMREX_ASSERT(dptr <= recv_data[ircv] + recv_size[ircv]);
242 }
243 }
244
245 const auto N_tags = static_cast<int>(tags.size());
246 // Small chunks keep threads on nearby boxes, which share cache lines.
247 int const chunk = std::clamp(N_tags/omp_get_max_threads(), 1, 64);
248#pragma omp parallel for schedule(static,chunk)
249 for (int itag = 0; itag < N_tags; ++itag) {
250 auto const& tag = *tags[itag].second;
251 auto const& dfab = mf.array(tag.dstIndex);
252 auto const& sfab = amrex::makeArray4((T const*)(tags[itag].first), tag.sbox, ncomp);
253 amrex::LoopConcurrentOnCpu(tag.dbox, ncomp, [=](int i, int j, int k, int n) noexcept {
254 Dim3 const di{.x = i, .y = j, .z = k};
255 auto const si = dtos(di);
256 dfab(i, j, k, dcomp + n) = detail::call_projection(proj, sfab, si, n, di);
257 });
258 }
259 return;
260 }
261#endif
262
263 for (int ircv = 0; ircv < N_rcvs; ++ircv) {
264 const char* dptr = recv_data[ircv];
265 auto const& cctc = *recv_cctc[ircv];
266 for (auto const& tag : cctc) {
267 auto const& dfab = mf.array(tag.dstIndex);
268 auto const& sfab = amrex::makeArray4((T const*)(dptr), tag.sbox, ncomp);
269 amrex::LoopConcurrentOnCpu(tag.dbox, ncomp, [=](int i, int j, int k, int n) noexcept {
270 Dim3 const di{.x = i, .y = j, .z = k};
271 auto const si = dtos(di);
272 dfab(i, j, k, dcomp + n) = detail::call_projection(proj, sfab, si, n, di);
273 });
274 dptr += tag.sbox.numPts() * ncomp * sizeof(T);
275 AMREX_ASSERT(dptr <= recv_data[ircv] + recv_size[ircv]);
276 }
277 }
278}
279
280#ifdef AMREX_USE_GPU
281template <class T>
282struct Array4Array4Box {
283 Array4<T > dfab;
284 Array4<T const> sfab;
285 Box dbox;
286
288 Box const& box () const noexcept { return dbox; }
289};
290
291template <BaseFabType FAB, class DTOS, class Proj>
292requires (IsCallableR<Dim3, DTOS, Dim3>::value && IsFabProjection<Proj, FAB>::value)
293void
294local_copy_gpu (FabArray<FAB>& dest, const FabArray<FAB>& src, int dcomp, int scomp, int ncomp,
295 FabArrayBase::CopyComTagsContainer const& local_tags, DTOS const& dtos, Proj const& proj) noexcept
296{
297 int N_locs = local_tags.size();
298 if (N_locs == 0) { return; }
299
300 using T = typename FAB::value_type;
301 Vector<Array4Array4Box<T> > loc_copy_tags;
302 loc_copy_tags.reserve(N_locs);
303 for (auto const& tag : local_tags) {
304 loc_copy_tags.push_back(Array4Array4Box<T>{.dfab = dest.array(tag.dstIndex),
305 .sfab = src.const_array(tag.srcIndex),
306 .dbox = tag.dbox});
307 }
308
309 ParallelFor(loc_copy_tags, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n,
310 Array4Array4Box<T> const& tag) noexcept
311 {
312 Dim3 const di{.x = i, .y = j, .z = k};
313 auto const si = dtos(di);
314 tag.dfab(i,j,k,dcomp+n) = detail::call_projection(proj, tag.sfab, si, scomp+n, di);
315 });
316 if (!Gpu::inNoSyncRegion()) { Gpu::streamSynchronize(); }
317}
318
319template <BaseFabType FAB, class DTOS, class Proj>
320requires (IsCallableR<Dim3, DTOS, Dim3>::value && IsFabProjection<Proj, FAB>::value)
321void
322unpack_recv_buffer_gpu (FabArray<FAB>& mf, int scomp, int ncomp,
323 Vector<char*> const& recv_data,
324 Vector<std::size_t> const& recv_size,
325 Vector<FabArrayBase::CopyComTagsContainer const*> const& recv_cctc,
326 DTOS const& dtos, Proj const& proj)
327{
328 amrex::ignore_unused(recv_size);
329
330 const int N_rcvs = recv_cctc.size();
331 if (N_rcvs == 0) { return; }
332
333 char* pbuffer = recv_data[0];
334#if 0
335 std::size_t szbuffer = 0;
336 // For linear solver test on summit, this is slower than writing to
337 // pinned memory directly on device.
338 if (not ParallelDescriptor::UseGpuAwareMpi()) {
339 // Memory in recv_data is pinned.
340 szbuffer = (recv_data[N_rcvs-1]-recv_data[0]) + recv_size[N_rcvs-1];
341 pbuffer = (char*)The_Arena()->alloc(szbuffer);
342 Gpu::copyAsync(Gpu::hostToDevice,recv_data[0],recv_data[0]+szbuffer,pbuffer);
343 Gpu::streamSynchronize();
344 }
345#endif
346
347 using T = typename FAB::value_type;
348 using TagType = Array4Array4Box<T>;
349 Vector<TagType> tags;
350 tags.reserve(N_rcvs);
351
352 for (int k = 0; k < N_rcvs; ++k)
353 {
354 std::ptrdiff_t offset = recv_data[k]-recv_data[0];
355 const char* dptr = pbuffer + offset;
356 auto const& cctc = *recv_cctc[k];
357 for (auto const& tag : cctc)
358 {
359 tags.emplace_back(TagType{mf.array(tag.dstIndex),
360 amrex::makeArray4((T const*)dptr, tag.sbox, ncomp),
361 tag.dbox});
362 dptr += tag.dbox.numPts() * ncomp * sizeof(T);
363 BL_ASSERT(dptr <= pbuffer + offset + recv_size[k]);
364 }
365 }
366
367 ParallelFor(tags, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n,
368 Array4Array4Box<T> const& tag) noexcept
369 {
370 Dim3 const di{.x = i, .y = j, .z = k};
371 auto const si = dtos(di);
372 tag.dfab(i,j,k,scomp+n) = detail::call_projection(proj, tag.sfab, si, n, di);
373 });
374
375 Gpu::streamSynchronize(); // recv buffer is freed by the caller
376
377 if (pbuffer != recv_data[0]) {
378 The_Arena()->free(pbuffer);
379 }
380}
381#endif
382
383template <typename DTOS>
384requires (IsIndexMapping<DTOS>::value)
385MultiBlockCommMetaData::MultiBlockCommMetaData (const FabArrayBase& dst, const Box& dstbox, const FabArrayBase& src,
386 const IntVect& ngrow, DTOS const& dtos)
387 : MultiBlockCommMetaData(dst.boxArray(), dst.DistributionMap(), dstbox, src.boxArray(),
388 src.DistributionMap(), ngrow, dtos) {}
389
390template <typename DTOS>
391requires (IsIndexMapping<DTOS>::value)
392MultiBlockCommMetaData::MultiBlockCommMetaData (const BoxArray& dstba, const DistributionMapping& dstdm,
393 const Box& dstbox, const BoxArray& srcba,
394 const DistributionMapping& srcdm, const IntVect& ngrow, DTOS const& dtos)
395{
396 define(dstba, dstdm, dstbox, srcba, srcdm, ngrow, dtos);
397}
398
400namespace detail {
401 // Sort the tags of each process by source and destination box.
402 void sort_tags (FabArrayBase::MapOfCopyComTagContainers& tags);
403
404 // Send tags of MultiBlockCommMetaData for a monotone index mapping, from
405 // the source boxes this process owns. The destination boxes are found
406 // with the inverse image of the source box. Not part of define, which
407 // must stay small to be optimized well.
408 template <typename DTOS>
409 void multiblock_send_tags (FabArrayBase::MapOfCopyComTagContainers& snd_tags,
410 const BoxArray& dstba, const DistributionMapping& dstdm, const Box& dstbox,
411 const BoxArray& srcba, const DistributionMapping& srcdm, const IntVect& ngrow,
412 DTOS const& dtos)
413 {
414 const int myproc = ParallelDescriptor::MyProc();
415 auto const& dst_owners = dstdm.ProcessorMap();
416 if (std::all_of(dst_owners.begin(), dst_owners.end(), [=] (int p) { return p == myproc; })) {
417 return; // nothing to send
418 }
419 std::vector<std::pair<int, Box>> isects;
420 for (int k = 0, N = static_cast<int>(srcba.size()); k < N; ++k) {
421 if (srcdm[k] != myproc) {
422 continue;
423 }
424 const Box src_gbox = grow(srcba[k], ngrow);
425 const Box src_gbox_mapped_in_dst = InverseImage(dtos, src_gbox).setType(dstba.ixType()) & dstbox;
426 if (src_gbox_mapped_in_dst.isEmpty()) {
427 continue;
428 }
429 dstba.intersections(src_gbox_mapped_in_dst, isects, false, ngrow);
430 for (auto const& isect : isects) {
431 const int i = isect.first;
432 const int dest_owner = dstdm[i];
433 if (dest_owner == myproc) {
434 continue;
435 }
436 const Box partial_dstbox = grow(dstba[i], ngrow) & dstbox;
437 const Box src_box = Image(dtos, partial_dstbox).setType(srcba.ixType()) & src_gbox;
438 if (src_box.ok()) {
439 const Box inverse_image = InverseImage(dtos, src_box).setType(dstba.ixType());
440 if ((inverse_image & partial_dstbox).ok()) {
441 snd_tags[dest_owner].emplace_back(inverse_image, src_box, i, k);
442 }
443 }
444 }
445 }
446 }
447}
449
450template <typename DTOS>
451requires (IsIndexMapping<DTOS>::value)
452void
453MultiBlockCommMetaData::define (const BoxArray& dstba, const DistributionMapping& dstdm, const Box& dstbox,
454 const BoxArray& srcba, const DistributionMapping& srcdm, const IntVect& ngrow,
455 DTOS const& dtos)
456{
457 m_LocTags = std::make_unique<FabArrayBase::CopyComTagsContainer>();
458 m_SndTags = std::make_unique<FabArrayBase::MapOfCopyComTagContainers>();
459 m_RcvTags = std::make_unique<FabArrayBase::MapOfCopyComTagContainers>();
460 const int myproc = ParallelDescriptor::MyProc();
461 // For a monotone index mapping, a process loops over its own destination
462 // boxes only, and finds its send tags from its own source boxes below.
463 constexpr bool own_boxes_only = IsMonotoneIndexMapping<DTOS>::value;
464 for (int i = 0, N = static_cast<int>(dstba.size()); i < N; ++i) {
465 const int dest_owner = dstdm[i];
466 if (own_boxes_only && dest_owner != myproc) {
467 continue;
468 }
469 const Box partial_dstbox = grow(dstba[i], ngrow) & dstbox;
470 if (partial_dstbox.isEmpty()) {
471 continue;
472 }
473 const Box partial_dstbox_mapped_in_src = Image(dtos, partial_dstbox).setType(srcba.ixType());
474 enum { not_first_only = 0, first_only = 1 };
475 std::vector<std::pair<int, Box>> boxes_from_src =
476 srcba.intersections(partial_dstbox_mapped_in_src, not_first_only, ngrow);
477 for (std::pair<int, Box> counted_box : boxes_from_src) {
478 const int k = counted_box.first;
479 const Box src_box = counted_box.second;
480 AMREX_ASSERT(k < srcba.size());
481 const int src_owner = srcdm[k];
482 if (dest_owner == myproc || src_owner == myproc) {
483 if (src_owner == dest_owner) {
484 const BoxList tilelist(src_box, FabArrayBase::comm_tile_size);
485 for (const Box& tilebox : tilelist) {
486 const Box inverse_image = InverseImage(dtos, tilebox).setType(dstba.ixType());
487 if ((inverse_image & partial_dstbox).ok()) {
488 m_LocTags->emplace_back(inverse_image, tilebox, i, k);
489 }
490 }
491 } else {
492 const Box inverse_image = InverseImage(dtos, src_box).setType(dstba.ixType());
493 if ((inverse_image & partial_dstbox).ok()) {
494 FabArrayBase::CopyComTagsContainer& copy_tags =
495 (src_owner == myproc) ? (*m_SndTags)[dest_owner]
496 : (*m_RcvTags)[src_owner];
497 copy_tags.emplace_back(inverse_image, src_box, i, k);
498 }
499 }
500 }
501 }
502 }
503
504 if constexpr (IsMonotoneIndexMapping<DTOS>::value) {
505 detail::multiblock_send_tags(*m_SndTags, dstba, dstdm, dstbox, srcba, srcdm, ngrow, dtos);
506 // Send and receive tags are found in different orders.
507 detail::sort_tags(*m_SndTags);
508 detail::sort_tags(*m_RcvTags);
509 }
510}
511
512template <BaseFabType FAB, class DTOS, class Proj>
513#ifdef AMREX_USE_MPI
514[[nodiscard]]
515#endif
516CommHandler
517Comm_nowait (FabArray<FAB>& mf, int scomp, int ncomp, FabArrayBase::CommMetaData const& cmd,
518 DTOS const& dtos, Proj const& proj)
519{
520 // Received data is indexed from 0, but local data from scomp.
521 AMREX_ALWAYS_ASSERT_WITH_MESSAGE((std::is_same_v<Proj,Identity>) ||
522 (std::is_same_v<Proj,MapComponents<Identity>>) || scomp == 0,
523 "NonLocalBC: scomp must be 0 unless the projection is Identity");
524
525#ifdef AMREX_USE_MPI
526 if (ParallelContext::NProcsSub() == 1)
527#endif
528 {
529 if (cmd.m_LocTags->empty()) { return CommHandler{}; }
530#ifdef AMREX_USE_GPU
531 if (Gpu::inLaunchRegion()) {
532 local_copy_gpu(mf, mf, scomp, scomp, ncomp, *cmd.m_LocTags, dtos, proj);
533 } else
534#endif
535 {
536 local_copy_cpu(mf, mf, scomp, scomp, ncomp, *cmd.m_LocTags, dtos, proj);
537 }
538 return CommHandler{};
539 }
540
541#ifdef AMREX_USE_MPI
542 //
543 // Do this before prematurely exiting if running in parallel.
544 // Otherwise sequence numbers will not match across MPI processes.
545 //
546 int SeqNum = ParallelDescriptor::SeqNum();
547
548 const auto N_locs = cmd.m_LocTags->size();
549 const auto N_rcvs = cmd.m_RcvTags->size();
550 const auto N_snds = cmd.m_SndTags->size();
551
552 if (N_locs == 0 && N_rcvs == 0 && N_snds == 0) {
553 // No work to do.
554 return CommHandler{};
555 }
556
557 CommHandler handler{};
558 handler.mpi_tag = SeqNum;
559
560 if (N_rcvs > 0) {
561 handler.recv.the_data = FabArray<FAB>::PostRcvs(*cmd.m_RcvTags, handler.recv.data, handler.recv.size,
562 handler.recv.rank, handler.recv.request, ncomp, SeqNum);
563 }
564
565 if (N_snds > 0) {
566 handler.send.the_data =
567 FabArray<FAB>::PrepareSendBuffers(*cmd.m_SndTags, handler.send.data, handler.send.size,
568 handler.send.rank, handler.send.request, handler.send.cctc, ncomp);
569 handler.send.id = FabArrayBase::getNextCommMetaDataId();
570
571#ifdef AMREX_USE_GPU
572 if (Gpu::inLaunchRegion()) {
573 FabArray<FAB>::pack_send_buffer_gpu(mf, scomp, ncomp, handler.send.data,
574 handler.send.size, handler.send.cctc, handler.send.id);
575 } else
576#endif
577 {
578 FabArray<FAB>::pack_send_buffer_cpu(mf, scomp, ncomp, handler.send.data,
579 handler.send.size, handler.send.cctc);
580 }
581
582 FabArray<FAB>::PostSnds(handler.send.data, handler.send.size, handler.send.rank, handler.send.request, SeqNum);
583 }
584
585 if (N_locs > 0)
586 {
587#ifdef AMREX_USE_GPU
588 if (Gpu::inLaunchRegion()) {
589 local_copy_gpu(mf, mf, scomp, scomp, ncomp, *cmd.m_LocTags, dtos, proj);
590 } else
591#endif
592 {
593 local_copy_cpu(mf, mf, scomp, scomp, ncomp, *cmd.m_LocTags, dtos, proj);
594 }
595 }
596
597 return handler;
598#endif
599}
600
601#ifdef AMREX_USE_MPI
602template <BaseFabType FAB, class DTOS, class Proj>
603void
604Comm_finish (FabArray<FAB>& mf, int scomp, int ncomp, FabArrayBase::CommMetaData const& cmd,
605 CommHandler handler, DTOS const& dtos, Proj const& proj)
606{
607 if (ParallelContext::NProcsSub() == 1) { return; }
608
609 const auto N_rcvs = static_cast<int>(cmd.m_RcvTags->size());
610 if (N_rcvs > 0)
611 {
612 handler.recv.cctc.resize(N_rcvs, nullptr);
613 for (int k = 0; k < N_rcvs; ++k) {
614 auto const& cctc = cmd.m_RcvTags->at(handler.recv.rank[k]);
615 handler.recv.cctc[k] = &cctc;
616 }
617 handler.recv.stats.resize(handler.recv.request.size());
618 ParallelDescriptor::Waitall(handler.recv.request, handler.recv.stats);
619#ifdef AMREX_DEBUG
620 if (!CheckRcvStats(handler.recv.stats, handler.recv.size, handler.mpi_tag)) {
621 amrex::Abort("NonLocalBC::Comm_finish failed with wrong message size");
622 }
623#endif
624
625#ifdef AMREX_USE_GPU
626 if (Gpu::inLaunchRegion())
627 {
628 unpack_recv_buffer_gpu(mf, scomp, ncomp, handler.recv.data,
629 handler.recv.size, handler.recv.cctc, dtos, proj);
630 } else
631#endif
632 {
633 unpack_recv_buffer_cpu(mf, scomp, ncomp, handler.recv.data,
634 handler.recv.size, handler.recv.cctc, dtos, proj);
635 }
636 }
637
638 if ( ! cmd.m_SndTags->empty() ) {
639 handler.send.stats.resize(handler.send.request.size());
640 ParallelDescriptor::Waitall(handler.send.request, handler.send.stats);
641 }
642}
643#endif
644
645template <BaseFabType FAB>
646void
647Rotate90 (FabArray<FAB>& mf, int scomp, int ncomp, IntVect const& nghost, Box const& domain)
648{
649 BL_PROFILE("Rotate90");
650
651 AMREX_ASSERT(domain.cellCentered());
652 AMREX_ASSERT(domain.smallEnd() == 0);
653 AMREX_ASSERT(domain.length(0) == domain.length(1));
654 AMREX_ASSERT(mf.is_cell_centered());
655 AMREX_ASSERT(scomp < mf.nComp() && scomp+ncomp <= mf.nComp());
656 AMREX_ASSERT(nghost.allLE(mf.nGrowVect()) && nghost[0] == nghost[1]);
657
658 if (nghost[0] <= 0) { return; }
659
660 const FabArrayBase::RB90& TheRB90 = mf.getRB90(nghost, domain);
661
662 auto handler = Comm_nowait(mf, scomp, ncomp, TheRB90,Rotate90DstToSrc{},
663 Identity{});
664
665#ifdef AMREX_USE_MPI
666 Comm_finish(mf, scomp, ncomp, TheRB90, std::move(handler), Rotate90DstToSrc{},
667 Identity{});
668#else
669 amrex::ignore_unused(handler);
670#endif
671}
672
673template <BaseFabType FAB>
674void
675Rotate90 (FabArray<FAB>& mf, Box const& domain)
676{
677 Rotate90(mf, 0, mf.nComp(), mf.nGrowVect(), domain);
678}
679
680template <BaseFabType FAB>
681void
682Rotate180 (FabArray<FAB>& mf, int scomp, int ncomp, IntVect const& nghost, Box const& domain)
683{
684 BL_PROFILE("Rotate180");
685
686 AMREX_ASSERT(domain.cellCentered());
687 AMREX_ASSERT(domain.smallEnd() == 0);
688 AMREX_ASSERT(domain.length(1) % 2 == 0);
689 AMREX_ASSERT(mf.is_cell_centered());
690 AMREX_ASSERT(scomp < mf.nComp() && scomp+ncomp <= mf.nComp());
691 AMREX_ASSERT(nghost.allLE(mf.nGrowVect()));
692
693 if (nghost[0] <= 0) { return; }
694
695 const FabArrayBase::RB180& TheRB180 = mf.getRB180(nghost, domain);
696
697 auto handler = Comm_nowait(mf, scomp, ncomp, TheRB180,
698 Rotate180Fn{domain.length(1)}, Identity{});
699
700#ifdef AMREX_USE_MPI
701 Comm_finish(mf, scomp, ncomp, TheRB180, std::move(handler),
702 Rotate180Fn{domain.length(1)}, Identity{});
703#else
704 amrex::ignore_unused(handler);
705#endif
706}
707
708template <BaseFabType FAB>
709void
710Rotate180 (FabArray<FAB>& mf, Box const& domain)
711{
712 Rotate180(mf, 0, mf.nComp(), mf.nGrowVect(), domain);
713}
714
715template <BaseFabType FAB>
716void
717FillPolar (FabArray<FAB>& mf, int scomp, int ncomp, IntVect const& nghost, Box const& domain)
718{
719 BL_PROFILE("FillPolar");
720
721 AMREX_ASSERT(domain.cellCentered());
722 AMREX_ASSERT(domain.smallEnd() == 0);
723 AMREX_ASSERT(domain.length(1) % 2 == 0);
724 AMREX_ASSERT(mf.is_cell_centered());
725 AMREX_ASSERT(scomp < mf.nComp() && scomp+ncomp <= mf.nComp());
726 AMREX_ASSERT(nghost.allLE(mf.nGrowVect()));
727
728 if (nghost[0] <= 0) { return; }
729
730 const FabArrayBase::PolarB& ThePolarB = mf.getPolarB(nghost, domain);
731
732 auto handler = Comm_nowait(mf, scomp, ncomp, ThePolarB,
733 PolarFn{.Lx = domain.length(0), .Ly = domain.length(1)},
734 Identity{});
735
736#ifdef AMREX_USE_MPI
737 Comm_finish(mf, scomp, ncomp, ThePolarB, std::move(handler),
738 PolarFn{.Lx = domain.length(0), .Ly = domain.length(1)}, Identity{});
739#else
740 amrex::ignore_unused(handler);
741#endif
742}
743
744template <BaseFabType FAB>
745void
746FillPolar (FabArray<FAB>& mf, Box const& domain)
747{
748 FillPolar(mf, 0, mf.nComp(), mf.nGrowVect(), domain);
749}
750
751template <BaseFabType FAB, typename DTOS, typename Proj>
752requires (IsCallableR<Dim3,DTOS,Dim3>::value && IsFabProjection<Proj,FAB>::value)
753CommHandler
754FillBoundary_nowait (FabArray<FAB>& mf, const FabArrayBase::CommMetaData& cmd,
755 int scomp, int ncomp, DTOS const& dtos, Proj const& proj)
756{
757 BL_PROFILE("FillBoundary_nowait(cmd)");
758 AMREX_ASSERT(scomp < mf.nComp() && scomp+ncomp <= mf.nComp());
759 return Comm_nowait(mf, scomp, ncomp, cmd, dtos, proj);
760}
761
762template <BaseFabType FAB, typename DTOS, typename Proj>
763requires (IsCallableR<Dim3,DTOS,Dim3>::value && IsFabProjection<Proj,FAB>::value)
764void
765FillBoundary_finish (CommHandler handler,
766 FabArray<FAB>& mf, const FabArrayBase::CommMetaData& cmd,
767 int scomp, int ncomp, DTOS const& dtos, Proj const& proj)
768{
769#ifdef AMREX_USE_MPI
770 BL_PROFILE("FillBoundary_finish(cmd)");
771 Comm_finish(mf, scomp, ncomp, cmd, std::move(handler), dtos, proj);
772#else
773 amrex::ignore_unused(handler,mf,cmd,scomp,ncomp,dtos,proj);
774#endif
775}
776
777template <typename DTOS>
778Vector<std::pair<Box,Box>>
779get_src_dst_boxes (DTOS const& dtos, Box const& dstbox, Box const& domain)
780{
781 Vector<std::pair<Box,Box>> r;
782 IntVect mapped_smallend(dtos(amrex::lbound(dstbox)));
783 IntVect mapped_bigend (dtos(amrex::ubound(dstbox)));
784 if (!domain.contains(mapped_smallend) || !domain.contains(mapped_bigend)) {
785 return r;
786 }
787
788 auto sign = dtos.sign(amrex::lbound(dstbox));
789 auto perm = dtos.permutation(amrex::lbound(dstbox));
790 auto dtype = dstbox.type();
791 IntVect stype{AMREX_D_DECL(dtype[perm[0]],
792 dtype[perm[1]],
793 dtype[perm[2]])};
794 Array<Array<std::pair<int,int>,2>,AMREX_SPACEDIM> ends;
795 Array<Array<std::pair<int,int>,2>,AMREX_SPACEDIM> dst_ends;
796 Array<int,AMREX_SPACEDIM> nboxes;
797 for (int ddim = 0; ddim < AMREX_SPACEDIM; ++ddim) {
798 int sdim = perm[ddim];
799 auto mm = std::minmax(mapped_smallend[sdim],mapped_bigend[sdim]);
800 if (((sign[ddim] > 0) && (mapped_smallend[sdim] <= mapped_bigend[sdim])) ||
801 ((sign[ddim] < 0) && (mapped_bigend[sdim] <= mapped_smallend[sdim])))
802 {
803 nboxes[sdim] = 1;
804 ends[sdim][0] = mm;
805 dst_ends[ddim][0] = std::make_pair(dstbox.smallEnd(ddim),
806 dstbox.bigEnd(ddim));
807 } else {
808 nboxes[sdim] = 2;
809 ends[sdim][0].first = domain.smallEnd(sdim);
810 ends[sdim][0].second = mm.first;
811 ends[sdim][1].first = mm.second;
812 ends[sdim][1].second = domain.bigEnd(sdim);
813 int n0 = ends[sdim][0].second - ends[sdim][0].first;
814 int n1 = ends[sdim][1].second - ends[sdim][1].first;
815 if (mm.first == mapped_smallend[sdim]) {
816 dst_ends[ddim][0] = std::make_pair(dstbox.smallEnd(ddim),
817 dstbox.smallEnd(ddim)+n0);
818 dst_ends[ddim][1] = std::make_pair(dstbox.bigEnd(ddim)-n1,
819 dstbox.bigEnd(ddim));
820 } else {
821 dst_ends[ddim][0] = std::make_pair(dstbox.bigEnd(ddim)-n0,
822 dstbox.bigEnd(ddim));
823 dst_ends[ddim][1] = std::make_pair(dstbox.smallEnd(ddim),
824 dstbox.smallEnd(ddim)+n1);
825 }
826 }
827 }
828
829 r.reserve(AMREX_D_TERM(nboxes[0],*nboxes[1],*nboxes[2]));
830
831#if (AMREX_SPACEDIM == 3)
832 for (int kbox = 0; kbox < nboxes[2]; ++kbox) {
833#endif
834#if (AMREX_SPACEDIM >=2 )
835 for (int jbox = 0; jbox < nboxes[1]; ++jbox) {
836#endif
837 for (int ibox = 0; ibox < nboxes[0]; ++ibox)
838 {
839 IntVect siv(AMREX_D_DECL(ibox,jbox,kbox));
840 IntVect div(AMREX_D_DECL(siv[perm[0]],siv[perm[1]],siv[perm[2]]));
841 r.emplace_back(Box(IntVect(AMREX_D_DECL(ends[0][ibox].first,
842 ends[1][jbox].first,
843 ends[2][kbox].first)),
844 IntVect(AMREX_D_DECL(ends[0][ibox].second,
845 ends[1][jbox].second,
846 ends[2][kbox].second)),
847 stype),
848 Box(IntVect(AMREX_D_DECL(dst_ends[0][div[0]].first,
849 dst_ends[1][div[1]].first,
850 dst_ends[2][div[2]].first)),
851 IntVect(AMREX_D_DECL(dst_ends[0][div[0]].second,
852 dst_ends[1][div[1]].second,
853 dst_ends[2][div[2]].second)),
854 dtype));
855 AMREX_D_TERM(},},})
856
857 return r;
858}
859
860template <typename DTOS>
861Box get_dst_subbox (DTOS const& dtos, std::pair<Box,Box> const& sdboxes,
862 Box const& srcsubbox)
863{
864 Box const& srcbox = sdboxes.first;
865 Box const& dstbox = sdboxes.second;
866 if (srcbox == srcsubbox) {
867 return dstbox;
868 } else {
869 auto sign = dtos.sign(amrex::lbound(dstbox));
870 auto perm = dtos.permutation(amrex::lbound(dstbox));
871 Box dstsubbox = dstbox;
872 for (int ddim = 0; ddim < AMREX_SPACEDIM; ++ddim) {
873 int sdim = perm[ddim];
874 if (sign[ddim] > 0) {
875 dstsubbox.growLo(ddim, srcbox.smallEnd(sdim)-srcsubbox.smallEnd(sdim));
876 dstsubbox.growHi(ddim, srcsubbox.bigEnd(sdim)-srcbox.bigEnd(sdim));
877 } else {
878 dstsubbox.growLo(ddim, srcsubbox.bigEnd(sdim)-srcbox.bigEnd(sdim));
879 dstsubbox.growHi(ddim, srcbox.smallEnd(sdim)-srcsubbox.smallEnd(sdim));
880 }
881 }
882 return dstsubbox;
883 }
884}
885
887namespace detail {
888 void split_boxes (BoxList& bl, Box const& domain);
889}
891
892template <BaseFabType FAB, typename DTOS>
893requires (IsCallableR<Dim3,DTOS,Dim3>::value)
894FabArrayBase::CommMetaData
895makeFillBoundaryMetaData (FabArray<FAB>& mf, IntVect const& nghost,
896 Geometry const& geom, DTOS const& dtos)
897{
898 FabArrayBase::CommMetaData cmd;
899 cmd.m_LocTags = std::make_unique<FabArrayBase::CopyComTagsContainer>();
900 cmd.m_SndTags = std::make_unique<FabArrayBase::MapOfCopyComTagContainers>();
901 cmd.m_RcvTags = std::make_unique<FabArrayBase::MapOfCopyComTagContainers>();
902
903 // Normal FillBoundary part
904 mf.define_fb_metadata(cmd, nghost, false, geom.periodicity(), false);
905
906 BoxArray const& ba = mf.boxArray();
907 DistributionMapping const& dm = mf.DistributionMap();
908 Box dombox = amrex::convert(geom.Domain(), ba.ixType());
909 Box pdombox = amrex::convert(geom.growPeriodicDomain(nghost), ba.ixType());
910
911 const int myproc = ParallelDescriptor::MyProc();
912 const auto nboxes = static_cast<int>(ba.size());
913 std::vector<std::pair<int,Box> > isects;
914
915 for (int i = 0; i < nboxes; ++i) {
916 Box const& gbx = amrex::grow(ba[i], nghost);
917 BoxList bl = amrex::boxDiff(gbx, pdombox);
918 if (bl.isEmpty()) { continue; }
919
920 detail::split_boxes(bl, dombox);
921
922 const int dst_owner = dm[i];
923 for (auto const& dst_box : bl) {
924 auto const& src_dst_boxes = get_src_dst_boxes(dtos, dst_box, dombox);
925 for (auto const& sd_box_pair : src_dst_boxes) {
926 ba.intersections(sd_box_pair.first, isects);
927 for (auto const& is : isects) {
928 int const k = is.first;
929 Box const src_b = is.second;
930 int const src_owner = dm[k];
931 if (dst_owner == myproc || src_owner == myproc) {
932 Box const& dst_b = get_dst_subbox(dtos, sd_box_pair, src_b);
933 if (src_owner == dst_owner) {
934 cmd.m_LocTags->emplace_back(dst_b, src_b, i, k);
935 } else {
936 auto& tags = (dst_owner == myproc) ?
937 (*cmd.m_RcvTags)[src_owner] :
938 (*cmd.m_SndTags)[dst_owner];
939 tags.emplace_back(dst_b, src_b, i, k);
940 }
941 }
942 }
943 }
944 }
945 }
946
947 return cmd;
948}
949
950struct SphThetaPhiRIndexMapping
951{
952 SphThetaPhiRIndexMapping (Box const& a_domain)
953 : nx(a_domain.length(0)),
954 ny(a_domain.length(1)),
955 nz(a_domain.length(2))
956 {
957 AMREX_ASSERT(a_domain.smallEnd() == 0);
958 }
959
960 [[nodiscard]] AMREX_GPU_HOST_DEVICE
961 Dim3 operator() (Dim3 const& ijk) const noexcept
962 {
963 const int i = ijk.x;
964 const int j = ijk.y;
965 const int k = ijk.z;
966 bool ilo = i < 0;
967 bool ihi = i >= nx;
968 bool imd = i >= 0 && i < nx;
969 bool jlo = j < 0;
970 bool jhi = j >= ny;
971 bool jmd = j >= 0 && j < ny;
972 bool klo = k < 0;
973 bool kmd = k >= 0 && k < nz;
974 // We do not need to do anything at the theta-lo/r-lo edge,
975 // theta-hi/r-lo edge, and r > r-hi.
976 if (ilo && jmd && kmd)
977 {
978 return Dim3{.x = -1-i, .y = (j+ny/2)%ny, .z = k};
979 }
980 else if (ihi && jmd && kmd)
981 {
982 return Dim3{.x = 2*nx-1-i, .y = (j+ny/2)%ny, .z = k};
983 }
984 else if (imd && jlo && kmd)
985 {
986 return Dim3{.x = i, .y = j+ny, .z = k};
987 }
988 else if (imd && jhi && kmd)
989 {
990 return Dim3{.x = i, .y = j-ny, .z = k};
991 }
992 else if (imd && jmd && klo)
993 {
994 return Dim3{.x = nx-1-i, .y = (j+ny/2)%ny, .z = -1-k};
995 }
996 else if (ilo && jlo && kmd)
997 {
998 return Dim3{.x = -1-i, .y = (j+ny/2)%ny, .z = k};
999 }
1000 else if (ihi && jlo && kmd)
1001 {
1002 return Dim3{.x = 2*nx-1-i, .y = (j+ny/2)%ny, .z = k};
1003 }
1004 else if (ilo && jhi && kmd)
1005 {
1006 return Dim3{.x = -1-i, .y = (j+ny/2)%ny, .z = k};
1007 }
1008 else if (ihi && jhi && kmd)
1009 {
1010 return Dim3{.x = 2*nx-1-i, .y = (j+ny/2)%ny, .z = k};
1011 }
1012 else if (imd && jlo && klo)
1013 {
1014 return Dim3{.x = nx-1-i, .y = (j+ny/2)%ny, .z = -1-k};
1015 }
1016 else if (imd && jhi && klo)
1017 {
1018 return Dim3{.x = nx-1-i, .y = (j+ny/2)%ny, .z = -1-k};
1019 }
1020 else
1021 {
1022 return ijk;
1023 }
1024 }
1025
1026 [[nodiscard]] IntVect sign (Dim3 const& ijk) const noexcept
1027 {
1028 if (ijk.z < 0) {
1029 return IntVect{AMREX_D_DECL(-1, 1,-1)};
1030 } else if (ijk.z >=0 && ijk.z < nz &&
1031 (ijk.x < 0 || ijk.x >= nx)) {
1032 return IntVect{AMREX_D_DECL(-1, 1, 1)};
1033 } else {
1034 return IntVect{AMREX_D_DECL( 1, 1, 1)};
1035 }
1036 }
1037
1038 [[nodiscard]] IntVect permutation (Dim3 const& /*ijk*/) const noexcept // NOLINT(readability-convert-member-functions-to-static)
1039 {
1040 return IntVect(AMREX_D_DECL(0,1,2));
1041 }
1042
1043private:
1044 int nx, ny, nz;
1045};
1046
1056struct SphThetaPhiRComponentMapping
1057{
1058 SphThetaPhiRComponentMapping (Box const& a_domain, int a_start_index)
1059 : nx(a_domain.length(0)),
1060 scomp(a_start_index)
1061 {
1062 AMREX_ASSERT(a_domain.smallEnd() == 0);
1063 }
1064
1065 template <typename T>
1066 [[nodiscard]] AMREX_GPU_HOST_DEVICE
1067 T operator() (Array4<const T> const& a, Dim3 const& src, int n, Dim3 const& dst) const noexcept
1068 {
1069 T const r = a(src.x, src.y, src.z, n);
1070 bool const origin = (dst.z < 0);
1071 bool const pole = (dst.x < 0) || (dst.x >= nx);
1072 if ((n == scomp) && (origin || pole)) {
1073 return -r;
1074 } else if ((n == scomp+2) && origin) {
1075 return -r;
1076 } else {
1077 return r;
1078 }
1079 }
1080private:
1081 int nx;
1082 int scomp;
1083};
1084
1085extern template MultiBlockCommMetaData ParallelCopy(FabArray<FArrayBox>& dest, const Box& destbox,
1086 const FabArray<FArrayBox>& src, int destcomp,
1087 int srccomp, int numcomp, const IntVect& ngrow,
1088 MultiBlockIndexMapping const&, Identity const&);
1089}
1090
1091#endif
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:593
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:123
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
while parser_exe_t p
Definition AMReX_Parser_Exe_Body.H:33
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
virtual void free(void *pt)=0
Free a previously allocated block pointed to by pt.
virtual void * alloc(std::size_t sz)=0
Allocate sz bytes from this arena.
__host__ __device__ BoxND & setType(const IndexTypeND< dim > &t) noexcept
Set indexing type.
Definition AMReX_Box.H:534
CopyComTag::CopyComTagsContainer CopyComTagsContainer
Definition AMReX_FabArrayBase.H:236
__host__ __device__ Dim3 ubound(Array4< T > const &a) noexcept
Return the inclusive upper bounds of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1377
__host__ __device__ Dim3 length(Array4< T > const &a) noexcept
Return the spatial extents of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1391
__host__ __device__ Dim3 lbound(Array4< T > const &a) noexcept
Return the inclusive lower bounds of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1363
__host__ __device__ BoxND< dim > convert(const BoxND< dim > &b, const IntVectND< dim > &typ) noexcept
Return a copy of b converted to the nodal flags typ.
Definition AMReX_Box.H:1632
__host__ __device__ BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Return a copy of b grown uniformly by i cells in every direction.
Definition AMReX_Box.H:1328
Arena * The_Arena()
Definition AMReX_Arena.cpp:839
Definition AMReX_NonLocalBC.cpp:53
void Rotate90(FabArray< FAB > &mf, int scomp, int ncomp, IntVect const &nghost, Box const &domain)
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
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 Rotate180(FabArray< FAB > &mf, int scomp, int ncomp, IntVect const &nghost, Box const &domain)
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 FillPolar(FabArray< FAB > &mf, int scomp, int ncomp, IntVect const &nghost, Box const &domain)
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
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
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{})
int SeqNum() noexcept
Returns sequential message sequence numbers, usually used as tags for send/recv.
Definition AMReX_ParallelDescriptor.H:678
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:273
__host__ __device__ Array4< T > makeArray4(T *p, Box const &bx, int ncomp) noexcept
Definition AMReX_BaseFab.H:137
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
BoxList boxDiff(const Box &b1in, const Box &b2)
Returns a BoxList defining the complement of b2 in b1in.
Definition AMReX_BoxList.cpp:621
void ParallelCopy(MF &dst, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &ng_src=IntVect(0), IntVect const &ng_dst=IntVect(0), Periodicity const &period=Periodicity::NonPeriodic())
dst = src w/ MPI communication
Definition AMReX_FabArrayUtility.H:2264
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
void LoopConcurrentOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition AMReX_Loop.H:388
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:239
This type trait tests if a type P is a projection for FAB.
Definition AMReX_NonLocalBC.H:301