| 745 | |
| 746 | template <class FAB> |
| 747 | void |
| 748 | FabArray<FAB>::copyTo (FAB& dest, int scomp, int dcomp, int ncomp, int nghost) const |
| 749 | { |
| 750 | BL_PROFILE("FabArray::copy(fab)"); |
| 751 | |
| 752 | BL_ASSERT(dcomp + ncomp <= dest.nComp()); |
| 753 | BL_ASSERT(IntVect(nghost).allLE(nGrowVect())); |
| 754 | |
| 755 | int root_proc = this->DistributionMap()[0]; |
| 756 | |
| 757 | BoxArray ba(dest.box()); |
| 758 | DistributionMapping dm(Vector<int>{root_proc}); |
| 759 | FabArray<FAB> destmf(ba, dm, ncomp, 0, MFInfo().SetAlloc(false)); |
| 760 | if (ParallelDescriptor::MyProc() == root_proc) { |
| 761 | destmf.setFab(0, FAB(dest, amrex::make_alias, dcomp, ncomp)); |
| 762 | } |
| 763 | |
| 764 | destmf.ParallelCopy(*this, scomp, 0, ncomp, nghost, 0); |
| 765 | |
| 766 | #ifdef BL_USE_MPI |
| 767 | using T = typename FAB::value_type; |
| 768 | if (ParallelContext::NProcsSub() > 1) { |
| 769 | Long count = dest.numPts()*ncomp; |
| 770 | T* const p0 = dest.dataPtr(dcomp); |
| 771 | T* pb = p0; |
| 772 | #ifdef AMREX_USE_GPU |
| 773 | if (dest.arena()->isDevice() && !ParallelDescriptor::UseGpuAwareMpi()) { |
| 774 | pb = (T*)The_Pinned_Arena()->alloc(sizeof(T)*count); |
| 775 | Gpu::dtoh_memcpy_async(pb, p0, sizeof(T)*count); |
| 776 | Gpu::streamSynchronize(); |
| 777 | } |
| 778 | #endif |
| 779 | ParallelDescriptor::Bcast(pb, count, ParallelContext::global_to_local_rank(root_proc), |
| 780 | ParallelContext::CommunicatorSub()); |
| 781 | #ifdef AMREX_USE_GPU |
| 782 | if (pb != p0) { |
| 783 | Gpu::htod_memcpy_async(p0, pb, sizeof(T)*count); |
| 784 | Gpu::streamSynchronize(); |
| 785 | The_Pinned_Arena()->free(pb); |
| 786 | } |
| 787 | #endif |
| 788 | } |
| 789 | #endif |
| 790 | } |
| 791 | |
| 792 | #ifdef BL_USE_MPI |
| 793 | template <class FAB> |
nothing calls this directly
no test coverage detected