diff --git a/clients/drcachesim/scheduler/scheduler.cpp b/clients/drcachesim/scheduler/scheduler.cpp index 55549292e43..d4ed82bc204 100644 --- a/clients/drcachesim/scheduler/scheduler.cpp +++ b/clients/drcachesim/scheduler/scheduler.cpp @@ -2981,6 +2981,11 @@ scheduler_tmpl_t::pick_next_input(output_ordinal_t outpu if (record_status != sched_type_t::STATUS_OK) return record_status; } + if (prev_index != INVALID_INPUT_ORDINAL) { + ++outputs_[output] + .stats[memtrace_stream_t:: + SCHED_STAT_SWITCH_INPUT_TO_IDLE]; + } } return status; } @@ -3714,7 +3719,7 @@ scheduler_tmpl_t::eof_or_idle(output_ordinal_t output, } } outputs_[output].waiting = true; - if (prev_input > 0) + if (prev_input != INVALID_INPUT_ORDINAL) ++outputs_[output].stats[memtrace_stream_t::SCHED_STAT_SWITCH_INPUT_TO_IDLE]; set_cur_input(output, INVALID_INPUT_ORDINAL); return sched_type_t::STATUS_IDLE; @@ -3738,7 +3743,7 @@ scheduler_tmpl_t::get_statistic( { if (stat >= memtrace_stream_t::SCHED_STAT_TYPE_COUNT) return -1; - return outputs_[output].stats[stat]; + return static_cast(outputs_[output].stats[stat]); } template diff --git a/clients/drcachesim/scheduler/scheduler.h b/clients/drcachesim/scheduler/scheduler.h index c4b2da44c51..b5f4f2b23e9 100644 --- a/clients/drcachesim/scheduler/scheduler.h +++ b/clients/drcachesim/scheduler/scheduler.h @@ -1131,7 +1131,9 @@ template class scheduler_tmpl_t { /** * Returns the value of the specified statistic for this output stream. - * The values for all output stream must be summed to obtain global counts. + * The values for all output streams must be summed to obtain global counts. + * These statistics are not guaranteed to be accurate when replaying a + * prior schedule via #MAP_TO_RECORDED_OUTPUT. */ double get_schedule_statistic(schedule_statistic_t stat) const override @@ -1810,6 +1812,8 @@ template class scheduler_tmpl_t { bool is_record_kernel(output_ordinal_t output); + // These statistics are not guaranteed to be accurate when replaying a + // prior schedule. double get_statistic(output_ordinal_t output, memtrace_stream_t::schedule_statistic_t stat) const; diff --git a/clients/drcachesim/tests/scheduler_unit_tests.cpp b/clients/drcachesim/tests/scheduler_unit_tests.cpp index 4b26318ee14..bca345d4bc3 100644 --- a/clients/drcachesim/tests/scheduler_unit_tests.cpp +++ b/clients/drcachesim/tests/scheduler_unit_tests.cpp @@ -1298,11 +1298,11 @@ test_synthetic_time_quanta() assert(false); // Check scheduler stats. verify_scheduler_stats(scheduler.get_stream(0), /*switch_input_to_input=*/1, - /*switch_input_to_idle=*/0, /*switch_idle_to_input=*/0, + /*switch_input_to_idle=*/1, /*switch_idle_to_input=*/0, /*switch_nop=*/1, /*preempts=*/2, /*direct_attempts=*/0, /*direct_successes=*/0); verify_scheduler_stats(scheduler.get_stream(1), /*switch_input_to_input=*/2, - /*switch_input_to_idle=*/0, /*switch_idle_to_input=*/1, + /*switch_input_to_idle=*/1, /*switch_idle_to_input=*/1, /*switch_nop=*/0, /*preempts=*/1, /*direct_attempts=*/0, /*direct_successes=*/0); } @@ -1859,11 +1859,11 @@ test_synthetic_with_syscalls_multiple() // appearing in between (and ignoring the last letter for an input: EOF doesn't // count as a preempt). verify_scheduler_stats(scheduler.get_stream(0), /*switch_input_to_input=*/17, - /*switch_input_to_idle=*/0, /*switch_idle_to_input=*/1, + /*switch_input_to_idle=*/2, /*switch_idle_to_input=*/1, /*switch_nop=*/2, /*preempts=*/11, /*direct_attempts=*/0, /*direct_successes=*/0); verify_scheduler_stats(scheduler.get_stream(1), /*switch_input_to_input=*/16, - /*switch_input_to_idle=*/0, /*switch_idle_to_input=*/1, + /*switch_input_to_idle=*/1, /*switch_idle_to_input=*/1, /*switch_nop=*/0, /*preempts=*/10, /*direct_attempts=*/0, /*direct_successes=*/0); } @@ -4259,7 +4259,7 @@ test_direct_switch() } assert(sched_as_string[0] == CORE0_SCHED_STRING); verify_scheduler_stats(scheduler.get_stream(0), /*switch_input_to_input=*/3, - /*switch_input_to_idle=*/0, /*switch_idle_to_input=*/1, + /*switch_input_to_idle=*/1, /*switch_idle_to_input=*/1, /*switch_nop=*/0, /*preempts=*/0, /*direct_attempts=*/3, /*direct_successes=*/2); } @@ -4300,7 +4300,7 @@ test_direct_switch() } assert(sched_as_string[0] == CORE0_SCHED_STRING); verify_scheduler_stats(scheduler.get_stream(0), /*switch_input_to_input=*/2, - /*switch_input_to_idle=*/0, /*switch_idle_to_input=*/2, + /*switch_input_to_idle=*/2, /*switch_idle_to_input=*/2, /*switch_nop=*/0, /*preempts=*/0, /*direct_attempts=*/0, /*direct_successes=*/0); }