Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ch4: fix win_shared_query for single process #6996

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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