X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=benchmarks%2Fcommon%2Futil.h;h=638f02419304705a704fe841c35639fe8e6e0d48;hb=d537de7deffa6036dab573ff174b7f8c8e470437;hp=6c4f963f01dc79c961f6d43f1d058450c5c19d02;hpb=5afc6b9bc2e3685220cffb3da66ad9f5f1f7b14f;p=riscv-tests.git diff --git a/benchmarks/common/util.h b/benchmarks/common/util.h index 6c4f963..638f024 100644 --- a/benchmarks/common/util.h +++ b/benchmarks/common/util.h @@ -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