Yes, this is the behavior defined by the MPI standard. More precisely, section 8.1.2 of the MPI 3.1 standard clearly states that the predefined attributes only exists for MPI_COMM_WORLD.
George. On Sun, Jul 8, 2018 at 1:55 AM Weiqun Zhang <weiqunzh...@lbl.gov> wrote: > Hi, > > It appears that MPI_Comm_get_attr fails to get MPI_TAG_UB for > sub-communicators created by MPI_Comm_split. I have tested the following > programs with openmpi 3.1.1 and openmpi 1.10.2. MPI_Comm_get_attr works on > MPI_COMM_WORLD, but not on sub-communicators. Is this expected? > > #include <stdio.h> > #include <mpi.h> > > int main(int argc, char** argv) > { > MPI_Init(&argc, &argv); > > int rank; > MPI_Comm_rank(MPI_COMM_WORLD, &rank); > void* p; int flag; > MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &p, &flag); > if (!flag) { > printf("MPI_COMM_WORLD: rank %d failed to get MPI_TAG_UB\n", rank); > } else { > printf("MPI_COMM_WORLD: rank %d succeeded to get MPI_TAG_UB\n", > rank); > } > > int color = rank%2; > MPI_Comm comm; > MPI_Comm_split(MPI_COMM_WORLD, color, rank, &comm); > int rank2; > MPI_Comm_rank(comm, &rank2); > MPI_Comm_get_attr(comm, MPI_TAG_UB, &p, &flag); > if (!flag) { > printf("Subcommunicator %d rank %d failed to get MPI_TAG_UB\n", > color, rank2); > } else { > printf("Subcommunicator %d rank %d succeeded to get MPI_TAG_UB\n", > color, rank2); > } > > MPI_Finalize(); > } > > program main > > use mpi > implicit none > > integer :: ierr, rank, color, comm, rank2 > integer(kind=MPI_ADDRESS_KIND) :: attrval > logical :: flag > > call MPI_Init(ierr) > > call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr) > call MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, attrval, flag, ierr) > if (.not.flag) then > print *, "MPI_COMM_WORLD: rank ", rank, " failed to get MPI_TAG_UB." > else > print *, "MPI_COMM_WORLD: rank ", rank, " succeeded to get > MPI_TAG_UB." > end if > > color = modulo(rank,2) > call MPI_Comm_split(MPI_COMM_WORLD, color, rank, comm, ierr) > call MPI_Comm_rank(comm, rank2, ierr) > call MPI_Comm_get_attr(comm, MPI_TAG_UB, attrval, flag, ierr) > if (.not.flag) then > print *, "Subcommunicator ", color, " rank ", rank2, " failed to get > MPI_TAG_UB." > else > print *, "Subcommunicator ", color, " rank ", rank2, " succeeded to > get MPI_TAG_UB." > end if > > call MPI_Finalize(ierr) > > end program main > > Thanks, > > Weiqun > > _______________________________________________ > users mailing list > users@lists.open-mpi.org > https://lists.open-mpi.org/mailman/listinfo/users
_______________________________________________ users mailing list users@lists.open-mpi.org https://lists.open-mpi.org/mailman/listinfo/users