Skip to content

Commit

Permalink
Add CLI option -sched_max_cores and an end-to-end analyzer test runni…
Browse files Browse the repository at this point in the history
…ng threadsig
  • Loading branch information
derekbruening committed Nov 20, 2024
1 parent 37d1eaf commit 0135968
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
5 changes: 3 additions & 2 deletions clients/drcachesim/analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ template <typename RecordType, typename ReaderType>
bool
analyzer_tmpl_t<RecordType, ReaderType>::init_scheduler(
const std::string &trace_path, const std::set<memref_tid_t> &only_threads,
const std::set<int> &only_shards, int verbosity,
const std::set<int> &only_shards, int output_limit, int verbosity,
typename sched_type_t::scheduler_options_t options)
{
verbosity_ = verbosity;
Expand All @@ -249,6 +249,7 @@ analyzer_tmpl_t<RecordType, ReaderType>::init_scheduler(
typename sched_type_t::input_workload_t workload(trace_path, regions);
workload.only_threads = only_threads;
workload.only_shards = only_shards;
workload.output_limit = output_limit;
if (regions.empty() && skip_to_timestamp_ > 0) {
workload.times_of_interest.emplace_back(skip_to_timestamp_, 0);
}
Expand Down Expand Up @@ -383,7 +384,7 @@ analyzer_tmpl_t<RecordType, ReaderType>::analyzer_tmpl_t(
// The scheduler will call reader_t::init() for each input file. We assume
// that won't block (analyzer_multi_t separates out IPC readers).
typename sched_type_t::scheduler_options_t sched_ops;
if (!init_scheduler(trace_path, {}, {}, verbosity, std::move(sched_ops))) {
if (!init_scheduler(trace_path, {}, {}, 0, verbosity, std::move(sched_ops))) {
success_ = false;
error_string_ = "Failed to create scheduler";
return;
Expand Down
2 changes: 1 addition & 1 deletion clients/drcachesim/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ template <typename RecordType, typename ReaderType> class analyzer_tmpl_t {
init_scheduler(const std::string &trace_path,
// To include all threads/shards, use empty sets.
const std::set<memref_tid_t> &only_threads,
const std::set<int> &only_shards, int verbosity,
const std::set<int> &only_shards, int output_limit, int verbosity,
typename sched_type_t::scheduler_options_t options);

// For core-sharded, worker_count_ must be set prior to calling this; for parallel
Expand Down
6 changes: 4 additions & 2 deletions clients/drcachesim/analyzer_multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,8 @@ analyzer_multi_tmpl_t<RecordType, ReaderType>::analyzer_multi_tmpl_t()
return;
}
if (!this->init_scheduler(tracedir, only_threads, only_shards,
op_verbose.get_value(), std::move(sched_ops))) {
op_sched_max_cores.get_value(), op_verbose.get_value(),
std::move(sched_ops))) {
this->success_ = false;
return;
}
Expand All @@ -573,7 +574,8 @@ analyzer_multi_tmpl_t<RecordType, ReaderType>::analyzer_multi_tmpl_t()
}
} else {
// Legacy file.
if (!this->init_scheduler(op_infile.get_value(), {}, {}, op_verbose.get_value(),
if (!this->init_scheduler(op_infile.get_value(), {}, {},
op_sched_max_cores.get_value(), op_verbose.get_value(),
std::move(sched_ops))) {
this->success_ = false;
return;
Expand Down
6 changes: 6 additions & 0 deletions clients/drcachesim/common/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,12 @@ droption_t<double> op_sched_exit_if_fraction_inputs_left(
"count is not considered (as it is not available), use discretion when raising "
"this value on uneven inputs.");

droption_t<int> op_sched_max_cores(
DROPTION_SCOPE_ALL, "sched_max_cores", 0,
"Limit scheduling to this many peak live cores",
"If non-zero, only this many live cores can be scheduled at any one time. "
"Other cores will remain idle.");

// Schedule_stats options.
droption_t<uint64_t>
op_schedule_stats_print_every(DROPTION_SCOPE_ALL, "schedule_stats_print_every",
Expand Down
1 change: 1 addition & 0 deletions clients/drcachesim/common/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ extern dynamorio::droption::droption_t<uint64_t> op_sched_migration_threshold_us
extern dynamorio::droption::droption_t<uint64_t> op_sched_rebalance_period_us;
extern dynamorio::droption::droption_t<double> op_sched_time_units_per_us;
extern dynamorio::droption::droption_t<double> op_sched_exit_if_fraction_inputs_left;
extern dynamorio::droption::droption_t<int> op_sched_max_cores;
extern dynamorio::droption::droption_t<uint64_t> op_schedule_stats_print_every;
extern dynamorio::droption::droption_t<std::string> op_syscall_template_file;
extern dynamorio::droption::droption_t<uint64_t> op_filter_stop_timestamp;
Expand Down
5 changes: 5 additions & 0 deletions suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3936,6 +3936,11 @@ if (BUILD_CLIENTS)
"")
set(tool.schedule_stats_nopreempt_rawtemp ON) # no preprocessor

torunonly_simtool(schedule_stats_maxcores ${ci_shared_app}
"-indir ${thread_trace_dir} -tool schedule_stats -core_sharded -sched_max_cores 2"
"")
set(tool.schedule_stats_nopreempt_rawtemp ON) # no preprocessor

torunonly_simtool(core_serial ${ci_shared_app}
"-indir ${thread_trace_dir} -tool schedule_stats:basic_counts -core_serial"
"")
Expand Down

0 comments on commit 0135968

Please sign in to comment.