X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3080c6b0d097d6b3b7d5b3dda0592154ce438f64..f6361035ba2972dede69bcdf16bc6724bd50bf7d:/teshsuite/smpi/mpich3-test/rma/mcs-mutex.c diff --git a/teshsuite/smpi/mpich3-test/rma/mcs-mutex.c b/teshsuite/smpi/mpich3-test/rma/mcs-mutex.c index 533fbdb882..96b0f7b580 100644 --- a/teshsuite/smpi/mpich3-test/rma/mcs-mutex.c +++ b/teshsuite/smpi/mpich3-test/rma/mcs-mutex.c @@ -39,10 +39,17 @@ int MCS_Mutex_create(int tail_rank, MPI_Comm comm, MCS_Mutex * hdl_out) hdl->tail_rank = tail_rank; #ifdef USE_WIN_SHARED - MPI_Win_allocate_shared(2*sizeof(int), sizeof(int), MPI_INFO_NULL, + MPI_Win_allocate_shared(2 * sizeof(int), sizeof(int), MPI_INFO_NULL, hdl->comm, &hdl->base, &hdl->window); #else - MPI_Win_allocate(2*sizeof(int), sizeof(int), MPI_INFO_NULL, hdl->comm, +#ifdef USE_WIN_ALLOC_SHM + MPI_Info_create(&hdl->win_info); + MPI_Info_set(hdl->win_info, (char*)"alloc_shm", (char*)"true"); +#else + MPI_Info_create(&hdl->win_info); + MPI_Info_set(hdl->win_info, (char*)"alloc_shm", (char*)"false"); +#endif + MPI_Win_allocate(2 * sizeof(int), sizeof(int), hdl->win_info, hdl->comm, &hdl->base, &hdl->window); #endif @@ -73,6 +80,9 @@ int MCS_Mutex_free(MCS_Mutex * hdl_ptr) MPI_Win_free(&hdl->window); MPI_Comm_free(&hdl->comm); +#ifndef USE_WIN_SHARED + MPI_Info_free(&hdl->win_info); +#endif free(hdl); hdl_ptr = NULL; @@ -109,7 +119,8 @@ int MCS_Mutex_lock(MCS_Mutex hdl) /* Wait for notification */ MPI_Status status; - MPI_Accumulate(&rank, 1, MPI_INT, prev, MCS_MTX_ELEM_DISP, 1, MPI_INT, MPI_REPLACE, hdl->window); + MPI_Accumulate(&rank, 1, MPI_INT, prev, MCS_MTX_ELEM_DISP, 1, MPI_INT, MPI_REPLACE, + hdl->window); MPI_Win_flush(prev, hdl->window); debug_print("%2d: LOCK - waiting for notification from %d\n", rank, prev); @@ -171,11 +182,10 @@ int MCS_Mutex_unlock(MCS_Mutex hdl) /* Read my next pointer. FOP is used since another process may write to * this location concurrent with this read. */ - MPI_Fetch_and_op(NULL, &next, MPI_INT, rank, MCS_MTX_ELEM_DISP, MPI_NO_OP, - hdl->window); + MPI_Fetch_and_op(NULL, &next, MPI_INT, rank, MCS_MTX_ELEM_DISP, MPI_NO_OP, hdl->window); MPI_Win_flush(rank, hdl->window); - if ( next == MPI_PROC_NULL) { + if (next == MPI_PROC_NULL) { int tail; int nil = MPI_PROC_NULL; @@ -196,10 +206,10 @@ int MCS_Mutex_unlock(MCS_Mutex hdl) MPI_NO_OP, hdl->window); MPI_Win_flush(rank, hdl->window); - if (next != MPI_PROC_NULL) break; + if (next != MPI_PROC_NULL) + break; - MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, - MPI_STATUS_IGNORE); + MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE); } } }