From f58df363b4ae81446f47085e15732d681b3f799d Mon Sep 17 00:00:00 2001 From: Hayden Laccabue Date: Fri, 13 Sep 2024 14:47:10 -0700 Subject: [PATCH] Creating initial support for NPU3 no-op tests throughput and latency Signed-off-by: Hayden Laccabue --- src/runtime_src/core/common/query_requests.h | 5 +- .../tools/common/tests/TestNPULatency.cpp | 48 ++++++++++++++++--- .../tools/common/tests/TestNPUThroughput.cpp | 48 ++++++++++++++++--- 3 files changed, 88 insertions(+), 13 deletions(-) diff --git a/src/runtime_src/core/common/query_requests.h b/src/runtime_src/core/common/query_requests.h index bb7da05f800..bbdf6d29887 100644 --- a/src/runtime_src/core/common/query_requests.h +++ b/src/runtime_src/core/common/query_requests.h @@ -568,7 +568,8 @@ struct sequence_name : request tct_one_column, tct_all_column, gemm_int8, - aie_reconfig_overhead + aie_reconfig_overhead, + nop }; static std::string @@ -585,6 +586,8 @@ struct sequence_name : request return "gemm_int8"; case type::aie_reconfig_overhead: return "aie_reconfig_overhead"; + case type::nop: + return "nop"; } return "unknown"; } diff --git a/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp b/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp index 58ff7c3c813..8a0e2719003 100644 --- a/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp +++ b/src/runtime_src/core/tools/common/tests/TestNPULatency.cpp @@ -9,7 +9,11 @@ #include "xrt/xrt_device.h" #include "xrt/xrt_hw_context.h" #include "xrt/xrt_kernel.h" +#include "experimental/xrt_elf.h" +#include "experimental/xrt_ext.h" +#include "experimental/xrt_module.h" namespace XBU = XBUtilities; +namespace xq = xrt_core::query; #include @@ -70,14 +74,46 @@ TestNPULatency::run(std::shared_ptr dev) xrt::hw_context hwctx; xrt::kernel testker; - try { + if(xrt_core::device_query(dev).find("umq") != std::string::npos) { + //Elf flow + const auto elf_name = xrt_core::device_query(dev, xrt_core::query::sequence_name::type::nop); + auto elf_path = findPlatformFile(elf_name, ptree); + if (!std::filesystem::exists(elf_path)) + return ptree; + + logger(ptree, "Elf", elf_path); + + xrt::elf elf; + try { + elf = xrt::elf(elf_path); + } + catch (const std::runtime_error& ex) { + logger(ptree, "Error", ex.what()); + ptree.put("status", test_token_failed); + return ptree; + } + + xrt::module mod{elf}; + try{ + hwctx = xrt::hw_context{working_dev, xclbin.get_uuid()}; + testker = xrt::ext::kernel{hwctx, mod, kernelName}; + } + catch (const std::exception& ex){ + logger(ptree, "Error", ex.what()); + ptree.put("status", test_token_failed); + return ptree; + } + } + else { + try { hwctx = xrt::hw_context(working_dev, xclbin.get_uuid()); testker = xrt::kernel(hwctx, kernelName); - } - catch (const std::exception& ex){ - logger(ptree, "Error", ex.what()); - ptree.put("status", test_token_failed); - return ptree; + } + catch (const std::exception& ex){ + logger(ptree, "Error", ex.what()); + ptree.put("status", test_token_failed); + return ptree; + } } //Create BOs, the values are not initialized as they are not really used by this special test running on the device diff --git a/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp b/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp index ceffe31986a..c862bd121b8 100644 --- a/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp +++ b/src/runtime_src/core/tools/common/tests/TestNPUThroughput.cpp @@ -9,7 +9,11 @@ #include "xrt/xrt_device.h" #include "xrt/xrt_hw_context.h" #include "xrt/xrt_kernel.h" +#include "experimental/xrt_elf.h" +#include "experimental/xrt_ext.h" +#include "experimental/xrt_module.h" namespace XBU = XBUtilities; +namespace xq = xrt_core::query; #include @@ -69,14 +73,46 @@ TestNPUThroughput::run(std::shared_ptr dev) xrt::hw_context hwctx; xrt::kernel testker; - try { + if(xrt_core::device_query(dev).find("umq") != std::string::npos) { + //Elf flow + const auto elf_name = xrt_core::device_query(dev, xrt_core::query::sequence_name::type::nop); + auto elf_path = findPlatformFile(elf_name, ptree); + if (!std::filesystem::exists(elf_path)) + return ptree; + + logger(ptree, "Elf", elf_path); + + xrt::elf elf; + try { + elf = xrt::elf(elf_path); + } + catch (const std::runtime_error& ex) { + logger(ptree, "Error", ex.what()); + ptree.put("status", test_token_failed); + return ptree; + } + + xrt::module mod{elf}; + try{ + hwctx = xrt::hw_context{working_dev, xclbin.get_uuid()}; + testker = xrt::ext::kernel{hwctx, mod, kernelName}; + } + catch (const std::exception& ex){ + logger(ptree, "Error", ex.what()); + ptree.put("status", test_token_failed); + return ptree; + } + } + else { + try { hwctx = xrt::hw_context(working_dev, xclbin.get_uuid()); testker = xrt::kernel(hwctx, kernelName); - } - catch (const std::exception& ex){ - logger(ptree, "Error", ex.what()); - ptree.put("status", test_token_failed); - return ptree; + } + catch (const std::exception& ex){ + logger(ptree, "Error", ex.what()); + ptree.put("status", test_token_failed); + return ptree; + } } //Create BOs, the values are not initialized as they are not really used by this special test running on the device