From fb7d1f35bc25c4676712b40e10c808bb1f37fa71 Mon Sep 17 00:00:00 2001 From: AShivangi Date: Tue, 11 Feb 2025 13:58:01 -0800 Subject: [PATCH 1/2] gemm test Signed-off-by: AShivangi --- .../core/tools/common/tests/TestGemm.cpp | 14 ++++--- .../common/tests/TestValidateUtilities.cpp | 37 +------------------ .../common/tests/TestValidateUtilities.h | 3 +- 3 files changed, 11 insertions(+), 43 deletions(-) diff --git a/src/runtime_src/core/tools/common/tests/TestGemm.cpp b/src/runtime_src/core/tools/common/tests/TestGemm.cpp index 8fa0d7bcd32..3193bd1d26d 100644 --- a/src/runtime_src/core/tools/common/tests/TestGemm.cpp +++ b/src/runtime_src/core/tools/common/tests/TestGemm.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +// Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved. // ------ I N C L U D E F I L E S ------------------------------------------- // Local - Include Files @@ -113,10 +113,6 @@ TestGemm::run(std::shared_ptr dev) // Create 128KB Debug BO to capture TOPS data xrt::bo bo_result = xrt_core::bo_int::create_debug_bo(hwctx, 0x20000); - // wait until clock reaches the max frequency. The performance metrics for a test - // are valid only when the clock reaches the max frequency. - uint64_t ipu_hclock = XBValidateUtils::wait_for_max_clock(dev); - try { //run kernel auto run = kernel(host_app, NULL, NULL, NULL, NULL, bo_instr, instr_size, NULL); @@ -134,6 +130,14 @@ TestGemm::run(std::shared_ptr dev) auto bo_result_map = bo_result.map(); //Calculate TOPS + uint64_t ipu_hclock = 0; + auto res_info = xrt_core::device_query_default(dev, {}); + for (auto &res : res_info) { + if (res.type != xrt_core::query::xrt_resource_raw::resource_type::ipu_clk_max) + continue; + ipu_hclock = res.data_uint64; + } + if (ipu_hclock == 0) { XBValidateUtils::logger(ptree, "Error", "IPU H-clock is 0"); ptree.put("status", XBValidateUtils::test_token_failed); diff --git a/src/runtime_src/core/tools/common/tests/TestValidateUtilities.cpp b/src/runtime_src/core/tools/common/tests/TestValidateUtilities.cpp index 70b49461e9b..48217bc1778 100644 --- a/src/runtime_src/core/tools/common/tests/TestValidateUtilities.cpp +++ b/src/runtime_src/core/tools/common/tests/TestValidateUtilities.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +// Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved. // ------ I N C L U D E F I L E S ------------------------------------------- // Local - Include Files @@ -145,41 +145,6 @@ get_instr_size(const std::string& dpu_file) { return size; } -/** - * @brief Waits for the IPU clock frequency to reach the target maximum clock frequency. - * - * This function queries the device for the target maximum clock frequency and then - * continuously checks the current IPU clock frequency until it reaches the target. - * - * @param dev A shared pointer to the xrt_core::device. - * @return The IPU clock frequency when it reaches the target maximum clock frequency. - */ -uint64_t -wait_for_max_clock(std::shared_ptr dev) { - uint64_t target_h_clock_freq = 0; - uint64_t ipu_hclock = 0; - auto res_info = xrt_core::device_query_default(dev, {}); - if (res_info.empty()) - return ipu_hclock; - - for (auto &res : res_info) - { - if (res.type != xrt_core::query::xrt_resource_raw::resource_type::ipu_clk_max) - continue; - target_h_clock_freq = res.data_uint64; - } - while (ipu_hclock < target_h_clock_freq) { - //get h-clock - auto raw = xrt_core::device_query(dev); - auto clock_topology = reinterpret_cast(raw.data()); - for (int c = 0; c < clock_topology->m_count; c++) { - if(boost::iequals(clock_topology->m_clock_freq[c].m_name, "H CLock")) - ipu_hclock = clock_topology->m_clock_freq[c].m_freq_Mhz; - } - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - } - return ipu_hclock; -} /* * mini logger to log errors, warnings and details produced by the test cases */ diff --git a/src/runtime_src/core/tools/common/tests/TestValidateUtilities.h b/src/runtime_src/core/tools/common/tests/TestValidateUtilities.h index c2667b7f046..084a2d34a24 100644 --- a/src/runtime_src/core/tools/common/tests/TestValidateUtilities.h +++ b/src/runtime_src/core/tools/common/tests/TestValidateUtilities.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +// Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved. #ifndef __TestValidateUtilities_h_ #define __TestValidateUtilities_h_ @@ -75,7 +75,6 @@ constexpr std::string_view test_token_passed = "PASSED"; void init_instr_buf(xrt::bo &bo_instr, const std::string& dpu_file); size_t get_instr_size(const std::string& dpu_file); -uint64_t wait_for_max_clock(std::shared_ptr); void logger(boost::property_tree::ptree& , const std::string&, const std::string&); std::string findPlatformPath(const std::shared_ptr& dev, boost::property_tree::ptree& ptTest); std::string findPlatformFile(const std::string& file_path, boost::property_tree::ptree& ptTest); From 33f902effa50c12cc3013717590b8145301a6459 Mon Sep 17 00:00:00 2001 From: AShivangi Date: Tue, 11 Feb 2025 14:38:32 -0800 Subject: [PATCH 2/2] add iterations Signed-off-by: AShivangi --- src/runtime_src/core/tools/common/tests/TestGemm.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/runtime_src/core/tools/common/tests/TestGemm.cpp b/src/runtime_src/core/tools/common/tests/TestGemm.cpp index 3193bd1d26d..6564287904c 100644 --- a/src/runtime_src/core/tools/common/tests/TestGemm.cpp +++ b/src/runtime_src/core/tools/common/tests/TestGemm.cpp @@ -115,9 +115,11 @@ TestGemm::run(std::shared_ptr dev) try { //run kernel - auto run = kernel(host_app, NULL, NULL, NULL, NULL, bo_instr, instr_size, NULL); - // Wait for kernel to be done - run.wait2(); + for(int i=0; i < 200; i++) { + auto run = kernel(host_app, NULL, NULL, NULL, NULL, bo_instr, instr_size, NULL); + // Wait for kernel to be done + run.wait2(); + } } catch (const std::exception& ex) { XBValidateUtils::logger(ptree, "Error", ex.what());