Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Xilinx/XRT into 2024.2_CRs_5
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Schumacher committed Oct 11, 2024
2 parents c0e1976 + 7fabe07 commit 0e58c30
Show file tree
Hide file tree
Showing 18 changed files with 281 additions and 223 deletions.
4 changes: 0 additions & 4 deletions src/runtime_src/core/edge/user/shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ shim(unsigned index)
shim::
~shim()
{
#ifdef XRT_ENABLE_AIE
if (m_aie_array) // Aie cleanup should be done before shim destroyed
m_aie_array.reset();
#endif

xclLog(XRT_INFO, "%s", __func__);

Expand Down
40 changes: 0 additions & 40 deletions src/runtime_src/core/tools/common/TestRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,46 +360,6 @@ TestRunner::validate_binary_file(const std::string& binaryfile)
else
return EXIT_SUCCESS;
}

// Copy values from text files into buff, expecting values are ascii encoded hex
void
TestRunner::init_instr_buf(xrt::bo &bo_instr, const std::string& dpu_file) {
std::ifstream dpu_stream(dpu_file);
if (!dpu_stream.is_open()) {
throw std::runtime_error(boost::str(boost::format("Failed to open %s for reading") % dpu_file));
}

auto instr = bo_instr.map<int*>();
std::string line;
while (std::getline(dpu_stream, line)) {
if (line.at(0) == '#') {
continue;
}
std::stringstream ss(line);
unsigned int word = 0;
ss >> std::hex >> word;
*(instr++) = word;
}
}

