MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / PrepareCommBuffers

Function PrepareCommBuffers

Src/Base/AMReX_NonLocalBC.cpp:43–107  ·  view source on GitHub ↗

Note, this is copied and modified from PrepareSendBuffers and PostRcvs

Source from the content-addressed store, hash-verified

41#ifdef AMREX_USE_MPI
42// Note, this is copied and modified from PrepareSendBuffers and PostRcvs
43void PrepareCommBuffers(CommData& comm,
44 const FabArrayBase::MapOfCopyComTagContainers& cctc, int n_components,
45 std::size_t object_size, std::size_t align)
46{
47 comm.data.clear();
48 comm.size.clear();
49 comm.rank.clear();
50 comm.request.clear();
51 comm.offset.clear();
52 comm.cctc.clear();
53 comm.stats.clear();
54
55 comm.id = FabArrayBase::getNextCommMetaDataId();
56
57 const auto N_comms = static_cast<int>(cctc.size());
58 if (N_comms == 0) { return; }
59 // reserve for upcominf push_backs
60 comm.data.reserve(N_comms);
61 comm.size.reserve(N_comms);
62 comm.rank.reserve(N_comms);
63 comm.request.reserve(N_comms);
64 comm.offset.reserve(N_comms);
65 comm.cctc.reserve(N_comms);
66 // resize to provide buffer for later
67 comm.stats.resize(N_comms);
68
69 std::size_t total_volume = 0;
70 for (const auto& kv : cctc)
71 {
72 std::size_t nbytes = 0;
73 for (auto const& cct : kv.second)
74 {
75 // Note: Does this hold for all FAB types?
76 // This nBytes() implementation is currently also assumed in unpack_recv_buffers
77 nbytes += cct.sbox.numPts() * object_size * n_components;
78 }
79
80 std::size_t acd = ParallelDescriptor::sizeof_selected_comm_data_type(nbytes);
81 nbytes = amrex::aligned_size(acd, nbytes); // so that nbytes are aligned
82
83 // Also need to align the offset properly
84 total_volume = amrex::aligned_size(std::max(align, acd), total_volume);
85
86 comm.offset.push_back(total_volume);
87 comm.data.push_back(nullptr);
88 comm.size.push_back(nbytes);
89 comm.rank.push_back(kv.first);
90 comm.request.push_back(MPI_REQUEST_NULL);
91 comm.cctc.push_back(&kv.second);
92
93 total_volume += nbytes;
94 }
95
96 if (total_volume == 0)
97 {
98 comm.the_data.reset();
99 }
100 else

Callers 2

PrepareSendBuffersFunction · 0.85
PrepareRecvBuffersFunction · 0.85

Calls 12

aligned_sizeFunction · 0.85
The_Comms_ArenaFunction · 0.85
clearMethod · 0.45
sizeMethod · 0.45
reserveMethod · 0.45
resizeMethod · 0.45
numPtsMethod · 0.45
push_backMethod · 0.45
resetMethod · 0.45
allocMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected