From fa6c70a44fc56cc50370e57c460dd61e8f127b51 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Fri, 23 May 2025 16:28:17 +0200 Subject: SpMV: Add AspectC++ support --- SpMV/include/timer.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 SpMV/include/timer.h (limited to 'SpMV/include/timer.h') diff --git a/SpMV/include/timer.h b/SpMV/include/timer.h new file mode 100644 index 0000000..cb513cb --- /dev/null +++ b/SpMV/include/timer.h @@ -0,0 +1,54 @@ +#pragma once + +#include +#include + +#if DFATOOL_TIMING + +#define dfatool_printf(fmt, ...) do { printf(fmt, __VA_ARGS__); } while (0) + +typedef struct Timer { + struct timeval startTime; + struct timeval endTime; +} Timer; + +static void startTimer(Timer *timer) +{ + gettimeofday(&(timer->startTime), NULL); +} + +static void stopTimer(Timer *timer) +{ + gettimeofday(&(timer->endTime), NULL); +} + +static double getElapsedTime(Timer timer) +{ + return ((double)((timer.endTime.tv_sec - timer.startTime.tv_sec) + + (timer.endTime.tv_usec - + timer.startTime.tv_usec) / 1.0e6)); +} + +#else + +#define dfatool_printf(fmt, ...) do {} while (0) + +typedef int Timer; + +static void startTimer(Timer* timer) +{ + (void)timer; +} + +static void stopTimer(Timer* timer) +{ + (void)timer; +} + +static double getElapsedTime(Timer timer) +{ + (void)timer; + return 0.0; +} + +#endif -- cgit v1.2.3