diff options
| author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
| commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
| tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/c/timingUtils.h | |
| parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (diff) | |
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to:
- Use libextra to loop as realtime jobs
- Preallocate memory before starting their main computation
- Accept input via stdin instead of via argc
Does not include the SD-VBS matlab code.
Fixes libextra execution in LITMUS^RT.
Diffstat (limited to 'SD-VBS/common/c/timingUtils.h')
| -rw-r--r-- | SD-VBS/common/c/timingUtils.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/SD-VBS/common/c/timingUtils.h b/SD-VBS/common/c/timingUtils.h new file mode 100644 index 0000000..818728f --- /dev/null +++ b/SD-VBS/common/c/timingUtils.h | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | #ifdef GCC | ||
| 2 | #define magic_timing_begin(cycleLo, cycleHi) {\ | ||
| 3 | asm volatile( "rdtsc": "=a" (cycleLo), "=d" (cycleHi)); \ | ||
| 4 | }\ | ||
| 5 | |||
| 6 | #define magic_timing_end(cycleLo, cycleHi) {\ | ||
| 7 | unsigned tempCycleLo, tempCycleHi; \ | ||
| 8 | asm volatile( "rdtsc": "=a" (tempCycleLo), "=d" (tempCycleHi)); \ | ||
| 9 | cycleLo = tempCycleLo-cycleLo;\ | ||
| 10 | cycleHi = tempCycleHi - cycleHi;\ | ||
| 11 | }\ | ||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | #define magic_timing_report(cycleLo, cycleHi) {\ | ||
| 16 | printf("Timing report: %d %d\n", cycleLo, cycleHi); \ | ||
| 17 | }\ | ||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | #endif | ||
| 23 | |||
| 24 | #ifdef METRO | ||
| 25 | |||
| 26 | #define magic_timing_begin(cycleLo, cycleHi) {\ | ||
| 27 | asm volatile( "mfsr $8, CYCLE_LO\n\t" \ | ||
| 28 | "mfsr $9, CYCLE_HI\n\t" \ | ||
| 29 | "addu %0, $8, $0\n\t" \ | ||
| 30 | "addu %1, $9, $0\n\t" \ | ||
| 31 | :"=r" (cycleLo), "=r" (cycleHi) \ | ||
| 32 | : \ | ||
| 33 | :"$8", "$9"\ | ||
| 34 | );\ | ||
| 35 | } | ||
| 36 | |||
| 37 | #define magic_timing_end(cycleLo, cycleHi) {\ | ||
| 38 | asm volatile( \ | ||
| 39 | "mfsr $8, CYCLE_LO\n\t" \ | ||
| 40 | "mfsr $9, CYCLE_HI\n\t" \ | ||
| 41 | "subu %0, $8, %0\n\t" \ | ||
| 42 | "subu %1, $9, %1\n\t" \ | ||
| 43 | :"=r" (cycleLo), "=r" (cycleHi) \ | ||
| 44 | : \ | ||
| 45 | :"$8", "$9"\ | ||
| 46 | ); \ | ||
| 47 | } | ||
| 48 | |||
| 49 | #define magic_timing_report(cycleLo, cycleHi) {\ | ||
| 50 | asm volatile( "addu $8, %0, $0\n\t" \ | ||
| 51 | "mtsr PASS $8\n\t" \ | ||
| 52 | "mtsr PASS $9\n\t" \ | ||
| 53 | : \ | ||
| 54 | :"r" (cycleLo), "r" (cycleHi) \ | ||
| 55 | : "$8", "$9" \ | ||
| 56 | );\ | ||
| 57 | } | ||
| 58 | |||
| 59 | //#define metro_magic_timing_report(cycleLo, cycleHi) {\ | ||
| 60 | // asm volatile( "nop\n\t");\ | ||
| 61 | //} | ||
| 62 | |||
| 63 | #endif | ||
| 64 | |||
| 65 | #ifdef BTL | ||
| 66 | |||
| 67 | #include "/u/kvs/raw/rawlib/archlib/include/raw.h" | ||
| 68 | |||
| 69 | #define magic_timing_begin(cycleLo, cycleHi) {\ | ||
| 70 | raw_magic_timing_report_begin();\ | ||
| 71 | } | ||
| 72 | |||
| 73 | #define magic_timing_end(cycleLo, cycleHi) {\ | ||
| 74 | raw_magic_timing_report_end(); \ | ||
| 75 | } | ||
| 76 | |||
| 77 | #define magic_timing_report(cycleLo, cycleHi) {\ | ||
| 78 | raw_magic_timing_report_print(); \ | ||
| 79 | } | ||
| 80 | |||
| 81 | |||
| 82 | // | ||
| 83 | //void metro_magic_timing_begin(int cycleLo, int cycleHi) | ||
| 84 | //{ | ||
| 85 | // raw_magic_timing_report_begin(); | ||
| 86 | //} | ||
| 87 | // | ||
| 88 | //void metro_magic_timing_end(int cycleLo, int cycleHi) | ||
| 89 | //{ | ||
| 90 | // raw_magic_timing_report_end(); | ||
| 91 | //} | ||
| 92 | // | ||
| 93 | //void metro_magic_timing_report(int cycleLo, int cycleHi) | ||
| 94 | //{ | ||
| 95 | // raw_magic_timing_report_print(); | ||
| 96 | // return; | ||
| 97 | //} | ||
| 98 | |||
| 99 | #endif | ||
