X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1bfdc9a38c22af6a9becf133be154a2fa2bc6589..722491bfd68bb3d9d0a97c4841d46bf46f9d9397:/teshsuite/xbt/parmap_bench/parmap_bench.c diff --git a/teshsuite/xbt/parmap_bench/parmap_bench.c b/teshsuite/xbt/parmap_bench/parmap_bench.c index e6558bc986..de148a00c2 100644 --- a/teshsuite/xbt/parmap_bench/parmap_bench.c +++ b/teshsuite/xbt/parmap_bench/parmap_bench.c @@ -9,7 +9,7 @@ #include #include #include -#include /* HAVE_FUTEX_H */ +#include "src/internal_config.h" /* HAVE_FUTEX_H */ #include "simgrid/simix.h" #include "xbt/xbt_os_time.h" @@ -46,7 +46,7 @@ static const char *parmap_mode_name(e_xbt_parmap_mode_t mode) static int parmap_skip_mode(e_xbt_parmap_mode_t mode) { switch (mode) { -#ifndef HAVE_FUTEX_H +#if !HAVE_FUTEX_H case XBT_PARMAP_FUTEX: printf("not available\n"); return 1; @@ -114,8 +114,7 @@ static void bench_parmap_full(int nthreads, e_xbt_parmap_mode_t mode) i++; } while (elapsed_time < TIMEOUT); - printf("ran %d times in %g seconds (%g/s)\n", - i, elapsed_time, i / elapsed_time); + printf("ran %d times in %g seconds (%g/s)\n", i, elapsed_time, i / elapsed_time); xbt_dynar_free(&data); xbt_free(a); @@ -125,8 +124,6 @@ static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode) { unsigned *a; xbt_dynar_t data; - xbt_parmap_t parmap; - int i; double start_time, elapsed_time; printf("** mode = %-15s ", parmap_mode_name(mode)); @@ -137,8 +134,8 @@ static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode) array_new(&a, &data); - parmap = xbt_parmap_new(nthreads, mode); - i = 0; + xbt_parmap_t parmap = xbt_parmap_new(nthreads, mode); + int i = 0; start_time = xbt_os_time(); do { xbt_parmap_apply(parmap, fun_to_apply, data); @@ -157,12 +154,9 @@ static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode) static void bench_all_modes(void (*bench_fun)(int, e_xbt_parmap_mode_t), int nthreads, unsigned modes) { - e_xbt_parmap_mode_t all_modes[] = { - XBT_PARMAP_POSIX, XBT_PARMAP_FUTEX, - XBT_PARMAP_BUSY_WAIT, XBT_PARMAP_DEFAULT - }; - unsigned i; - for (i = 0 ; i < sizeof all_modes / sizeof all_modes[0] ; i++) { + e_xbt_parmap_mode_t all_modes[] = {XBT_PARMAP_POSIX, XBT_PARMAP_FUTEX, XBT_PARMAP_BUSY_WAIT, XBT_PARMAP_DEFAULT}; + + for (unsigned i = 0 ; i < sizeof all_modes / sizeof all_modes[0] ; i++) { if (1U << i & modes) bench_fun(nthreads, all_modes[i]); } @@ -176,8 +170,7 @@ int main(int argc, char *argv[]) SIMIX_global_init(&argc, argv); if (argc != 2 && argc != 3) { - fprintf(stderr, - "Usage: %s nthreads [modes]\n" + fprintf(stderr, "Usage: %s nthreads [modes]\n" " nthreads - number of working threads\n" " modes - bitmask of modes to test\n", argv[0]); @@ -191,8 +184,7 @@ int main(int argc, char *argv[]) if (argc == 3) modes = strtol(argv[2], NULL, 0); - printf("Parmap benchmark with %d workers (modes = %#x)...\n\n", - nthreads, modes); + printf("Parmap benchmark with %d workers (modes = %#x)...\n\n", nthreads, modes); fun_to_apply = fun_small_comp;