1 /* chrono - demo of GRAS benchmarking features */
3 /* Copyright (c) 2005, 2007, 2009, 2010. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
12 XBT_LOG_NEW_DEFAULT_CATEGORY(Chrono, "Messages specific to this example");
15 /* Function prototypes */
16 int multiplier(int argc, char *argv[]);
18 int multiplier(int argc, char *argv[])
26 gras_init(&argc, argv);
28 A = malloc(n * n * sizeof(double));
29 B = malloc(n * n * sizeof(double));
30 C = malloc(n * n * sizeof(double));
32 start = now = gras_os_time();
34 XBT_INFO("Begin matrix multiplication loop (time: %g)", start);
36 for (l = 0; l < 4; l++) {
38 GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
39 for (i = 0; i < n; i++)
40 for (j = 0; j < n; j++) {
46 for (i = 0; i < n; i++)
47 for (j = 0; j < n; j++)
48 for (k = 0; k < n; k++)
49 C[i * n + j] += A[i * n + k] * B[k * n + j];
51 GRAS_BENCH_ONCE_RUN_ONCE_END();
52 now = gras_os_time() - now;
53 XBT_INFO("Iteration %d : %g ", l, now);
56 now = gras_os_time() - start;
57 XBT_INFO("End matrix multiplication loop (time: %g; Duration: %g)",
60 start = now = gras_os_time();
61 XBT_INFO("Begin malloc loop (time: %g)", start);
62 for (l = 0; l < 4; l++) {
64 GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
66 A = malloc(n * n * sizeof(double));
67 GRAS_BENCH_ONCE_RUN_ONCE_END();
68 now = gras_os_time() - now;
69 XBT_INFO("Iteration %d : %g ", l, now);
72 start = now = gras_os_time();
73 XBT_INFO("Begin integer incrementation loop (time: %g)", start);
74 for (l = 0; l < 4; l++) {
75 GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
77 GRAS_BENCH_ONCE_RUN_ONCE_END();