X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9b73466ada27682d1729f394549479da83ef4a99..90f50bba185f1c86225aa498dcc3a01c9080b52b:/teshsuite/smpi/mpich3-test/coll/red4.c diff --git a/teshsuite/smpi/mpich3-test/coll/red4.c b/teshsuite/smpi/mpich3-test/coll/red4.c index a3e91831b2..f69668d1a6 100644 --- a/teshsuite/smpi/mpich3-test/coll/red4.c +++ b/teshsuite/smpi/mpich3-test/coll/red4.c @@ -15,9 +15,9 @@ static char MTEST_Descrip[] = "Test MPI_Reduce with non-commutative user-define /* * This tests that the reduce operation respects the noncommutative flag. - * and that can distinguish between P_{root} P_{root+1} + * and that can distinguish between P_{root} P_{root+1} * ... P_{root-1} and P_0 ... P_{size-1} . The MPI standard clearly - * specifies that the result is P_0 ... P_{size-1}, independent of the root + * specifies that the result is P_0 ... P_{size-1}, independent of the root * (see 4.9.4 in MPI-1) */ @@ -28,34 +28,35 @@ static char MTEST_Descrip[] = "Test MPI_Reduce with non-commutative user-define c(i,j) is cin[j+i*matSize] */ #define MAXCOL 256 -static int matSize = 0; /* Must be < MAXCOL */ +static int matSize = 0; /* Must be < MAXCOL */ -void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype ); -void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype ) +void uop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype); +void uop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype) { const int *cin; - int *cout; - int i, j, k, nmat; - int tempCol[MAXCOL]; + int *cout; + int i, j, k, nmat; + int tempCol[MAXCOL]; - if (*count != 1) printf( "Panic!\n" ); + if (*count != 1) + printf("Panic!\n"); for (nmat = 0; nmat < *count; nmat++) { - cin = (const int *)cinPtr; - cout = (int *)coutPtr; - for (j=0; j MAXCOL) { - /* Skip because there are too many processes */ - MTestFreeComm( &comm ); - continue; - } + while (MTestGetIntracommGeneral(&comm, minsize, 1)) { + if (comm == MPI_COMM_NULL) + continue; + MPI_Comm_size(comm, &size); + MPI_Comm_rank(comm, &rank); - /* Only one matrix for now */ - count = 1; + if (size > MAXCOL) { + /* Skip because there are too many processes */ + MTestFreeComm(&comm); + continue; + } - /* A single matrix, the size of the communicator */ - MPI_Type_contiguous( size*size, MPI_INT, &mattype ); - MPI_Type_commit( &mattype ); - - buf = (int *)malloc( count * size * size * sizeof(int) ); - if (!buf) MPI_Abort( MPI_COMM_WORLD, 1 ); - bufout = (int *)malloc( count * size * size * sizeof(int) ); - if (!bufout) MPI_Abort( MPI_COMM_WORLD, 1 ); + /* Only one matrix for now */ + count = 1; - for (root = 0; root < size; root ++) { - initMat( comm, buf ); - MPI_Reduce( buf, bufout, count, mattype, op, root, comm ); - if (rank == root) { - errs += isPermutedIdentity( comm, bufout ); - } + /* A single matrix, the size of the communicator */ + MPI_Type_contiguous(size * size, MPI_INT, &mattype); + MPI_Type_commit(&mattype); - /* Try the same test, but using MPI_IN_PLACE */ - initMat( comm, bufout ); - if (rank == root) { - MPI_Reduce( MPI_IN_PLACE, bufout, count, mattype, op, root, comm ); - } - else { - MPI_Reduce( bufout, NULL, count, mattype, op, root, comm ); - } - if (rank == root) { - errs += isPermutedIdentity( comm, bufout ); - } - } - MPI_Type_free( &mattype ); + buf = (int *) malloc(count * size * size * sizeof(int)); + if (!buf) + MPI_Abort(MPI_COMM_WORLD, 1); + bufout = (int *) malloc(count * size * size * sizeof(int)); + if (!bufout) + MPI_Abort(MPI_COMM_WORLD, 1); + + for (root = 0; root < size; root++) { + initMat(comm, buf); + MPI_Reduce(buf, bufout, count, mattype, op, root, comm); + if (rank == root) { + errs += isPermutedIdentity(comm, bufout); + } + + /* Try the same test, but using MPI_IN_PLACE */ + initMat(comm, bufout); + if (rank == root) { + MPI_Reduce(MPI_IN_PLACE, bufout, count, mattype, op, root, comm); + } + else { + MPI_Reduce(bufout, NULL, count, mattype, op, root, comm); + } + if (rank == root) { + errs += isPermutedIdentity(comm, bufout); + } + } + MPI_Type_free(&mattype); - free( buf ); - free( bufout ); + free(buf); + free(bufout); - MTestFreeComm( &comm ); + MTestFreeComm(&comm); } - MPI_Op_free( &op ); + MPI_Op_free(&op); - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; }