Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_FACopyDescriptor.H
Go to the documentation of this file.
1
2#ifndef BL_FACOPYDESCRIPTOR_H_
3#define BL_FACOPYDESCRIPTOR_H_
4#include <AMReX_Config.H>
5
6#include <AMReX_FabArray.H>
7#include <string>
8
9namespace amrex {
10
15
17
19{
20 public:
21
22 FillBoxId () = default;
23
24 FillBoxId (int newid, const Box& fillbox)
25 :
26 m_fillBox(fillbox),
27 m_fillBoxId(newid)
28 {}
29
30 [[nodiscard]] int Id () const { return m_fillBoxId; }
31 [[nodiscard]] int FabIndex () const { return m_fabIndex; }
32 void FabIndex (int fabindex) { m_fabIndex = fabindex; }
33 [[nodiscard]] const Box& box () const { return m_fillBox; }
34
35private:
36
37 Box m_fillBox;
38 int m_fillBoxId{-1};
39 int m_fabIndex{-1};
40};
41
43{
44public:
45
46 explicit FabArrayId (int newid = -1)
47 :
48 fabArrayId(newid) {}
49
50 [[nodiscard]] int Id () const { return fabArrayId; }
51
52 bool operator== (const FabArrayId& rhs) const
53 {
54 return fabArrayId == rhs.fabArrayId;
55 }
56
57private:
58
59 int fabArrayId;
60};
61
62template <class FAB>
86
87template <class FAB>
89 :
90 localFabSource(nullptr)
91
92{}
93
94template <class FAB>
96{
97 if (cacheDataAllocated) {
98 delete localFabSource;
99 }
100}
101
106template <class FAB>
108{
109 using FCDMap = std::multimap<int,FabCopyDescriptor<FAB>*>;
110
111 using FCDMapValueType = typename FCDMap::value_type;
112 using FCDMapIter = typename FCDMap::iterator;
113 using FCDMapConstIter = typename FCDMap::const_iterator;
114
115public:
116
118
120
125
127
129 const Box& destFabBox,
130 BoxList* unfilledBoxes);
131
133 const Box& destFabBox,
134 BoxList* unfilledBoxes,
135 int srccomp,
136 int destcomp,
137 int numcomp);
142 const Box& destFabBox,
143 BoxList* unfilledBoxes,
144 int fabarrayindex,
145 int srccomp,
146 int destcomp,
147 int numcomp,
148 bool bUseValidBox = true);
149
150 void CollectData ();
151
152 void FillFab (FabArrayId faid,
153 const FillBoxId& fillboxid,
154 FAB& destFab);
155
156 void FillFab (FabArrayId faid,
157 const FillBoxId& fillboxid,
158 FAB& destFab,
159 const Box& destBox);
160
161 void PrintStats () const;
162
163 [[nodiscard]] bool DataAvailable () const { return dataAvailable; }
164
165 void clear ();
166
167 [[nodiscard]] int CurrentNFabArrays () const { return fabArrays.size(); }
168
169 [[nodiscard]] int nFabComTags () const { return fabComTagList.size(); }
170
171 [[nodiscard]] int nFabCopyDescs () const { return fabCopyDescList.size(); }
172
173private:
177 void AddBoxDoIt (FabArrayId fabarrayid,
178 const Box& destFabBox,
179 BoxList* returnedUnfilledBoxes,
180 int faindex,
181 int srccomp,
182 int destcomp,
183 int numcomp,
184 bool bUseValidBox,
185 BoxDomain& unfilledBoxDomain);
189 using FabComTagContainer = std::vector<FabArrayBase::FabComTag>;
190
191 using FabComTagIterContainer = std::vector<FabComTagContainer::const_iterator>;
195 std::vector<FabArray<FAB>*> fabArrays;
196 std::vector<FCDMap> fabCopyDescList;
197 FabComTagContainer fabComTagList;
198 int nextFillBoxId{0};
199 bool dataAvailable{false};
200};
201
202template <class FAB>
203FabArrayId
205{
206 BL_ASSERT(fabArrays.size() == fabCopyDescList.size());
207
208 FabArrayId result(fabArrays.size());
209
210 fabArrays.push_back(fabarray); /* Bump size() by one */
211
212 fabCopyDescList.push_back(FCDMap());
213
214 return result;
215}
216
217template <class FAB>
218void
220 const Box& destFabBox,
221 BoxList* returnedUnfilledBoxes,
222 int faindex,
223 int srccomp,
224 int destcomp,
225 int numcomp,
226 bool bUseValidBox,
227 BoxDomain& unfilledBoxDomain)
228{
229 const int myProc = ParallelDescriptor::MyProc();
230
231 FabArray<FAB>* fabArray = fabArrays[fabarrayid.Id()];
232
233 BL_ASSERT(faindex >= 0 && faindex < fabArray->size());
234
235 Box intersect = destFabBox;
236
237 if (bUseValidBox)
238 {
239 intersect &= fabArray->box(faindex);
240 }
241 else
242 {
243 intersect &= fabArray->fabbox(faindex);
244 }
245
246 if (intersect.ok())
247 {
248 auto* fcd = new FabCopyDescriptor<FAB>;
249
250 int remoteProc = fabArray->DistributionMap()[faindex];
251 if(remoteProc >= ParallelDescriptor::NProcs()) {
252 amrex::Abort("Bad remoteProc: "
253 + std::to_string(ParallelDescriptor::MyProc())
254 + ":: _in AddBoxDoIt: nProcs remoteProc = "
255 + std::to_string(ParallelDescriptor::NProcs())
256 + " " + std::to_string(remoteProc) + "\n");
257 }
258 fcd->fillBoxId = nextFillBoxId;
259 fcd->subBox = intersect;
260 fcd->myProc = myProc;
261 fcd->copyFromProc = remoteProc;
262 fcd->copyFromIndex = faindex;
263 fcd->srcComp = srccomp;
264 fcd->destComp = destcomp;
265 fcd->nComp = numcomp;
266
267 if (ParallelDescriptor::sameTeam(remoteProc))
268 {
269 //
270 // Data is local.
271 //
272 fcd->fillType = FillLocally;
273 fcd->localFabSource = &(*fabArray)[faindex];
274 }
275 else
276 {
277 //
278 // Data is remote.
279 //
280 FabArrayBase::FabComTag fabComTag;
281
282 dataAvailable = false;
283 fcd->fillType = FillRemotely;
284 fcd->localFabSource = new FAB(intersect, numcomp);
285 fcd->cacheDataAllocated = true;
286 fabComTag.fabArrayId = fabarrayid.Id();
287 fabComTag.fillBoxId = nextFillBoxId;
288 fabComTag.fabIndex = faindex;
289 fabComTag.procThatNeedsData = myProc;
290 fabComTag.procThatHasData = remoteProc;
291 fabComTag.box = intersect;
292 fabComTag.srcComp = srccomp;
293 fabComTag.destComp = destcomp;
294 fabComTag.nComp = numcomp;
295 //
296 // Do not send the data yet.
297 //
298 fabComTagList.push_back(fabComTag);
299 }
300
301 fabCopyDescList[fabarrayid.Id()].insert(FCDMapValueType(fcd->fillBoxId,fcd));
302
303 if (returnedUnfilledBoxes != nullptr)
304 {
305 unfilledBoxDomain.rmBox(intersect);
306 }
307 }
308}
309
310template <class FAB>
311FillBoxId
313 const Box& destFabBox,
314 BoxList* returnedUnfilledBoxes,
315 int srccomp,
316 int destcomp,
317 int numcomp)
318{
319 BoxDomain unfilledBoxDomain(destFabBox.ixType());
320
321 if (returnedUnfilledBoxes != nullptr)
322 {
323 unfilledBoxDomain.add(destFabBox);
324 }
325
326 std::vector< std::pair<int,Box> > isects;
327
328 fabArrays[fabarrayid.Id()]->boxArray().intersections(destFabBox,isects);
329
330 for (auto & isect : isects)
331 {
332 AddBoxDoIt(fabarrayid,
333 destFabBox,
334 returnedUnfilledBoxes,
335 isect.first,
336 srccomp,
337 destcomp,
338 numcomp,
339 true,
340 unfilledBoxDomain);
341 }
342
343 if (returnedUnfilledBoxes != nullptr)
344 {
345 returnedUnfilledBoxes->clear();
346 (*returnedUnfilledBoxes) = unfilledBoxDomain.boxList();
347 }
348
349 return FillBoxId(nextFillBoxId++, destFabBox);
350}
351
352template <class FAB>
355 const Box& destFabBox,
356 BoxList* returnedUnfilledBoxes,
357 int fabarrayindex,
358 int srccomp,
359 int destcomp,
360 int numcomp,
361 bool bUseValidBox)
362{
363 BoxDomain unfilledBoxDomain(destFabBox.ixType());
364
365 if (returnedUnfilledBoxes != nullptr)
366 {
367 unfilledBoxDomain.add(destFabBox);
368 }
369
370 AddBoxDoIt(fabarrayid,
371 destFabBox,
372 returnedUnfilledBoxes,
373 fabarrayindex,
374 srccomp,
375 destcomp,
376 numcomp,
377 bUseValidBox,
378 unfilledBoxDomain);
379
380 if (returnedUnfilledBoxes != nullptr)
381 {
382 returnedUnfilledBoxes->clear();
383 (*returnedUnfilledBoxes) = unfilledBoxDomain.boxList();
384 }
385
386 return FillBoxId(nextFillBoxId++, destFabBox);
387}
388
389template <class FAB>
392 const Box& destFabBox,
393 BoxList* returnedUnfilledBoxes)
394{
395 return AddBox(fabarrayid,
396 destFabBox,
397 returnedUnfilledBoxes,
398 0,
399 0,
400 fabArrays[fabarrayid.Id()]->nComp());
401}
402
403template <class FAB>
408
409template <class FAB>
410void
412{
413 for (unsigned int i = 0, N = fabCopyDescList.size(); i < N; ++i)
414 {
415 for (auto fmi = fabCopyDescList[i].begin(), End = fabCopyDescList[i].end();
416 fmi != End;
417 ++fmi)
418 {
419 delete (*fmi).second;
420 }
421 }
422
423 fabArrays.clear();
424 fabCopyDescList.clear();
425 fabComTagList.clear();
426
427 nextFillBoxId = 0;
428 dataAvailable = false;
429}
430
431template <class FAB>
432void
434{
435 dataAvailable = true;
436
437 if (ParallelDescriptor::NProcs() == 1) { return; }
438
439#ifdef BL_USE_MPI
440 using value_type = typename FAB::value_type;
441
442 BL_PROFILE("FabArrayCopyDescriptor::CollectData()");
443
444 const int MyProc = ParallelDescriptor::MyProc();
445 amrex::ignore_unused(MyProc);
446
447 int Total_Rcvs_Size = 0;
448 //
449 // We use this to make finding matching FabComTags more efficient.
450 //
451 std::map< int,FabComTagIterContainer > RcvTags;
452
453 std::map<int,int> Snds, Rcvs, Npts;
454 //
455 // Set Rcvs[i] to # of blocks needed from CPU i
456 //
457 for (auto it = fabComTagList.begin(),
458 End = fabComTagList.end();
459 it != End;
460 ++it)
461 {
462 BL_ASSERT(it->box.ok());
463 BL_ASSERT(it->procThatNeedsData == MyProc);
464 BL_ASSERT(it->procThatHasData != MyProc);
465
466 const int Who = it->procThatHasData;
467 const Long cnt_long = it->box.numPts() * Long(it->nComp);
468 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(cnt_long >= 0 &&
469 cnt_long <= Long(std::numeric_limits<int>::max()),
470 "CollectData: message chunk exceeds INT_MAX elements");
471 const int Cnt = static_cast<int>(cnt_long);
472
473 RcvTags[Who].emplace_back(it);
474
475 Total_Rcvs_Size += Cnt;
476
477 if (Rcvs.contains(Who))
478 {
479 Rcvs[Who] += 1;
480 }
481 else
482 {
483 Rcvs[Who] = 1;
484 }
485
486 if (Npts.contains(Who))
487 {
488 Npts[Who] += Cnt;
489 }
490 else
491 {
492 Npts[Who] = Cnt;
493 }
494 }
495 BL_ASSERT(!Rcvs.contains(MyProc));
496
497 BL_ASSERT((Total_Rcvs_Size*sizeof(value_type))
498 < static_cast<std::size_t>(std::numeric_limits<int>::max()));
499
500 const int NProcs = ParallelDescriptor::NProcs();
501
502 {
503 Vector<int> SndsArray(NProcs,0), RcvsArray(NProcs,0);
504
505 for (auto const& Rcv : Rcvs)
506 {
507 RcvsArray[Rcv.first] = Rcv.second;
508 }
509
510 {
511 BL_PROFILE_VAR("CollectData_Alltoall()", blpvCDATA);
512 BL_COMM_PROFILE(BLProfiler::Alltoall, sizeof(int), ParallelDescriptor::MyProc(),
513 BLProfiler::BeforeCall());
514
515 BL_MPI_REQUIRE( MPI_Alltoall(RcvsArray.dataPtr(),
516 1,
518 SndsArray.dataPtr(),
519 1,
522
523 BL_COMM_PROFILE(BLProfiler::Alltoall, sizeof(int), ParallelDescriptor::MyProc(),
524 BLProfiler::AfterCall());
525
526 BL_PROFILE_VAR_STOP(blpvCDATA);
527 }
528 BL_ASSERT(SndsArray[MyProc] == 0);
529
530 for (int i = 0; i < NProcs; i++) {
531 if (SndsArray[i] > 0) {
532 Snds[i] = SndsArray[i];
533 }
534 }
535 }
536
537 // There are two rounds of send and recv.
538 // First, the data receivers need to send the data senders meta-data (e.g., boxes).
539 // Then, the senders know what data to send and perform send.
540 const int SeqNum_md = ParallelDescriptor::SeqNum();
541 const int SeqNum_data = ParallelDescriptor::SeqNum();
542
543 const auto N_snds = static_cast<int>(Snds.size());
544 const auto N_rcvs = static_cast<int>(Rcvs.size());
545
546 if ( N_snds == 0 && N_rcvs == 0 ) { return; }
547
548 const int Nints = 4 + 3*AMREX_SPACEDIM; // # of ints in a meta-data
549
550 // for meta-data
551 Vector<int> md_sender, md_offset, md_icnts, md_bcnts;
552 int* md_recv_data = nullptr;
553 Vector<int*> md_send_data;
554 Vector<MPI_Request> md_recv_reqs, md_send_reqs;
555
556 // for data
557 Vector<int> data_sender, data_offset;
558 value_type* recv_data = nullptr;
559 Vector<value_type*> send_data;
560 Vector<MPI_Request> data_recv_reqs, data_send_reqs;
561
562 if (N_snds > 0)
563 {
564 // Recv meta-data
565
566 int N = 0;
567 for (auto const& Snd : Snds)
568 {
569 md_sender.push_back(Snd.first);
570 md_bcnts.push_back(Snd.second);
571 int cnt = Snd.second * Nints;
572 md_icnts.push_back(cnt);
573 md_offset.push_back(N);
574 N += cnt;
575 }
576
577 md_recv_data = static_cast<int*>(amrex::The_Arena()->alloc(N*sizeof(int)));
578
579 for (int i = 0; i < N_snds; ++i)
580 {
581 md_recv_reqs.push_back(ParallelDescriptor::Arecv(&md_recv_data[md_offset[i]],
582 md_icnts[i], md_sender[i],
583 SeqNum_md).req());
584 }
585 }
586
587 if (N_rcvs > 0)
588 {
589 // Send meta-data
590 for (auto const& Rcv : Rcvs)
591 {
592 int rank = Rcv.first;
593 int Nmds = Rcv.second;
594 int cnt = Nmds * Nints;
595
596 int* p = static_cast<int*>(amrex::The_Arena()->alloc(cnt*sizeof(int)));
597 md_send_data.push_back(p);
598
599 const FabComTagIterContainer& tags = RcvTags[rank];
600
601 // initialized the data
602 int * md = p;
603 for (int i = 0; i < Nmds; ++i, md += Nints)
604 {
605 md[0] = tags[i]->fabArrayId;
606 md[1] = tags[i]->fabIndex;
607 md[2] = tags[i]->srcComp;
608 md[3] = tags[i]->nComp;
609 const int* lo = tags[i]->box.loVect();
610 const int* hi = tags[i]->box.hiVect();
611 const IntVect& bxtyp = tags[i]->box.type();
612 const int* tp = bxtyp.getVect();
613 AMREX_D_EXPR(md[4] = lo[0],
614 md[5] = lo[1],
615 md[6] = lo[2]);
616 AMREX_D_EXPR(md[4+ AMREX_SPACEDIM] = hi[0],
617 md[5+ AMREX_SPACEDIM] = hi[1],
618 md[6+ AMREX_SPACEDIM] = hi[2]);
619 AMREX_D_EXPR(md[4+2*AMREX_SPACEDIM] = tp[0],
620 md[5+2*AMREX_SPACEDIM] = tp[1],
621 md[6+2*AMREX_SPACEDIM] = tp[2]);
622 }
623
624 md_send_reqs.push_back(ParallelDescriptor::Asend(p,cnt,rank,SeqNum_md).req());
625 }
626 }
627
628 if (N_rcvs > 0)
629 {
630 recv_data = static_cast<value_type*>(amrex::The_Arena()->alloc(Total_Rcvs_Size*sizeof(value_type)));
631
632 // Post receives for data
633 int Idx = 0;
634 for (auto & Npt : Npts)
635 {
636 int Who = Npt.first;
637 int Cnt = Npt.second;
638 BL_ASSERT(Cnt > 0);
639 BL_ASSERT(Cnt < std::numeric_limits<int>::max());
640 data_sender.push_back(Who);
641 data_recv_reqs.push_back(ParallelDescriptor::Arecv(&recv_data[Idx],
642 Cnt,Who,SeqNum_data).req());
643 data_offset.push_back(Idx);
644 Idx += Cnt;
645 }
646 }
647
648 // Wait on meta-data and do send
649 if (N_snds > 0)
650 {
651 int send_counter = 0;
652 while (send_counter++ < N_snds)
653 {
654 MPI_Status status;
655 int index;
656 ParallelDescriptor::Waitany(md_recv_reqs, index, status);
657
658 int rank = status.MPI_SOURCE;
659 BL_ASSERT(status.MPI_TAG == SeqNum_md);
660 BL_ASSERT(rank == md_sender[index]);
661
662 const int* p = &md_recv_data[md_offset[index]];
663 int numboxes = md_bcnts[index];
664 Vector<int> faid(numboxes);
665 Vector<int> fidx(numboxes);
666 Vector<int> scomp(numboxes);
667 Vector<int> ncomp(numboxes);
668 Vector<int> npts(numboxes);
669 Vector<Box> bxs;
670 int N = 0;
671 const int * md = p;
672 for (int i = 0; i < numboxes; ++i, md += Nints)
673 {
674 faid[i] = md[0];
675 fidx[i] = md[1];
676 scomp[i] = md[2];
677 ncomp[i] = md[3];
678 bxs.push_back(Box(IntVect(&md[4]),
679 IntVect(&md[4+AMREX_SPACEDIM]),
680 IntVect(&md[4+AMREX_SPACEDIM*2])));
681 const Long np_long = bxs.back().numPts() * Long(ncomp[i]);
682 AMREX_ALWAYS_ASSERT(np_long <= Long(std::numeric_limits<int>::max()));
683 npts[i] = static_cast<int>(np_long);
684 N += npts[i];
685 }
686
687 BL_ASSERT(N < std::numeric_limits<int>::max());
688
689 auto* data = static_cast<value_type*>(amrex::The_Arena()->alloc(N*sizeof(value_type)));
690 value_type* dptr = data;
691 send_data.push_back(data);
692
693 for (int i = 0; i < numboxes; ++i)
694 {
695 (*fabArrays[faid[i]])[fidx[i]].template copyToMem<RunOn::Host>(bxs[i],scomp[i],ncomp[i],dptr);
696 dptr += npts[i];
697 }
698
699 data_send_reqs.push_back(ParallelDescriptor::Asend(data,N,rank,SeqNum_data).req());
700 }
701
702 amrex::The_Arena()->free(md_recv_data);
703 }
704
705 // Wait and unpack data
706 if (N_rcvs > 0)
707 {
708 Vector<MPI_Status> stats(N_rcvs);
709
710 ParallelDescriptor::Waitall(md_send_reqs, stats);
711 for (int i = 0; i < N_rcvs; ++i) {
712 amrex::The_Arena()->free(md_send_data[i]);
713 }
714
715 ParallelDescriptor::Waitall(data_recv_reqs, stats);
716
717 std::pair<FCDMapIter,FCDMapIter> match;
718 std::map< int,FabComTagIterContainer >::const_iterator found;
719
720 for (int k = 0; k < N_rcvs; k++)
721 {
722 const int Who = data_sender[k];
723 const value_type* dptr = &recv_data[data_offset[k]];
724
725 BL_ASSERT(dptr != nullptr);
726
727 found = RcvTags.find(Who);
728
729 BL_ASSERT(found != RcvTags.end());
730
731 const FabComTagIterContainer& tags = found->second;
732
733 for (auto const& it : tags)
734 {
735 const FabArrayBase::FabComTag& tag = *it;
736
737 BL_ASSERT(tag.procThatHasData == Who);
738
739 match = fabCopyDescList[tag.fabArrayId].equal_range(tag.fillBoxId);
740
741 for (auto fmi = match.first; fmi != match.second; ++fmi)
742 {
743 FabCopyDescriptor<FAB>* fcdp = (*fmi).second;
744
745 BL_ASSERT(fcdp->fillBoxId == tag.fillBoxId);
746
747 if (fcdp->subBox == tag.box)
748 {
749 BL_ASSERT(fcdp->localFabSource->dataPtr() != nullptr);
750 BL_ASSERT(fcdp->localFabSource->box() == tag.box);
751 const Long cnt_long = tag.box.numPts() * Long(tag.nComp);
752 AMREX_ALWAYS_ASSERT(cnt_long <= Long(std::numeric_limits<int>::max()));
753 auto Cnt = static_cast<int>(cnt_long);
754 fcdp->localFabSource->template copyFromMem<RunOn::Host>(tag.box,0,tag.nComp,dptr);
755 dptr += Cnt;
756 break;
757 }
758 }
759 }
760 }
761
762 amrex::The_Arena()->free(recv_data);
763 }
764
765 // Finished send
766 if (N_snds > 0)
767 {
768 Vector<MPI_Status> stats(N_snds);
769 ParallelDescriptor::Waitall(data_send_reqs, stats);
770
771 for (int i = 0; i < N_snds; ++i) {
772 amrex::The_Arena()->free(send_data[i]);
773 }
774 }
775
776#endif /*BL_USE_MPI*/
777}
778
779
780template <class FAB>
781void
783 const FillBoxId& fillboxid,
784 FAB& destFab)
785{
786 BL_ASSERT(dataAvailable);
787
788 std::pair<FCDMapIter,FCDMapIter> match = fabCopyDescList[faid.Id()].equal_range(fillboxid.Id());
789
790 for (auto fmi = match.first; fmi != match.second; ++fmi)
791 {
792 FabCopyDescriptor<FAB>* fcdp = (*fmi).second;
793
794 BL_ASSERT(fcdp->fillBoxId == fillboxid.Id());
795
796 destFab.template copy<RunOn::Host>
797 (*fcdp->localFabSource,
798 fcdp->subBox,
799 fcdp->fillType == FillLocally ? fcdp->srcComp : 0,
800 fcdp->subBox,
801 fcdp->destComp,
802 fcdp->nComp);
803 }
804}
805
806template <class FAB>
807void
809 const FillBoxId& fillboxid,
810 FAB& destFab,
811 const Box& destBox)
812{
813 BL_ASSERT(dataAvailable);
814
815 FCDMapIter fmi = fabCopyDescList[faid.Id()].lower_bound(fillboxid.Id());
816
817 BL_ASSERT(fmi != fabCopyDescList[faid.Id()].end());
818
819 FabCopyDescriptor<FAB>* fcdp = (*fmi).second;
820
821 BL_ASSERT(fcdp->fillBoxId == fillboxid.Id());
822
823 BL_ASSERT(fcdp->subBox.sameSize(destBox));
824
825 destFab.ParallelCopy(*fcdp->localFabSource,
826 fcdp->subBox,
827 fcdp->fillType == FillLocally ? fcdp->srcComp : 0,
828 destBox,
829 fcdp->destComp,
830 fcdp->nComp);
831
832 BL_ASSERT(++fmi == fabCopyDescList[faid.Id()].upper_bound(fillboxid.Id()));
833}
834
835template <class FAB>
836void
838{
839 const int MyProc = ParallelDescriptor::MyProc();
840
841 amrex::AllPrint() << "----- "
842 << MyProc
843 << ": Parallel stats for FabArrayCopyDescriptor:" << '\n';
844
845 for (int fa = 0; fa < fabArrays.size(); ++fa)
846 {
847 amrex::AllPrint() << "fabArrays["
848 << fa
849 << "]->boxArray() = "
850 << fabArrays[fa]->boxArray()
851 << '\n';
852 }
853}
854
855}
856
857#endif
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:551
#define BL_COMM_PROFILE(cft, size, pid, tag)
Definition AMReX_BLProfiler.H:587
#define BL_PROFILE_VAR_STOP(vname)
Definition AMReX_BLProfiler.H:563
#define BL_PROFILE_VAR(fname, vname)
Definition AMReX_BLProfiler.H:560
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
#define AMREX_ALWAYS_ASSERT(EX)
Definition AMReX_BLassert.H:50
#define AMREX_D_EXPR(a, b, c)
Definition AMReX_SPACE.H:170
Print on all processors of the default communicator.
Definition AMReX_Print.H:113
virtual void free(void *pt)=0
A pure virtual function for deleting the arena pointed to by pt.
virtual void * alloc(std::size_t sz)=0
bool ok() const
Return true if Box is valid and they all have the same IndexType. Is true by default if the BoxArray ...
Definition AMReX_BoxArray.cpp:894
A List of Disjoint Boxes.
Definition AMReX_BoxDomain.H:67
BoxDomain & rmBox(const Box &b)
Remove a box from the domain.
Definition AMReX_BoxDomain.cpp:159
const BoxList & boxList() const
Return a const reference to the underlying BoxList of this BoxDomain.
Definition AMReX_BoxDomain.cpp:82
void add(const Box &b)
Add a Box to the domain.
Definition AMReX_BoxDomain.cpp:121
A class for managing a List of Boxes that share a common IndexType. This class implements operations ...
Definition AMReX_BoxList.H:52
void clear()
Remove all Boxes from this BoxList.
Definition AMReX_BoxList.cpp:65
__host__ __device__ Long numPts() const noexcept
Return the number of points contained in the BoxND.
Definition AMReX_Box.H:356
__host__ __device__ bool sameSize(const BoxND &b) const noexcept
Return true is Boxes same size, ie translates of each other,. It is an error if they have different t...
Definition AMReX_Box.H:287
__host__ __device__ IndexTypeND< dim > ixType() const noexcept
Return the indexing type.
Definition AMReX_Box.H:135
const DistributionMapping & DistributionMap() const noexcept
Return constant reference to associated DistributionMapping.
Definition AMReX_FabArrayBase.H:131
Box box(int K) const noexcept
Return the Kth Box in the BoxArray. That is, the valid region of the Kth grid.
Definition AMReX_FabArrayBase.H:101
Box fabbox(int K) const noexcept
Return the Kth FABs Box in the FabArray. That is, the region the Kth fab is actually defined on.
Definition AMReX_FabArrayBase.cpp:217
This class orchestrates filling a destination fab of size destFabBox from fabarray on the local proce...
Definition AMReX_FACopyDescriptor.H:108
void PrintStats() const
Definition AMReX_FACopyDescriptor.H:837
int nFabCopyDescs() const
Definition AMReX_FACopyDescriptor.H:171
FabArrayCopyDescriptor(const FabArrayCopyDescriptor< FAB > &)=delete
FabArrayCopyDescriptor(FabArrayCopyDescriptor< FAB > &&)=delete
int nFabComTags() const
Definition AMReX_FACopyDescriptor.H:169
void clear()
Definition AMReX_FACopyDescriptor.H:411
void FillFab(FabArrayId faid, const FillBoxId &fillboxid, FAB &destFab)
Definition AMReX_FACopyDescriptor.H:782
FabArrayCopyDescriptor< FAB > & operator=(const FabArrayCopyDescriptor< FAB > &)=delete
void CollectData()
Definition AMReX_FACopyDescriptor.H:433
FillBoxId AddBox(FabArrayId fabarrayid, const Box &destFabBox, BoxList *unfilledBoxes)
Definition AMReX_FACopyDescriptor.H:391
FabArrayId RegisterFabArray(FabArray< FAB > *fabarray)
Definition AMReX_FACopyDescriptor.H:204
int CurrentNFabArrays() const
Definition AMReX_FACopyDescriptor.H:167
FillBoxId AddBox(FabArrayId fabarrayid, const Box &destFabBox, BoxList *unfilledBoxes, int srccomp, int destcomp, int numcomp)
Definition AMReX_FACopyDescriptor.H:312
~FabArrayCopyDescriptor()
Definition AMReX_FACopyDescriptor.H:404
bool DataAvailable() const
Definition AMReX_FACopyDescriptor.H:163
FillBoxId AddBox(FabArrayId fabarrayid, const Box &destFabBox, BoxList *unfilledBoxes, int fabarrayindex, int srccomp, int destcomp, int numcomp, bool bUseValidBox=true)
Definition AMReX_FACopyDescriptor.H:354
void FillFab(FabArrayId faid, const FillBoxId &fillboxid, FAB &destFab, const Box &destBox)
Definition AMReX_FACopyDescriptor.H:808
Definition AMReX_FACopyDescriptor.H:43
int Id() const
Definition AMReX_FACopyDescriptor.H:50
bool operator==(const FabArrayId &rhs) const
Definition AMReX_FACopyDescriptor.H:52
FabArrayId(int newid=-1)
Definition AMReX_FACopyDescriptor.H:46
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:351
Definition AMReX_FACopyDescriptor.H:19
FillBoxId()=default
const Box & box() const
Definition AMReX_FACopyDescriptor.H:33
int Id() const
Definition AMReX_FACopyDescriptor.H:30
int FabIndex() const
Definition AMReX_FACopyDescriptor.H:31
FillBoxId(int newid, const Box &fillbox)
Definition AMReX_FACopyDescriptor.H:24
void FabIndex(int fabindex)
Definition AMReX_FACopyDescriptor.H:32
__host__ __device__ const int * getVect() const &noexcept
Returns a const pointer to an array of coordinates of the IntVectND. Useful for arguments to FORTRAN ...
Definition AMReX_IntVect.H:383
MPI_Request req() const
Definition AMReX_ParallelDescriptor.H:74
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:28
T * dataPtr() noexcept
get access to the underlying data pointer
Definition AMReX_Vector.H:49
amrex_long Long
Definition AMReX_INT.H:30
Arena * The_Arena()
Definition AMReX_Arena.cpp:820
int MyProc() noexcept
Definition AMReX_ParallelDescriptor.H:128
int NProcs() noexcept
Definition AMReX_ParallelDescriptor.H:255
bool sameTeam(int rank) noexcept
Definition AMReX_ParallelDescriptor.H:345
Message Asend(const T *, size_t n, int pid, int tag)
Definition AMReX_ParallelDescriptor.H:1172
MPI_Comm Communicator() noexcept
Definition AMReX_ParallelDescriptor.H:223
void Waitany(Vector< MPI_Request > &, int &, MPI_Status &)
Definition AMReX_ParallelDescriptor.cpp:1312
void Waitall(Vector< MPI_Request > &, Vector< MPI_Status > &)
Definition AMReX_ParallelDescriptor.cpp:1308
int SeqNum() noexcept
Returns sequential message sequence numbers, usually used as tags for send/recv.
Definition AMReX_ParallelDescriptor.H:696
Message Arecv(T *, size_t n, int pid, int tag)
Definition AMReX_ParallelDescriptor.H:1214
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:139
BoxArray intersect(const BoxArray &ba, const Box &b, int ng)
Make a BoxArray from the intersection of Box b and BoxArray(+ghostcells).
Definition AMReX_BoxArray.cpp:1717
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:30
__host__ __device__ Dim3 begin(BoxND< dim > const &box) noexcept
Definition AMReX_Box.H:2006
bool match(const BoxArray &x, const BoxArray &y)
Note that two BoxArrays that match are not necessarily equal.
Definition AMReX_BoxArray.cpp:1930
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
FillType
Definition AMReX_FACopyDescriptor.H:16
@ FillLocally
Definition AMReX_FACopyDescriptor.H:16
@ Unfillable
Definition AMReX_FACopyDescriptor.H:16
@ FillRemotely
Definition AMReX_FACopyDescriptor.H:16
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:241
Used for collecting information used in communicating FABs.
Definition AMReX_FabArrayBase.H:272
int fabArrayId
Definition AMReX_FabArrayBase.H:281
int procThatHasData
Definition AMReX_FabArrayBase.H:284
Box box
Definition AMReX_FabArrayBase.H:285
int nComp
Definition AMReX_FabArrayBase.H:279
int fillBoxId
Definition AMReX_FabArrayBase.H:282
Definition AMReX_FACopyDescriptor.H:64
int destComp
Definition AMReX_FACopyDescriptor.H:81
FabCopyDescriptor(const FabCopyDescriptor &)=delete
int copyFromIndex
Definition AMReX_FACopyDescriptor.H:78
FabCopyDescriptor()
Definition AMReX_FACopyDescriptor.H:88
int myProc
Definition AMReX_FACopyDescriptor.H:76
bool cacheDataAllocated
Definition AMReX_FACopyDescriptor.H:84
FAB * localFabSource
Definition AMReX_FACopyDescriptor.H:74
FabCopyDescriptor & operator=(const FabCopyDescriptor &)=delete
~FabCopyDescriptor()
Definition AMReX_FACopyDescriptor.H:95
Box subBox
Definition AMReX_FACopyDescriptor.H:75
int nComp
Definition AMReX_FACopyDescriptor.H:82
int fillBoxId
Definition AMReX_FACopyDescriptor.H:79
int srcComp
Definition AMReX_FACopyDescriptor.H:80
FillType fillType
Definition AMReX_FACopyDescriptor.H:83
FabCopyDescriptor(FabCopyDescriptor &&)=delete
int copyFromProc
Definition AMReX_FACopyDescriptor.H:77
Communication datatype (note: this structure also works without MPI)
Definition AMReX_ccse-mpi.H:78
Definition AMReX_ccse-mpi.H:55