X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dccf1b41e9c7b5a696f01abceaa2779fe65f154f..4347df3835009b6526b26de2a7f3bc5ac39a3d0a:/teshsuite/smpi/macro-sample/macro-sample.c diff --git a/teshsuite/smpi/macro-sample/macro-sample.c b/teshsuite/smpi/macro-sample/macro-sample.c index 9f8546de1a..8e10034b6d 100644 --- a/teshsuite/smpi/macro-sample/macro-sample.c +++ b/teshsuite/smpi/macro-sample/macro-sample.c @@ -13,8 +13,7 @@ static double compute(double d0) { double d = d0; - int j; - for (j = 0; j < 100 * 1000 * 1000; j++) { /* 100 kflop */ + for (int j = 0; j < 100 * 1000 * 1000; j++) { /* 100 kflop */ if (d < 100000) { d = d * d; } else { @@ -26,18 +25,17 @@ static double compute(double d0) int main(int argc, char *argv[]) { - int verbose; - int i, n; - double d; + int n, rank; MPI_Init(&argc, &argv); - verbose = argc <= 1; + int verbose = argc <= 1; MPI_Comm_size(MPI_COMM_WORLD, &n); - d = 2.0; - for (i = 0; i < 5; i++) { + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + double d = 2.0; + for (int i = 0; i < 5; i++) { /* I want no more than n + 1 benchs (thres < 0) */ SMPI_SAMPLE_GLOBAL(n + 1, -1) { if (verbose) - fprintf(stderr, "(%12.6f) [rank:%d]", MPI_Wtime(), smpi_process_index()); + fprintf(stderr, "(%12.6f) [rank:%d]", MPI_Wtime(), rank); else fprintf(stderr, "(0)"); fprintf(stderr, " Run the first computation. It's globally benched, " @@ -47,27 +45,28 @@ int main(int argc, char *argv[]) } n = 0; - for (i = 0; i < 5; i++) { + for (int i = 0; i < 5; i++) { /* I want the standard error to go below 0.1 second. * Two tests at least will be run (count is not > 0) */ SMPI_SAMPLE_LOCAL(0, 0.1) { - if (verbose || n++ < 2) { + if (verbose || n < 2) { + n++; if (verbose) fprintf(stderr, "(%12.6f)", MPI_Wtime()); else fprintf(stderr, "(1)"); fprintf(stderr, " [rank:%d] Run the first (locally benched) computation. It's locally benched, and I want the " - "standard error to go below 0.1 second (count is not >0)\n", smpi_process_index()); + "standard error to go below 0.1 second (count is not >0)\n", rank); } d = compute(d); } } if (verbose) - fprintf(stderr, "(%12.6f) [rank:%d] The result of the computation is: %f\n", MPI_Wtime(), smpi_process_index(), d); + fprintf(stderr, "(%12.6f) [rank:%d] The result of the computation is: %f\n", MPI_Wtime(), rank, d); else - fprintf(stderr, "(2) [rank:%d] Done.\n", smpi_process_index()); + fprintf(stderr, "(2) [rank:%d] Done.\n", rank); MPI_Finalize(); return 0;