From 59111de2bbb4ae9ee4443e8c212e4a3eb6de5f48 Mon Sep 17 00:00:00 2001 From: AShivangi <124935354+AShivangi@users.noreply.github.com> Date: Sun, 8 Sep 2024 15:41:13 +0530 Subject: [PATCH] VITIS-13337 Add pmode turbo to xrt-smi (#8394) * add turbo mode to performance Signed-off-by: AShivangi * requested changes --------- Signed-off-by: AShivangi --- src/runtime_src/core/common/info_platform.cpp | 17 +---------------- src/runtime_src/core/common/query_requests.h | 17 ++++++++++------- .../core/tools/common/tests/TestGemm.cpp | 2 +- .../core/tools/xbutil2/OO_Performance.cpp | 11 +++++++---- .../core/tools/xbutil2/SubCmdValidate.cpp | 17 +---------------- 5 files changed, 20 insertions(+), 44 deletions(-) diff --git a/src/runtime_src/core/common/info_platform.cpp b/src/runtime_src/core/common/info_platform.cpp index 5019f0d660b..9bd25485f0b 100644 --- a/src/runtime_src/core/common/info_platform.cpp +++ b/src/runtime_src/core/common/info_platform.cpp @@ -153,22 +153,7 @@ add_performance_info(const xrt_core::device* device, ptree_type& pt) { try { const auto mode = xrt_core::device_query(device); - const std::string pmode = xq::performance_mode::parse_status(mode); - if (boost::iequals(pmode, "DEFAULT")) { - pt.add("power_mode", "Default"); - } - else if (boost::iequals(pmode, "LOW")) { - pt.add("power_mode", "Powersaver"); - } - else if (boost::iequals(pmode, "MEDIUM")) { - pt.add("power_mode", "Balanced"); - } - else if (boost::iequals(pmode, "HIGH")) { - pt.add("power_mode", "Performance"); - } - else { - pt.add("power_mode", "N/A"); - } + pt.add("power_mode", xq::performance_mode::parse_status(mode)); } catch (xrt_core::query::no_such_key&) { pt.add("power_mode", "not supported"); diff --git a/src/runtime_src/core/common/query_requests.h b/src/runtime_src/core/common/query_requests.h index 7d67897c837..3d698c2b275 100644 --- a/src/runtime_src/core/common/query_requests.h +++ b/src/runtime_src/core/common/query_requests.h @@ -3696,10 +3696,11 @@ struct performance_mode : request // Get and set power mode of device enum class power_type { - basic, // deafult - low, - medium, - high + basic = 0, // deafult + powersaver, + balanced, + performance, + turbo }; using result_type = uint32_t; // get value type using value_type = power_type; // put value type @@ -3719,11 +3720,13 @@ struct performance_mode : request case 0: return "Default"; case 1: - return "Low"; + return "Powersaver"; case 2: - return "Medium"; + return "Balanced"; case 3: - return "High"; + return "Performance"; + case 4: + return "Turbo"; default: throw xrt_core::system_error(EINVAL, "Invalid performance status: " + std::to_string(status)); } diff --git a/src/runtime_src/core/tools/common/tests/TestGemm.cpp b/src/runtime_src/core/tools/common/tests/TestGemm.cpp index 4e0406da3e7..d89f81440cb 100644 --- a/src/runtime_src/core/tools/common/tests/TestGemm.cpp +++ b/src/runtime_src/core/tools/common/tests/TestGemm.cpp @@ -124,7 +124,7 @@ TestGemm::run(std::shared_ptr dev) const auto perf_mode = xrt_core::device_query(dev); //set to performance mode - xrt_core::device_update(dev.get(), xrt_core::query::performance_mode::power_type::high); + xrt_core::device_update(dev.get(), xrt_core::query::performance_mode::power_type::performance); // wait until clock reaches the targeted frequency auto const target_h_clock_freq = 1810; diff --git a/src/runtime_src/core/tools/xbutil2/OO_Performance.cpp b/src/runtime_src/core/tools/xbutil2/OO_Performance.cpp index 181fb40a6cd..ccc7acd955b 100644 --- a/src/runtime_src/core/tools/xbutil2/OO_Performance.cpp +++ b/src/runtime_src/core/tools/xbutil2/OO_Performance.cpp @@ -27,7 +27,7 @@ OO_Performance::OO_Performance( const std::string &_longName, bool _isHidden ) ; m_optionsHidden.add_options() - ("mode", boost::program_options::value(&m_action)->required(), "Action to perform: default, powersaver, balanced, performance") + ("mode", boost::program_options::value(&m_action)->required(), "Action to perform: default, powersaver, balanced, performance, turbo") ; m_positionalOptions. @@ -88,13 +88,16 @@ OO_Performance::execute(const SubCmdOptions& _options) const xrt_core::device_update(device.get(), xrt_core::query::performance_mode::power_type::basic); // default } else if (boost::iequals(m_action, "POWERSAVER")) { - xrt_core::device_update(device.get(), xrt_core::query::performance_mode::power_type::low); + xrt_core::device_update(device.get(), xrt_core::query::performance_mode::power_type::powersaver); } else if (boost::iequals(m_action, "BALANCED")) { - xrt_core::device_update(device.get(), xrt_core::query::performance_mode::power_type::medium); + xrt_core::device_update(device.get(), xrt_core::query::performance_mode::power_type::balanced); } else if (boost::iequals(m_action, "PERFORMANCE")) { - xrt_core::device_update(device.get(), xrt_core::query::performance_mode::power_type::high); + xrt_core::device_update(device.get(), xrt_core::query::performance_mode::power_type::performance); + } + else if (boost::iequals(m_action, "TURBO")) { + xrt_core::device_update(device.get(), xrt_core::query::performance_mode::power_type::turbo); } else { throw xrt_core::error(boost::str(boost::format("Invalid pmode value: '%s'\n") % m_action)); diff --git a/src/runtime_src/core/tools/xbutil2/SubCmdValidate.cpp b/src/runtime_src/core/tools/xbutil2/SubCmdValidate.cpp index e4df260ef15..75692d4f037 100644 --- a/src/runtime_src/core/tools/xbutil2/SubCmdValidate.cpp +++ b/src/runtime_src/core/tools/xbutil2/SubCmdValidate.cpp @@ -254,22 +254,7 @@ get_ryzen_platform_info(const std::shared_ptr& device, { ptTree.put("platform", xrt_core::device_query(device)); const auto mode = xrt_core::device_query_default(device, 0); - const std::string pmode = xrt_core::query::performance_mode::parse_status(mode); - if (boost::iequals(pmode, "DEFAULT")) { - ptTree.put("power_mode", "Default"); - } - else if (boost::iequals(pmode, "LOW")) { - ptTree.put("power_mode", "Powersaver"); - } - else if (boost::iequals(pmode, "MEDIUM")) { - ptTree.put("power_mode", "Balanced"); - } - else if (boost::iequals(pmode, "HIGH")) { - ptTree.put("power_mode", "Performance"); - } - else { - ptTree.put("power_mode", "N/A"); - } + ptTree.put("power_mode", xrt_core::query::performance_mode::parse_status(mode)); } static void