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

Function Distribute

Src/Base/AMReX_DistributionMapping.cpp:1196–1277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1194
1195namespace {
1196void
1197Distribute (const std::vector<SFCToken>& tokens,
1198 const std::vector<Long>& wgts,
1199 int nprocs,
1200 Real volpercpu,
1201 std::vector< std::vector<int> >& v)
1202
1203{
1204 BL_PROFILE("DistributionMapping::Distribute()");
1205
1206 if (flag_verbose_mapper) {
1207 Print() << "Distribute:" << '\n'
1208 << " volpercpu: " << volpercpu << '\n'
1209 << " Sorted SFC Tokens:" << '\n';
1210 int idx = 0;
1211 for (const auto &t : tokens) {
1212 Print() << " " << idx++ << ": "
1213 << t.m_box << ": "
1214 << t.m_morton << '\n';
1215 }
1216 }
1217
1218 BL_ASSERT(std::ssize(v) == nprocs);
1219
1220 int K = 0;
1221 Real totalvol = 0;
1222
1223 for (int i = 0; i < nprocs; ++i)
1224 {
1225 int cnt = 0;
1226 Real vol = 0;
1227
1228 for ( int TSZ = static_cast<int>(tokens.size());
1229 K < TSZ && (i == (nprocs-1) || (vol < volpercpu));
1230 ++K)
1231 {
1232 vol += static_cast<Real>(wgts[tokens[K].m_box]);
1233 ++cnt;
1234
1235 v[i].push_back(tokens[K].m_box);
1236 }
1237
1238 totalvol += vol;
1239
1240 if ((totalvol/static_cast<Real>(i+1)) > volpercpu && // Too much for this bin.
1241 cnt > 1 && // More than one box in this bin.
1242 i < nprocs-1) // Not the last bin, which has to take all.
1243 {
1244 --K;
1245 v[i].pop_back();
1246 totalvol -= static_cast<Real>(wgts[tokens[K].m_box]);
1247 }
1248 }
1249
1250 if (flag_verbose_mapper) {
1251 Print() << "Distributed SFC Tokens:" << '\n';
1252 int idx = 0;
1253 for (int i = 0; i < nprocs; ++i) {

Callers 2

SFCProcessorMapDoItMethod · 0.85
makeSFCMethod · 0.85

Calls 4

PrintClass · 0.85
sizeMethod · 0.45
push_backMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected