diff options
Diffstat (limited to 'SD-VBS')
| -rw-r--r-- | SD-VBS/benchmarks/tracking/src/c/script_tracking.c | 6 | ||||
| -rw-r--r-- | SD-VBS/common/c/extra.h | 479 |
2 files changed, 481 insertions, 4 deletions
diff --git a/SD-VBS/benchmarks/tracking/src/c/script_tracking.c b/SD-VBS/benchmarks/tracking/src/c/script_tracking.c index 2938126..c0af2d7 100644 --- a/SD-VBS/benchmarks/tracking/src/c/script_tracking.c +++ b/SD-VBS/benchmarks/tracking/src/c/script_tracking.c | |||
| @@ -93,9 +93,8 @@ int main(int argc, char* argv[]) | |||
| 93 | 93 | ||
| 94 | I2D* images[counter]; | 94 | I2D* images[counter]; |
| 95 | /** Read input image **/ | 95 | /** Read input image **/ |
| 96 | for(count=1; count<=counter; count++) | 96 | for(count=1; count<=counter; count++){ |
| 97 | { | 97 | /** Read Image **/ |
| 98 | /** Read image **/ | ||
| 99 | scanf("%s", im1); | 98 | scanf("%s", im1); |
| 100 | images[count - 1] = readImage(im1); | 99 | images[count - 1] = readImage(im1); |
| 101 | if(count == 1) Ic = readImage(im1); | 100 | if(count == 1) Ic = readImage(im1); |
| @@ -227,7 +226,6 @@ int main(int argc, char* argv[]) | |||
| 227 | fFreeHandle(newpoints); | 226 | fFreeHandle(newpoints); |
| 228 | } | 227 | } |
| 229 | } | 228 | } |
| 230 | |||
| 231 | #ifdef CHECK | 229 | #ifdef CHECK |
| 232 | /* Self checking */ | 230 | /* Self checking */ |
| 233 | { | 231 | { |
diff --git a/SD-VBS/common/c/extra.h b/SD-VBS/common/c/extra.h new file mode 100644 index 0000000..8c67b33 --- /dev/null +++ b/SD-VBS/common/c/extra.h | |||
| @@ -0,0 +1,479 @@ | |||
| 1 | /** | ||
| 2 | * Copyright 2019 Sims Hill Osborne and 2020 Joshua Bakita | ||
| 3 | * | ||
| 4 | * This header provides facilities by which to separably run and time TACLeBench | ||
| 5 | * To use this for paired task timing, define PAIRED (pass CFLAGS=-DPAIRED to make) | ||
| 6 | **/ | ||
| 7 | #define _GNU_SOURCE | ||
| 8 | #include <fcntl.h> // For O_CREAT and O_RDWR | ||
| 9 | #include <sched.h> // For sched_yield() | ||
| 10 | #include <semaphore.h> // For sem_{open, post, wait}() | ||
| 11 | #include <stdio.h> | ||
| 12 | #include <stdlib.h> // For exit() | ||
| 13 | #include <string.h> // For strlen() | ||
| 14 | #include <sys/mman.h> // For mlockall() | ||
| 15 | #include <unistd.h> // For ftruncate() | ||
| 16 | #include <time.h> | ||
| 17 | |||
| 18 | // This is only visible if _GNU_SOURCE is defined, and that define does not | ||
| 19 | // come along to places where this file is included. Address this by manually | ||
| 20 | // forcing it into the global namespace. | ||
| 21 | extern int sched_getcpu(); | ||
| 22 | |||
| 23 | // These constants correspond to the imx6q-sabredb platform | ||
| 24 | #define LINE_SIZE 32 | ||
| 25 | #define L2_SIZE 16*2048*32 | ||
| 26 | |||
| 27 | #if __arm__ | ||
| 28 | #include <unistd.h> | ||
| 29 | #include <sys/syscall.h> | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #define LITMUS 1 | ||
| 33 | #define MC2 0 | ||
| 34 | #define MMDC_PROF 0 | ||
| 35 | |||
| 36 | #if LITMUS | ||
| 37 | #include <litmus.h> | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #if MMDC_PROF | ||
| 41 | #include "/media/speedy/litmus/tools/mmdc/mmdc.h" | ||
| 42 | #endif | ||
| 43 | |||
| 44 | #if LITMUS | ||
| 45 | #define SET_UP LOAD_PARAMS SETUP_LITMUS | ||
| 46 | #else | ||
| 47 | #define SET_UP LOAD_PARAMS | ||
| 48 | #endif | ||
| 49 | |||
| 50 | #if MMDC_PROF | ||
| 51 | #define LOAD_PARAMS LOAD_PARAMS_ITRL SETUP_MMDC | ||
| 52 | #else | ||
| 53 | #define LOAD_PARAMS LOAD_PARAMS_ITRL | ||
| 54 | #endif | ||
| 55 | |||
| 56 | // Store state globally so that the job can be outside main() | ||
| 57 | // Arrays use float as a comprimise between overflow and size | ||
| 58 | // Paired arrays use long longs as precision is more important for those times | ||
| 59 | #ifdef PAIRED | ||
| 60 | long long *_rt_start_time; | ||
| 61 | long long *_rt_end_time; | ||
| 62 | #else | ||
| 63 | float *_rt_exec_time; | ||
| 64 | #endif | ||
| 65 | #if MMDC_PERF | ||
| 66 | float *_rt_mmdc_read; | ||
| 67 | float *_rt_mmdc_write; | ||
| 68 | #endif | ||
| 69 | long _rt_jobs_complete; | ||
| 70 | long _rt_max_jobs; | ||
| 71 | int _rt_core; | ||
| 72 | int _rt_will_output; | ||
| 73 | struct timespec _rt_start, _rt_end; | ||
| 74 | |||
| 75 | char *_rt_run_id; | ||
| 76 | char *_rt_our_prog_name; | ||
| 77 | char *_rt_other_prog_name; | ||
| 78 | char *_rt_other_core; | ||
| 79 | #define _RT_FILENAME_LEN 64 | ||
| 80 | #define _BILLION (1000*1000*1000) | ||
| 81 | #ifdef PAIRED | ||
| 82 | char *_rt_barrier; | ||
| 83 | sem_t *_rt_first_sem, *_rt_second_sem; | ||
| 84 | int _rt_lock_id; | ||
| 85 | #endif | ||
| 86 | |||
| 87 | static void _rt_load_params_itrl(int argc, char **argv) { | ||
| 88 | #ifdef PAIRED | ||
| 89 | if (argc != 8) { | ||
| 90 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <other core> <other name> <runID> <lockID>", argv[0]); | ||
| 91 | fprintf(stderr, " <name> string for logging. Name of this task.\n"); | ||
| 92 | fprintf(stderr, " <loops> integer number of iterations. -1 for infinite.\n"); | ||
| 93 | fprintf(stderr, " <my core> UNUSED. Core is now auto-detected.\n"); | ||
| 94 | fprintf(stderr, " <other core> integer for logging. Core of paired task.\n"); | ||
| 95 | fprintf(stderr, " <other name> string for logging. Name of paired task.\n"); | ||
| 96 | fprintf(stderr, " <runID> string to append with .txt to yield output file name.\n"); | ||
| 97 | fprintf(stderr, " <lockID> 1 to indicate this is pair member 1, otherwise pair member 2.\n"); | ||
| 98 | exit(1); | ||
| 99 | } | ||
| 100 | #else | ||
| 101 | if (argc != 6) { | ||
| 102 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <runID> <save results?>\n", argv[0]); | ||
| 103 | fprintf(stderr, " <name> string for logging. Name of this task.\n"); | ||
| 104 | fprintf(stderr, " <loops> integer number of iterations. -1 for infinite.\n"); | ||
| 105 | fprintf(stderr, " <my core> UNUSED. Core is now auto-detected.\n"); | ||
| 106 | fprintf(stderr, " <runID> string to append with .txt to yield output file name.\n"); | ||
| 107 | fprintf(stderr, " <save results?> 1 to save results, 0 to discard.\n"); | ||
| 108 | exit(1); | ||
| 109 | } | ||
| 110 | #endif | ||
| 111 | _rt_our_prog_name = argv[1]; | ||
| 112 | _rt_max_jobs = atol(argv[2]); | ||
| 113 | _rt_core = sched_getcpu(); | ||
| 114 | #ifdef PAIRED | ||
| 115 | _rt_other_core = argv[4]; | ||
| 116 | _rt_other_prog_name = argv[5]; | ||
| 117 | _rt_run_id = argv[6]; | ||
| 118 | _rt_lock_id = atoi(argv[7]); | ||
| 119 | // The paired version doesn't support disabling output (legacy compatibility) | ||
| 120 | _rt_will_output = 1; | ||
| 121 | #else | ||
| 122 | _rt_other_core = "none"; | ||
| 123 | _rt_other_prog_name = "none"; | ||
| 124 | _rt_run_id = argv[4]; | ||
| 125 | _rt_will_output = atoi(argv[5]); | ||
| 126 | #endif /* PAIRED */ | ||
| 127 | if (_rt_max_jobs < 0 && _rt_will_output != 0) { | ||
| 128 | fprintf(stderr, "Infinite loops only supported when _rt_will_output is disabled!\n"); | ||
| 129 | exit(1); | ||
| 130 | } | ||
| 131 | if (strlen(_rt_run_id) + 5 > _RT_FILENAME_LEN) { | ||
| 132 | fprintf(stderr, "Run ID is too large! Keep it to less than %d characters.\n", _RT_FILENAME_LEN); | ||
| 133 | exit(1); | ||
| 134 | } | ||
| 135 | #ifdef PAIRED | ||
| 136 | _rt_start_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); | ||
| 137 | _rt_end_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); | ||
| 138 | if (!_rt_end_time || !_rt_start_time) { | ||
| 139 | perror("Unable to allocate buffers for execution times"); | ||
| 140 | exit(1); | ||
| 141 | } | ||
| 142 | _rt_first_sem = sem_open("/_libextra_first_sem", O_CREAT, 644, 0); | ||
| 143 | _rt_second_sem = sem_open("/_libextra_second_sem", O_CREAT, 644, 0); | ||
| 144 | if (_rt_first_sem == SEM_FAILED || _rt_second_sem == SEM_FAILED) { | ||
| 145 | perror("Error while creating semaphores"); | ||
| 146 | exit(1); | ||
| 147 | } | ||
| 148 | int barrier_file = shm_open("/_libextra_barrier", O_CREAT | O_RDWR, 644); | ||
| 149 | if (barrier_file == -1) { | ||
| 150 | perror("Error while creating shared memory for barrier synchronization"); | ||
| 151 | exit(1); | ||
| 152 | } | ||
| 153 | if (ftruncate(barrier_file, 1) == -1) { | ||
| 154 | perror("Error while setting size of shared memory for barrier synchronization"); | ||
| 155 | exit(1); | ||
| 156 | } | ||
| 157 | _rt_barrier = mmap(NULL, 1, PROT_WRITE, MAP_SHARED, barrier_file, 0); | ||
| 158 | if (_rt_barrier == MAP_FAILED) { | ||
| 159 | perror("Error while mapping shared memory for barrier synchronization"); | ||
| 160 | exit(1); | ||
| 161 | } | ||
| 162 | *_rt_barrier = 0; | ||
| 163 | #else | ||
| 164 | _rt_exec_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(float)); | ||
| 165 | if (!_rt_exec_time) { | ||
| 166 | perror("Unable to allocate buffer for execution times"); | ||
| 167 | exit(1); | ||
| 168 | } | ||
| 169 | #endif /* PAIRED */ | ||
| 170 | _rt_jobs_complete = 0; | ||
| 171 | mlockall(MCL_CURRENT || MCL_FUTURE); | ||
| 172 | } | ||
| 173 | #define LOAD_PARAMS_ITRL _rt_load_params_itrl(argc, argv); | ||
| 174 | |||
| 175 | #define SETUP_MMDC \ | ||
| 176 | _rt_mmdc_read = calloc(_rt_max_jobs * _rt_will_output, sizeof(float));\ | ||
| 177 | _rt_mmdc_write = calloc(_rt_max_jobs * _rt_will_output, sizeof(float));\ | ||
| 178 | |||
