diff --git a/src/runtime_src/core/tools/common/TestRunner.cpp b/src/runtime_src/core/tools/common/TestRunner.cpp index 1e546e682b6..13cd8bf5b8e 100644 --- a/src/runtime_src/core/tools/common/TestRunner.cpp +++ b/src/runtime_src/core/tools/common/TestRunner.cpp @@ -39,18 +39,6 @@ runTestInternal(std::shared_ptr dev, is_thread_running = false; } -static void -program_xclbin(const std::shared_ptr& device, const std::string& xclbin) -{ - auto bdf = xq::pcie_bdf::to_string(xrt_core::device_query(device)); - auto xclbin_obj = xrt::xclbin{xclbin}; - try { - device->load_xclbin(xclbin_obj); - } - catch (const std::exception& e) { - XBUtilities::throw_cancel(boost::format("Could not program device %s : %s") % bdf % e.what()); - } -} } //end anonymous namespace // ----- C L A S S M E T H O D S ------------------------------------------- @@ -194,70 +182,6 @@ TestRunner::runPyTestCase( const std::shared_ptr& _dev, const } } -int -TestRunner::validate_binary_file(const std::string& binaryfile) -{ - std::ifstream infile(binaryfile); - if (!infile.good()) - return EOPNOTSUPP; - else - return EXIT_SUCCESS; -} -bool -TestRunner::search_and_program_xclbin(const std::shared_ptr& dev, boost::property_tree::ptree& ptTest) -{ - xuid_t uuid; - uuid_parse(xrt_core::device_query(dev).c_str(), uuid); - - const std::string xclbin_path = XBValidateUtils::findXclbinPath(dev, ptTest); - - try { - program_xclbin(dev, xclbin_path); - } - catch (const std::exception& e) { - XBValidateUtils::logger(ptTest, "Error", e.what()); - ptTest.put("status", XBValidateUtils::test_token_failed); - return false; - } - - return true; -} - -/* - * Runs dpu sequence or elf flow for xrt_smi tests -*/ -std::string -TestRunner::dpu_or_elf(const std::shared_ptr& dev, const xrt::xclbin& xclbin, - boost::property_tree::ptree& ptTest) -{ - if (xrt_core::device_query(dev).device_id != 5696) { // device ID for npu3 in decimal - // Determine The DPU Kernel Name - auto xkernels = xclbin.get_kernels(); - - auto itr = std::find_if(xkernels.begin(), xkernels.end(), [](xrt::xclbin::kernel& k) { - auto name = k.get_name(); - return name.rfind("DPU",0) == 0; // Starts with "DPU" - }); - - xrt::xclbin::kernel xkernel; - if (itr!=xkernels.end()) - xkernel = *itr; - else { - XBValidateUtils::logger(ptTest, "Error", "No kernel with `DPU` found in the xclbin"); - ptTest.put("status", XBValidateUtils::test_token_failed); - } - auto kernelName = xkernel.get_name(); - - return kernelName; - } - else { - // Elf flow - const auto elf_name = xrt_core::device_query(dev, xrt_core::query::elf_name::type::nop); - auto elf_path = XBValidateUtils::findPlatformFile(elf_name, ptTest); - - return elf_path; - } -} /* * Gets kernel depending on if 2nd param is dpu sequence or elf file diff --git a/src/runtime_src/core/tools/common/TestRunner.h b/src/runtime_src/core/tools/common/TestRunner.h index fafe322b53d..9bc65f5a57c 100644 --- a/src/runtime_src/core/tools/common/TestRunner.h +++ b/src/runtime_src/core/tools/common/TestRunner.h @@ -40,12 +40,8 @@ class TestRunner : public JSONConfigurable { const std::string & xclbin = "", bool is_explicit = false); void runPyTestCase( const std::shared_ptr& _dev, const std::string& py, boost::property_tree::ptree& _ptTest); - bool search_and_program_xclbin(const std::shared_ptr& dev, boost::property_tree::ptree& ptTest); std::vector findDependencies( const std::string& test_path, const std::string& ps_kernel_name); - int validate_binary_file(const std::string& binaryfile); - std::string dpu_or_elf(const std::shared_ptr& dev, const xrt::xclbin& xclbin, - boost::property_tree::ptree& ptTest); xrt::kernel get_kernel(const xrt::hw_context& hwctx, const std::string& kernel_or_elf); std::string m_xclbin; diff --git a/src/runtime_src/core/tools/common/tests/TestAiePs.cpp b/src/runtime_src/core/tools/common/tests/TestAiePs.cpp index bdd0012b402..8b8361cd45a 100644 --- a/src/runtime_src/core/tools/common/tests/TestAiePs.cpp +++ b/src/runtime_src/core/tools/common/tests/TestAiePs.cpp @@ -48,7 +48,7 @@ TestAiePs::runTest(std::shared_ptr dev, boost::property_tree:: const std::vector dependency_paths = findDependencies(test_path, m_xclbin); // Load dependency xclbins onto device if any for (const auto& path : dependency_paths) { - auto retVal = validate_binary_file(path); + auto retVal = XBValidateUtils::validate_binary_file(path); if (retVal == EOPNOTSUPP) { ptree.put("status", XBValidateUtils::test_token_skipped); return; @@ -58,7 +58,7 @@ TestAiePs::runTest(std::shared_ptr dev, boost::property_tree:: const std::string b_file = XBValidateUtils::findXclbinPath(dev, ptree); // Load ps kernel onto device - auto retVal = validate_binary_file(b_file); + auto retVal = XBValidateUtils::validate_binary_file(b_file); if (retVal == EOPNOTSUPP) { ptree.put("status", XBValidateUtils::test_token_skipped); return; diff --git a/src/runtime_src/core/tools/common/tests/TestDMA.cpp b/src/runtime_src/core/tools/common/tests/TestDMA.cpp index dded6767911..e2d87bc1fa0 100644 --- a/src/runtime_src/core/tools/common/tests/TestDMA.cpp +++ b/src/runtime_src/core/tools/common/tests/TestDMA.cpp @@ -26,7 +26,7 @@ TestDMA::run(std::shared_ptr dev) boost::property_tree::ptree ptree = get_test_header(); ptree.put("status", XBValidateUtils::test_token_skipped); - if (!search_and_program_xclbin(dev, ptree)) + if (!XBValidateUtils::search_and_program_xclbin(dev, ptree)) return ptree; // get DDR bank count from mem_topology if possible diff --git a/src/runtime_src/core/tools/common/tests/TestHostMemBandwidthKernel.cpp b/src/runtime_src/core/tools/common/tests/TestHostMemBandwidthKernel.cpp index 860fd9d1acb..9e88f986cf6 100644 --- a/src/runtime_src/core/tools/common/tests/TestHostMemBandwidthKernel.cpp +++ b/src/runtime_src/core/tools/common/tests/TestHostMemBandwidthKernel.cpp @@ -68,10 +68,10 @@ TestHostMemBandwidthKernel::runTest(std::shared_ptr dev, boost const std::string b_file = XBValidateUtils::findXclbinPath(dev, ptree); // bandwidth.xclbin std::string old_b_file = "/slavebridge.xclbin"; - auto retVal = validate_binary_file(b_file); + auto retVal = XBValidateUtils::validate_binary_file(b_file); // This is for backward compatibility support when older platforms still having slavebridge.xclbin. auto old_binary_file = std::filesystem::path(test_path) / old_b_file; - auto check_old_b_file = validate_binary_file(old_binary_file.string()); + auto check_old_b_file = XBValidateUtils::validate_binary_file(old_binary_file.string()); if (retVal == EOPNOTSUPP) { if (check_old_b_file == EOPNOTSUPP) { XBValidateUtils::logger(ptree, "Details", "Test is not supported on this device."); diff --git a/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp b/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp index 4dfffa9d9d4..bf4f90cb8f1 100644 --- a/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp +++ b/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp @@ -54,7 +54,7 @@ TestNPULatency::run(std::shared_ptr dev) xrt::kernel testker; try { - std::string sequence = dpu_or_elf(dev, xclbin, ptree); + std::string sequence = XBValidateUtils::dpu_or_elf(dev, xclbin, ptree); hwctx = xrt::hw_context(working_dev, xclbin.get_uuid()); testker = get_kernel(hwctx, sequence); } diff --git a/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp b/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp index c02fd6ec946..57b900586f9 100644 --- a/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp +++ b/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp @@ -54,7 +54,7 @@ TestNPUThroughput::run(std::shared_ptr dev) xrt::kernel testker; try { - std::string sequence = dpu_or_elf(dev, xclbin, ptree); + std::string sequence = XBValidateUtils::dpu_or_elf(dev, xclbin, ptree); hwctx = xrt::hw_context(working_dev, xclbin.get_uuid()); testker = get_kernel(hwctx, sequence); } diff --git a/src/runtime_src/core/tools/common/tests/TestPsIops.cpp b/src/runtime_src/core/tools/common/tests/TestPsIops.cpp index 6c3a868d840..0c45f49dc90 100644 --- a/src/runtime_src/core/tools/common/tests/TestPsIops.cpp +++ b/src/runtime_src/core/tools/common/tests/TestPsIops.cpp @@ -182,7 +182,7 @@ TestPsIops::runTest(std::shared_ptr dev, boost::property_tree: const std::vector dependency_paths = findDependencies(test_path, m_xclbin); // Validate dependency xclbins onto device if any for (const auto& path : dependency_paths) { - auto retVal = validate_binary_file(path); + auto retVal = XBValidateUtils::validate_binary_file(path); if (retVal == EOPNOTSUPP) { ptree.put("status", XBValidateUtils::test_token_skipped); return; @@ -195,7 +195,7 @@ TestPsIops::runTest(std::shared_ptr dev, boost::property_tree: } const std::string b_file = XBValidateUtils::findXclbinPath(dev, ptree); // "/lib/firmware/xilinx/ps_kernels/ps_bandwidth.xclbin" - auto retVal = validate_binary_file(b_file); + auto retVal = XBValidateUtils::validate_binary_file(b_file); if (retVal == EOPNOTSUPP) { ptree.put("status", XBValidateUtils::test_token_skipped); return; diff --git a/src/runtime_src/core/tools/common/tests/TestPsPlVerify.cpp b/src/runtime_src/core/tools/common/tests/TestPsPlVerify.cpp index 108344c07a2..4e11c5a8bcd 100644 --- a/src/runtime_src/core/tools/common/tests/TestPsPlVerify.cpp +++ b/src/runtime_src/core/tools/common/tests/TestPsPlVerify.cpp @@ -45,7 +45,7 @@ TestPsPlVerify::runTest(std::shared_ptr dev, boost::property_t // Load dependency xclbins onto device if any for (const auto& path : dependency_paths) { - auto retVal = validate_binary_file(path); + auto retVal = XBValidateUtils::validate_binary_file(path); if (retVal == EOPNOTSUPP) { ptree.put("status", XBValidateUtils::test_token_skipped); return; @@ -59,7 +59,7 @@ TestPsPlVerify::runTest(std::shared_ptr dev, boost::property_t } // Load ps kernel onto device - auto retVal = validate_binary_file(b_file); + auto retVal = XBValidateUtils::validate_binary_file(b_file); if (flag_s || retVal == EOPNOTSUPP) { ptree.put("status", XBValidateUtils::test_token_skipped); return; diff --git a/src/runtime_src/core/tools/common/tests/TestPsVerify.cpp b/src/runtime_src/core/tools/common/tests/TestPsVerify.cpp index ff477133d54..10dd98c0719 100644 --- a/src/runtime_src/core/tools/common/tests/TestPsVerify.cpp +++ b/src/runtime_src/core/tools/common/tests/TestPsVerify.cpp @@ -38,7 +38,7 @@ TestPsVerify::runTest(std::shared_ptr dev, boost::property_tre const std::vector dependency_paths = findDependencies(test_path, m_xclbin); // Load dependency xclbins onto device if any for (const auto& path : dependency_paths) { - auto retVal = validate_binary_file(path); + auto retVal = XBValidateUtils::validate_binary_file(path); if (retVal == EOPNOTSUPP) { ptree.put("status", XBValidateUtils::test_token_skipped); return; @@ -48,7 +48,7 @@ TestPsVerify::runTest(std::shared_ptr dev, boost::property_tre const std::string b_file = XBValidateUtils::findXclbinPath(dev, ptree); // Load ps kernel onto device - auto retVal = validate_binary_file(b_file); + auto retVal = XBValidateUtils::validate_binary_file(b_file); if (retVal == EOPNOTSUPP) { ptree.put("status", XBValidateUtils::test_token_skipped); return; diff --git a/src/runtime_src/core/tools/common/tests/TestSpatialSharingOvd.cpp b/src/runtime_src/core/tools/common/tests/TestSpatialSharingOvd.cpp index 17f2a002936..56ce924b7da 100644 --- a/src/runtime_src/core/tools/common/tests/TestSpatialSharingOvd.cpp +++ b/src/runtime_src/core/tools/common/tests/TestSpatialSharingOvd.cpp @@ -15,7 +15,7 @@ namespace XBU = XBUtilities; static constexpr size_t host_app = 1; //opcode -static constexpr size_t buffer_size = 1024; //1 KB +static constexpr size_t buffer_size = 1024 * 1024 * 1024; //1 GB // Method to run the test // Parameters: @@ -96,7 +96,7 @@ boost::property_tree::ptree TestSpatialSharingOvd::run(std::shared_ptr testcases; // Create two test cases and add them to the vector - TestParams params(xclbin, working_dev, kernelName, dpu_instr, 8, buffer_size, 10000); + TestParams params(xclbin, working_dev, kernelName, dpu_instr, 2, buffer_size, 10); testcases.emplace_back(params); testcases.emplace_back(params); diff --git a/src/runtime_src/core/tools/common/tests/TestTemporalSharingOvd.cpp b/src/runtime_src/core/tools/common/tests/TestTemporalSharingOvd.cpp index 7450e63b496..a3878e52a6b 100644 --- a/src/runtime_src/core/tools/common/tests/TestTemporalSharingOvd.cpp +++ b/src/runtime_src/core/tools/common/tests/TestTemporalSharingOvd.cpp @@ -17,7 +17,7 @@ namespace XBU = XBUtilities; -static constexpr size_t buffer_size = 1024; //1 KB +static constexpr size_t buffer_size = 1024*1024*1024; //1 GB boost::property_tree::ptree TestTemporalSharingOvd::run(std::shared_ptr dev) { @@ -67,7 +67,7 @@ TestTemporalSharingOvd::run(std::shared_ptr dev) { std::vector testcases; // Create two test cases and add them to the vector - TestParams params(xclbin, working_dev, kernelName, dpu_instr, 8, buffer_size, 10000); + TestParams params(xclbin, working_dev, kernelName, dpu_instr, 1, buffer_size, 10); testcases.emplace_back(params); testcases.emplace_back(params); diff --git a/src/runtime_src/core/tools/common/tests/TestValidateUtilities.cpp b/src/runtime_src/core/tools/common/tests/TestValidateUtilities.cpp index b0ec1302a46..70b49461e9b 100644 --- a/src/runtime_src/core/tools/common/tests/TestValidateUtilities.cpp +++ b/src/runtime_src/core/tools/common/tests/TestValidateUtilities.cpp @@ -16,6 +16,10 @@ #include "TestValidateUtilities.h" namespace xq = xrt_core::query; +static constexpr size_t param_size = 0x100; +static constexpr size_t inter_size = 0x100; +static constexpr size_t mc_size = 0x100; + // Constructor for BO_set // BO_set is a collection of all the buffer objects so that the operations on all buffers can be done from a single object // Parameters: @@ -24,17 +28,18 @@ namespace xq = xrt_core::query; BO_set::BO_set(const xrt::device& device, const xrt::kernel& kernel, const std::string& dpu_instr, size_t buffer_size) : buffer_size(buffer_size), bo_ifm (device, buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(1)), - bo_param (device, buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(2)), + bo_param (device, param_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(2)), bo_ofm (device, buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(3)), - bo_inter (device, buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(4)), - bo_mc (device, buffer_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(7)) + bo_inter (device, inter_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(4)), + bo_mc (device, mc_size, XRT_BO_FLAGS_HOST_ONLY, kernel.group_id(7)) { if (dpu_instr.empty()) { // Create a no-op instruction if no instruction file is provided std::memset(bo_instr.map(), (uint8_t)0, buffer_size); } else { size_t instr_size = XBValidateUtils::get_instr_size(dpu_instr); - bo_instr = xrt::bo(device, instr_size, XCL_BO_FLAGS_CACHEABLE, kernel.group_id(5)); + bo_instr = xrt::bo(device, instr_size * sizeof(int), XCL_BO_FLAGS_CACHEABLE, kernel.group_id(5)); + XBValidateUtils::init_instr_buf(bo_instr, dpu_instr); } } @@ -57,7 +62,7 @@ void BO_set::set_kernel_args(xrt::run& run) const { run.set_arg(3, bo_ofm); run.set_arg(4, bo_inter); run.set_arg(5, bo_instr); - run.set_arg(6, buffer_size/sizeof(int)); + run.set_arg(6, bo_instr.size()/sizeof(int)); run.set_arg(7, bo_mc); } @@ -68,11 +73,7 @@ TestCase::initialize() // Initialize kernels, buffer objects, and runs for (int j = 0; j < params.queue_len; j++) { xrt::kernel kernel; - try { - kernel = xrt::kernel(hw_ctx, params.kernel_name); - } catch (const std::exception& ) { - throw std::runtime_error("Not enough columns available. Please make sure no other workload is running on the device."); //rethrow - } + kernel = xrt::kernel(hw_ctx, params.kernel_name); auto bos = BO_set(params.device, kernel, params.dpu_file, params.buffer_size); bos.sync_bos_to_device(); auto run = xrt::run(kernel); @@ -370,4 +371,82 @@ searchSSV2Xclbin(const std::string& logic_uuid, _ptTest.put("status", test_token_skipped); return ""; } + +void +program_xclbin(const std::shared_ptr& device, const std::string& xclbin) +{ + auto bdf = xq::pcie_bdf::to_string(xrt_core::device_query(device)); + auto xclbin_obj = xrt::xclbin{xclbin}; + try { + device->load_xclbin(xclbin_obj); + } + catch (const std::exception& e) { + XBUtilities::throw_cancel(boost::format("Could not program device %s : %s") % bdf % e.what()); + } +} +bool +search_and_program_xclbin(const std::shared_ptr& dev, boost::property_tree::ptree& ptTest) +{ + xuid_t uuid; + uuid_parse(xrt_core::device_query(dev).c_str(), uuid); + + const std::string xclbin_path = XBValidateUtils::findXclbinPath(dev, ptTest); + + try { + program_xclbin(dev, xclbin_path); + } + catch (const std::exception& e) { + XBValidateUtils::logger(ptTest, "Error", e.what()); + ptTest.put("status", XBValidateUtils::test_token_failed); + return false; + } + + return true; +} + +int +validate_binary_file(const std::string& binaryfile) +{ + std::ifstream infile(binaryfile); + if (!infile.good()) + return EOPNOTSUPP; + else + return EXIT_SUCCESS; +} + +/* + * Runs dpu sequence or elf flow for xrt_smi tests +*/ +std::string +dpu_or_elf(const std::shared_ptr& dev, const xrt::xclbin& xclbin, + boost::property_tree::ptree& ptTest) +{ + if (xrt_core::device_query(dev).device_id != 5696) { // device ID for npu3 in decimal + // Determine The DPU Kernel Name + auto xkernels = xclbin.get_kernels(); + + auto itr = std::find_if(xkernels.begin(), xkernels.end(), [](xrt::xclbin::kernel& k) { + auto name = k.get_name(); + return name.rfind("DPU",0) == 0; // Starts with "DPU" + }); + + xrt::xclbin::kernel xkernel; + if (itr!=xkernels.end()) + xkernel = *itr; + else { + XBValidateUtils::logger(ptTest, "Error", "No kernel with `DPU` found in the xclbin"); + ptTest.put("status", XBValidateUtils::test_token_failed); + } + auto kernelName = xkernel.get_name(); + + return kernelName; + } + else { + // Elf flow + const auto elf_name = xrt_core::device_query(dev, xrt_core::query::elf_name::type::nop); + auto elf_path = XBValidateUtils::findPlatformFile(elf_name, ptTest); + + return elf_path; + } +} }// end of namespace XBValidateUtils diff --git a/src/runtime_src/core/tools/common/tests/TestValidateUtilities.h b/src/runtime_src/core/tools/common/tests/TestValidateUtilities.h index 745d38d29d4..c2667b7f046 100644 --- a/src/runtime_src/core/tools/common/tests/TestValidateUtilities.h +++ b/src/runtime_src/core/tools/common/tests/TestValidateUtilities.h @@ -85,5 +85,10 @@ std::string searchLegacyXclbin(const uint16_t vendor, const std::string& dev_nam boost::property_tree::ptree& _ptTest); std::string searchSSV2Xclbin(const std::string& logic_uuid, boost::property_tree::ptree& _ptTest); +void program_xclbin(const std::shared_ptr& device, const std::string& xclbin); +bool search_and_program_xclbin(const std::shared_ptr& dev, boost::property_tree::ptree& ptTest); +int validate_binary_file(const std::string& binaryfile); +std::string dpu_or_elf(const std::shared_ptr& dev, const xrt::xclbin& xclbin, + boost::property_tree::ptree& ptTest); } //End of namespace XBValidateUtils #endif diff --git a/src/runtime_src/core/tools/common/tests/Testm2m.cpp b/src/runtime_src/core/tools/common/tests/Testm2m.cpp index dbc004d66c8..d59ad788c95 100644 --- a/src/runtime_src/core/tools/common/tests/Testm2m.cpp +++ b/src/runtime_src/core/tools/common/tests/Testm2m.cpp @@ -25,7 +25,7 @@ Testm2m::run(std::shared_ptr dev) return ptree; } - if (!search_and_program_xclbin(dev, ptree)) { + if (!XBValidateUtils::search_and_program_xclbin(dev, ptree)) { return ptree; } diff --git a/src/runtime_src/core/tools/common/tests/Testp2p.cpp b/src/runtime_src/core/tools/common/tests/Testp2p.cpp index 42f367cdedc..3c2a635240e 100644 --- a/src/runtime_src/core/tools/common/tests/Testp2p.cpp +++ b/src/runtime_src/core/tools/common/tests/Testp2p.cpp @@ -144,7 +144,7 @@ Testp2p::run(std::shared_ptr dev) boost::property_tree::ptree ptree = get_test_header(); auto no_dma = xrt_core::device_query_default(dev, 0); - if (!search_and_program_xclbin(dev, ptree)) { + if (!XBValidateUtils::search_and_program_xclbin(dev, ptree)) { return ptree; } diff --git a/src/runtime_src/core/tools/xbutil2/OO_Performance.cpp b/src/runtime_src/core/tools/xbutil2/OO_Performance.cpp index 93e6bc11cb9..71ca00aa225 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") //to-do: add turbo mode back to help! + ("mode", boost::program_options::value(&m_action)->required(), "Action to perform: default, powersaver, balanced, performance, turbo") ; m_positionalOptions.