X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a339a624022dea90c2f8a3e44b69563bec3c3b81..a3d08dd00246eb26ced68c5b0e046096706bbe23:/teshsuite/smpi/coll-allreduce/coll-allreduce.c diff --git a/teshsuite/smpi/coll-allreduce/coll-allreduce.c b/teshsuite/smpi/coll-allreduce/coll-allreduce.c index e2953f9e7e..509aec9883 100644 --- a/teshsuite/smpi/coll-allreduce/coll-allreduce.c +++ b/teshsuite/smpi/coll-allreduce/coll-allreduce.c @@ -15,14 +15,11 @@ #define EXIT_FAILURE 1 #endif -//define MAXLEN 300000 - int main(int argc, char *argv[]) { - int rank, size; + int rank; + int size; int i; - int *sb; - int *rb; int status; int mult=1; @@ -31,10 +28,11 @@ int main(int argc, char *argv[]) MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); - if (maxlen>1)mult=size; - sb = (int *) xbt_malloc(size *maxlen * sizeof(int)); - rb = (int *) xbt_malloc(size *maxlen * sizeof(int)); - + if (maxlen > 1) + mult = maxlen > size ? size : maxlen; + int* sb = (int *) xbt_malloc(size *maxlen * sizeof(int)); + int* rb = (int *) xbt_malloc(size *maxlen * sizeof(int)); + for (i = 0; i < size *maxlen; ++i) { sb[i] = rank*size + i; rb[i] = 0; @@ -52,15 +50,14 @@ int main(int argc, char *argv[]) printf("%d ", rb[i]); printf("]\n"); - if (rank == 0) { if (status != MPI_SUCCESS) { printf("all_to_all returned %d\n", status); fflush(stdout); } } - free(sb); - free(rb); + xbt_free(sb); + xbt_free(rb); MPI_Finalize(); return (EXIT_SUCCESS); }