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

DF_bandwidth ELF flow #8782

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
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
19 changes: 17 additions & 2 deletions src/runtime_src/core/common/query_requests.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020-2022 Xilinx, Inc
// Copyright (C) 2022-2024 Advanced Micro Devices, Inc. - All rights reserved
// Copyright (C) 2022-2025 Advanced Micro Devices, Inc. - All rights reserved

#ifndef xrt_core_common_query_requests_h
#define xrt_core_common_query_requests_h
Expand Down Expand Up @@ -598,7 +598,8 @@ struct xclbin_name : request
{
enum class type {
validate,
gemm
gemm,
validate_elf
};

static std::string
Expand All @@ -609,6 +610,8 @@ struct xclbin_name : request
return "validate";
case type::gemm:
return "gemm";
case type::validate_elf:
return "validate_elf";
}
return "unknown";
}
Expand Down Expand Up @@ -672,13 +675,25 @@ struct sequence_name : request
struct elf_name : request
{
enum class type {
df_bandwidth,
tct_one_column,
tct_all_column,
aie_reconfig_overhead,
nop
};

static std::string
enum_to_str(const type& type)
{
switch (type) {
case type::df_bandwidth:
return "df_bandwidth";
case type::tct_one_column:
return "tct_one_column";
case type::tct_all_column:
return "tct_all_column";
case type::aie_reconfig_overhead:
return "aie_reconfig_overhead";
case type::nop:
return "nop";
}
Expand Down
3 changes: 2 additions & 1 deletion src/runtime_src/core/common/smi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ construct_validate_subcommand() const
{"run", "r", "Run a subset of the test suite. Valid options are:\n", "common", "", "array", construct_option_description(validate_test_desc)},
{"path", "p", "Path to the directory containing validate xclbins", "hidden", "", "string"},
{"param", "", "Extended parameter for a given test. Format: <test-name>:<key>:<value>", "hidden", "", "string"},
{"pmode", "", "Specify which power mode to run the benchmarks in. Note: Some tests might be unavailable for some modes", "hidden", "", "string"}
{"pmode", "", "Specify which power mode to run the benchmarks in. Note: Some tests might be unavailable for some modes", "hidden", "", "string"},
{"elf", "", "Run the test in ELF mode", "hidden", "", "none"}
};

ptree options_ptree;
Expand Down
17 changes: 16 additions & 1 deletion src/runtime_src/core/tools/common/TestRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ TestRunner::runPyTestCase( const std::shared_ptr<xrt_core::device>& _dev, const


/*
* Gets kernel depending on if 2nd param is dpu sequence or elf file
* Gets kernel depending on if elf_path (3rd argument) is provided
*/
xrt::kernel
TestRunner::get_kernel(const xrt::hw_context& hwctx, const std::string& kernel_or_elf)
Expand All @@ -219,6 +219,21 @@ TestRunner::get_kernel(const xrt::hw_context& hwctx, const std::string& kernel_o
}
}

xrt::kernel
TestRunner::get_kernel(const xrt::hw_context& hwctx, const std::string& kernel_name,
const std::string& elf_path)
{
if (elf_path.find(".elf") == std::string::npos) {
return xrt::kernel(hwctx, kernel_name);
}
else {
xrt::elf elf;
elf = xrt::elf(elf_path);
xrt::module mod{elf};
return xrt::ext::kernel{hwctx, mod, kernel_name};
}
}

std::vector<std::string>
TestRunner::findDependencies( const std::string& test_path,
const std::string& ps_kernel_name)
Expand Down
4 changes: 3 additions & 1 deletion src/runtime_src/core/tools/common/TestRunner.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.

#ifndef __TestRunner_h_
#define __TestRunner_h_
Expand Down Expand Up @@ -43,6 +43,8 @@ class TestRunner : public JSONConfigurable {
std::vector<std::string> findDependencies( const std::string& test_path,
const std::string& ps_kernel_name);
xrt::kernel get_kernel(const xrt::hw_context& hwctx, const std::string& kernel_or_elf);
xrt::kernel get_kernel(const xrt::hw_context& hwctx, const std::string& kernel_name,
const std::string& elf_path);

std::string m_xclbin;

Expand Down
21 changes: 21 additions & 0 deletions src/runtime_src/core/tools/common/XBUtilitiesCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (C) 2019-2022 Xilinx, Inc
// Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.


// ------ I N C L U D E F I L E S -------------------------------------------
// Local - Include Files
#include "XBUtilitiesCore.h"
Expand All @@ -27,6 +28,7 @@ static bool m_bTrace = false;
static bool m_disableEscapeCodes = false;
static bool m_bAdvance = false;
static bool m_bForce = false;
static bool m_bElf = false;


// ------ F U N C T I O N S ---------------------------------------------------
Expand All @@ -50,6 +52,25 @@ XBUtilities::getVerbose()
return m_bVerbose;
}

void
XBUtilities::setElf(bool _bElf)
{
bool prevElf = m_bElf;

if ((prevElf == true) && (_bElf == false))
verbose("Disabling ELF");

m_bElf = _bElf;

if ((prevElf == false) && (_bElf == true))
verbose("Enabling ELF");
}

bool XBUtilities::getElf()
{
return m_bElf;
}

void
XBUtilities::setTrace(bool _bTrace)
{
Expand Down
5 changes: 5 additions & 0 deletions src/runtime_src/core/tools/common/XBUtilitiesCore.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2019-2022 Xilinx, Inc
// Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.

#ifndef __XBUtilitiesCore_h_
#define __XBUtilitiesCore_h_

Expand Down Expand Up @@ -35,6 +36,10 @@ namespace XBUtilities {
*/
void setVerbose(bool _bVerbose);
bool getVerbose();

void setElf(bool _bElf);
bool getElf();

void setTrace(bool _bVerbose);

void setAdvance(bool _bAdvance);
Expand Down
154 changes: 112 additions & 42 deletions src/runtime_src/core/tools/common/tests/TestAIEReconfigOverhead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "xrt/xrt_device.h"
#include "xrt/xrt_hw_context.h"
#include "xrt/xrt_kernel.h"
namespace XBU = XBUtilities;

// System - Include Files
#include <fstream>
Expand All @@ -21,6 +22,8 @@ static constexpr int itr_count = 1000;
static constexpr size_t inter_size = 1024 * 1024;
static constexpr unsigned int StartAddr = 32 * 1024 * 1024;

static size_t host_app = 1; //opcode - default to be 1 for DPU sequence

TestAIEReconfigOverhead::TestAIEReconfigOverhead()
: TestRunner("aie-reconfig-overhead", "Run end-to-end array reconfiguration overhead through shim DMA")
{}
Expand All @@ -31,8 +34,24 @@ TestAIEReconfigOverhead::run(std::shared_ptr<xrt_core::device> dev)
boost::property_tree::ptree ptree = get_test_header();
ptree.erase("xclbin");

const auto xclbin_name = xrt_core::device_query<xrt_core::query::xclbin_name>(dev, xrt_core::query::xclbin_name::type::validate);
auto xclbin_path = XBValidateUtils::findPlatformFile(xclbin_name, ptree);
// Check Whether Use ELF or DPU Sequence
auto elf = XBU::getElf();
if (!elf)
XBValidateUtils::logger(ptree, "Details", "Using DPU Sequence");
else
XBValidateUtils::logger(ptree, "Details", "Using ELF");

// Find xclbin File
std::string xclbin_path;
if (!elf) { // DPU
const auto xclbin_name = xrt_core::device_query<xrt_core::query::xclbin_name>(dev, xrt_core::query::xclbin_name::type::validate);
xclbin_path = XBValidateUtils::findPlatformFile(xclbin_name, ptree);
}
else { // ELF
const auto xclbin_name = xrt_core::device_query<xrt_core::query::xclbin_name>(dev, xrt_core::query::xclbin_name::type::validate_elf);
xclbin_path = XBValidateUtils::findPlatformFile(xclbin_name, ptree);
}

if (!std::filesystem::exists(xclbin_path)){
XBValidateUtils::logger(ptree, "Details", "The test is not supported on this device.");
return ptree;
Expand Down Expand Up @@ -68,48 +87,83 @@ TestAIEReconfigOverhead::run(std::shared_ptr<xrt_core::device> dev)

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);

size_t instr_size = 0;
std::string dpu_instr;

xrt::hw_context hwctx;
xrt::kernel kernel;
try {
hwctx = xrt::hw_context(working_dev, xclbin.get_uuid());
kernel = xrt::kernel(hwctx, kernelName);
}
catch (const std::exception& )
{
XBValidateUtils::logger (ptree, "Error", "Not enough columns available. Please make sure no other workload is running on the device.");
ptree.put("status", XBValidateUtils::test_token_failed);ptree.put("status", XBValidateUtils::test_token_failed);
return ptree;
}
xrt::kernel kernel, kernel_no_op;

if (!elf) { // DPU
try {
hwctx = xrt::hw_context(working_dev, xclbin.get_uuid());
kernel = xrt::kernel(hwctx, kernelName);
}
catch (const std::exception& )
{
XBValidateUtils::logger (ptree, "Error", "Not enough columns available. Please make sure no other workload is running on the device.");
ptree.put("status", XBValidateUtils::test_token_failed);ptree.put("status", XBValidateUtils::test_token_failed);
return ptree;
}

const auto seq_name = xrt_core::device_query<xrt_core::query::sequence_name>(dev, xrt_core::query::sequence_name::type::aie_reconfig_overhead);
auto dpu_instr = XBValidateUtils::findPlatformFile(seq_name, ptree);
if (!std::filesystem::exists(dpu_instr))
return ptree;
const auto seq_name = xrt_core::device_query<xrt_core::query::sequence_name>(dev, xrt_core::query::sequence_name::type::aie_reconfig_overhead);
dpu_instr = XBValidateUtils::findPlatformFile(seq_name, ptree);
if (!std::filesystem::exists(dpu_instr))
return ptree;

size_t instr_size = 0;
try {
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
try {
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
}
catch(const std::exception& ex) {
XBValidateUtils::logger(ptree, "Error", ex.what());
ptree.put("status", XBValidateUtils::test_token_failed);
return ptree;
}
}
catch(const std::exception& ex) {
XBValidateUtils::logger(ptree, "Error", ex.what());
ptree.put("status", XBValidateUtils::test_token_failed);
return ptree;
else { // ELF
host_app = 3; // Opcode 3 for ELF Flow
const auto elf_name = xrt_core::device_query<xrt_core::query::elf_name>(dev, xrt_core::query::elf_name::type::aie_reconfig_overhead);
auto elf_path = XBValidateUtils::findPlatformFile(elf_name, ptree);

if (!std::filesystem::exists(elf_path))
return ptree;

try {
hwctx = xrt::hw_context(working_dev, xclbin.get_uuid());
kernel = get_kernel(hwctx, kernelName, elf_path);
kernel_no_op = get_kernel(hwctx, kernelName);
}
catch (const std::exception& )
{
XBValidateUtils::logger (ptree, "Error", "Not enough columns available. Please make sure no other workload is running on the device.");
ptree.put("status", XBValidateUtils::test_token_failed);ptree.put("status", XBValidateUtils::test_token_failed);
return ptree;
}
}

//Create BOs
int argno = 1;
xrt::bo bo_ifm(working_dev, buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(argno++));
argno++;
xrt::bo bo_ofm(working_dev, buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(argno++));
xrt::bo bo_inter(working_dev, inter_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(argno++));
xrt::bo bo_instr(working_dev, instr_size*sizeof(int), XCL_BO_FLAGS_CACHEABLE, kernel.group_id(argno));
xrt::bo bo_instr_no_op(working_dev, instr_size*sizeof(int), XCL_BO_FLAGS_CACHEABLE, kernel.group_id(argno++));
argno++;
xrt::bo bo_mc(working_dev, 16, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(argno++));

XBValidateUtils::init_instr_buf(bo_instr, dpu_instr);
//Create ctrlcode with NOPs
std::memset(bo_instr_no_op.map<char*>(), 0, instr_size);
xrt::bo bo_ifm, bo_ofm, bo_inter, bo_instr, bo_instr_no_op, bo_mc;
if (!elf) {
int argno = 1;
bo_ifm = xrt::bo(working_dev, buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(argno++));
argno++;
bo_ofm = xrt::bo(working_dev, buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(argno++));
bo_inter = xrt::bo(working_dev, inter_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(argno++));
bo_instr = xrt::bo(working_dev, instr_size*sizeof(int), XCL_BO_FLAGS_CACHEABLE, kernel.group_id(argno));
bo_instr_no_op = xrt::bo(working_dev, instr_size*sizeof(int), XCL_BO_FLAGS_CACHEABLE, kernel.group_id(argno++));
argno++;
bo_mc = xrt::bo(working_dev, 16, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(argno++));

XBValidateUtils::init_instr_buf(bo_instr, dpu_instr);
//Create ctrlcode with NOPs
std::memset(bo_instr_no_op.map<char*>(), 0, instr_size);
}
else {
bo_ifm = xrt::ext::bo{working_dev, buffer_size};
bo_ofm = xrt::ext::bo{working_dev, buffer_size};
bo_inter = xrt::ext::bo{working_dev, inter_size};
bo_mc = xrt::ext::bo{working_dev, 16};
}

// map input buffer
// Incremental byte pattern
Expand All @@ -118,20 +172,29 @@ TestAIEReconfigOverhead::run(std::shared_ptr<xrt_core::device> dev)
ifm_mapped[i] = (int)(i % word_count);

//Sync BOs
bo_instr.sync(XCL_BO_SYNC_BO_TO_DEVICE);
bo_mc.sync(XCL_BO_SYNC_BO_TO_DEVICE);
bo_ifm.sync(XCL_BO_SYNC_BO_TO_DEVICE);
if (!elf) {
bo_instr.sync(XCL_BO_SYNC_BO_TO_DEVICE);
bo_mc.sync(XCL_BO_SYNC_BO_TO_DEVICE);
}

//Log
if(XBUtilities::getVerbose()) {
if(XBU::getVerbose()) {
XBValidateUtils::logger(ptree, "Details", boost::str(boost::format("Buffer size: %f MB") % buffer_size_mb));
XBValidateUtils::logger(ptree, "Details", boost::str(boost::format("No. of iterations: %f") % itr_count));
}

auto start = std::chrono::high_resolution_clock::now();
for (int i = 0 ;i < itr_count ; i++){
try{
auto run = kernel(1, bo_ifm, NULL, bo_ofm, bo_inter, bo_instr_no_op, instr_size, bo_mc);
xrt::run run;
if (!elf) {
run = kernel(host_app, bo_ifm, NULL, bo_ofm, bo_inter, bo_instr_no_op, instr_size, bo_mc);
} else {
run = kernel_no_op(host_app, 0, 0, bo_ifm, 0, bo_ofm, bo_inter, 0);
}

// Wait for kernel to be done
run.wait2();
}
catch (const std::exception& ex)
Expand All @@ -150,7 +213,14 @@ TestAIEReconfigOverhead::run(std::shared_ptr<xrt_core::device> dev)
for (int i = 0; i< itr_count; i++)
{
try{
auto run = kernel(1, bo_ifm, NULL, bo_ofm, bo_inter, bo_instr, instr_size, bo_mc);
xrt::run run;
if (!elf) {
run = kernel(host_app, bo_ifm, NULL, bo_ofm, bo_inter, bo_instr, instr_size, bo_mc);
}
else {
run = kernel(host_app, 0, 0, bo_ifm, 0, bo_ofm, bo_inter, 0);
}
// Wait for kernel to be done
run.wait2();
}
catch (const std::exception& ex)
Expand Down
Loading
Loading