}
}
-static void bench_parmap_full(int nthreads, e_xbt_parmap_mode_t mode)
+static void bench_parmap_full(int nthreads, e_xbt_parmap_mode_t mode, unsigned stride)
{
unsigned *a;
xbt_dynar_t data;
start_time = xbt_os_time();
do {
parmap = xbt_parmap_new(nthreads, mode);
- xbt_parmap_apply(parmap, fun_to_apply, data);
+ xbt_parmap_apply(parmap, fun_to_apply, data, stride, 0);
xbt_parmap_destroy(parmap);
elapsed_time = xbt_os_time() - start_time;
i++;
xbt_free(a);
}
-static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode)
+static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode, unsigned stride)
{
unsigned *a;
xbt_dynar_t data;
i = 0;
start_time = xbt_os_time();
do {
- xbt_parmap_apply(parmap, fun_to_apply, data);
+ xbt_parmap_apply(parmap, fun_to_apply, data, stride, 0);
elapsed_time = xbt_os_time() - start_time;
i++;
} while (elapsed_time < TIMEOUT);
xbt_free(a);
}
-static void bench_all_modes(void (*bench_fun)(int, e_xbt_parmap_mode_t),
- int nthreads, unsigned modes)
+static void bench_all_modes(void (*bench_fun)(int, e_xbt_parmap_mode_t, unsigned),
+ int nthreads, unsigned modes, unsigned stride)
{
e_xbt_parmap_mode_t all_modes[] = {
XBT_PARMAP_POSIX, XBT_PARMAP_FUTEX,
unsigned i;
for (i = 0 ; i < sizeof all_modes / sizeof all_modes[0] ; i++) {
if (1U << i & modes)
- bench_fun(nthreads, all_modes[i]);
+ bench_fun(nthreads, all_modes[i], stride);
}
}
{
int nthreads;
unsigned modes = MODES_DEFAULT;
+ unsigned stride = 1;
SIMIX_global_init(&argc, argv);
- if (argc != 2 && argc != 3) {
+ if (argc < 2 || argc > 4) {
fprintf(stderr,
- "Usage: %s nthreads [modes]\n"
+ "Usage: %s nthreads [modes [stride]]\n"
" nthreads - number of working threads\n"
- " modes - bitmask of modes to test\n",
+ " modes - bitmask of modes to test\n"
+ " stride - parmap stride\n",
argv[0]);
return EXIT_FAILURE;
}
fprintf(stderr, "ERROR: invalid thread count: %d\n", nthreads);
return EXIT_FAILURE;
}
- if (argc == 3)
+ if (argc >= 3)
modes = strtol(argv[2], NULL, 0);
+ if (argc >= 4)
+ stride = atoi(argv[3]);
- printf("Parmap benchmark with %d workers (modes = %#x)...\n\n",
- nthreads, modes);
+ printf("Parmap benchmark with %d workers (modes = %#x; stride = %d)...\n\n",
+ nthreads, modes, stride);
fun_to_apply = fun_small_comp;
printf("Benchmark for parmap create+apply+destroy (small comp):\n");
- bench_all_modes(bench_parmap_full, nthreads, modes);
+ bench_all_modes(bench_parmap_full, nthreads, modes, stride);
printf("\n");
printf("Benchmark for parmap apply only (small comp):\n");
- bench_all_modes(bench_parmap_apply, nthreads, modes);
+ bench_all_modes(bench_parmap_apply, nthreads, modes, stride);
printf("\n");
fun_to_apply = fun_big_comp;
printf("Benchmark for parmap create+apply+destroy (big comp):\n");
- bench_all_modes(bench_parmap_full, nthreads, modes);
+ bench_all_modes(bench_parmap_full, nthreads, modes, stride);
printf("\n");
printf("Benchmark for parmap apply only (big comp):\n");
- bench_all_modes(bench_parmap_apply, nthreads, modes);
+ bench_all_modes(bench_parmap_apply, nthreads, modes, stride);
printf("\n");
return EXIT_SUCCESS;