summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--baseline/source/extra.h52
1 files changed, 31 insertions, 21 deletions
diff --git a/baseline/source/extra.h b/baseline/source/extra.h
index 5e527c6..3f6df32 100644
--- a/baseline/source/extra.h
+++ b/baseline/source/extra.h
@@ -11,6 +11,7 @@
11#include <signal.h> 11#include <signal.h>
12#include <limits.h> 12#include <limits.h>
13#include <fcntl.h> 13#include <fcntl.h>
14#include <stdint.h>
14 15
15// These constants correspond to the imx6q-sabredb platform 16// These constants correspond to the imx6q-sabredb platform
16#define LINE_SIZE 32 17#define LINE_SIZE 32
@@ -55,19 +56,20 @@
55 char *thisCore=argv[3];\ 56 char *thisCore=argv[3];\
56 char *runID=argv[4];\ 57 char *runID=argv[4];\
57 int output=atoi(argv[5]);\ 58 int output=atoi(argv[5]);\
58 pid_t killMe;\ 59 struct timespec _start, _end;\
59 struct timespec start, end;\
60 int jobsComplete;\ 60 int jobsComplete;\
61 int jobs_complete = -1;\ 61 int jobs_complete = -1;\
62 float progTime[maxJobs*output];\ 62 float *progTime = malloc(sizeof(float)*maxJobs*output);\
63 memset(progTime, 0, sizeof(float)*maxJobs*output);\ 63 memset(progTime, 0, sizeof(float)*maxJobs*output);\
64 char fileName[50];\ 64 char fileName[64];\
65 char *bigArray;\ 65 float *mmdc_read = malloc(sizeof(float)*maxJobs*output);\
66 int wasteCount;\ 66 float *mmdc_write = malloc(sizeof(float)*maxJobs*output);\
67 float mmdc_read[maxJobs];\ 67 memset(mmdc_read, 0, sizeof(float)*maxJobs*output);\
68 float mmdc_write[maxJobs];\ 68 memset(mmdc_write, 0, sizeof(float)*maxJobs*output);\
69 memset(mmdc_read, 0, sizeof(float)*maxJobs);\ 69 if (strlen(runID) + 5 > sizeof(fileName)) {\
70 memset(mmdc_write, 0, sizeof(float)*maxJobs);\ 70 fprintf(stderr, "Run ID is too large! Keep it to less than 60 characters.\n");\
71 exit(1);\
72 }\
71 strcpy(fileName, runID);\ 73 strcpy(fileName, runID);\
72 strcat(fileName, ".txt");\ 74 strcat(fileName, ".txt");\
73 mlockall(MCL_CURRENT || MCL_FUTURE); 75 mlockall(MCL_CURRENT || MCL_FUTURE);
@@ -160,19 +162,27 @@
160 162
161#if MMDC_PROF 163#if MMDC_PROF
162#define SAVE_RESULTS \ 164#define SAVE_RESULTS \
163 if(jobs_complete>-1) {\ 165 if(jobs_complete >= maxJobs) {\
164 progTime[jobs_complete] = end.tv_sec - start.tv_sec;\ 166 fprintf(stderr, "Max jobs setting too small! Exiting...\n");\
167 exit(1);\
168 }\
169 if(jobs_complete>-1 && output) {\
170 progTime[jobs_complete] = _end.tv_sec - _start.tv_sec;\
165 progTime[jobs_complete] *= 1000000000;\ 171 progTime[jobs_complete] *= 1000000000;\
166 progTime[jobs_complete] += end.tv_nsec - start.tv_nsec;\ 172 progTime[jobs_complete] += _end.tv_nsec - _start.tv_nsec;\
167 mmdc_read[jobs_complete] = mmdc_res.read_bytes;\ 173 mmdc_read[jobs_complete] = mmdc_res.read_bytes;\
168 mmdc_write[jobs_complete] = mmdc_res.write_bytes;\ 174 mmdc_write[jobs_complete] = mmdc_res.write_bytes;\
169 } 175 }
170#else 176#else
171#define SAVE_RESULTS \ 177#define SAVE_RESULTS \
172 if(jobs_complete>-1) {\ 178 if(jobs_complete >= maxJobs) {\
173 progTime[jobs_complete] = end.tv_sec - start.tv_sec;\ 179 fprintf(stderr, "Max jobs setting too small! Exiting...\n");\
180 exit(1);\
181 }\
182 if(jobs_complete>-1 && output) {\
183 progTime[jobs_complete] = _end.tv_sec - _start.tv_sec;\
174 progTime[jobs_complete] *= 1000000000;\ 184 progTime[jobs_complete] *= 1000000000;\
175 progTime[jobs_complete] += end.tv_nsec - start.tv_nsec;\ 185 progTime[jobs_complete] += _end.tv_nsec - _start.tv_nsec;\
176 } 186 }
177#endif 187#endif
178 188
@@ -187,7 +197,7 @@
187 munlockall();\ 197 munlockall();\
188 FILE *fp=fopen(fileName, "a");\ 198 FILE *fp=fopen(fileName, "a");\
189 if (fp == NULL) {\ 199 if (fp == NULL) {\
190 perror("Error opening file. \n");\ 200 perror("Unable to open output file");\
191 exit(1);\ 201 exit(1);\
192 }\ 202 }\
193 for(int i = 0; i <= jobs_complete; i++){\ 203 for(int i = 0; i <= jobs_complete; i++){\
@@ -226,19 +236,19 @@
226 /* This disables profiling, resets the counters, clears the overflow bit, and enables profiling */ \ 236 /* This disables profiling, resets the counters, clears the overflow bit, and enables profiling */ \
227 start_mmdc_profiling(mmdc); \ 237 start_mmdc_profiling(mmdc); \
228 /*nanosleep(&(struct timespec){0, ms2ns(999)}, NULL);*/ \ 238 /*nanosleep(&(struct timespec){0, ms2ns(999)}, NULL);*/ \
229 clock_gettime(CLOCK_MONOTONIC, &start); 239 clock_gettime(CLOCK_MONOTONIC, &_start);
230#else 240#else
231#define START_TIMER clock_gettime(CLOCK_MONOTONIC, &start); 241#define START_TIMER clock_gettime(CLOCK_MONOTONIC, &_start);
232#endif 242#endif
233 243
234#if MMDC_PROF 244#if MMDC_PROF
235#define STOP_TIMER \ 245#define STOP_TIMER \
236 clock_gettime(CLOCK_MONOTONIC, &end); \ 246 clock_gettime(CLOCK_MONOTONIC, &_end); \
237 /* This freezes the profiling and makes results available */ \ 247 /* This freezes the profiling and makes results available */ \
238 pause_mmdc_profiling(mmdc); \ 248 pause_mmdc_profiling(mmdc); \
239 get_mmdc_profiling_results(mmdc, &mmdc_res); 249 get_mmdc_profiling_results(mmdc, &mmdc_res);
240#else 250#else
241#define STOP_TIMER clock_gettime(CLOCK_MONOTONIC, &end); 251#define STOP_TIMER clock_gettime(CLOCK_MONOTONIC, &_end);
242#endif 252#endif
243 253
244#define SLEEP nanosleep((const struct timespec[]){{0, 1000000}}, NULL); 254#define SLEEP nanosleep((const struct timespec[]){{0, 1000000}}, NULL);