| 370 | } |
| 371 | |
| 372 | void |
| 373 | DistributionMapping::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) |