From bf7e90c1b59b6bc1fec1952a2ed8fbce5508e1c6 Mon Sep 17 00:00:00 2001 From: Lakshmi Sriharshini Komali Date: Fri, 5 Jul 2024 10:35:00 -0700 Subject: [PATCH] Set max_threads to concurrency --- src/c++/perf_analyzer/command_line_parser.cc | 2 + .../perf_analyzer/test_command_line_parser.cc | 65 +++++++++++++++++-- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/c++/perf_analyzer/command_line_parser.cc b/src/c++/perf_analyzer/command_line_parser.cc index bd3d72d73..88cf441d7 100644 --- a/src/c++/perf_analyzer/command_line_parser.cc +++ b/src/c++/perf_analyzer/command_line_parser.cc @@ -1716,6 +1716,8 @@ CLParser::ParseCommandLine(int argc, char** argv) // Overriding the max_threads default for request_rate search if (!params_->max_threads_specified && params_->targeting_concurrency()) { params_->max_threads = 16; + params_->max_threads = + std::max(params_->max_threads, params_->concurrency_range.end); } if (params_->using_custom_intervals) { diff --git a/src/c++/perf_analyzer/test_command_line_parser.cc b/src/c++/perf_analyzer/test_command_line_parser.cc index 765def112..42c5a4644 100644 --- a/src/c++/perf_analyzer/test_command_line_parser.cc +++ b/src/c++/perf_analyzer/test_command_line_parser.cc @@ -371,10 +371,12 @@ class TestCLParser : public CLParser { void CheckValidRange( std::vector& args, char* option_name, TestCLParser& parser, - PAParamsPtr& act, bool& using_range, Range& range) + PAParamsPtr& act, bool& using_range, Range& range, + PAParamsPtr& exp) { SUBCASE("start:end provided") { + exp->max_threads = 400; args.push_back(option_name); args.push_back("100:400"); // start:end @@ -392,6 +394,7 @@ CheckValidRange( SUBCASE("start:end:step provided") { + exp->max_threads = 400; args.push_back(option_name); args.push_back("100:400:10"); // start:end:step @@ -1126,12 +1129,12 @@ TEST_CASE("Testing Command Line Parser") exp->using_concurrency_range = true; exp->concurrency_range.start = 100; + exp->max_threads = 16; } CheckValidRange( args, option_name, parser, act, exp->using_concurrency_range, - exp->concurrency_range); - + exp->concurrency_range, exp); CheckInvalidRange(args, option_name, parser, act, check_params); SUBCASE("wrong separator") @@ -1173,6 +1176,60 @@ TEST_CASE("Testing Command Line Parser") check_params = false; } + + SUBCASE("concurrency-range.end < 16") + { + args.push_back(option_name); + args.push_back("10:10"); // start + + int argc = args.size(); + char* argv[argc]; + std::copy(args.begin(), args.end(), argv); + + REQUIRE_NOTHROW(act = parser.Parse(argc, argv)); + CHECK(!parser.UsageCalled()); + + exp->using_concurrency_range = true; + exp->concurrency_range.start = 10; + exp->concurrency_range.end = 10; + exp->max_threads = 16; + } + + SUBCASE("concurrency-range.end == 16") + { + args.push_back(option_name); + args.push_back("10:16"); // start + + int argc = args.size(); + char* argv[argc]; + std::copy(args.begin(), args.end(), argv); + + REQUIRE_NOTHROW(act = parser.Parse(argc, argv)); + CHECK(!parser.UsageCalled()); + + exp->using_concurrency_range = true; + exp->concurrency_range.start = 10; + exp->concurrency_range.end = 16; + exp->max_threads = 16; + } + + SUBCASE("concurrency-range.end > 16") + { + args.push_back(option_name); + args.push_back("10:40"); // start + + int argc = args.size(); + char* argv[argc]; + std::copy(args.begin(), args.end(), argv); + + REQUIRE_NOTHROW(act = parser.Parse(argc, argv)); + CHECK(!parser.UsageCalled()); + + exp->using_concurrency_range = true; + exp->concurrency_range.start = 10; + exp->concurrency_range.end = 40; + exp->max_threads = 40; + } } SUBCASE("Option : --periodic-concurrency-range") @@ -1210,7 +1267,7 @@ TEST_CASE("Testing Command Line Parser") CheckValidRange( args, option_name, parser, act, exp->is_using_periodic_concurrency_mode, - exp->periodic_concurrency_range); + exp->periodic_concurrency_range, exp); CheckInvalidRange(args, option_name, parser, act, check_params);