From f74635f16cb5ba7266ca12f4e9c23d138221c1e9 Mon Sep 17 00:00:00 2001 From: Shaojie Zhu Date: Wed, 23 Oct 2024 21:01:41 +0800 Subject: [PATCH] [NPU] Add pfn build log to pfn-related function (#26772) There are many OPENVINO_THROW, OPENVINO_ASSERT inside https://github.com/openvinotoolkit/openvino/blob/master/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp, call getLatestBuildError to show error info when pfn-related function is called and remove exception handle fuction that would never be called. Use a macro THROW_ON_FAIL_FOR_LEVELZERO_EXT to simplify exception handling code. There are two functions zeroUtils::throwOnFail() in zero_utils.hpp, but only the two-parameters function zeroUtils::throwOnFail() is actually used. And zeroUtils::throwOnFail() will use its code location instead of the real location where issue happen, so use a macro THROW_ON_FAIL_FOR_LEVELZERO instead of the function zeroUtils::throwOnFail() with two parameters. Function zeroUtils::throwOnFail() with three parameters is preserved. - [EISW-139871](https://jira.devtools.intel.com/browse/EISW-139871) --- .../intel_npu/src/backend/src/zero_device.cpp | 28 +- .../src/backend/src/zero_executor.cpp | 20 +- .../src/backend/src/zero_infer_request.cpp | 4 +- .../intel_npu/src/backend/src/zero_init.cpp | 32 +- .../src/backend/src/zero_profiling.cpp | 37 +-- .../src/backend/src/zero_remote_tensor.cpp | 27 +- .../src/backend/src/zero_wrappers.cpp | 78 ++--- .../include/zero_compiler_in_driver.hpp | 12 - .../compiler/src/zero_compiler_in_driver.cpp | 274 +++--------------- 9 files changed, 163 insertions(+), 349 deletions(-) diff --git a/src/plugins/intel_npu/src/backend/src/zero_device.cpp b/src/plugins/intel_npu/src/backend/src/zero_device.cpp index 66baa621f214a6..4a849462a8a355 100644 --- a/src/plugins/intel_npu/src/backend/src/zero_device.cpp +++ b/src/plugins/intel_npu/src/backend/src/zero_device.cpp @@ -20,8 +20,8 @@ ZeroDevice::ZeroDevice(const std::shared_ptr& initStructs log("ZeroDevice", Logger::global().level()) { log.debug("ZeroDevice::ZeroDevice init"); device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES; - zeroUtils::throwOnFail("zeDeviceGetProperties", - zeDeviceGetProperties(_initStructs->getDevice(), &device_properties)); + THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties", + zeDeviceGetProperties(_initStructs->getDevice(), &device_properties)); // Query PCI information // Older drivers do not have this implementend. Linux driver returns NOT_IMPLEMENTED, while windows driver returns @@ -62,7 +62,7 @@ ZeroDevice::ZeroDevice(const std::shared_ptr& initStructs std::vector command_group_properties; uint32_t command_queue_group_count = 0; // Discover all command queue groups - zeroUtils::throwOnFail( + THROW_ON_FAIL_FOR_LEVELZERO( "zeDeviceGetCommandQueueGroupProperties", zeDeviceGetCommandQueueGroupProperties(_initStructs->getDevice(), &command_queue_group_count, nullptr)); @@ -74,10 +74,10 @@ ZeroDevice::ZeroDevice(const std::shared_ptr& initStructs prop.pNext = nullptr; } - zeroUtils::throwOnFail("zeDeviceGetCommandQueueGroupProperties", - zeDeviceGetCommandQueueGroupProperties(_initStructs->getDevice(), - &command_queue_group_count, - command_group_properties.data())); + THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetCommandQueueGroupProperties", + zeDeviceGetCommandQueueGroupProperties(_initStructs->getDevice(), + &command_queue_group_count, + command_group_properties.data())); // Find the corresponding command queue group. log.debug("ZeroDevice::ZeroDevice - findGroupOrdinal"); @@ -138,17 +138,19 @@ uint32_t ZeroDevice::getMaxNumSlices() const { uint64_t ZeroDevice::getAllocMemSize() const { ze_graph_memory_query_t query{}; - zeroUtils::throwOnFail( - "pfnQueryContextMemory", - _graph_ddi_table_ext.pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query)); + ze_result_t result = + _graph_ddi_table_ext.pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryContextMemory", result, _graph_ddi_table_ext); + return query.allocated; } uint64_t ZeroDevice::getTotalMemSize() const { ze_graph_memory_query_t query{}; - zeroUtils::throwOnFail( - "pfnQueryContextMemory", - _graph_ddi_table_ext.pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query)); + ze_result_t result = + _graph_ddi_table_ext.pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryContextMemory", result, _graph_ddi_table_ext); + return query.total; } diff --git a/src/plugins/intel_npu/src/backend/src/zero_executor.cpp b/src/plugins/intel_npu/src/backend/src/zero_executor.cpp index e6c1dee032614b..32da2b2e0e4189 100644 --- a/src/plugins/intel_npu/src/backend/src/zero_executor.cpp +++ b/src/plugins/intel_npu/src/backend/src/zero_executor.cpp @@ -50,10 +50,9 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr& i _networkDesc->compiledNetwork.size(), _networkDesc->compiledNetwork.data(), nullptr}; - - zeroUtils::throwOnFail( - "pfnCreate", - _graph_ddi_table_ext.pfnCreate(_initStructs->getContext(), _initStructs->getDevice(), &desc, &_graph)); + ze_result_t result = + _graph_ddi_table_ext.pfnCreate(_initStructs->getContext(), _initStructs->getDevice(), &desc, &_graph); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _graph_ddi_table_ext); } else { _logger.debug("reuse graph handle created from compiler"); @@ -65,7 +64,9 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr& i ze_graph_properties_t props{}; props.stype = ZE_STRUCTURE_TYPE_GRAPH_PROPERTIES; - zeroUtils::throwOnFail("pfnGetProperties", _graph_ddi_table_ext.pfnGetProperties(_graph, &props)); + ze_result_t result = _graph_ddi_table_ext.pfnGetProperties(_graph, &props); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetProperties", result, _graph_ddi_table_ext); + auto targetDriverExtVersion = _graph_ddi_table_ext.version(); if (targetDriverExtVersion <= ZE_GRAPH_EXT_VERSION_1_1) { OPENVINO_THROW("Incompatibility between the NPU plugin and driver! The driver version is too old, please " @@ -77,8 +78,8 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr& i for (uint32_t index = 0; index < props.numGraphArgs; ++index) { ze_graph_argument_properties_3_t arg3{}; arg3.stype = ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_PROPERTIES; - zeroUtils::throwOnFail("pfnGetArgumentProperties3", - _graph_ddi_table_ext.pfnGetArgumentProperties3(_graph, index, &arg3)); + ze_result_t result = _graph_ddi_table_ext.pfnGetArgumentProperties3(_graph, index, &arg3); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetArgumentProperties3", result, _graph_ddi_table_ext); if (arg3.type == ZE_GRAPH_ARGUMENT_TYPE_INPUT) { _input_descriptors.push_back(ArgumentDescriptor{arg3, index}); @@ -163,7 +164,10 @@ void ZeroExecutor::setWorkloadType(const ov::WorkloadType workloadType) const { } void ZeroExecutor::setArgumentValue(uint32_t argi_, const void* argv_) const { - zeroUtils::throwOnFail("zeGraphSetArgumentValue", _graph_ddi_table_ext.pfnSetArgumentValue(_graph, argi_, argv_)); + ze_result_t result = _graph_ddi_table_ext.pfnSetArgumentValue(_graph, argi_, argv_); + if (ZE_RESULT_SUCCESS != result) { + THROW_ON_FAIL_FOR_LEVELZERO_EXT("zeGraphSetArgumentValue", result, _graph_ddi_table_ext); + } } void ZeroExecutor::mutexLock() const { diff --git a/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp b/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp index 7a4754fb0bd7e9..0a55945872b278 100644 --- a/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp +++ b/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp @@ -188,8 +188,8 @@ ZeroInferRequest::ZeroInferRequest(const std::shared_ptr& } _properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES; - zeroUtils::throwOnFail("zeDeviceGetProperties", - zeDeviceGetProperties(_executor->getInitStructs()->getDevice(), &_properties)); + THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties", + zeDeviceGetProperties(_executor->getInitStructs()->getDevice(), &_properties)); _outputAllocator = std::make_shared(_initStructs); _inputAllocator = diff --git a/src/plugins/intel_npu/src/backend/src/zero_init.cpp b/src/plugins/intel_npu/src/backend/src/zero_init.cpp index 76ff470c92eaf5..b220491aa1db22 100644 --- a/src/plugins/intel_npu/src/backend/src/zero_init.cpp +++ b/src/plugins/intel_npu/src/backend/src/zero_init.cpp @@ -54,13 +54,13 @@ static std::tuple queryDriverExtensionVersion( ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder", Logger::global().level()) { OV_ITT_SCOPED_TASK(itt::domains::LevelZeroBackend, "ZeroInitStructsHolder::ZeroInitStructsHolder"); log.debug("ZeroInitStructsHolder - performing zeInit on VPU only"); - zeroUtils::throwOnFail("zeInit", zeInit(ZE_INIT_FLAG_VPU_ONLY)); + THROW_ON_FAIL_FOR_LEVELZERO("zeInit", zeInit(ZE_INIT_FLAG_VPU_ONLY)); uint32_t drivers = 0; - zeroUtils::throwOnFail("zeDriverGet", zeDriverGet(&drivers, nullptr)); + THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGet", zeDriverGet(&drivers, nullptr)); std::vector all_drivers(drivers); - zeroUtils::throwOnFail("zeDriverGet", zeDriverGet(&drivers, all_drivers.data())); + THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGet", zeDriverGet(&drivers, all_drivers.data())); // Get our target driver driver_properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; @@ -79,7 +79,7 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder", // Check L0 API version ze_api_version_t ze_drv_api_version = {}; - zeroUtils::throwOnFail("zeDriverGetApiVersion", zeDriverGetApiVersion(driver_handle, &ze_drv_api_version)); + THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGetApiVersion", zeDriverGetApiVersion(driver_handle, &ze_drv_api_version)); if (ZE_MAJOR_VERSION(ZE_API_VERSION_CURRENT) != ZE_MAJOR_VERSION(ze_drv_api_version)) { OPENVINO_THROW("Incompatibility between NPU plugin and driver! ", @@ -97,13 +97,13 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder", } uint32_t count = 0; - zeroUtils::throwOnFail("zeDriverGetExtensionProperties", - zeDriverGetExtensionProperties(driver_handle, &count, nullptr)); + THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGetExtensionProperties", + zeDriverGetExtensionProperties(driver_handle, &count, nullptr)); std::vector extProps; extProps.resize(count); - zeroUtils::throwOnFail("zeDriverGetExtensionProperties", - zeDriverGetExtensionProperties(driver_handle, &count, extProps.data())); + THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGetExtensionProperties", + zeDriverGetExtensionProperties(driver_handle, &count, extProps.data())); // Query our graph extension version std::string graph_ext_name; @@ -149,7 +149,7 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder", // Load our command queue extension ze_command_queue_npu_dditable_ext_last_t* _command_queue_npu_dditable_ext = nullptr; if (command_queue_ext_version) { - zeroUtils::throwOnFail( + THROW_ON_FAIL_FOR_LEVELZERO( "zeDriverGetExtensionFunctionAddress " + command_queue_ext_name, zeDriverGetExtensionFunctionAddress(driver_handle, command_queue_ext_name.c_str(), @@ -162,10 +162,10 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder", // Load our graph extension ze_graph_dditable_ext_last_t* graph_ddi_table_ext = nullptr; - zeroUtils::throwOnFail("zeDriverGetExtensionFunctionAddress", - zeDriverGetExtensionFunctionAddress(driver_handle, - graph_ext_name.c_str(), - reinterpret_cast(&graph_ddi_table_ext))); + THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGetExtensionFunctionAddress", + zeDriverGetExtensionFunctionAddress(driver_handle, + graph_ext_name.c_str(), + reinterpret_cast(&graph_ddi_table_ext))); graph_dditable_ext_decorator = std::make_unique(graph_ddi_table_ext, graph_ext_version); @@ -190,7 +190,7 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder", // Load our profiling extension ze_graph_profiling_dditable_ext_t* _graph_profiling_ddi_table_ext = nullptr; - zeroUtils::throwOnFail( + THROW_ON_FAIL_FOR_LEVELZERO( "zeDriverGetExtensionFunctionAddress", zeDriverGetExtensionFunctionAddress(driver_handle, "ZE_extension_profiling_data", @@ -201,11 +201,11 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder", uint32_t device_count = 1; // Get our target device - zeroUtils::throwOnFail("zeDeviceGet", zeDeviceGet(driver_handle, &device_count, &device_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGet", zeDeviceGet(driver_handle, &device_count, &device_handle)); // Create context - share between the compiler and the backend ze_context_desc_t context_desc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, 0, 0}; - zeroUtils::throwOnFail("zeContextCreate", zeContextCreate(driver_handle, &context_desc, &context)); + THROW_ON_FAIL_FOR_LEVELZERO("zeContextCreate", zeContextCreate(driver_handle, &context_desc, &context)); log.debug("ZeroInitStructsHolder initialize complete"); } diff --git a/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp b/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp index 5474d073a112bf..52302b38df512d 100644 --- a/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp +++ b/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp @@ -46,8 +46,9 @@ ProfilingPool::~ProfilingPool() { } void ProfilingQuery::create(const ze_graph_profiling_pool_handle_t& profiling_pool) { - zeroUtils::throwOnFail("pfnProfilingQueryCreate", - _graph_profiling_ddi_table_ext.pfnProfilingQueryCreate(profiling_pool, _index, &_handle)); + THROW_ON_FAIL_FOR_LEVELZERO( + "pfnProfilingQueryCreate", + _graph_profiling_ddi_table_ext.pfnProfilingQueryCreate(profiling_pool, _index, &_handle)); } LayerStatistics ProfilingQuery::getLayerStatistics() const { @@ -66,7 +67,7 @@ void ProfilingQuery::queryGetData(const ze_graph_profiling_type_t profilingType, uint32_t* pSize, uint8_t* pData) const { if (_handle && pSize) { - zeroUtils::throwOnFail( + THROW_ON_FAIL_FOR_LEVELZERO( "pfnProfilingQueryGetData", _graph_profiling_ddi_table_ext.pfnProfilingQueryGetData(_handle, profilingType, pSize, pData)); } @@ -92,7 +93,7 @@ template std::vector ProfilingQuery::getData() const; void ProfilingQuery::getProfilingProperties(ze_device_profiling_data_properties_t* properties) const { if (_handle && properties) { - zeroUtils::throwOnFail( + THROW_ON_FAIL_FOR_LEVELZERO( "getProfilingProperties", _graph_profiling_ddi_table_ext.pfnDeviceGetProfilingDataProperties(_device_handle, properties)); } @@ -187,23 +188,25 @@ NpuInferProfiling::NpuInferProfiling(ze_context_handle_t context, _logger("InferProfiling", loglevel) { /// Fetch and store the device timer resolution _dev_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2; - zeroUtils::throwOnFail("zeDeviceGetProperties", zeDeviceGetProperties(_device_handle, &_dev_properties)); + THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties", zeDeviceGetProperties(_device_handle, &_dev_properties)); /// Request mem allocations ze_host_mem_alloc_desc_t desc = {ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC, nullptr, ZE_HOST_MEM_ALLOC_FLAG_BIAS_CACHED}; - zeroUtils::throwOnFail("zeMemAllocHost", - zeMemAllocHost(_context, - &desc, - sizeof(uint64_t), - 64, - &npu_ts_infer_start)); // align to 64 bytes to match npu l2 cache line size - zeroUtils::throwOnFail("zeMemAllocHost", - zeMemAllocHost(_context, - &desc, - sizeof(uint64_t), - 64, - &npu_ts_infer_end)); // alight to 64 bytes to match npu l2 cache line size + THROW_ON_FAIL_FOR_LEVELZERO( + "zeMemAllocHost", + zeMemAllocHost(_context, + &desc, + sizeof(uint64_t), + 64, + &npu_ts_infer_start)); // align to 64 bytes to match npu l2 cache line size + THROW_ON_FAIL_FOR_LEVELZERO( + "zeMemAllocHost", + zeMemAllocHost(_context, + &desc, + sizeof(uint64_t), + 64, + &npu_ts_infer_end)); // alight to 64 bytes to match npu l2 cache line size } void NpuInferProfiling::sampleNpuTimestamps() { diff --git a/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp b/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp index 5bcf7b00819431..8419fec7a8612f 100644 --- a/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp +++ b/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp @@ -37,7 +37,8 @@ ZeroRemoteTensor::ZeroRemoteTensor(std::shared_ptr context, _mem_type(mem_type), _mem(mem) { _ze_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES; - zeroUtils::throwOnFail("zeDeviceGetProperties", zeDeviceGetProperties(_init_structs->getDevice(), &_ze_properties)); + THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties", + zeDeviceGetProperties(_init_structs->getDevice(), &_ze_properties)); const auto byte_size = ov::element::get_memory_size(_element_type, shape_size(_shape)); @@ -97,8 +98,9 @@ void ZeroRemoteTensor::allocate(const size_t bytes) { } else { desc = {ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC, nullptr, 0}; } - zeroUtils::throwOnFail("zeMemAllocHost", - zeMemAllocHost(_init_structs->getContext(), &desc, size, STANDARD_PAGE_SIZE, &_data)); + THROW_ON_FAIL_FOR_LEVELZERO( + "zeMemAllocHost", + zeMemAllocHost(_init_structs->getContext(), &desc, size, STANDARD_PAGE_SIZE, &_data)); break; } case MemType::SHARED_BUF: { @@ -116,13 +118,13 @@ void ZeroRemoteTensor::allocate(const size_t bytes) { _mem, nullptr}; ze_device_mem_alloc_desc_t desc = {ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC, &memory_import, 0, 0}; - zeroUtils::throwOnFail("zeMemAllocDevice", - zeMemAllocDevice(_init_structs->getContext(), - &desc, - bytes, - STANDARD_PAGE_SIZE, - _init_structs->getDevice(), - &_data)); + THROW_ON_FAIL_FOR_LEVELZERO("zeMemAllocDevice", + zeMemAllocDevice(_init_structs->getContext(), + &desc, + bytes, + STANDARD_PAGE_SIZE, + _init_structs->getDevice(), + &_data)); #else // in the case of Linux platforms memory could be changed after allocation - using zeMemAllocHost for importing // memory @@ -131,8 +133,9 @@ void ZeroRemoteTensor::allocate(const size_t bytes) { ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF, static_cast(reinterpret_cast(_mem))}; ze_host_mem_alloc_desc_t desc = {.pNext = &memory_import}; - zeroUtils::throwOnFail("zeMemAllocHost", - zeMemAllocHost(_init_structs->getContext(), &desc, bytes, STANDARD_PAGE_SIZE, &_data)); + THROW_ON_FAIL_FOR_LEVELZERO( + "zeMemAllocHost", + zeMemAllocHost(_init_structs->getContext(), &desc, bytes, STANDARD_PAGE_SIZE, &_data)); #endif break; } diff --git a/src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp b/src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp index e793dc7378d3c1..2de6cb2d3c4c58 100644 --- a/src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp +++ b/src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp @@ -19,8 +19,8 @@ EventPool::EventPool(ze_device_handle_t device_handle, nullptr, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, event_count}; - zeroUtils::throwOnFail("zeEventPoolCreate", - zeEventPoolCreate(context, &event_pool_desc, 1, &device_handle, &_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeEventPoolCreate", + zeEventPoolCreate(context, &event_pool_desc, 1, &device_handle, &_handle)); } EventPool::~EventPool() { auto result = zeEventPoolDestroy(_handle); @@ -32,25 +32,25 @@ EventPool::~EventPool() { Event::Event(const ze_event_pool_handle_t& event_pool, uint32_t event_index, const Config& config) : _log("Event", config.get()) { ze_event_desc_t event_desc = {ZE_STRUCTURE_TYPE_EVENT_DESC, nullptr, event_index, 0, 0}; - zeroUtils::throwOnFail("zeEventCreate", zeEventCreate(event_pool, &event_desc, &_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeEventCreate", zeEventCreate(event_pool, &event_desc, &_handle)); } void Event::AppendSignalEvent(CommandList& command_list) const { - zeroUtils::throwOnFail("zeCommandListAppendSignalEvent", - zeCommandListAppendSignalEvent(command_list.handle(), _handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendSignalEvent", + zeCommandListAppendSignalEvent(command_list.handle(), _handle)); } void Event::AppendWaitOnEvent(CommandList& command_list) { - zeroUtils::throwOnFail("zeCommandListAppendWaitOnEvents", - zeCommandListAppendWaitOnEvents(command_list.handle(), 1, &_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendWaitOnEvents", + zeCommandListAppendWaitOnEvents(command_list.handle(), 1, &_handle)); } void Event::AppendEventReset(CommandList& command_list) const { - zeroUtils::throwOnFail("zeCommandListAppendEventReset", - zeCommandListAppendEventReset(command_list.handle(), _handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendEventReset", + zeCommandListAppendEventReset(command_list.handle(), _handle)); } void Event::hostSynchronize() const { - zeroUtils::throwOnFail("zeEventHostSynchronize", zeEventHostSynchronize(_handle, UINT64_MAX)); + THROW_ON_FAIL_FOR_LEVELZERO("zeEventHostSynchronize", zeEventHostSynchronize(_handle, UINT64_MAX)); } void Event::reset() const { - zeroUtils::throwOnFail("zeEventHostReset", zeEventHostReset(_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeEventHostReset", zeEventHostReset(_handle)); } Event::~Event() { auto result = zeEventDestroy(_handle); @@ -70,42 +70,42 @@ CommandList::CommandList(const ze_device_handle_t& device_handle, _log("CommandList", config.get()) { ze_mutable_command_list_exp_desc_t mutable_desc = {ZE_STRUCTURE_TYPE_MUTABLE_COMMAND_LIST_EXP_DESC, nullptr, 0}; ze_command_list_desc_t desc = {ZE_STRUCTURE_TYPE_COMMAND_LIST_DESC, &mutable_desc, group_ordinal, 0}; - zeroUtils::throwOnFail("zeCommandListCreate", zeCommandListCreate(_context, device_handle, &desc, &_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListCreate", zeCommandListCreate(_context, device_handle, &desc, &_handle)); if (mtci_is_supported) { ze_mutable_command_id_exp_desc_t mutableCmdIdDesc = {ZE_STRUCTURE_TYPE_MUTABLE_COMMAND_ID_EXP_DESC, nullptr, ZE_MUTABLE_COMMAND_EXP_FLAG_GRAPH_ARGUMENT}; - zeroUtils::throwOnFail("zeCommandListGetNextCommandIdExp", - zeCommandListGetNextCommandIdExp(_handle, &mutableCmdIdDesc, &_command_id)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListGetNextCommandIdExp", + zeCommandListGetNextCommandIdExp(_handle, &mutableCmdIdDesc, &_command_id)); } } void CommandList::reset() const { - zeroUtils::throwOnFail("zeCommandListReset", zeCommandListReset(_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListReset", zeCommandListReset(_handle)); } void CommandList::appendMemoryCopy(void* dst, const void* src, const std::size_t size) const { - zeroUtils::throwOnFail("zeCommandListAppendMemoryCopy", - zeCommandListAppendMemoryCopy(_handle, dst, src, size, nullptr, 0, nullptr)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendMemoryCopy", + zeCommandListAppendMemoryCopy(_handle, dst, src, size, nullptr, 0, nullptr)); } void CommandList::appendGraphInitialize(const ze_graph_handle_t& graph_handle) const { - zeroUtils::throwOnFail("pfnAppendGraphInitialize", - _graph_ddi_table_ext.pfnAppendGraphInitialize(_handle, graph_handle, nullptr, 0, nullptr)); + ze_result_t result = _graph_ddi_table_ext.pfnAppendGraphInitialize(_handle, graph_handle, nullptr, 0, nullptr); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnAppendGraphInitialize", result, _graph_ddi_table_ext); } void CommandList::appendGraphExecute(const ze_graph_handle_t& graph_handle, const ze_graph_profiling_query_handle_t& profiling_query_handle) const { - zeroUtils::throwOnFail( - "pfnAppendGraphExecute", - _graph_ddi_table_ext.pfnAppendGraphExecute(_handle, graph_handle, profiling_query_handle, nullptr, 0, nullptr)); + ze_result_t result = + _graph_ddi_table_ext.pfnAppendGraphExecute(_handle, graph_handle, profiling_query_handle, nullptr, 0, nullptr); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnAppendGraphExecute", result, _graph_ddi_table_ext); } void CommandList::appendNpuTimestamp(uint64_t* timestamp_buff) const { - zeroUtils::throwOnFail("zeCommandListAppendWriteGlobalTimestamp", - zeCommandListAppendWriteGlobalTimestamp(_handle, timestamp_buff, nullptr, 0, nullptr)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendWriteGlobalTimestamp", + zeCommandListAppendWriteGlobalTimestamp(_handle, timestamp_buff, nullptr, 0, nullptr)); } void CommandList::appendBarrier() const { - zeroUtils::throwOnFail("zeCommandListAppendBarrier", zeCommandListAppendBarrier(_handle, nullptr, 0, nullptr)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendBarrier", zeCommandListAppendBarrier(_handle, nullptr, 0, nullptr)); } void CommandList::close() const { - zeroUtils::throwOnFail("zeCommandListClose", zeCommandListClose(_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListClose", zeCommandListClose(_handle)); } CommandList::~CommandList() { auto result = zeCommandListDestroy(_handle); @@ -124,8 +124,8 @@ void CommandList::updateMutableCommandList(uint32_t arg_index, const void* arg_v &desc, 0}; - zeroUtils::throwOnFail("zeCommandListUpdateMutableCommandsExp", - zeCommandListUpdateMutableCommandsExp(_handle, &mutable_commands_exp_desc_t)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListUpdateMutableCommandsExp", + zeCommandListUpdateMutableCommandsExp(_handle, &mutable_commands_exp_desc_t)); } CommandQueue::CommandQueue(const ze_device_handle_t& device_handle, @@ -148,22 +148,22 @@ CommandQueue::CommandQueue(const ze_device_handle_t& device_handle, OPENVINO_THROW("Turbo is not supported by the current driver"); } } - zeroUtils::throwOnFail("zeCommandQueueCreate", - zeCommandQueueCreate(_context, device_handle, &queue_desc, &_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandQueueCreate", + zeCommandQueueCreate(_context, device_handle, &queue_desc, &_handle)); } void CommandQueue::executeCommandList(CommandList& command_list) const { - zeroUtils::throwOnFail("zeCommandQueueExecuteCommandLists", - zeCommandQueueExecuteCommandLists(_handle, 1, &command_list._handle, nullptr)); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandQueueExecuteCommandLists", + zeCommandQueueExecuteCommandLists(_handle, 1, &command_list._handle, nullptr)); } void CommandQueue::executeCommandList(CommandList& command_list, Fence& fence) const { - zeroUtils::throwOnFail("zeCommandQueueExecuteCommandLists", - zeCommandQueueExecuteCommandLists(_handle, 1, &command_list._handle, fence.handle())); + THROW_ON_FAIL_FOR_LEVELZERO("zeCommandQueueExecuteCommandLists", + zeCommandQueueExecuteCommandLists(_handle, 1, &command_list._handle, fence.handle())); } void CommandQueue::setWorkloadType(ze_command_queue_workload_type_t workloadType) const { if (_command_queue_npu_dditable_ext.version()) { - zeroUtils::throwOnFail("zeSetWorkloadType", - _command_queue_npu_dditable_ext.pfnSetWorkloadType(_handle, workloadType)); + THROW_ON_FAIL_FOR_LEVELZERO("zeSetWorkloadType", + _command_queue_npu_dditable_ext.pfnSetWorkloadType(_handle, workloadType)); } else { OPENVINO_THROW("The WorkloadType property is not supported by the current Driver Version!"); } @@ -178,13 +178,13 @@ CommandQueue::~CommandQueue() { Fence::Fence(const CommandQueue& command_queue, const Config& config) : _log("Fence", config.get()) { ze_fence_desc_t fence_desc = {ZE_STRUCTURE_TYPE_FENCE_DESC, nullptr, 0}; - zeroUtils::throwOnFail("zeFenceCreate", zeFenceCreate(command_queue.handle(), &fence_desc, &_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeFenceCreate", zeFenceCreate(command_queue.handle(), &fence_desc, &_handle)); } void Fence::reset() const { - zeroUtils::throwOnFail("zeFenceReset", zeFenceReset(_handle)); + THROW_ON_FAIL_FOR_LEVELZERO("zeFenceReset", zeFenceReset(_handle)); } void Fence::hostSynchronize() const { - zeroUtils::throwOnFail("zeFenceHostSynchronize", zeFenceHostSynchronize(_handle, UINT64_MAX)); + THROW_ON_FAIL_FOR_LEVELZERO("zeFenceHostSynchronize", zeFenceHostSynchronize(_handle, UINT64_MAX)); } Fence::~Fence() { auto result = zeFenceDestroy(_handle); diff --git a/src/plugins/intel_npu/src/compiler/include/zero_compiler_in_driver.hpp b/src/plugins/intel_npu/src/compiler/include/zero_compiler_in_driver.hpp index e84ac345591f95..658f138a72c102 100644 --- a/src/plugins/intel_npu/src/compiler/include/zero_compiler_in_driver.hpp +++ b/src/plugins/intel_npu/src/compiler/include/zero_compiler_in_driver.hpp @@ -18,9 +18,6 @@ namespace driverCompilerAdapter { using SerializedIR = std::pair>; -#define NotSupportLogHandle(T) \ - (std::is_same::value || std::is_same::value) - #define NotSupportQuery(T) (std::is_same::value) // ext version == 1.3 && 1.4, support API (pfnQueryNetworkCreate, pfnQueryNetworkDestroy, @@ -186,15 +183,6 @@ class LevelZeroCompilerInDriver final : public ICompiler { const uint32_t& flags, ze_graph_handle_t* graph) const; - template = true> - std::string getLatestBuildError() const; - - template = true> - std::string getLatestBuildError() const { - std::printf(" --getLatestBuildError2--> this part seems not support log.\n"); - return ""; - } - private: ze_driver_handle_t _driverHandle = nullptr; ze_device_handle_t _deviceHandle = nullptr; diff --git a/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp b/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp index 711b67356555c1..0d487cce782129 100644 --- a/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp +++ b/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp @@ -376,27 +376,15 @@ void LevelZeroCompilerInDriver::getNativeBinary(ze_graph_dditabl // Get blob size first auto result = _graphDdiTableExt.pfnGetNativeBinary(graphHandle, &blobSize, nullptr); blob.resize(blobSize); - OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS, - "Failed to compile network. L0 pfnGetNativeBinary get blob size", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result), - ". ", - getLatestBuildError()); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob size, Failed to compile network.", + result, + _graphDdiTableExt); // Get blob data result = _graphDdiTableExt.pfnGetNativeBinary(graphHandle, &blobSize, blob.data()); - OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS, - "Failed to compile network. L0 pfnGetNativeBinary get blob data", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result), - ". ", - getLatestBuildError()); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob data, Failed to compile network.", + result, + _graphDdiTableExt); blobPtr = blob.data(); } @@ -410,15 +398,9 @@ void LevelZeroCompilerInDriver::getNativeBinary(ze_graph_dditabl size_t& blobSize) const { // Get blob ptr and size auto result = _graphDdiTableExt.pfnGetNativeBinary2(graphHandle, &blobSize, &blobPtr); - OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS, - "Failed to compile network. L0 pfnGetNativeBinary get blob size", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result), - ". ", - getLatestBuildError()); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob size, Failed to compile network.", + result, + _graphDdiTableExt); } template @@ -664,6 +646,7 @@ ze_result_t LevelZeroCompilerInDriver::seriazlideIRModelAndQuery // Create querynetwork handle ze_result_t result = _graphDdiTableExt.pfnQueryNetworkCreate(_context, _deviceHandle, &desc, &hGraphQueryNetwork); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("seriazlideIRModelAndQueryNetworkCreateV1", result, _graphDdiTableExt); return result; } @@ -678,14 +661,7 @@ std::unordered_set LevelZeroCompilerInDriver::query ze_device_graph_properties_t deviceGraphProperties{}; auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 pfnDeviceGetGraphProperties", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnDeviceGetGraphProperties", result, _graphDdiTableExt); ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; @@ -726,15 +702,7 @@ ze_result_t LevelZeroCompilerInDriver::seriazlideIRModelAndQuery // Create querynetwork handle _logger.debug("seriazlideIRModelAndQueryNetworkCreateV2 - performing pfnQueryNetworkCreate2"); ze_result_t result = _graphDdiTableExt.pfnQueryNetworkCreate2(_context, _deviceHandle, &desc, &hGraphQueryNetwork); - - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 seriazlideIRModelAndQueryNetworkCreateV2", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + THROW_ON_FAIL_FOR_LEVELZERO_EXT("seriazlideIRModelAndQueryNetworkCreateV2", result, _graphDdiTableExt); return result; } @@ -749,14 +717,7 @@ std::unordered_set LevelZeroCompilerInDriver::query ze_device_graph_properties_t deviceGraphProperties{}; auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 pfnDeviceGetGraphProperties", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnDeviceGetGraphProperties", result, _graphDdiTableExt); ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; @@ -774,26 +735,14 @@ template > std::unordered_set LevelZeroCompilerInDriver::getQueryResultFromSupportedLayers( ze_result_t result, ze_graph_query_network_handle_t& hGraphQueryNetwork) const { - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 getQueryResultFromSupportedLayers", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } - // Get the size of query result size_t size = 0; result = _graphDdiTableExt.pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, nullptr); if (ZE_RESULT_SUCCESS != result) { _graphDdiTableExt.pfnQueryNetworkDestroy(hGraphQueryNetwork); - OPENVINO_THROW("L0 pfnQueryNetworkGetSupportedLayers get size of query result", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkGetSupportedLayers get size of query result", + result, + _graphDdiTableExt); } // Get the result data of query @@ -801,23 +750,13 @@ std::unordered_set LevelZeroCompilerInDriver::getQu result = _graphDdiTableExt.pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, supportedLayers.data()); if (ZE_RESULT_SUCCESS != result) { _graphDdiTableExt.pfnQueryNetworkDestroy(hGraphQueryNetwork); - OPENVINO_THROW("L0 pfnQueryNetworkGetSupportedLayers get result data of query", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkGetSupportedLayers get result data of query", + result, + _graphDdiTableExt); } result = _graphDdiTableExt.pfnQueryNetworkDestroy(hGraphQueryNetwork); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 pfnQueryNetworkDestroy", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkDestroy", result, _graphDdiTableExt); return parseQueryResult(supportedLayers); } @@ -859,8 +798,12 @@ ze_result_t LevelZeroCompilerInDriver::createGraph(const ze_grap serializedIR.second.get(), buildFlags.c_str()}; + _logger.debug("createGraph - performing pfnCreate"); // Create querynetwork handle - return _graphDdiTableExt.pfnCreate(_context, _deviceHandle, &desc, graph); + auto result = _graphDdiTableExt.pfnCreate(_context, _deviceHandle, &desc, graph); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _graphDdiTableExt); + + return result; } // For ext version >= 1.5, calling pfnCreate2 api in _graphDdiTableExt @@ -882,14 +825,7 @@ ze_result_t LevelZeroCompilerInDriver::createGraph(const ze_grap _logger.debug("createGraph - performing pfnCreate2"); // Create querynetwork handle auto result = _graphDdiTableExt.pfnCreate2(_context, _deviceHandle, &desc, graph); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 pfnCreate2", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _graphDdiTableExt); return result; } @@ -923,14 +859,6 @@ ze_result_t LevelZeroCompilerInDriver::seriazlideIRModelAndCreat _logger.info("compileIR Using extension version: %s", typeid(TableExtension).name()); ze_result_t result = createGraph(format, serializedIR, buildFlags, flags, &graphHandle); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("Failed to create graph. L0 createGraph", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } return result; } @@ -938,47 +866,32 @@ template NetworkDescription LevelZeroCompilerInDriver::compile(const std::shared_ptr& model, const Config& config) const { _logger.debug("compile start"); - - std::printf("=================1====================\n"); - getLatestBuildError(); + std::printf("=================1====================\n");//add by manual + getLatestBuildError(_graphDdiTableExt); std::printf("=================2====================\n"); + ze_device_graph_properties_t deviceGraphProperties{}; auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties); - std::printf(" before call 1\n"); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("Failed to compile network. L0 pfnDeviceGetGraphProperties", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + std::printf("=================3====================\n"); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnDeviceGetGraphProperties, Failed to compile network.", + result, + _graphDdiTableExt); + std::printf("=================4====================\n"); // Graph handle should be used only in scope of compile / parse functions. ze_graph_handle_t graphHandle; result = seriazlideIRModelAndCreateGraph(model, config, deviceGraphProperties, graphHandle); - std::printf(" --------call getLatestBuildError strat--------\n"); - OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS, - "Failed to compile network. L0 createGraph", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result), - ". ", - getLatestBuildError()); - std::printf(" --------call getLatestBuildError end--------\n"); auto networkMeta = getNetworkMeta(graphHandle); networkMeta.name = model->get_friendly_name(); _logger.debug("compile end"); auto networkDescription = NetworkDescription(std::move(networkMeta)); - std::printf("=================3====================\n"); - getLatestBuildError(); - std::printf("=================4====================\n"); + std::printf("=================5====================\n");//add by manual + getLatestBuildError(_graphDdiTableExt); + std::printf("=================6====================\n"); return networkDescription; } @@ -1001,14 +914,8 @@ NetworkMetadata LevelZeroCompilerInDriver::parse(const std::vect auto result = _graphDdiTableExt.pfnCreate(_context, _deviceHandle, &desc, &graphHandle); OV_ITT_TASK_NEXT(PARSE_BLOB, "_graphDdiTableExt"); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 pfnCreate", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _graphDdiTableExt); + } else { OPENVINO_THROW("Empty blob"); } @@ -1028,15 +935,8 @@ uint32_t LevelZeroCompilerInDriver::getSupportedOpsetVersion() c ze_device_graph_properties_t graphProperties; auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &graphProperties); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnDeviceGetGraphProperties", result, _graphDdiTableExt); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 pfnDeviceGetGraphProperties", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } const auto maxOpsetVersion = graphProperties.maxOVOpsetVersionSupported; _logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion); _logger.debug("getSupportedOpset end"); @@ -1107,14 +1007,7 @@ void LevelZeroCompilerInDriver::getMetadata(ze_graph_dditable_ex std::vector& outputs) const { ze_graph_argument_properties_3_t arg; auto result = graphDdiTableExt.pfnGetArgumentProperties3(graphHandle, index, &arg); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 pfnGetArgumentProperties3", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetArgumentProperties3", result, _graphDdiTableExt); switch (arg.type) { case ZE_GRAPH_ARGUMENT_TYPE_INPUT: { @@ -1138,28 +1031,14 @@ void LevelZeroCompilerInDriver::getMetadata(ze_graph_dditable_ex std::vector& outputs) const { ze_graph_argument_properties_3_t arg; auto result = graphDdiTableExt.pfnGetArgumentProperties3(graphHandle, index, &arg); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 pfnGetArgumentProperties3", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetArgumentProperties3", result, _graphDdiTableExt); std::optional optionalMetadata = std::nullopt; if (!isStateInputName(arg.name) && !isStateOutputName(arg.name) && !isShapeTensorName(arg.name)) { ze_graph_argument_metadata_t metadata; result = graphDdiTableExt.pfnGraphGetArgumentMetadata(graphHandle, index, &metadata); - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 pfnGraphGetArgumentMetadata", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGraphGetArgumentMetadata", result, _graphDdiTableExt); optionalMetadata = std::optional(metadata); } @@ -1182,15 +1061,7 @@ NetworkMetadata LevelZeroCompilerInDriver::getNetworkMeta(ze_gra ze_graph_properties_t graphProperties{}; auto result = _graphDdiTableExt.pfnGetProperties(graphHandle, &graphProperties); - - if (ZE_RESULT_SUCCESS != result) { - OPENVINO_THROW("L0 pfnGetProperties", - " result: ", - ze_result_to_string(result), - ", code 0x", - std::hex, - uint64_t(result)); - } + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetProperties", result, _graphDdiTableExt); NetworkMetadata meta; @@ -1206,63 +1077,6 @@ NetworkMetadata LevelZeroCompilerInDriver::getNetworkMeta(ze_gra return meta; } -template -template > -std::string LevelZeroCompilerInDriver::getLatestBuildError() const { - std::printf(" ----> getLatestBuildError start\n"); - _logger.debug("getLatestBuildError start"); - - // Get log size - uint32_t size = 0; - // Null graph handle to get erro log - auto result = _graphDdiTableExt.pfnBuildLogGetString(nullptr, &size, nullptr); - std::printf(" --1--> getLatestBuildError log=%s\n", logContent.c_str()); - std::printf(" --1--> getLatestBuildError size=%d\n", size); - if ( logContent.find( "::stored" ) != std::string::npos ) { - std::printf(" --1-->stored\n"); - } - if ( logContent.find( "::found" ) != std::string::npos ) { - std::printf(" --1s-->found\n"); - } - - if (ZE_RESULT_SUCCESS != result) { - // The failure will not break normal execution, only warning here - _logger.warning("getLatestBuildError Failed to get size of latest error log!"); - return ""; - } - - if (size <= 0) { - // The failure will not break normal execution, only warning here - _logger.warning("getLatestBuildError No error log stored in driver when error " - "detected, may not be compiler issue!"); - return ""; - } - - // Get log contents - std::string logContent{}; - logContent.resize(size); - result = _graphDdiTableExt.pfnBuildLogGetString(nullptr, &size, const_cast(logContent.data())); - - std::printf(" --2--> getLatestBuildError log=%s\n", logContent.c_str()); - std::printf(" --2--> getLatestBuildError size=%d\n", size); - if ( logContent.find( "::stored" ) != std::string::npos ) { - std::printf(" --2-->stored\n"); - } - if ( logContent.find( "::found" ) != std::string::npos ) { - std::printf(" --2-->found\n"); - } - - if (ZE_RESULT_SUCCESS != result) { - // The failure will not break normal execution, only warning here - _logger.warning("getLatestBuildError size of latest error log > 0, failed to get " - "content of latest error log!"); - return ""; - } - _logger.debug("getLatestBuildError end"); - std::printf(" ----> getLatestBuildError end\n"); - return logContent; -} - template class LevelZeroCompilerInDriver; template class LevelZeroCompilerInDriver; template class LevelZeroCompilerInDriver;