Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeMM test enhancement #8754

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/runtime_src/core/tools/common/tests/TestGemm.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -113,15 +113,13 @@ TestGemm::run(std::shared_ptr<xrt_core::device> 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);
// 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());
Expand All @@ -134,6 +132,14 @@ TestGemm::run(std::shared_ptr<xrt_core::device> dev)
auto bo_result_map = bo_result.map<uint8_t*>();

//Calculate TOPS
uint64_t ipu_hclock = 0;
auto res_info = xrt_core::device_query_default<xrt_core::query::xrt_resource_raw>(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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<xrt_core::device> dev) {
uint64_t target_h_clock_freq = 0;
uint64_t ipu_hclock = 0;
auto res_info = xrt_core::device_query_default<xrt_core::query::xrt_resource_raw>(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<xrt_core::query::clock_freq_topology_raw>(dev);
auto clock_topology = reinterpret_cast<const clock_freq_topology*>(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
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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_
Expand Down Expand Up @@ -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<xrt_core::device>);
void logger(boost::property_tree::ptree& , const std::string&, const std::string&);
std::string findPlatformPath(const std::shared_ptr<xrt_core::device>& dev, boost::property_tree::ptree& ptTest);
std::string findPlatformFile(const std::string& file_path, boost::property_tree::ptree& ptTest);
Expand Down
Loading