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#6262: query cpu id for scheduler output streams #6263

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions clients/drcachesim/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ scheduler_tmpl_t<RecordType, ReaderType>::read_traced_schedule()
// We also need to translate the thread and cpu id values into 0-based ordinals.
std::unordered_map<memref_tid_t, input_ordinal_t> tid2input;
for (int i = 0; i < static_cast<input_ordinal_t>(inputs_.size()); ++i) {
VPRINT(this, 1, "tid2input: tid: %" PRId64 " -> %d\n", inputs_[i].tid, i);
tid2input[inputs_[i].tid] = i;
}
std::vector<std::set<uint64_t>> start2stop(inputs_.size());
Expand Down Expand Up @@ -857,6 +858,8 @@ scheduler_tmpl_t<RecordType, ReaderType>::read_traced_schedule()
}
}
cur_cpu = entry.cpu;
VPRINT(this, 1, "Output #%d is CPU #%" PRId64 "\n", cur_output, cur_cpu);
outputs_[cur_output].cpu = (int)cur_cpu;
}
input_ordinal_t input = tid2input[entry.thread];
// We'll fill in the stop ordinal in our second pass below.
Expand Down
13 changes: 13 additions & 0 deletions clients/drcachesim/scheduler/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,18 @@ template <typename RecordType, typename ReaderType> class scheduler_tmpl_t {
return &outputs_[ordinal].stream;
}

/**
* Returns the cpu number for the 'ordinal'-th output stream. This is only valid for
* MAP_TO_RECORDED_OUTPUT and returns -1 for other mappings.
*/
virtual int
get_output_cpuid(output_ordinal_t ordinal)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We figured this would be on the stream, not the scheduler. We may also want this for other modes, including core-oriented analysis tool modes #5694, where it has to be on the stream as the scheduler is not exposed through the analyzer framework.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up needing this for #5694 and I put it into PR #6279 -- does that meet your needs as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks like this should be good.

{
if (ordinal < 0 || ordinal >= static_cast<output_ordinal_t>(outputs_.size()))
return -1;
return outputs_[ordinal].cpu;
}

/** Returns the number of input streams. */
virtual int
get_input_stream_count() const
Expand Down Expand Up @@ -976,6 +988,7 @@ template <typename RecordType, typename ReaderType> class scheduler_tmpl_t {
// sched_lock_.
std::vector<schedule_record_t> record;
int record_index = 0;
int cpu = -1;
bool waiting = false;
bool active = true;
// Used for time-based quanta.
Expand Down
Loading