Clean up canonical mt benchmarks and reorganize extra versions in /mt. All versions...
[riscv-tests.git] / benchmarks / common / util.h
index 6c4f963f01dc79c961f6d43f1d058450c5c19d02..638f02419304705a704fe841c35639fe8e6e0d48 100644 (file)
@@ -113,4 +113,15 @@ static void __attribute__((noinline)) barrier(int ncores)
 #include "encoding.h"
 #endif
 
+#define stringify_1(s) #s
+#define stringify(s) stringify_1(s)
+#define stats(code, iter) do { \
+    unsigned long _c = -rdcycle(), _i = -rdinstret(); \
+    code; \
+    _c += rdcycle(), _i += rdinstret(); \
+    if (cid == 0) \
+      printf("\n%s: %ld cycles, %ld.%ld cycles/iter, %ld.%ld CPI\n", \
+             stringify(code), _c, _c/iter, 10*_c/iter%10, _c/_i, 10*_c/_i%10); \
+  } while(0)
+
 #endif //__UTIL_H