X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c57842fe897f53b46f0be3da87f7c996674be7d6..5ca17dc381bb7fba4f2689143e2080f7549ee0ab:/teshsuite/smpi/mpich3-test/rma/fetchandadd_tree.c diff --git a/teshsuite/smpi/mpich3-test/rma/fetchandadd_tree.c b/teshsuite/smpi/mpich3-test/rma/fetchandadd_tree.c index 8b3c8f37a4..4229a9e7b7 100644 --- a/teshsuite/smpi/mpich3-test/rma/fetchandadd_tree.c +++ b/teshsuite/smpi/mpich3-test/rma/fetchandadd_tree.c @@ -3,78 +3,78 @@ * (C) 2001 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */ -#include "mpi.h" +#include "mpi.h" #include "stdio.h" #include "stdlib.h" #include "mpitest.h" /* This is the tree-based scalable version of the fetch-and-add example from Using MPI-2, pg 206-207. The code in the book (Fig - 6.16) has bugs that are fixed below. */ + 6.16) has bugs that are fixed below. */ -#define NTIMES 20 /* no of times each process calls the counter - routine */ +#define NTIMES 20 /* no of times each process calls the counter + * routine */ -int localvalue=0; /* contribution of this process to the counter. We - define it as a global variable because attribute - caching on the window is not enabled yet. */ +int localvalue = 0; /* contribution of this process to the counter. We + * define it as a global variable because attribute + * caching on the window is not enabled yet. */ void Get_nextval_tree(MPI_Win win, int *get_array, MPI_Datatype get_type, - MPI_Datatype acc_type, int nlevels, int *value); + MPI_Datatype acc_type, int nlevels, int *value); int compar(const void *a, const void *b); -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) +{ int rank, nprocs, i, *counter_mem, *get_array, *get_idx, *acc_idx, mask, nlevels, level, idx, tmp_rank, pof2; MPI_Datatype get_type, acc_type; MPI_Win win; int errs = 0, *results, *counter_vals; - - MTest_Init(&argc,&argv); - MPI_Comm_size(MPI_COMM_WORLD,&nprocs); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); + + MTest_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD, &nprocs); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (rank == 0) { /* allocate counter memory and initialize to 0 */ /* find the next power-of-two >= nprocs */ pof2 = 1; - while (pof2 < nprocs) pof2 *= 2; + while (pof2 < nprocs) + pof2 *= 2; - counter_mem = (int *) calloc(pof2*2, sizeof(int)); - MPI_Win_create(counter_mem, pof2*2*sizeof(int), sizeof(int), + counter_mem = (int *) calloc(pof2 * 2, sizeof(int)); + MPI_Win_create(counter_mem, pof2 * 2 * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win); - MPI_Win_free(&win); + MPI_Win_free(&win); free(counter_mem); - /* gather the results from other processes, sort them, and check - whether they represent a counter being incremented by 1 */ + /* gather the results from other processes, sort them, and check + * whether they represent a counter being incremented by 1 */ - results = (int *) malloc(NTIMES*nprocs*sizeof(int)); - for (i=0; i>= 1; @@ -83,28 +83,28 @@ int main(int argc, char *argv[]) get_idx = (int *) malloc(nlevels * sizeof(int)); acc_idx = (int *) malloc(nlevels * sizeof(int)); - level = 0; - idx = 0; + level = 0; + idx = 0; tmp_rank = rank; - while (mask >= 1) { - if (tmp_rank < mask) { + while (mask >= 1) { + if (tmp_rank < mask) { /* go to left for acc_idx, go to right for - get_idx. set idx=acc_idx for next iteration */ - acc_idx[level] = idx + 1; - get_idx[level] = idx + mask*2; - idx = idx + 1; - } - else { + * get_idx. set idx=acc_idx for next iteration */ + acc_idx[level] = idx + 1; + get_idx[level] = idx + mask * 2; + idx = idx + 1; + } + else { /* go to right for acc_idx, go to left for - get_idx. set idx=acc_idx for next iteration */ - acc_idx[level] = idx + mask*2; - get_idx[level] = idx + 1; - idx = idx + mask*2; - } + * get_idx. set idx=acc_idx for next iteration */ + acc_idx[level] = idx + mask * 2; + get_idx[level] = idx + 1; + idx = idx + mask * 2; + } level++; tmp_rank = tmp_rank % mask; - mask >>= 1; - } + mask >>= 1; + } /* for (i=0; i