diff options
Diffstat (limited to 'extra.h')
| -rw-r--r-- | extra.h | 32 |
1 files changed, 23 insertions, 9 deletions
| @@ -44,12 +44,12 @@ extern int sched_getcpu(); | |||
| 44 | // Store state globally so that the job can be outside main() | 44 | // Store state globally so that the job can be outside main() |
| 45 | // Arrays use float as a comprimise between overflow and size | 45 | // Arrays use float as a comprimise between overflow and size |
| 46 | // Paired arrays use long longs as precision is more important for those times | 46 | // Paired arrays use long longs as precision is more important for those times |
| 47 | #ifdef PAIRED | 47 | // #ifdef PAIRED |
| 48 | long long *_rt_start_time; | 48 | long long *_rt_start_time; |
| 49 | long long *_rt_end_time; | 49 | long long *_rt_end_time; |
| 50 | #else | 50 | // #else |
| 51 | float *_rt_exec_time; | 51 | float *_rt_exec_time; |
| 52 | #endif | 52 | // #endif |
| 53 | #if MMDC_PERF | 53 | #if MMDC_PERF |
| 54 | float *_rt_mmdc_read; | 54 | float *_rt_mmdc_read; |
| 55 | float *_rt_mmdc_write; | 55 | float *_rt_mmdc_write; |
| @@ -154,6 +154,7 @@ static void _rt_load_params_itrl(int argc, char **argv) { | |||
| 154 | } | 154 | } |
| 155 | _rt_start_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); | 155 | _rt_start_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); |
| 156 | _rt_end_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); | 156 | _rt_end_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); |
| 157 | _rt_exec_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(float)); | ||
| 157 | if (!_rt_end_time || !_rt_start_time) { | 158 | if (!_rt_end_time || !_rt_start_time) { |
| 158 | perror("Unable to allocate buffers for execution times"); | 159 | perror("Unable to allocate buffers for execution times"); |
| 159 | exit(1); | 160 | exit(1); |
| @@ -197,6 +198,8 @@ static void _rt_load_params_itrl(int argc, char **argv) { | |||
| 197 | } | 198 | } |
| 198 | *_rt_barrier = 0; | 199 | *_rt_barrier = 0; |
| 199 | #else | 200 | #else |
| 201 | _rt_start_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); | ||
| 202 | _rt_end_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); | ||
| 200 | _rt_exec_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(float)); | 203 | _rt_exec_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(float)); |
| 201 | if (!_rt_exec_time) { | 204 | if (!_rt_exec_time) { |
| 202 | perror("Unable to allocate buffer for execution times"); | 205 | perror("Unable to allocate buffer for execution times"); |
| @@ -342,18 +345,29 @@ static void _rt_save_job_result() { | |||
| 342 | fprintf(stderr, "Max jobs setting too small! Trying to record job #%ld when we only have space for %ld jobs. Exiting...\n", _rt_jobs_complete, _rt_max_jobs); | 345 | fprintf(stderr, "Max jobs setting too small! Trying to record job #%ld when we only have space for %ld jobs. Exiting...\n", _rt_jobs_complete, _rt_max_jobs); |
| 343 | exit(1); | 346 | exit(1); |
| 344 | } | 347 | } |
| 345 | #ifdef PAIRED | 348 | // #ifdef PAIRED |
| 346 | _rt_start_time[_rt_jobs_complete] = _rt_start.tv_sec; | 349 | _rt_start_time[_rt_jobs_complete] = _rt_start.tv_sec; |
| 347 | _rt_start_time[_rt_jobs_complete] *= _BILLION; | 350 | _rt_start_time[_rt_jobs_complete] *= _BILLION; |
| 348 | _rt_start_time[_rt_jobs_complete] += _rt_start.tv_nsec; | 351 | _rt_start_time[_rt_jobs_complete] += _rt_start.tv_nsec; |
| 349 | _rt_end_time[_rt_jobs_complete] = _rt_end.tv_sec; | 352 | _rt_end_time[_rt_jobs_complete] = _rt_end.tv_sec; |
| 350 | _rt_end_time[_rt_jobs_complete] *= _BILLION; | 353 | _rt_end_time[_rt_jobs_complete] *= _BILLION; |
| 351 | _rt_end_time[_rt_jobs_complete] += _rt_end.tv_nsec; | 354 | _rt_end_time[_rt_jobs_complete] += _rt_end.tv_nsec; |
| 352 | #else | 355 | |
| 353 | _rt_exec_time[_rt_jobs_complete] = _rt_end.tv_sec - _rt_start.tv_sec; | 356 | _rt_exec_time[_rt_jobs_complete] = _rt_end.tv_sec - _rt_start.tv_sec; |
| 354 | _rt_exec_time[_rt_jobs_complete] *= _BILLION; | 357 | _rt_exec_time[_rt_jobs_complete] *= _BILLION; |
| 355 | _rt_exec_time[_rt_jobs_complete] += _rt_end.tv_nsec - _rt_start.tv_nsec; | 358 | _rt_exec_time[_rt_jobs_complete] += _rt_end.tv_nsec - _rt_start.tv_nsec; |
| 356 | #endif /* PAIRED */ | 359 | // #else |
| 360 | // _rt_start_time[_rt_jobs_complete] = _rt_start.tv_sec; | ||
| 361 | // _rt_start_time[_rt_jobs_complete] *= _BILLION; | ||
| 362 | // _rt_start_time[_rt_jobs_complete] += _rt_start.tv_nsec; | ||
| 363 | // _rt_end_time[_rt_jobs_complete] = _rt_end.tv_sec; | ||
| 364 | // _rt_end_time[_rt_jobs_complete] *= _BILLION; | ||
| 365 | // _rt_end_time[_rt_jobs_complete] += _rt_end.tv_nsec; | ||
| 366 | |||
| 367 | // _rt_exec_time[_rt_jobs_complete] = _rt_end.tv_sec - _rt_start.tv_sec; | ||
| 368 | // _rt_exec_time[_rt_jobs_complete] *= _BILLION; | ||
| 369 | // _rt_exec_time[_rt_jobs_complete] += _rt_end.tv_nsec - _rt_start.tv_nsec; | ||
| 370 | // #endif /* PAIRED */ | ||
| 357 | #if MMDC_PROF | 371 | #if MMDC_PROF |
| 358 | _rt_mmdc_read[_rt_jobs_complete] = mmdc_res.read_bytes; | 372 | _rt_mmdc_read[_rt_jobs_complete] = mmdc_res.read_bytes; |
| 359 | _rt_mmdc_write[_rt_jobs_complete] = mmdc_res.write_bytes; | 373 | _rt_mmdc_write[_rt_jobs_complete] = mmdc_res.write_bytes; |
| @@ -378,14 +392,14 @@ static void _rt_write_to_file() { | |||
| 378 | for (int i = 0; i < _rt_jobs_complete; i++){ | 392 | for (int i = 0; i < _rt_jobs_complete; i++){ |
| 379 | fprintf(fp, "%s %s %u %s %ld", _rt_our_prog_name, _rt_other_prog_name, | 393 | fprintf(fp, "%s %s %u %s %ld", _rt_our_prog_name, _rt_other_prog_name, |
| 380 | _rt_core, _rt_other_core, _rt_max_jobs); | 394 | _rt_core, _rt_other_core, _rt_max_jobs); |
| 381 | #ifdef PAIRED | 395 | // #ifdef PAIRED |
| 382 | // For unclear legacy reasons, paired tasks emit sec and ns separately | 396 | // For unclear legacy reasons, paired tasks emit sec and ns separately |
| 383 | fprintf(fp, " %lld %lld %lld %lld", | 397 | fprintf(fp, " %lld %lld %lld %lld", |
| 384 | _rt_start_time[i] / _BILLION, _rt_start_time[i] % _BILLION, | 398 | _rt_start_time[i] / _BILLION, _rt_start_time[i] % _BILLION, |
| 385 | _rt_end_time[i] / _BILLION, _rt_end_time[i] % _BILLION); | 399 | _rt_end_time[i] / _BILLION, _rt_end_time[i] % _BILLION); |
| 386 | #else | 400 | // #else |
| 387 | fprintf(fp, " %.f", _rt_exec_time[i]); | 401 | fprintf(fp, " %.f", _rt_exec_time[i]); |
| 388 | #endif /* PAIRED */ | 402 | // #endif /* PAIRED */ |
| 389 | fprintf(fp, " %s %d %.f %.f\n", _rt_run_id, i, | 403 | fprintf(fp, " %s %d %.f %.f\n", _rt_run_id, i, |
| 390 | #if MMDC_PROF | 404 | #if MMDC_PROF |
| 391 | _rt_mmdc_read[i], _rt_mmdc_write[i]); | 405 | _rt_mmdc_read[i], _rt_mmdc_write[i]); |
