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

Function StartTeams

Src/Base/AMReX_ParallelDescriptor.cpp:1598–1652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1596
1597#ifndef BL_AMRPROF
1598void
1599StartTeams ()
1600{
1601 int nprocs = ParallelDescriptor::NProcs();
1602 int rank = ParallelDescriptor::MyProc();
1603
1604 int team_size = 1;
1605 int do_team_reduce = 0;
1606
1607#if defined(BL_USE_MPI3)
1608 ParmParse pp("amrex.team");
1609 pp.query("size", team_size);
1610 pp.query("reduce", do_team_reduce);
1611 if (team_size <= 0) {
1612 amrex::Abort("amrex.team.size must be > 0");
1613 }
1614 if (nprocs % team_size != 0) {
1615 amrex::Abort("Number of processes not divisible by team size");
1616 }
1617#endif
1618
1619 m_Team.m_numTeams = nprocs / team_size;
1620 m_Team.m_size = team_size;
1621 m_Team.m_color = rank / team_size;
1622 m_Team.m_lead = m_Team.m_color * team_size;
1623 m_Team.m_rankInTeam = rank - m_Team.m_lead;
1624
1625 m_Team.m_do_team_reduce = team_size > 0 && do_team_reduce;
1626
1627#if defined(BL_USE_MPI3)
1628 {
1629 MPI_Group grp, team_grp, lead_grp;
1630 BL_MPI_REQUIRE( MPI_Comm_group(ParallelDescriptor::Communicator(), &grp) );
1631 Vector<int> team_ranks(team_size);
1632 for (int i = 0; i < team_size; ++i) {
1633 team_ranks[i] = MyTeamLead() + i;
1634 }
1635 BL_MPI_REQUIRE( MPI_Group_incl(grp, team_size, team_ranks.data(), &team_grp) );
1636 BL_MPI_REQUIRE( MPI_Comm_create(ParallelDescriptor::Communicator(),
1637 team_grp, &m_Team.m_team_comm) );
1638
1639 std::vector<int>lead_ranks(m_Team.m_numTeams);
1640 for (int i = 0; i < lead_ranks.size(); ++i) {
1641 lead_ranks[i] = i * team_size;
1642 }
1643 BL_MPI_REQUIRE( MPI_Group_incl(grp, lead_ranks.size(), lead_ranks.data(), &lead_grp) );
1644 BL_MPI_REQUIRE( MPI_Comm_create(ParallelDescriptor::Communicator(),
1645 lead_grp, &m_Team.m_lead_comm) );
1646
1647 BL_MPI_REQUIRE( MPI_Group_free(&grp) );
1648 BL_MPI_REQUIRE( MPI_Group_free(&team_grp) );
1649 BL_MPI_REQUIRE( MPI_Group_free(&lead_grp) );
1650 }
1651#endif
1652}
1653#endif
1654
1655void

Callers 1

InitializeFunction · 0.85

Calls 8

AbortFunction · 0.85
CommunicatorFunction · 0.85
MyTeamLeadFunction · 0.85
NProcsFunction · 0.70
MyProcFunction · 0.70
queryMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected