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 1 commit
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
18 changes: 12 additions & 6 deletions clients/drcachesim/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3488,7 +3488,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 @@ -3510,10 +3510,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 @@ -3555,12 +3557,16 @@ 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) {
if (!preempt && // Already reset to 0 for preempt.
derekbruening marked this conversation as resolved.
Show resolved Hide resolved
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