From 0135968ed609cb82434820853444c6407b4bbb1a Mon Sep 17 00:00:00 2001 From: Derek Bruening Date: Tue, 19 Nov 2024 20:06:25 -0500 Subject: [PATCH] Add CLI option -sched_max_cores and an end-to-end analyzer test running threadsig --- clients/drcachesim/analyzer.cpp | 5 +++-- clients/drcachesim/analyzer.h | 2 +- clients/drcachesim/analyzer_multi.cpp | 6 ++++-- clients/drcachesim/common/options.cpp | 6 ++++++ clients/drcachesim/common/options.h | 1 + suite/tests/CMakeLists.txt | 5 +++++ 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/clients/drcachesim/analyzer.cpp b/clients/drcachesim/analyzer.cpp index 6f905c10f9e..fe295620045 100644 --- a/clients/drcachesim/analyzer.cpp +++ b/clients/drcachesim/analyzer.cpp @@ -230,7 +230,7 @@ template bool analyzer_tmpl_t::init_scheduler( const std::string &trace_path, const std::set &only_threads, - const std::set &only_shards, int verbosity, + const std::set &only_shards, int output_limit, int verbosity, typename sched_type_t::scheduler_options_t options) { verbosity_ = verbosity; @@ -249,6 +249,7 @@ analyzer_tmpl_t::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); } @@ -383,7 +384,7 @@ analyzer_tmpl_t::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; diff --git a/clients/drcachesim/analyzer.h b/clients/drcachesim/analyzer.h index 6b37ad31195..91418cac1d4 100644 --- a/clients/drcachesim/analyzer.h +++ b/clients/drcachesim/analyzer.h @@ -221,7 +221,7 @@ template class analyzer_tmpl_t { init_scheduler(const std::string &trace_path, // To include all threads/shards, use empty sets. const std::set &only_threads, - const std::set &only_shards, int verbosity, + const std::set &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 diff --git a/clients/drcachesim/analyzer_multi.cpp b/clients/drcachesim/analyzer_multi.cpp index 521ae6bf488..909839cc44f 100644 --- a/clients/drcachesim/analyzer_multi.cpp +++ b/clients/drcachesim/analyzer_multi.cpp @@ -549,7 +549,8 @@ analyzer_multi_tmpl_t::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; } @@ -573,7 +574,8 @@ analyzer_multi_tmpl_t::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; diff --git a/clients/drcachesim/common/options.cpp b/clients/drcachesim/common/options.cpp index 3bd7d7c4a03..58047dd40ad 100644 --- a/clients/drcachesim/common/options.cpp +++ b/clients/drcachesim/common/options.cpp @@ -1061,6 +1061,12 @@ droption_t 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 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 op_schedule_stats_print_every(DROPTION_SCOPE_ALL, "schedule_stats_print_every", diff --git a/clients/drcachesim/common/options.h b/clients/drcachesim/common/options.h index 9e64dd920b3..8951cef60d0 100644 --- a/clients/drcachesim/common/options.h +++ b/clients/drcachesim/common/options.h @@ -222,6 +222,7 @@ extern dynamorio::droption::droption_t op_sched_migration_threshold_us extern dynamorio::droption::droption_t op_sched_rebalance_period_us; extern dynamorio::droption::droption_t op_sched_time_units_per_us; extern dynamorio::droption::droption_t op_sched_exit_if_fraction_inputs_left; +extern dynamorio::droption::droption_t op_sched_max_cores; extern dynamorio::droption::droption_t op_schedule_stats_print_every; extern dynamorio::droption::droption_t op_syscall_template_file; extern dynamorio::droption::droption_t op_filter_stop_timestamp; diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index c7cd5363549..a35ba5aa182 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -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" "")