Skip to content

Commit

Permalink
Merge pull request #6996 from hzhou/2404_win_query
Browse files Browse the repository at this point in the history
ch4: fix win_shared_query for single process

Approved-by: Ken Raffenetti
  • Loading branch information
hzhou committed Apr 29, 2024
2 parents 5885d80 + 28964c3 commit 4e47dc6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mpid/ch4/src/mpidig_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ MPL_STATIC_INLINE_PREFIX int MPIDIG_mpi_win_fence(int massert, MPIR_Win * win)
MPL_STATIC_INLINE_PREFIX int MPIDIG_win_shared_query_self(MPIR_Win * win, int rank, MPI_Aint * size,
int *disp_unit, void *baseptr)
{
if (rank == win->comm_ptr->rank) {
if (rank == win->comm_ptr->rank || (rank == MPI_PROC_NULL && win->comm_ptr->local_size == 1)) {
*size = win->size;
*disp_unit = win->disp_unit;
*((void **) baseptr) = win->base;
Expand Down
15 changes: 13 additions & 2 deletions test/mpi/rma/win_shared_query_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ int main(int argc, char **argv)

MTest_Init(&argc, &argv);

size = sizeof(int) * 4;

/* First test the query on self works */
MPI_Win_allocate_shared(size, sizeof(int), MPI_INFO_NULL, MPI_COMM_SELF, &my_base, &shm_win);
MPI_Win_shared_query(shm_win, MPI_PROC_NULL, &query_size, &query_disp_unit, &query_base);
if (query_base == NULL || query_size != size || query_disp_unit != sizeof(int)) {
fprintf(stderr, "Self shared query with PROC_NULL: base %p, size %ld, unit %d\n",
query_base, query_size, query_disp_unit);
errors++;
}
MPI_Win_free(&shm_win);

/* Next test the query with a true shared domain */
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, rank, MPI_INFO_NULL, &shm_comm);

Expand All @@ -38,8 +51,6 @@ int main(int argc, char **argv)
if (shm_nproc < 2)
goto exit;

size = sizeof(int) * 4;

/* Allocate zero-byte window on rank 0 and non-zero for others */
if (shm_rank == 0) {
MPI_Win_allocate_shared(0, sizeof(int), MPI_INFO_NULL, shm_comm, &my_base, &shm_win);
Expand Down

0 comments on commit 4e47dc6

Please sign in to comment.