X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/50130868c2f0c10d86bf368ede7154f6845b0d51..90f50bba185f1c86225aa498dcc3a01c9080b52b:/teshsuite/smpi/mpich3-test/coll/allred4.c diff --git a/teshsuite/smpi/mpich3-test/coll/allred4.c b/teshsuite/smpi/mpich3-test/coll/allred4.c index 1638657ddf..0efc44006c 100644 --- a/teshsuite/smpi/mpich3-test/coll/allred4.c +++ b/teshsuite/smpi/mpich3-test/coll/allred4.c @@ -13,7 +13,7 @@ static char MTEST_Descrip[] = "Test MPI_Allreduce with non-commutative user-defined operations using matrix rotations"; */ -/* This example is similar to allred3.c, but uses only 3x3 matrics with +/* This example is similar to allred3.c, but uses only 3x3 matrics with integer-valued entries. This is an associative but not commutative operation. The number of matrices is the count argument. The matrix is stored @@ -26,211 +26,214 @@ static char MTEST_Descrip[] = "Test MPI_Allreduce with non-commutative user-defi 0 0 1 1 0 0 0 1 0) 0 0 1) - The product + The product I^k A I^(p-2-k-j) B I^j - is + is - ( 0 1 0 + (0 1 0 0 0 1 - 1 0 0 ) + 1 0 0) - for all values of k, p, and j. + for all values of k, p, and j. */ -void matmult( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype ); +void matmult(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype); -void matmult( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype ) +void matmult(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype) { - const int *cin = (const int *)cinPtr; - int *cout = (int *)coutPtr; + const int *cin = (const int *) cinPtr; + int *cout = (int *) coutPtr; int i, j, k, nmat; int tempcol[3]; int offset1, offset2; for (nmat = 0; nmat < *count; nmat++) { - for (j=0; j<3; j++) { - for (i=0; i<3; i++) { - tempcol[i] = 0; - for (k=0; k<3; k++) { - /* col[i] += cin(i,k) * cout(k,j) */ - offset1 = k+i*3; - offset2 = j+k*3; - tempcol[i] += cin[offset1] * cout[offset2]; - } - } - for (i=0; i<3; i++) { - offset1 = j+i*3; - cout[offset1] = tempcol[i]; - } - } - /* Advance to the next matrix */ - cin += 9; - cout += 9; + for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) { + tempcol[i] = 0; + for (k = 0; k < 3; k++) { + /* col[i] += cin(i,k) * cout(k,j) */ + offset1 = k + i * 3; + offset2 = j + k * 3; + tempcol[i] += cin[offset1] * cout[offset2]; + } + } + for (i = 0; i < 3; i++) { + offset1 = j + i * 3; + cout[offset1] = tempcol[i]; + } + } + /* Advance to the next matrix */ + cin += 9; + cout += 9; } } -/* Initialize the integer matrix as one of the +/* Initialize the integer matrix as one of the above matrix entries, as a function of count. We guarantee that both the A and B matrices are included. -*/ -static void initMat( int rank, int size, int nmat, int mat[] ) +*/ +static void initMat(int rank, int size, int nmat, int mat[]) { int i, kind; /* Zero the matrix */ - for (i=0; i<9; i++) { - mat[i] = 0; + for (i = 0; i < 9; i++) { + mat[i] = 0; } /* Decide which matrix to create (I, A, or B) */ - if ( size == 2) { - /* rank 0 is A, 1 is B */ - kind = 1 + rank; + if (size == 2) { + /* rank 0 is A, 1 is B */ + kind = 1 + rank; } else { - int tmpA, tmpB; - /* Most ranks are identity matrices */ - kind = 0; - /* Make sure exactly one rank gets the A matrix - and one the B matrix */ - tmpA = size / 4; - tmpB = (3 * size) / 4; - - if (rank == tmpA) kind = 1; - if (rank == tmpB) kind = 2; + int tmpA, tmpB; + /* Most ranks are identity matrices */ + kind = 0; + /* Make sure exactly one rank gets the A matrix + * and one the B matrix */ + tmpA = size / 4; + tmpB = (3 * size) / 4; + + if (rank == tmpA) + kind = 1; + if (rank == tmpB) + kind = 2; } - + switch (kind) { - case 0: /* Identity */ - mat[0] = 1; - mat[4] = 1; - mat[8] = 1; - break; - case 1: /* A */ - mat[0] = 1; - mat[5] = 1; - mat[7] = 1; - break; - case 2: /* B */ - mat[1] = 1; - mat[3] = 1; - mat[8] = 1; - break; + case 0: /* Identity */ + mat[0] = 1; + mat[4] = 1; + mat[8] = 1; + break; + case 1: /* A */ + mat[0] = 1; + mat[5] = 1; + mat[7] = 1; + break; + case 2: /* B */ + mat[1] = 1; + mat[3] = 1; + mat[8] = 1; + break; } } /* Compare a matrix with the known result */ -static int checkResult( int nmat, int mat[], const char *msg ) +static int checkResult(int nmat, int mat[], const char *msg) { int n, k, errs = 0, wrank; - static int solution[9] = { 0, 1, 0, - 0, 0, 1, - 1, 0, 0 }; - - MPI_Comm_rank( MPI_COMM_WORLD, &wrank ); - - for (n=0; n