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 true);
402}
403
404template <class FAB>
409
410template <class FAB>
411void
413{
414 for (unsigned int i = 0, N = fabCopyDescList.size(); i < N; ++i)
415 {
416 for (auto fmi = fabCopyDescList[i].begin(), End = fabCopyDescList[i].end();
417 fmi != End;
418 ++fmi)
419 {
420 delete (*fmi).second;
421 }
422 }
423
424 fabArrays.clear();
425 fabCopyDescList.clear();
426 fabComTagList.clear();
427
428 nextFillBoxId = 0;
429 dataAvailable = false;
430}
431
432template <class FAB>
433void
435{
436 dataAvailable = true;
437
438 if (ParallelDescriptor::NProcs() == 1) { return; }
439
440#ifdef BL_USE_MPI
441 using value_type = typename FAB::value_type;
442
443 BL_PROFILE("FabArrayCopyDescriptor::CollectData()");
444
445 const int MyProc = ParallelDescriptor::MyProc();
446 amrex::ignore_unused(MyProc);
447
448 int Total_Rcvs_Size = 0;
449 //
450 // We use this to make finding matching FabComTags more efficient.
451 //
452 std::map< int,FabComTagIterContainer > RcvTags;
453
454 std::map<int,int> Snds, Rcvs, Npts;
455 //
456 // Set Rcvs[i] to # of blocks needed from CPU i
457 //
458 for (auto it = fabComTagList.begin(),
459 End = fabComTagList.end();
460 it != End;
461 ++it)
462 {
463 BL_ASSERT(it->box.ok());
464 BL_ASSERT(it->procThatNeedsData == MyProc);
465 BL_ASSERT(it->procThatHasData != MyProc);
466
467 const int Who = it->procThatHasData;
468 const Long cnt_long = it->box.numPts() * Long(it->nComp);
469 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(cnt_long >= 0 &&
470 cnt_long <= Long(std::numeric_limits<int>::max()),
471 "CollectData: message chunk exceeds INT_MAX elements");
472 const int Cnt = static_cast<int>(cnt_long);
473
474 RcvTags[Who].emplace_back(it);
475
476 Total_Rcvs_Size += Cnt;
477
478 if (Rcvs.count(Who) > 0)
479 {
480 Rcvs[Who] += 1;
481 }
482 else
483 {
484 Rcvs[Who] = 1;
485 }
486
487 if (Npts.count(Who) > 0)
488 {
489 Npts[Who] += Cnt;
490 }
491 else
492 {
493 Npts[Who] = Cnt;
494 }
495 }
496 BL_ASSERT(Rcvs.count(MyProc) == 0);
497
498 BL_ASSERT((Total_Rcvs_Size*sizeof(value_type))
499 < static_cast<std::size_t>(std::numeric_limits<int>::max()));
500
501 const int NProcs = ParallelDescriptor::NProcs();
502
503 {
504 Vector<int> SndsArray(NProcs,0), RcvsArray(NProcs,0);
505
506 for (auto const& Rcv : Rcvs)
507 {
508 RcvsArray[Rcv.first] = Rcv.second;
509 }
510
511 {
512 BL_PROFILE_VAR("CollectData_Alltoall()", blpvCDATA);
513 BL_COMM_PROFILE(BLProfiler::Alltoall, sizeof(int), ParallelDescriptor::MyProc(),
514 BLProfiler::BeforeCall());
515
516 BL_MPI_REQUIRE( MPI_Alltoall(RcvsArray.dataPtr(),
517 1,
519 SndsArray.dataPtr(),
520 1,
523
524 BL_COMM_PROFILE(BLProfiler::Alltoall, sizeof(int), ParallelDescriptor::MyProc(),
525 BLProfiler::AfterCall());
526
527 BL_PROFILE_VAR_STOP(blpvCDATA);
528 }
529 BL_ASSERT(SndsArray[MyProc] == 0);
530
531 for (int i = 0; i < NProcs; i++) {
532 if (SndsArray[i] > 0) {
533 Snds[i] = SndsArray[i];
534 }
535 }
536 }
537
538 // There are two rounds of send and recv.
539 // First, the data receivers need to send the data senders meta-data (e.g., boxes).
540 // Then, the senders know what data to send and perform send.
541 const int SeqNum_md = ParallelDescriptor::SeqNum();
542 const int SeqNum_data = ParallelDescriptor::SeqNum();
543
544 const auto N_snds = static_cast<int>(Snds.size());
545 const auto N_rcvs = static_cast<int>(Rcvs.size());
546
547 if ( N_snds == 0 && N_rcvs == 0 ) { return; }
548
549 const int Nints = 4 + 3*AMREX_SPACEDIM; // # of ints in a meta-data
550
551 // for meta-data
552 Vector<int> md_sender, md_offset, md_icnts, md_bcnts;
553 int* md_recv_data = nullptr;
554 Vector<int*> md_send_data;
555 Vector<MPI_Request> md_recv_reqs, md_send_reqs;
556
557 // for data
558 Vector<int> data_sender, data_offset;
559 value_type* recv_data = nullptr;
560 Vector<value_type*> send_data;
561 Vector<MPI_Request> data_recv_reqs, data_send_reqs;
562
563 if (N_snds > 0)
564 {
565 // Recv meta-data
566
567 int N = 0;
568 for (auto const& Snd : Snds)
569 {
570 md_sender.push_back(Snd.first);
571 md_bcnts.push_back(Snd.second);
572 int cnt = Snd.second * Nints;
573 md_icnts.push_back(cnt);
574 md_offset.push_back(N);
575 N += cnt;
576 }
577
578 md_recv_data = static_cast<int*>(amrex::The_Arena()->alloc(N*sizeof(int)));
579
580 for (int i = 0; i < N_snds; ++i)
581 {
582 md_recv_reqs.push_back(ParallelDescriptor::Arecv(&md_recv_data[md_offset[i]],
583 md_icnts[i], md_sender[i],
584 SeqNum_md).req());
585 }
586 }
587
588 if (N_rcvs > 0)
589 {
590 // Send meta-data
591 for (auto const& Rcv : Rcvs)
592 {
593 int rank = Rcv.first;
594 int Nmds = Rcv.second;
595 int cnt = Nmds * Nints;
596
597 int* p = static_cast<int*>(amrex::The_Arena()->alloc(cnt*sizeof(int)));
598 md_send_data.push_back(p);
599
600 const FabComTagIterContainer& tags = RcvTags[rank];
601
602 // initialized the data
603 int * md = p;
604 for (int i = 0; i < Nmds; ++i, md += Nints)
605 {
606 md[0] = tags[i]->fabArrayId;
607 md[1] = tags[i]->fabIndex;
608 md[2] = tags[i]->srcComp;
609 md[3] = tags[i]->nComp;
610 const int* lo = tags[i]->box.loVect();
611 const int* hi = tags[i]->box.hiVect();
612 const IntVect& bxtyp = tags[i]->box.type();
613 const int* tp = bxtyp.getVect();
614 AMREX_D_EXPR(md[4] = lo[0],
615 md[5] = lo[1],
616 md[6] = lo[2]);
617 AMREX_D_EXPR(md[4+ AMREX_SPACEDIM] = hi[0],
618 md[5+ AMREX_SPACEDIM] = hi[1],
619 md[6+ AMREX_SPACEDIM] = hi[2]);
620 AMREX_D_EXPR(md[4+2*AMREX_SPACEDIM] = tp[0],
621 md[5+2*AMREX_SPACEDIM] = tp[1],
622 md[6+2*AMREX_SPACEDIM] = tp[2]);
623 }
624
625 md_send_reqs.push_back(ParallelDescriptor::Asend(p,cnt,rank,SeqNum_md).req());
626 }
627 }
628
629 if (N_rcvs > 0)
630 {
631 recv_data = static_cast<value_type*>(amrex::The_Arena()->alloc(Total_Rcvs_Size*sizeof(value_type)));
632
633 // Post receives for data
634 int Idx = 0;
635 for (auto & Npt : Npts)
636 {
637 int Who = Npt.first;
638 int Cnt = Npt.second;
639 BL_ASSERT(Cnt > 0);
640 BL_ASSERT(Cnt < std::numeric_limits<int>::max());
641 data_sender.push_back(Who);
642 data_recv_reqs.push_back(ParallelDescriptor::Arecv(&recv_data[Idx],
643 Cnt,Who,SeqNum_data).req());
644 data_offset.push_back(Idx);
645 Idx += Cnt;
646 }
647 }
648
649 // Wait on meta-data and do send
650 if (N_snds > 0)
651 {
652 int send_counter = 0;
653 while (send_counter++ < N_snds)
654 {
655 MPI_Status status;
656 int index;
657 ParallelDescriptor::Waitany(md_recv_reqs, index, status);
658
659 int rank = status.MPI_SOURCE;
660 BL_ASSERT(status.MPI_TAG == SeqNum_md);
661 BL_ASSERT(rank == md_sender[index]);
662
663 const int* p = &md_recv_data[md_offset[index]];
664 int numboxes = md_bcnts[index];
665 Vector<int> faid(numboxes);
666 Vector<int> fidx(numboxes);
667 Vector<int> scomp(numboxes);
668 Vector<int> ncomp(numboxes);
669 Vector<int> npts(numboxes);
670 Vector<Box> bxs;
671 int N = 0;
672 const int * md = p;
673 for (int i = 0; i < numboxes; ++i, md += Nints)
674 {
675 faid[i] = md[0];
676 fidx[i] = md[1];
677 scomp[i] = md[2];
678 ncomp[i] = md[3];
679 bxs.push_back(Box(IntVect(&md[4]),
680 IntVect(&md[4+AMREX_SPACEDIM]),
681 IntVect(&md[4+AMREX_SPACEDIM*2])));
682 const Long np_long = bxs.back().numPts() * Long(ncomp[i]);
683 AMREX_ALWAYS_ASSERT(np_long <= Long(std::numeric_limits<int>::max()));
684 npts[i] = static_cast<int>(np_long);
685 N += npts[i];
686 }
687
688 BL_ASSERT(N < std::numeric_limits<int>::max());
689
690 auto* data = static_cast<value_type*>(amrex::The_Arena()->alloc(N*sizeof(value_type)));
691 value_type* dptr = data;
692 send_data.push_back(data);
693
694 for (int i = 0; i < numboxes; ++i)
695 {
696 (*fabArrays[faid[i]])[fidx[i]].template copyToMem<RunOn::Host>(bxs[i],scomp[i],ncomp[i],dptr);
697 dptr += npts[i];
698 }
699
700 data_send_reqs.push_back(ParallelDescriptor::Asend(data,N,rank,SeqNum_data).req());
701 }
702
703 amrex::The_Arena()->free(md_recv_data);
704 }
705
706 // Wait and unpack data
707 if (N_rcvs > 0)
708 {
709 Vector<MPI_Status> stats(N_rcvs);
710
711 ParallelDescriptor::Waitall(md_send_reqs, stats);
712 for (int i = 0; i < N_rcvs; ++i) {
713 amrex::The_Arena()->free(md_send_data[i]);
714 }
715
716 ParallelDescriptor::Waitall(data_recv_reqs, stats);
717
718 std::pair<FCDMapIter,FCDMapIter> match;
719 std::map< int,FabComTagIterContainer >::const_iterator found;
720
721 for (int k = 0; k < N_rcvs; k++)
722 {
723 const int Who = data_sender[k];
724 const value_type* dptr = &recv_data[data_offset[k]];
725
726 BL_ASSERT(dptr != nullptr);
727
728 found = RcvTags.find(Who);
729
730 BL_ASSERT(found != RcvTags.end());
731
732 const FabComTagIterContainer& tags = found->second;
733
734 for (auto const& it : tags)
735 {
736 const FabArrayBase::FabComTag& tag = *it;
737
738 BL_ASSERT(tag.procThatHasData == Who);
739
740 match = fabCopyDescList[tag.fabArrayId].equal_range(tag.fillBoxId);
741
742 for (auto fmi = match.first; fmi != match.second; ++fmi)
743 {
744 FabCopyDescriptor<FAB>* fcdp = (*fmi).second;
745
746 BL_ASSERT(fcdp->fillBoxId == tag.fillBoxId);
747
748 if (fcdp->subBox == tag.box)
749 {
750 BL_ASSERT(fcdp->localFabSource->dataPtr() != nullptr);
751 BL_ASSERT(fcdp->localFabSource->box() == tag.box);
752 const Long cnt_long = tag.box.numPts() * Long(tag.nComp);
753 AMREX_ALWAYS_ASSERT(cnt_long <= Long(std::numeric_limits<int>::max()));
754 auto Cnt = static_cast<int>(cnt_long);
755 fcdp->localFabSource->template copyFromMem<RunOn::Host>(tag.box,0,tag.nComp,dptr);
756 dptr += Cnt;
757 break;
758 }
759 }
760 }
761 }
762
763 amrex::The_Arena()->free(recv_data);
764 }
765
766 // Finished send
767 if (N_snds > 0)
768 {
769 Vector<MPI_Status> stats(N_snds);
770 ParallelDescriptor::Waitall(data_send_reqs, stats);
771
772 for (int i = 0; i < N_snds; ++i) {
773 amrex::The_Arena()->free(send_data[i]);
774 }
775 }
776
777#endif /*BL_USE_MPI*/
778}
779
780
781template <class FAB>
782void
784 const FillBoxId& fillboxid,
785 FAB& destFab)
786{
787 BL_ASSERT(dataAvailable);
788
789 std::pair<FCDMapIter,FCDMapIter> match = fabCopyDescList[faid.Id()].equal_range(fillboxid.Id());
790
791 for (auto fmi = match.first; fmi != match.second; ++fmi)
792 {
793 FabCopyDescriptor<FAB>* fcdp = (*fmi).second;
794
795 BL_ASSERT(fcdp->fillBoxId == fillboxid.Id());
796
797 destFab.template copy<RunOn::Host>
798 (*fcdp->localFabSource,
799 fcdp->subBox,
800 fcdp->fillType == FillLocally ? fcdp->srcComp : 0,
801 fcdp->subBox,
802 fcdp->destComp,
803 fcdp->nComp);
804 }
805}
806
807template <class FAB>
808void
810 const FillBoxId& fillboxid,
811 FAB& destFab,
812 const Box& destBox)
813{
814 BL_ASSERT(dataAvailable);
815
816 FCDMapIter fmi = fabCopyDescList[faid.Id()].lower_bound(fillboxid.Id());
817
818 BL_ASSERT(fmi != fabCopyDescList[faid.Id()].end());
819
820 FabCopyDescriptor<FAB>* fcdp = (*fmi).second;
821
822 BL_ASSERT(fcdp->fillBoxId == fillboxid.Id());
823
824 BL_ASSERT(fcdp->subBox.sameSize(destBox));
825
826 destFab.ParallelCopy(*fcdp->localFabSource,
827 fcdp->subBox,
828 fcdp->fillType == FillLocally ? fcdp->srcComp : 0,
829 destBox,
830 fcdp->destComp,
831 fcdp->nComp);
832
833 BL_ASSERT(++fmi == fabCopyDescList[faid.Id()].upper_bound(fillboxid.Id()));
834}
835
836template <class FAB>
837void
839{
840 const int MyProc = ParallelDescriptor::MyProc();
841
842 amrex::AllPrint() << "----- "
843 << MyProc
844 << ": Parallel stats for FabArrayCopyDescriptor:" << '\n';
845
846 for (int fa = 0; fa < fabArrays.size(); ++fa)
847 {
848 amrex::AllPrint() << "fabArrays["
849 << fa
850 << "]->boxArray() = "
851 << fabArrays[fa]->boxArray()
852 << '\n';
853 }
854}
855
856}
857
858#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:838
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:412
void FillFab(FabArrayId faid, const FillBoxId &fillboxid, FAB &destFab)
Definition AMReX_FACopyDescriptor.H:783
FabArrayCopyDescriptor< FAB > & operator=(const FabArrayCopyDescriptor< FAB > &)=delete
void CollectData()
Definition AMReX_FACopyDescriptor.H:434
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:405
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:809
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:349
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:291
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:805
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:49
__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:1721
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:1934
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:240
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