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

Method RoundRobinDoIt

Src/Base/AMReX_DistributionMapping.cpp:372–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372void
373DistributionMapping::RoundRobinDoIt (int nboxes,
374 int /* nprocs */,
375 std::vector<LIpair>* LIpairV,
376 bool sort)
377{
378 if (flag_verbose_mapper) {
379 Print() << "DM: RoundRobinDoIt called..." << '\n';
380 }
381
382 int nprocs = ParallelContext::NProcsSub();
383
384 // If team is not use, we are going to treat it as a special case in which
385 // the number of teams is nprocs and the number of workers is 1.
386
387 int nteams = nprocs;
388 int nworkers = 1;
389#if defined(BL_USE_TEAM)
390 nteams = ParallelDescriptor::NTeams();
391 nworkers = ParallelDescriptor::TeamSize();
392#endif
393
394 Vector<int> ord;
395 Vector<Vector<int> > wrkerord;
396
397 if (nteams == nprocs) {
398 if (sort) {
399 LeastUsedCPUs(nprocs,ord);
400 } else {
401 ord.resize(nprocs);
402 std::iota(ord.begin(), ord.end(), 0);
403 }
404 wrkerord.resize(nprocs);
405 for (int i = 0; i < nprocs; ++i) {
406 wrkerord[i].resize(1);
407 wrkerord[i][0] = 0;
408 }
409 } else {
410 if (sort) {
411 LeastUsedTeams(ord,wrkerord,nteams,nworkers);
412 } else {
413 ord.resize(nteams);
414 std::iota(ord.begin(), ord.end(), 0);
415 wrkerord.resize(nteams);
416 for (auto& v : wrkerord) {
417 v.resize(nworkers);
418 std::iota(v.begin(), v.end(), 0);
419 }
420 }
421 }
422
423 Vector<int> w(nteams,0);
424
425 if (LIpairV)
426 {
427 BL_ASSERT(std::ssize(*LIpairV) == nboxes);
428
429 for (int i = 0; i < nboxes; ++i)

Callers

nothing calls this directly

Calls 8

PrintClass · 0.85
NProcsSubFunction · 0.85
NTeamsFunction · 0.85
TeamSizeFunction · 0.85
local_to_global_rankFunction · 0.85
resizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected