From 97832c7e2cd874a87f61d8031ed31adf4823c8eb Mon Sep 17 00:00:00 2001 From: Gabor Dozsa Date: Fri, 28 Oct 2016 16:10:02 +0100 Subject: [PATCH] Add timing to measure ROI in native runs This is useful for estimating the expected simulation time. Signed-off-by: Gabor Dozsa --- marker_stub.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/marker_stub.h b/marker_stub.h index 1661e1c..d9eaa29 100644 --- a/marker_stub.h +++ b/marker_stub.h @@ -56,9 +56,33 @@ extern "C" { #ifdef ARM_MARKERS #include #else /* ARM_MARKERS */ -#define MARKER_INIT -#define MARKER_START(myrank) -#define MARKER_STOP(myrank) +#include +#include + +struct timespec arm_marker_t0, arm_marker_t1, arm_marker_t2; + +#define MARKER_INIT { \ + if (clock_gettime(CLOCK_MONOTONIC_RAW, &arm_marker_t0) != 0) \ + fprintf(stderr, "(W) clock_gettime() failed in MARKET_INIT\n"); \ +} + +#define MARKER_START(myrank) { \ + if (myrank == 0) { \ + if (clock_gettime(CLOCK_MONOTONIC_RAW, &arm_marker_t1) != 0) \ + fprintf(stderr, "(W) clock_gettime() failed in MARKET_START\n"); \ + } \ +} + +#define MARKER_STOP(myrank) { \ + if (myrank == 0) { \ + if (clock_gettime(CLOCK_MONOTONIC_RAW, &arm_marker_t2) != 0) \ + fprintf(stderr, "(W) clock_gettime() failed in MARKET_STOP\n"); \ + fprintf(stderr, "(I) MARKER init-to-stop time: %12.6f(s)\n(I) MARKER start-to-stop time:%12.6f(s)\n", \ + (arm_marker_t2.tv_sec + 1e-9 * arm_marker_t2.tv_nsec) - (arm_marker_t0.tv_sec + 1e-9 * arm_marker_t0.tv_nsec), \ + (arm_marker_t2.tv_sec + 1e-9 * arm_marker_t2.tv_nsec) - (arm_marker_t1.tv_sec + 1e-9 * arm_marker_t1.tv_nsec)); \ + } \ +} + #define MARKER_BEGIN(id,thread) #define MARKER_END(id,thread) #define MARKER_INFO(level,msg)