size_t
TestRunner::get_instr_size(const std::string& dpu_file) {
std::ifstream file(dpu_file);
if (!file.is_open()) {
throw std::runtime_error(boost::str(boost::format("Failed to open %s for reading") % dpu_file));
}
size_t size = 0;
std::string line;
while (std::getline(file, line)) {
if (line.at(0) != '#') {
size++;
}
}
if (size == 0) {
throw std::runtime_error("Invalid DPU instruction length");
}
return size;
}
bool
TestRunner::search_and_program_xclbin(const std::shared_ptr<xrt_core::device>& dev, boost::property_tree::ptree& ptTest)
{
Expand Down
2 changes: 0 additions & 2 deletions src/runtime_src/core/tools/common/TestRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class TestRunner : public JSONConfigurable {
std::vector<std::string> findDependencies( const std::string& test_path,
const std::string& ps_kernel_name);
int validate_binary_file(const std::string& binaryfile);
void init_instr_buf(xrt::bo &bo_instr, const std::string& dpu_file);
size_t get_instr_size(const std::string& dpu_file);
void result_in_range(double value, double threshold, boost::property_tree::ptree& ptTest);
void set_threshold(const std::shared_ptr<xrt_core::device>& dev, boost::property_tree::ptree& ptTest);
double get_threshold(){return m_threshold;};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Local - Include Files

#include "TestAIEReconfigOverhead.h"
#include "TestValidateUtilities.h"
#include "tools/common/XBUtilities.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
Expand Down Expand Up @@ -104,7 +105,7 @@ TestAIEReconfigOverhead::run(std::shared_ptr<xrt_core::device> dev)

size_t instr_size = 0;
try {
instr_size = get_instr_size(dpu_instr);
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
}
catch(const std::exception& ex) {
logger(ptree, "Error", ex.what());
Expand All @@ -123,7 +124,7 @@ TestAIEReconfigOverhead::run(std::shared_ptr<xrt_core::device> dev)
argno++;
xrt::bo bo_mc(working_dev, 16, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(argno++));

init_instr_buf(bo_instr, dpu_instr);
XBValidateUtils::init_instr_buf(bo_instr, dpu_instr);
//Create ctrlcode with NOPs
std::memset(bo_instr_no_op.map<char*>(), 0, instr_size);

Expand Down
5 changes: 3 additions & 2 deletions src/runtime_src/core/tools/common/tests/TestDF_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// ------ I N C L U D E F I L E S -------------------------------------------
// Local - Include Files
#include "TestDF_bandwidth.h"
#include "TestValidateUtilities.h"
#include "tools/common/XBUtilities.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
Expand Down Expand Up @@ -108,7 +109,7 @@ TestDF_bandwidth::run(std::shared_ptr<xrt_core::device> dev)

size_t instr_size = 0;
try {
instr_size = get_instr_size(dpu_instr);
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
}
catch(const std::exception& ex) {
logger(ptree, "Error", ex.what());
Expand All @@ -121,7 +122,7 @@ TestDF_bandwidth::run(std::shared_ptr<xrt_core::device> dev)
xrt::bo bo_ofm(working_dev, buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(3));
xrt::bo bo_instr(working_dev, instr_size*sizeof(int), XCL_BO_FLAGS_CACHEABLE, kernel.group_id(5));

init_instr_buf(bo_instr, dpu_instr);
XBValidateUtils::init_instr_buf(bo_instr, dpu_instr);

// map input buffer
auto ifm_mapped = bo_ifm.map<int*>();
Expand Down
40 changes: 4 additions & 36 deletions src/runtime_src/core/tools/common/tests/TestGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// ------ I N C L U D E F I L E S -------------------------------------------
// Local - Include Files
#include "TestGemm.h"
#include "TestValidateUtilities.h"
#include "tools/common/XBUtilities.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
Expand Down Expand Up @@ -112,7 +113,7 @@ TestGemm::run(std::shared_ptr<xrt_core::device> dev)

size_t instr_size = 0;
try {
instr_size = get_instr_size(dpu_instr);
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
}
catch(const std::exception& ex) {
logger(ptree, "Error", ex.what());
Expand All @@ -122,49 +123,16 @@ TestGemm::run(std::shared_ptr<xrt_core::device> dev)

//Create Instruction BO
xrt::bo bo_instr(working_dev, instr_size*sizeof(int), XCL_BO_FLAGS_CACHEABLE, kernel.group_id(5));
init_instr_buf(bo_instr, dpu_instr);
XBValidateUtils::init_instr_buf(bo_instr, dpu_instr);
//Sync Instruction BO
bo_instr.sync(XCL_BO_SYNC_BO_TO_DEVICE);

// 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
int ipu_hclock_pre = 0;
int ipu_hclock = 0;
auto hclock_steady_counter = 0;
auto first_steady_state = -1, second_steady_state = -1;;

for(int i=0; i<100;i++){
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));
//std::cout << "NPU clock: " << ipu_hclock <<std::endl;

hclock_steady_counter = (ipu_hclock == ipu_hclock_pre) ? hclock_steady_counter + 1 : 0;
if(hclock_steady_counter == 8 && first_steady_state == -1 && ipu_hclock >= 1810) {
//break;
first_steady_state = ipu_hclock_pre;
hclock_steady_counter = 0;
}

if(hclock_steady_counter == 8 && first_steady_state != -1 && second_steady_state == -1 && ipu_hclock > first_steady_state) {
//break;
second_steady_state = ipu_hclock;
hclock_steady_counter = 0;
}

if (hclock_steady_counter == 8 && second_steady_state != -1 && ipu_hclock > second_steady_state) {
break;
}

ipu_hclock_pre = ipu_hclock; // Update hclk with hclk_pre

}
XBValidateUtils::wait_for_max_clock(ipu_hclock, dev);

try {
//run kernel
Expand Down
82 changes: 0 additions & 82 deletions src/runtime_src/core/tools/common/tests/TestHelper.cpp

This file was deleted.

24 changes: 15 additions & 9 deletions src/runtime_src/core/tools/common/tests/TestSpatialSharingOvd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// ------ I N C L U D E F I L E S -------------------------------------------
// Local - Include Files
#include "TestSpatialSharingOvd.h"
#include "TestHelper.h"
#include "TestValidateUtilities.h"
#include "tools/common/XBUtilities.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
Expand All @@ -15,6 +15,7 @@
namespace XBU = XBUtilities;

static constexpr size_t host_app = 1; //opcode
static constexpr size_t buffer_size = 1024; //1 KB

// Method to run the test
// Parameters:
Expand Down Expand Up @@ -103,13 +104,20 @@ boost::property_tree::ptree TestSpatialSharingOvd::run(std::shared_ptr<xrt_core:
}
};

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

logger(ptree, "DPU-Sequence", dpu_instr);
/* Run 1 */
std::vector<std::thread> threads;
std::vector<TestCase> testcases;

// Create two test cases and add them to the vector
testcases.emplace_back(xclbin, kernelName, working_dev);
testcases.emplace_back(xclbin, kernelName, working_dev);
TestParams params(xclbin, working_dev, kernelName, dpu_instr, 8, buffer_size, 10000);
testcases.emplace_back(params);
testcases.emplace_back(params);

for (uint32_t i = 0; i < testcases.size(); i++) {
try{
Expand Down Expand Up @@ -140,7 +148,7 @@ boost::property_tree::ptree TestSpatialSharingOvd::run(std::shared_ptr<xrt_core:

/* Run 2 */
// Create a single test case and run it in a single thread
TestCase singleHardwareCtxTest(xclbin, kernelName, working_dev);
TestCase singleHardwareCtxTest(params);
try{
singleHardwareCtxTest.initialize();
} catch (const std::exception& ex) {
Expand All @@ -159,15 +167,13 @@ boost::property_tree::ptree TestSpatialSharingOvd::run(std::shared_ptr<xrt_core:

// Log the latencies and the overhead
if(XBU::getVerbose()){
logger(ptree, "Details", boost::str(boost::format("Single context latency: '%.1f' ms") % (latencySingle * 1000)));
logger(ptree, "Details", boost::str(boost::format("Spatially shared multiple context latency: '%.1f' ms") % (latencyShared * 1000)));
logger(ptree, "Details", boost::str(boost::format("Single context latency: %.1f ms") % (latencySingle * 1000)));
logger(ptree, "Details", boost::str(boost::format("Spatially shared multiple context latency: %.1f ms") % (latencyShared * 1000)));
}
auto overhead = (latencyShared - latencySingle) * 1000;
logger(ptree, "Details", boost::str(boost::format("Overhead: '%.1f' ms") % overhead));
logger(ptree, "Details", boost::str(boost::format("Overhead: %.1f ms") % overhead));

//check if the value is in range
result_in_range(overhead, get_threshold(), ptree);

logger(ptree, "Details", boost::str(boost::format("Average latency: %.1f ms") % overhead));
return ptree;
}
5 changes: 3 additions & 2 deletions src/runtime_src/core/tools/common/tests/TestTCTAllColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// ------ I N C L U D E F I L E S -------------------------------------------
// Local - Include Files
#include "TestTCTAllColumn.h"
#include "TestValidateUtilities.h"
#include "tools/common/XBUtilities.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
Expand Down Expand Up @@ -105,7 +106,7 @@ TestTCTAllColumn::run(std::shared_ptr<xrt_core::device> dev)

size_t instr_size = 0;
try {
instr_size = get_instr_size(dpu_instr);
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
}
catch(const std::exception& ex) {
logger(ptree, "Error", ex.what());
Expand All @@ -118,7 +119,7 @@ TestTCTAllColumn::run(std::shared_ptr<xrt_core::device> dev)
xrt::bo bo_ofm(working_dev, 4*buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(3));
xrt::bo bo_instr(working_dev, instr_size*sizeof(int), XCL_BO_FLAGS_CACHEABLE, kernel.group_id(5));

init_instr_buf(bo_instr, dpu_instr);
XBValidateUtils::init_instr_buf(bo_instr, dpu_instr);

// map input buffer
auto ifm_mapped = bo_ifm.map<int*>();
Expand Down
5 changes: 3 additions & 2 deletions src/runtime_src/core/tools/common/tests/TestTCTOneColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// ------ I N C L U D E F I L E S -------------------------------------------
// Local - Include Files
#include "TestTCTOneColumn.h"
#include "TestValidateUtilities.h"
#include "tools/common/XBUtilities.h"
#include "xrt/xrt_bo.h"
#include "xrt/xrt_device.h"
Expand Down Expand Up @@ -105,7 +106,7 @@ TestTCTOneColumn::run(std::shared_ptr<xrt_core::device> dev)

size_t instr_size = 0;
try {
instr_size = get_instr_size(dpu_instr);
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
}
catch(const std::exception& ex) {
logger(ptree, "Error", ex.what());
Expand All @@ -118,7 +119,7 @@ TestTCTOneColumn::run(std::shared_ptr<xrt_core::device> dev)
xrt::bo bo_ofm(working_dev, 4*buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(3));
xrt::bo bo_instr(working_dev, instr_size*sizeof(int), XCL_BO_FLAGS_CACHEABLE, kernel.group_id(5));

init_instr_buf(bo_instr, dpu_instr);
XBValidateUtils::init_instr_buf(bo_instr, dpu_instr);

// map input buffer
auto ifm_mapped = bo_ifm.map<int*>();
Expand Down
Loading

0 comments on commit 0e58c30

Please sign in to comment.