X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c57842fe897f53b46f0be3da87f7c996674be7d6..b195400e3382f070aa49293a0ab7d9441889f5e4:/teshsuite/smpi/mpich3-test/rma/accfence2_am.c diff --git a/teshsuite/smpi/mpich3-test/rma/accfence2_am.c b/teshsuite/smpi/mpich3-test/rma/accfence2_am.c index 96c651635e..0d11fb4535 100644 --- a/teshsuite/smpi/mpich3-test/rma/accfence2_am.c +++ b/teshsuite/smpi/mpich3-test/rma/accfence2_am.c @@ -19,77 +19,79 @@ static char MTEST_Descrip[] = "Test MPI_Accumulate with fence"; /* same as accfence2.c, but uses alloc_mem */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size, source; - int minsize = 2, count, i; - MPI_Comm comm; - MPI_Win win; - int *winbuf, *sbuf; + int minsize = 2, count, i; + MPI_Comm comm; + MPI_Win win; + int *winbuf, *sbuf; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - /* The following illustrates the use of the routines to - run through a selection of communicators and datatypes. - Use subsets of these for tests that do not involve combinations - of communicators, datatypes, and counts of datatypes */ - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; - /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); - source = 0; - - for (count = 32768; count < 65000; count = count * 2) { + /* The following illustrates the use of the routines to + * run through a selection of communicators and datatypes. + * Use subsets of these for tests that do not involve combinations + * of communicators, datatypes, and counts of datatypes */ + while (MTestGetIntracommGeneral(&comm, minsize, 1)) { + if (comm == MPI_COMM_NULL) + continue; + /* Determine the sender and receiver */ + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); + source = 0; + for (count = 32768; count < 65000; count = count * 2) { - /* We compare with an integer value that can be as large as - size * (count * count + (1/2)*(size-1)) - For large machines (size large), this can exceed the - maximum integer for some large values of count. We check - that in advance and break this loop if the above value - would exceed MAX_INT. Specifically, + /* We compare with an integer value that can be as large as + * size * (count * count + (1/2)*(size-1)) + * For large machines (size large), this can exceed the + * maximum integer for some large values of count. We check + * that in advance and break this loop if the above value + * would exceed MAX_INT. Specifically, + * + * size*count*count + (1/2)*size*(size-1) > MAX_INT + * count*count > (MAX_INT/size - (1/2)*(size-1)) + */ + if (count * count > (MAX_INT / size - (size - 1) / 2)) + break; - size*count*count + (1/2)*size*(size-1) > MAX_INT - count*count > (MAX_INT/size - (1/2)*(size-1)) - */ - if (count * count > (MAX_INT/size - (size-1)/2)) break; + MPI_Alloc_mem(count * sizeof(int), MPI_INFO_NULL, &winbuf); + MPI_Alloc_mem(count * sizeof(int), MPI_INFO_NULL, &sbuf); - MPI_Alloc_mem( count * sizeof(int), MPI_INFO_NULL, &winbuf ); - MPI_Alloc_mem( count * sizeof(int), MPI_INFO_NULL, &sbuf ); + for (i = 0; i < count; i++) + winbuf[i] = 0; + for (i = 0; i < count; i++) + sbuf[i] = rank + i * count; + MPI_Win_create(winbuf, count * sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win); + MPI_Win_fence(0, win); + MPI_Accumulate(sbuf, count, MPI_INT, source, 0, count, MPI_INT, MPI_SUM, win); + MPI_Win_fence(0, win); + if (rank == source) { + /* Check the results */ + for (i = 0; i < count; i++) { + int result = i * count * size + (size * (size - 1)) / 2; + if (winbuf[i] != result) { + if (errs < 10) { + fprintf(stderr, + "Winbuf[%d] = %d, expected %d (count = %d, size = %d)\n", i, + winbuf[i], result, count, size); + } + errs++; + } + } + } - for (i=0; i