diff options
Diffstat (limited to 'baseline/source/extra.h')
| -rw-r--r-- | baseline/source/extra.h | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/baseline/source/extra.h b/baseline/source/extra.h index 3f6df32..02e97af 100644 --- a/baseline/source/extra.h +++ b/baseline/source/extra.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | * | 3 | * |
| 4 | * This header provides facilities by which to separably run and time TACLeBench | 4 | * This header provides facilities by which to separably run and time TACLeBench |
| 5 | **/ | 5 | **/ |
| 6 | #define _GNU_SOURCE | ||
| 6 | #include <time.h> | 7 | #include <time.h> |
| 7 | #include <sys/mman.h> | 8 | #include <sys/mman.h> |
| 8 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| @@ -12,6 +13,12 @@ | |||
| 12 | #include <limits.h> | 13 | #include <limits.h> |
| 13 | #include <fcntl.h> | 14 | #include <fcntl.h> |
| 14 | #include <stdint.h> | 15 | #include <stdint.h> |
| 16 | #include <sched.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(); | ||
| 15 | 22 | ||
| 16 | // These constants correspond to the imx6q-sabredb platform | 23 | // These constants correspond to the imx6q-sabredb platform |
| 17 | #define LINE_SIZE 32 | 24 | #define LINE_SIZE 32 |
| @@ -47,15 +54,24 @@ | |||
| 47 | #endif | 54 | #endif |
| 48 | 55 | ||
| 49 | #define LOAD_PARAMS_ITRL \ | 56 | #define LOAD_PARAMS_ITRL \ |
| 50 | if (argc < 6) { \ | 57 | if (argc != 6) { \ |
| 51 | printf("Usage: %s <name> <loops> <my core> <runID> <save results?>\n", argv[0]);\ | 58 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <runID> <save results?>\n", argv[0]);\ |
| 59 | fprintf(stderr, " <loops> integer number of iterations. -1 for infitite.\n");\ | ||
| 60 | fprintf(stderr, " <save results?> 1 to save results, 0 to discard.\n");\ | ||
| 52 | exit(1);\ | 61 | exit(1);\ |
| 53 | }\ | 62 | }\ |
| 54 | char *thisProgram=argv[1];\ | 63 | char *thisProgram=argv[1];\ |
| 55 | int maxJobs=atoi(argv[2]);\ | 64 | int parsedMaxJobs=atoi(argv[2]);\ |
| 56 | char *thisCore=argv[3];\ | 65 | unsigned int thisCore=atoi(argv[3]);\ |
| 66 | thisCore = sched_getcpu();\ | ||
| 57 | char *runID=argv[4];\ | 67 | char *runID=argv[4];\ |
| 58 | int output=atoi(argv[5]);\ | 68 | int output=atoi(argv[5]);\ |
| 69 | if (parsedMaxJobs < 0 && output != 0){\ | ||
| 70 | fprintf(stderr, "Infinite loops only supported when output is disabled!\n");\ | ||
| 71 | exit(1);\ | ||
| 72 | }\ | ||
| 73 | /* Cheat. -1 is larger than jobsComplete can ever reach. */\ | ||
| 74 | unsigned int maxJobs = parsedMaxJobs;\ | ||
| 59 | struct timespec _start, _end;\ | 75 | struct timespec _start, _end;\ |
| 60 | int jobsComplete;\ | 76 | int jobsComplete;\ |
| 61 | int jobs_complete = -1;\ | 77 | int jobs_complete = -1;\ |
| @@ -163,10 +179,10 @@ | |||
| 163 | #if MMDC_PROF | 179 | #if MMDC_PROF |
| 164 | #define SAVE_RESULTS \ | 180 | #define SAVE_RESULTS \ |
| 165 | if(jobs_complete >= maxJobs) {\ | 181 | if(jobs_complete >= maxJobs) {\ |
| 166 | fprintf(stderr, "Max jobs setting too small! Exiting...\n");\ | 182 | fprintf(stderr, "Max jobs setting too small! Trying to record job #%d when we only have space for %d jobs. Exiting...\n", jobs_complete, maxJobs);\ |
| 167 | exit(1);\ | 183 | exit(1);\ |
| 168 | }\ | 184 | }\ |
| 169 | if(jobs_complete>-1 && output) {\ | 185 | if(jobs_complete > -1 && output) {\ |
| 170 | progTime[jobs_complete] = _end.tv_sec - _start.tv_sec;\ | 186 | progTime[jobs_complete] = _end.tv_sec - _start.tv_sec;\ |
| 171 | progTime[jobs_complete] *= 1000000000;\ | 187 | progTime[jobs_complete] *= 1000000000;\ |
| 172 | progTime[jobs_complete] += _end.tv_nsec - _start.tv_nsec;\ | 188 | progTime[jobs_complete] += _end.tv_nsec - _start.tv_nsec;\ |
| @@ -176,10 +192,10 @@ | |||
| 176 | #else | 192 | #else |
| 177 | #define SAVE_RESULTS \ | 193 | #define SAVE_RESULTS \ |
| 178 | if(jobs_complete >= maxJobs) {\ | 194 | if(jobs_complete >= maxJobs) {\ |
| 179 | fprintf(stderr, "Max jobs setting too small! Exiting...\n");\ | 195 | fprintf(stderr, "Max jobs setting too small! Trying to record job #%d when we only have space for %d jobs. Exiting...\n", jobs_complete, maxJobs);\ |
| 180 | exit(1);\ | 196 | exit(1);\ |
| 181 | }\ | 197 | }\ |
| 182 | if(jobs_complete>-1 && output) {\ | 198 | if(jobs_complete > -1 && output) {\ |
| 183 | progTime[jobs_complete] = _end.tv_sec - _start.tv_sec;\ | 199 | progTime[jobs_complete] = _end.tv_sec - _start.tv_sec;\ |
| 184 | progTime[jobs_complete] *= 1000000000;\ | 200 | progTime[jobs_complete] *= 1000000000;\ |
| 185 | progTime[jobs_complete] += _end.tv_nsec - _start.tv_nsec;\ | 201 | progTime[jobs_complete] += _end.tv_nsec - _start.tv_nsec;\ |
| @@ -200,8 +216,8 @@ | |||
| 200 | perror("Unable to open output file");\ | 216 | perror("Unable to open output file");\ |
| 201 | exit(1);\ | 217 | exit(1);\ |
| 202 | }\ | 218 | }\ |
| 203 | for(int i = 0; i <= jobs_complete; i++){\ | 219 | for (int i = 0; i <= jobs_complete; i++){\ |
| 204 | fprintf(fp, "%s none %s none %d %.f %s %d %.f %.f \n",\ | 220 | fprintf(fp, "%s none %u none %d %.f %s %d %.f %.f \n",\ |
| 205 | thisProgram, thisCore, maxJobs,\ | 221 | thisProgram, thisCore, maxJobs,\ |
| 206 | progTime[i], runID, i, mmdc_read[i], mmdc_write[i]);\ | 222 | progTime[i], runID, i, mmdc_read[i], mmdc_write[i]);\ |
| 207 | }\ | 223 | }\ |
| @@ -260,7 +276,7 @@ | |||
| 260 | } \ | 276 | } \ |
| 261 | FLUSH_CACHES START_TIMER | 277 | FLUSH_CACHES START_TIMER |
| 262 | #else | 278 | #else |
| 263 | #define START_LOOP FLUSH_CACHES START_TIMER | 279 | #define START_LOOP sched_yield(); FLUSH_CACHES START_TIMER |
| 264 | #endif | 280 | #endif |
| 265 | 281 | ||
| 266 | #define STOP_LOOP STOP_TIMER jobs_complete++; SAVE_RESULTS | 282 | #define STOP_LOOP STOP_TIMER jobs_complete++; SAVE_RESULTS |
| @@ -272,7 +288,7 @@ Intended structure | |||
| 272 | main | 288 | main |
| 273 | SET_UP | 289 | SET_UP |
| 274 | notice that STOP LOOP negates the ++ if outout=0 | 290 | notice that STOP LOOP negates the ++ if outout=0 |
| 275 | for (jobsComplete=-1; jobsComplete<maxJobs; jobsComplete++){ | 291 | for (jobsComplete=0; jobsComplete<maxJobs; jobsComplete++){ |
| 276 | START_LOOP | 292 | START_LOOP |
| 277 | tacleInit(); | 293 | tacleInit(); |
| 278 | tacleMain(); | 294 | tacleMain(); |
