summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Bakita <jbakita@cs.unc.edu>2020-10-21 14:09:25 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2020-10-21 14:09:25 -0400
commitedb491490ccd0cae4bd28ca9c9a7e095a47c749b (patch)
treeff6a711d669d8cd47f30fe5db6f2288d52c53050
parent859a1095e19eef6a10e429d1a2c58ffba7238a76 (diff)
Fix infinite looping with libextra
-rw-r--r--extra.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/extra.h b/extra.h
index a15313a..30940df 100644
--- a/extra.h
+++ b/extra.h
@@ -125,7 +125,7 @@ static void _rt_load_params_itrl(int argc, char **argv) {
125 _rt_will_output = atoi(argv[5]); 125 _rt_will_output = atoi(argv[5]);
126#endif /* PAIRED */ 126#endif /* PAIRED */
127 if (_rt_max_jobs < 0 && _rt_will_output != 0) { 127 if (_rt_max_jobs < 0 && _rt_will_output != 0) {
128 fprintf(stderr, "Infinite loops only supported when _rt_will_output is disabled!\n"); 128 fprintf(stderr, "Infinite loops only supported when output is disabled!\n");
129 exit(1); 129 exit(1);
130 } 130 }
131 if (strlen(_rt_run_id) + 5 > _RT_FILENAME_LEN) { 131 if (strlen(_rt_run_id) + 5 > _RT_FILENAME_LEN) {
@@ -326,28 +326,28 @@ static void _rt_load_params_itrl(int argc, char **argv) {
326 326
327// Buffer timing result from a single job 327// Buffer timing result from a single job
328static void _rt_save_job_result() { 328static void _rt_save_job_result() {
329 if (!_rt_will_output)
330 return;
329 if (_rt_jobs_complete >= _rt_max_jobs) { 331 if (_rt_jobs_complete >= _rt_max_jobs) {
330 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); 332 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);
331 exit(1); 333 exit(1);
332 } 334 }
333 if (_rt_jobs_complete > -1 && _rt_will_output) {
334#ifdef PAIRED 335#ifdef PAIRED
335 _rt_start_time[_rt_jobs_complete] = _rt_start.tv_sec; 336 _rt_start_time[_rt_jobs_complete] = _rt_start.tv_sec;
336 _rt_start_time[_rt_jobs_complete] *= _BILLION; 337 _rt_start_time[_rt_jobs_complete] *= _BILLION;
337 _rt_start_time[_rt_jobs_complete] += _rt_start.tv_nsec; 338 _rt_start_time[_rt_jobs_complete] += _rt_start.tv_nsec;
338 _rt_end_time[_rt_jobs_complete] = _rt_end.tv_sec; 339 _rt_end_time[_rt_jobs_complete] = _rt_end.tv_sec;
339 _rt_end_time[_rt_jobs_complete] *= _BILLION; 340 _rt_end_time[_rt_jobs_complete] *= _BILLION;
340 _rt_end_time[_rt_jobs_complete] += _rt_end.tv_nsec; 341 _rt_end_time[_rt_jobs_complete] += _rt_end.tv_nsec;
341#else 342#else
342 _rt_exec_time[_rt_jobs_complete] = _rt_end.tv_sec - _rt_start.tv_sec; 343 _rt_exec_time[_rt_jobs_complete] = _rt_end.tv_sec - _rt_start.tv_sec;
343 _rt_exec_time[_rt_jobs_complete] *= _BILLION; 344 _rt_exec_time[_rt_jobs_complete] *= _BILLION;
344 _rt_exec_time[_rt_jobs_complete] += _rt_end.tv_nsec - _rt_start.tv_nsec; 345 _rt_exec_time[_rt_jobs_complete] += _rt_end.tv_nsec - _rt_start.tv_nsec;
345#endif /* PAIRED */ 346#endif /* PAIRED */
346#if MMDC_PROF 347#if MMDC_PROF
347 _rt_mmdc_read[_rt_jobs_complete] = mmdc_res.read_bytes; 348 _rt_mmdc_read[_rt_jobs_complete] = mmdc_res.read_bytes;
348 _rt_mmdc_write[_rt_jobs_complete] = mmdc_res.write_bytes; 349 _rt_mmdc_write[_rt_jobs_complete] = mmdc_res.write_bytes;
349#endif 350#endif /* MMDC_PROF */
350 }
351} 351}
352 352
353// Save all buffered timing results to disk 353// Save all buffered timing results to disk
@@ -465,7 +465,7 @@ static void _rt_stop_loop() {
465 * result. We use this to call our void function from inside a comparison. 465 * result. We use this to call our void function from inside a comparison.
466 */ 466 */
467#define for_each_job \ 467#define for_each_job \
468 for (; _rt_jobs_complete < _rt_max_jobs && (_rt_start_loop(),1); \ 468 for (; (_rt_max_jobs == -1 || _rt_jobs_complete < _rt_max_jobs) && (_rt_start_loop(),1); \
469 _rt_stop_loop()) 469 _rt_stop_loop())
470 470
471/****** Legacy API ****** 471/****** Legacy API ******