summaryrefslogtreecommitdiffstats
path: root/testbench.h
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2023-06-09 19:38:01 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2023-06-09 19:38:01 -0400
commit5ba80e14efb595688a3dc3d49c212bc393840513 (patch)
tree87b57ee39eaf0c12603eb1b6f4ea9e0889a20e8e /testbench.h
parente63404cfda97050b9d516232ceb4f918f48edcfc (diff)
Add constant_cycles_kernel benchmark + header split and Makefile
Benchmark supports: => Looping on the GPU for a specified number of iterations => Looping infinitely on the GPU => Logging the sum time (ns and ms) for all iterations to complete Also splits `testbench.h` out of `copy_testbench.h` for use in other benchmarks.
Diffstat (limited to 'testbench.h')
-rw-r--r--testbench.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/testbench.h b/testbench.h
new file mode 100644
index 0000000..28d7f77
--- /dev/null
+++ b/testbench.h
@@ -0,0 +1,14 @@
1/* Copyright 2021-2023 Joshua Bakita
2 * Header for miscellaneous experimental helper functions.
3 */
4
5#define SAFE(x) \
6 if ((err = (cudaError_t)(x)) != 0) { \
7 printf("CUDA error %d! %s\n", err, cudaGetErrorString(err)); \
8 printf("Suspect line: %s\n", #x); \
9 exit(1); \
10 }
11
12#define s2ns(s) ((s)*1000l*1000l*1000l)
13#define ns2ms(s) ((s)/(1000l*1000l))
14#define timediff(start, end) ((s2ns((end).tv_sec) + (end).tv_nsec) - (s2ns((start).tv_sec) + (start).tv_nsec))