Skip to content

MPMD MPI_APPNUM equivalent with srun #11845

Open
@b-fg

Description

@b-fg

To run MPMD I use the classic form: mpirun -n 4 exe1 : -n 4 exe2 : ....
I normally split the world communicator into a communicator for each executable using MPI_APPNUM (Fortran):

integer(mpi_address_kind) :: color_ptr
logical :: mpi_app_num_flag

! Init MPI_COMM_WORLD communicator (shared accros all applications launched with mpirun MPMD)
call mpi_init(mpi_err)
world_comm = MPI_COMM_WORLD
call mpi_comm_rank(world_comm, mpi_world_rank, mpi_err)
call mpi_comm_size(world_comm, mpi_world_size, mpi_err)

! Get the app number (color)
call MPI_Comm_get_attr(world_comm, MPI_APPNUM, color_ptr, mpi_app_num_flag, mpi_err)
app_color = color_ptr ! necessary to get integer from pointer

! Split world_comm and create a communicator for this app only (color must be unique for each application)
if (mpi_app_num_flag) then
   call MPI_Comm_split(world_comm, app_color, mpi_world_rank, app_comm, mpi_err)
   call MPI_Comm_rank(app_comm, mpi_rank, mpi_err)
   call MPI_Comm_size(app_comm, mpi_size, mpi_err)
else
   write(*,*) 'Fatal error in init_mpi()! Cannot find MPI_APPNUM.'
   call MPI_Abort(world_comm,-1,mpi_err)
end if

However, the MPI_APPNUM variable is not found when running with srun (mpi_app_num_flag results in .false.). How can I use srun and still have access to MPI_APPNUM, ie: srun -n 4 exe? Otherwise a different implementation will be required to run with both commands seamlessly.
Thanks for the support!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions