Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i#6977: Fix quantum underflow #6973

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions clients/drcachesim/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3497,7 +3497,7 @@ scheduler_tmpl_t<RecordType, ReaderType>::next_record(output_ordinal_t output,
VPRINT(this, 4,
"next_record[%d]: input %d hit end of instr quantum\n", output,
input->index);
preempt = !need_new_input;
preempt = true;
need_new_input = true;
input->instrs_in_quantum = 0;
++outputs_[output]
Expand All @@ -3519,10 +3519,12 @@ scheduler_tmpl_t<RecordType, ReaderType>::next_record(output_ordinal_t output,
// in between (e.g., scatter/gather long sequence of reads/writes) by
// setting input->switching_pre_instruction.
record_type_is_instr_boundary(record, outputs_[output].last_record)) {
VPRINT(this, 4,
"next_record[%d]: hit end of time quantum after %" PRIu64 "\n",
output, input->time_spent_in_quantum);
preempt = !need_new_input;
VPRINT(
this, 4,
"next_record[%d]: input %d hit end of time quantum after %" PRIu64
"\n",
output, input->index, input->time_spent_in_quantum);
preempt = true;
need_new_input = true;
input->time_spent_in_quantum = 0;
++outputs_[output]
Expand Down Expand Up @@ -3553,9 +3555,10 @@ scheduler_tmpl_t<RecordType, ReaderType>::next_record(output_ordinal_t output,
res != sched_type_t::STATUS_SKIPPED)
return res;
if (outputs_[output].cur_input != prev_input) {
// TODO i#5843: Queueing here and in a few other places gets the
// ordinals off: we need to undo the ordinal increases to avoid
// over-counting while queued and double-counting when we resume.
// TODO i#5843: Queueing here and in a few other places gets the stream
// record and instruction ordinals off: we need to undo the ordinal
// increases to avoid over-counting while queued and double-counting
// when we resume.
// In some cases we need to undo this on the output stream too.
// So we should set suppress_ref_count_ in the input to get
// is_record_synthetic() (and have our stream class check that
Expand All @@ -3564,12 +3567,18 @@ scheduler_tmpl_t<RecordType, ReaderType>::next_record(output_ordinal_t output,
lock.lock();
VPRINT(this, 5, "next_record_mid[%d]: switching from %d to %d\n", output,
prev_input, outputs_[output].cur_input);
if (!preempt) {
// We need to offset the {instrs,time_spent}_in_quantum values from
// overshooting during dynamic scheduling, unless this is a preempt when
// we've already reset to 0.
if (!preempt && options_.mapping == MAP_TO_ANY_OUTPUT) {
if (options_.quantum_unit == QUANTUM_INSTRUCTIONS &&
record_type_is_instr_boundary(record,
outputs_[output].last_record)) {
assert(inputs_[prev_input].instrs_in_quantum > 0);
--inputs_[prev_input].instrs_in_quantum;
} else if (options_.quantum_unit == QUANTUM_TIME) {
assert(inputs_[prev_input].time_spent_in_quantum >=
cur_time - prev_time_in_quantum);
inputs_[prev_input].time_spent_in_quantum -=
(cur_time - prev_time_in_quantum);
}
Expand Down
Loading