A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement stride for parmap_apply.
[simgrid.git]
/
testsuite
/
xbt
/
parmap_bench.c
diff --git
a/testsuite/xbt/parmap_bench.c
b/testsuite/xbt/parmap_bench.c
index
d63bfc3
..
1ce420a
100644
(file)
--- a/
testsuite/xbt/parmap_bench.c
+++ b/
testsuite/xbt/parmap_bench.c
@@
-4,6
+4,7
@@
#include <xbt/parmap.h>
#include <xbt/sysdep.h>
#include <internal_config.h> /* HAVE_FUTEX_H */
#include <xbt/parmap.h>
#include <xbt/sysdep.h>
#include <internal_config.h> /* HAVE_FUTEX_H */
+#include "simgrid/simix.h"
#include "xbt/xbt_os_time.h"
#define MODES_DEFAULT 0x7
#include "xbt/xbt_os_time.h"
#define MODES_DEFAULT 0x7
@@
-81,7
+82,7
@@
static void array_new(unsigned **a, xbt_dynar_t *data)
}
}
}
}
-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;
{
unsigned *a;
xbt_dynar_t data;
@@
-101,7
+102,7
@@
static void bench_parmap_full(int nthreads, e_xbt_parmap_mode_t mode)
start_time = xbt_os_time();
do {
parmap = xbt_parmap_new(nthreads, mode);
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_parmap_destroy(parmap);
elapsed_time = xbt_os_time() - start_time;
i++;
@@
-114,7
+115,7
@@
static void bench_parmap_full(int nthreads, e_xbt_parmap_mode_t mode)
xbt_free(a);
}
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;
{
unsigned *a;
xbt_dynar_t data;
@@
-134,7
+135,7
@@
static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode)
i = 0;
start_time = xbt_os_time();
do {
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);
elapsed_time = xbt_os_time() - start_time;
i++;
} while (elapsed_time < TIMEOUT);
@@
-147,8
+148,8
@@
static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode)
xbt_free(a);
}
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,
{
e_xbt_parmap_mode_t all_modes[] = {
XBT_PARMAP_POSIX, XBT_PARMAP_FUTEX,
@@
-157,7
+158,7
@@
static void bench_all_modes(void (*bench_fun)(int, e_xbt_parmap_mode_t),
unsigned i;
for (i = 0 ; i < sizeof all_modes / sizeof all_modes[0] ; i++) {
if (1U << i & modes)
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
);
}
}
}
}
@@
-165,12
+166,16
@@
int main(int argc, char *argv[])
{
int nthreads;
unsigned modes = MODES_DEFAULT;
{
int nthreads;
unsigned modes = MODES_DEFAULT;
+ unsigned stride = 1;
- if (argc != 2 && argc != 3) {
+ SIMIX_global_init(&argc, argv);
+
+ if (argc < 2 || argc > 4) {
fprintf(stderr,
fprintf(stderr,
- "Usage: %s nthreads [modes]\n"
+ "Usage: %s nthreads [modes
[stride]
]\n"
" nthreads - number of working threads\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;
}
argv[0]);
return EXIT_FAILURE;
}
@@
-179,30
+184,32
@@
int main(int argc, char *argv[])
fprintf(stderr, "ERROR: invalid thread count: %d\n", nthreads);
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);
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");
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");
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");
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");
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;
printf("\n");
return EXIT_SUCCESS;