X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fc0a76c21f0bceb0314aee5d62f785ea8009495e..b382315f0693083344eb9a25a8fc37b7091bddc7:/teshsuite/smpi/mpich3-test/rma/req_example.c diff --git a/teshsuite/smpi/mpich3-test/rma/req_example.c b/teshsuite/smpi/mpich3-test/rma/req_example.c index 571325c8cc..93cd8da9fa 100644 --- a/teshsuite/smpi/mpich3-test/rma/req_example.c +++ b/teshsuite/smpi/mpich3-test/rma/req_example.c @@ -25,15 +25,16 @@ /* Use a global variable to inhibit compiler optimizations in the compute * function. */ double junk = 0.0; - -void compute(int step, double *data) { +void compute(int step, double *data); +void compute(int step, double *data) +{ int i; for (i = 0; i < N; i++) junk += data[i] * (double) step; } -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int i, rank, nproc; int errors = 0, all_errors = 0; @@ -41,7 +42,8 @@ int main( int argc, char *argv[] ) MPI_Request put_req[M] = { MPI_REQUEST_NULL }; MPI_Request get_req; double *baseptr; - double data[M][N]; /* M buffers of length N */ + double data[M][N]; /* M buffers of length N */ + MPI_Info win_info; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); @@ -49,29 +51,36 @@ int main( int argc, char *argv[] ) assert(M < NSTEPS); - MPI_Win_allocate(NSTEPS*N*sizeof(double), sizeof(double), MPI_INFO_NULL, + MPI_Info_create(&win_info); + +#ifdef USE_WIN_ALLOC_SHM + MPI_Info_set(win_info, (char*)"alloc_shm", (char*)"true"); +#else + MPI_Info_set(win_info, (char*)"alloc_shm", (char*)"false"); +#endif + + MPI_Win_allocate(NSTEPS * N * sizeof(double), sizeof(double), win_info, MPI_COMM_WORLD, &baseptr, &win); MPI_Win_lock_all(0, win); for (i = 0; i < NSTEPS; i++) { - int target = (rank+1) % nproc; + int target = (rank + 1) % nproc; int j; /* Find a free put request */ if (i < M) { j = i; - } else { + } + else { MPI_Waitany(M, put_req, &j, MPI_STATUS_IGNORE); } - MPI_Rget(data[j], N, MPI_DOUBLE, target, i*N, N, MPI_DOUBLE, win, - &get_req); - MPI_Wait(&get_req,MPI_STATUS_IGNORE); + MPI_Rget(data[j], N, MPI_DOUBLE, target, i * N, N, MPI_DOUBLE, win, &get_req); + MPI_Wait(&get_req, MPI_STATUS_IGNORE); compute(i, data[j]); - MPI_Rput(data[j], N, MPI_DOUBLE, target, i*N, N, MPI_DOUBLE, win, - &put_req[j]); + MPI_Rput(data[j], N, MPI_DOUBLE, target, i * N, N, MPI_DOUBLE, win, &put_req[j]); } @@ -80,6 +89,8 @@ int main( int argc, char *argv[] ) MPI_Win_free(&win); + MPI_Info_free(&win_info); + MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); if (rank == 0 && all_errors == 0)