summaryrefslogtreecommitdiff
path: root/Microbenchmarks/STREAM/support/cyclecount.h
diff options
context:
space:
mode:
authorJuan Gomez Luna <juan.gomez@safari.ethz.ch>2021-06-16 19:46:05 +0200
committerJuan Gomez Luna <juan.gomez@safari.ethz.ch>2021-06-16 19:46:05 +0200
commit3de4b495fb176eba9a0eb517a4ce05903cb67acb (patch)
treefc6776a94549d2d4039898f183dbbeb2ce013ba9 /Microbenchmarks/STREAM/support/cyclecount.h
parentef5c3688c486b80a56d3c1cded25f2b2387f2668 (diff)
PrIM -- first commit
Diffstat (limited to 'Microbenchmarks/STREAM/support/cyclecount.h')
-rw-r--r--Microbenchmarks/STREAM/support/cyclecount.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/Microbenchmarks/STREAM/support/cyclecount.h b/Microbenchmarks/STREAM/support/cyclecount.h
new file mode 100644
index 0000000..4ef377e
--- /dev/null
+++ b/Microbenchmarks/STREAM/support/cyclecount.h
@@ -0,0 +1,20 @@
+#include <perfcounter.h>
+
+// Timer
+typedef struct perfcounter_cycles{
+ perfcounter_t start;
+ perfcounter_t end;
+ perfcounter_t end2;
+
+}perfcounter_cycles;
+
+void timer_start(perfcounter_cycles *cycles){
+ cycles->start = perfcounter_get(); // START TIMER
+}
+
+uint64_t timer_stop(perfcounter_cycles *cycles){
+ cycles->end = perfcounter_get(); // STOP TIMER
+ cycles->end2 = perfcounter_get(); // STOP TIMER
+ return(((uint64_t)((uint32_t)(((cycles->end >> 4) - (cycles->start >> 4)) - ((cycles->end2 >> 4) - (cycles->end >> 4))))) << 4);
+}
+