Skip to content

Commit

Permalink
Add explicit cast to satisfy Windows warning; add missing input->idle…
Browse files Browse the repository at this point in the history
… case.
  • Loading branch information
derekbruening committed Aug 28, 2024
1 parent 0c710b5 commit 16b04c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 7 additions & 2 deletions clients/drcachesim/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2981,6 +2981,11 @@ scheduler_tmpl_t<RecordType, ReaderType>::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;
}
Expand Down Expand Up @@ -3714,7 +3719,7 @@ scheduler_tmpl_t<RecordType, ReaderType>::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;
Expand All @@ -3738,7 +3743,7 @@ scheduler_tmpl_t<RecordType, ReaderType>::get_statistic(
{
if (stat >= memtrace_stream_t::SCHED_STAT_TYPE_COUNT)
return -1;
return outputs_[output].stats[stat];
return static_cast<double>(outputs_[output].stats[stat]);
}

template <typename RecordType, typename ReaderType>
Expand Down
6 changes: 5 additions & 1 deletion clients/drcachesim/scheduler/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,9 @@ template <typename RecordType, typename ReaderType> 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
Expand Down Expand Up @@ -1810,6 +1812,8 @@ template <typename RecordType, typename ReaderType> 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;
Expand Down
12 changes: 6 additions & 6 deletions clients/drcachesim/tests/scheduler_unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 16b04c7

Please sign in to comment.