- Commit
- 1497e5933ac42eeb193dd11272e0227f51521c0a
- Parent
- 3afbf537102a2107f34922063d34eddb2aa06333
- Author
- Pablo <pablo-pie@riseup.net>
- Date
Added compile-time checks to perf.h
Educational material on the SciPy implementation of numerical linear algebra algorithms
Added compile-time checks to perf.h
2 files changed, 21 insertions, 11 deletions
Status | File Name | N° Changes | Insertions | Deletions |
Modified | getrf/benchmarks/src/main.c | 18 | 9 | 9 |
Modified | getrf/benchmarks/src/perf.h | 14 | 12 | 2 |
diff --git a/getrf/benchmarks/src/main.c b/getrf/benchmarks/src/main.c @@ -145,19 +145,19 @@ int main(int argc, char **argv) "We need to update argv parsing if we add more perf events"); if (argc < 2 || strcmp(argv[1], "standard") == 0) { getrf = dgetrf_; - output_paths[CACHE_LOADS] = OUTPUT_DIR "cache-loads.bin";; - output_paths[CACHE_MISSES] = OUTPUT_DIR "cache-misses.bin";; - output_paths[CPU_CYCLES] = OUTPUT_DIR "cpu-cycles.bin";; + output_paths[CACHE_LOADS] = OUTPUT_DIR "cache-loads.bin"; + output_paths[CACHE_MISSES] = OUTPUT_DIR "cache-misses.bin"; + output_paths[CPU_CYCLES] = OUTPUT_DIR "cpu-cycles.bin"; } else if (strcmp(argv[1], "naive") == 0) { getrf = dgetrfnaive_; - output_paths[CACHE_LOADS] = OUTPUT_DIR "cache-loads-naive.bin";; - output_paths[CACHE_MISSES] = OUTPUT_DIR "cache-misses-naive.bin";; - output_paths[CPU_CYCLES] = OUTPUT_DIR "cpu-cycles-naive.bin";; + output_paths[CACHE_LOADS] = OUTPUT_DIR "cache-loads-naive.bin"; + output_paths[CACHE_MISSES] = OUTPUT_DIR "cache-misses-naive.bin"; + output_paths[CPU_CYCLES] = OUTPUT_DIR "cpu-cycles-naive.bin"; } else if (strcmp(argv[1], "unblocked") == 0) { getrf = dgetrf2_; - output_paths[CACHE_LOADS] = OUTPUT_DIR "cache-loads-unblocked.bin";; - output_paths[CACHE_MISSES] = OUTPUT_DIR "cache-misses-unblocked.bin";; - output_paths[CPU_CYCLES] = OUTPUT_DIR "cpu-cycles-unblocked.bin";; + output_paths[CACHE_LOADS] = OUTPUT_DIR "cache-loads-unblocked.bin"; + output_paths[CACHE_MISSES] = OUTPUT_DIR "cache-misses-unblocked.bin"; + output_paths[CPU_CYCLES] = OUTPUT_DIR "cpu-cycles-unblocked.bin"; } else { fprintf(stderr, "ERROR: unknown command \"%s\"\n", argv[1]); fprintf(stderr, "USAGE: %s [standard|naive|unblocked]\n", argv[0]);
diff --git a/getrf/benchmarks/src/perf.h b/getrf/benchmarks/src/perf.h @@ -1,6 +1,10 @@ #ifndef PERF_H_ #define PERF_H_ +#ifndef __linux__ +#error "The perf.h library can only be compiled in the Linux platform" +#endif // __linux__ + #include <sys/syscall.h> #include <sys/ioctl.h> #include <unistd.h> @@ -22,12 +26,16 @@ enum { PERF_EVENT_COUNT }; +static_assert(PERF_EVENT_COUNT == 3, + "We should update this array if we add more events"); uint32_t perf_event_types[PERF_EVENT_COUNT] = { [CACHE_LOADS] = PERF_TYPE_HW_CACHE, [CACHE_MISSES] = PERF_TYPE_HW_CACHE, - [CPU_CYCLES] = PERF_TYPE_HARDWARE, + [CPU_CYCLES] = PERF_TYPE_HARDWARE, }; +static_assert(PERF_EVENT_COUNT == 3, + "We should update this array if we add more events"); uint64_t perf_event_configs[PERF_EVENT_COUNT] = { [CACHE_LOADS] = PERF_COUNT_HW_CACHE_L1D | (PERF_COUNT_HW_CACHE_OP_READ << 8) @@ -38,10 +46,12 @@ uint64_t perf_event_configs[PERF_EVENT_COUNT] = { [CPU_CYCLES] = PERF_COUNT_HW_CPU_CYCLES, }; +static_assert(PERF_EVENT_COUNT == 3, + "We should update this array if we add more events"); const char *perf_event_str[PERF_EVENT_COUNT] = { [CACHE_LOADS] = "CACHE_LOADS", [CACHE_MISSES] = "CACHE_MISSES", - [CPU_CYCLES] = "CPU_CYCLES", + [CPU_CYCLES] = "CPU_CYCLES", }; static_assert(PERF_EVENT_COUNT == 3,