Skip to content

Commit

Permalink
Move driver version to backend and crete getDriverExtVersion method
Browse files Browse the repository at this point in the history
  • Loading branch information
pereanub committed Apr 5, 2024
1 parent 073d242 commit 0c78a8e
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 29 deletions.
5 changes: 4 additions & 1 deletion src/plugins/intel_npu/src/al/include/npu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class IEngineBackend : public std::enable_shared_from_this<IEngineBackend> {
virtual const std::shared_ptr<IDevice> getDevice(const ov::AnyMap& paramMap) const;
/** @brief Provide a list of names of all devices, with which user can work directly */
virtual const std::vector<std::string> getDeviceNames() const;
/** @brief Provide driver version */
virtual uint32_t getDriverVersion() const;
/** @brief Provide driver extension version */
virtual uint32_t getDriverExtVersion() const;
/** @brief Get name of backend */
virtual const std::string getName() const = 0;
/** @brief Register backend-specific options */
Expand Down Expand Up @@ -60,7 +64,6 @@ class IDevice : public std::enable_shared_from_this<IDevice> {
virtual uint32_t getMaxNumSlices() const;
virtual uint64_t getAllocMemSize() const;
virtual uint64_t getTotalMemSize() const;
virtual uint32_t getDriverVersion() const;

virtual std::shared_ptr<SyncInferRequest> createInferRequest(
const std::shared_ptr<const ICompiledModel>& compiledModel,
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/intel_npu/src/al/src/npu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const std::shared_ptr<IDevice> IEngineBackend::getDevice(const ov::AnyMap&) cons
const std::vector<std::string> IEngineBackend::getDeviceNames() const {
OPENVINO_THROW("Get all device names not implemented");
}
uint32_t IEngineBackend::getDriverVersion() const {
OPENVINO_THROW("Get NPU driver version is not supported with this backend");
}
uint32_t IEngineBackend::getDriverExtVersion() const {
OPENVINO_THROW("Get NPU driver extension version is not supported with this backend");
}

void IEngineBackend::registerOptions(OptionsDesc&) const {}

Expand All @@ -44,8 +50,4 @@ uint64_t IDevice::getTotalMemSize() const {
OPENVINO_THROW("Get TotalMemSize is not supported");
}

uint32_t IDevice::getDriverVersion() const {
OPENVINO_THROW("Get NPU driver version is not supported with this backend");
}

} // namespace intel_npu
4 changes: 4 additions & 0 deletions src/plugins/intel_npu/src/backend/include/zero_backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ class ZeroEngineBackend final : public IEngineBackend {
return "LEVEL0";
}
const std::vector<std::string> getDeviceNames() const override;
uint32_t getDriverVersion() const override;
uint32_t getDriverExtVersion() const override;

private:
std::shared_ptr<ZeroInitStructsHolder> _instance;

std::map<std::string, std::shared_ptr<IDevice>> _devices{};

ze_driver_properties_t _driver_properties = {};
};

} // namespace intel_npu
1 change: 0 additions & 1 deletion src/plugins/intel_npu/src/backend/include/zero_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class ZeroDevice : public IDevice {
uint32_t getMaxNumSlices() const override;
uint64_t getAllocMemSize() const override;
uint64_t getTotalMemSize() const override;
uint32_t getDriverVersion() const override;

std::shared_ptr<SyncInferRequest> createInferRequest(const std::shared_ptr<const ICompiledModel>& compiledModel,
const std::shared_ptr<IExecutor>& executor,
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/intel_npu/src/backend/include/zero_init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class ZeroInitStructsHolder final {
inline ze_graph_profiling_dditable_ext_t* getProfilingDdiTable() const {
return _graph_profiling_ddi_table_ext;
}
inline uint32_t getDriverExtVersion() const {
return driver_ext_version;
}

private:
static const ze_driver_uuid_t uuid;
Expand All @@ -52,6 +55,8 @@ class ZeroInitStructsHolder final {
ze_context_handle_t context = nullptr;
std::unique_ptr<ze_graph_dditable_ext_decorator> graph_dditable_ext_decorator;
ze_graph_profiling_dditable_ext_t* _graph_profiling_ddi_table_ext = nullptr;

uint32_t driver_ext_version = 0;
};

} // namespace intel_npu
8 changes: 8 additions & 0 deletions src/plugins/intel_npu/src/backend/src/zero_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ ZeroEngineBackend::ZeroEngineBackend(const Config& config) {
_devices.emplace(std::make_pair(device->getName(), device));
}

uint32_t ZeroEngineBackend::getDriverVersion() const {
return _driver_properties.driverVersion;
}

uint32_t ZeroEngineBackend::getDriverExtVersion() const {
return _instance->getDriverExtVersion();
}

ZeroEngineBackend::~ZeroEngineBackend() = default;

const std::shared_ptr<IDevice> ZeroEngineBackend::getDevice() const {
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/intel_npu/src/backend/src/zero_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ IDevice::Uuid ZeroDevice::getUuid() const {
return uuid;
}

uint32_t ZeroDevice::getDriverVersion() const {
return driver_properties.driverVersion;
}

uint32_t ZeroDevice::getSubDevId() const {
return device_properties.subdeviceId;
}
Expand Down
15 changes: 7 additions & 8 deletions src/plugins/intel_npu/src/backend/src/zero_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,24 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",
}

// Query our graph extension version
uint32_t driverExtVersion = 0;
std::string graphExtName;
std::tie(driverExtVersion, graphExtName) = queryDriverExtensionVersion(driver_handle);
std::string graph_ext_name;
std::tie(driver_ext_version, graph_ext_name) = queryDriverExtensionVersion(driver_handle);

log.debug("Found Driver Version %d.%d, Driver Extension Version %d.%d (%s)",
ZE_MAJOR_VERSION(ze_drv_api_version),
ZE_MINOR_VERSION(ze_drv_api_version),
ZE_MAJOR_VERSION(driverExtVersion),
ZE_MINOR_VERSION(driverExtVersion),
graphExtName.c_str());
ZE_MAJOR_VERSION(driver_ext_version),
ZE_MINOR_VERSION(driver_ext_version),
graph_ext_name.c_str());

// Load our graph extension
ze_graph_dditable_ext_last_t* graph_ddi_table_ext = nullptr;
zeroUtils::throwOnFail("zeDriverGetExtensionFunctionAddress",
zeDriverGetExtensionFunctionAddress(driver_handle,
graphExtName.c_str(),
graph_ext_name.c_str(),
reinterpret_cast<void**>(&graph_ddi_table_ext)));
graph_dditable_ext_decorator =
std::make_unique<ze_graph_dditable_ext_decorator>(graph_ddi_table_ext, driverExtVersion);
std::make_unique<ze_graph_dditable_ext_decorator>(graph_ddi_table_ext, driver_ext_version);

// Load our profiling extension
zeroUtils::throwOnFail(
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/intel_npu/src/plugin/include/backends.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class NPUBackends final {
std::shared_ptr<IDevice> getDevice(const ov::AnyMap& paramMap) const;
std::vector<std::string> getAvailableDevicesNames() const;
std::string getBackendName() const;
uint32_t getDriverVersion() const;
uint32_t getDriverExtVersion() const;
void registerOptions(OptionsDesc& options) const;
std::string getCompilationPlatform(const std::string_view platform, const std::string& deviceId) const;

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/intel_npu/src/plugin/include/metrics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class Metrics final {
std::string GetBackendName() const;
uint64_t GetDeviceAllocMemSize(const std::string& specifiedDeviceName) const;
uint64_t GetDeviceTotalMemSize(const std::string& specifiedDeviceName) const;
uint32_t GetDriverVersion(const std::string& specifiedDeviceName) const;
uint32_t GetDriverVersion() const;
uint32_t GetDriverExtVersion() const;

std::vector<ov::PropertyName> GetCachingProperties() const;
std::vector<ov::PropertyName> GetInternalSupportedProperties() const;
Expand Down
16 changes: 16 additions & 0 deletions src/plugins/intel_npu/src/plugin/src/backends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,22 @@ std::string NPUBackends::getBackendName() const {
return "";
}

uint32_t NPUBackends::getDriverVersion() const {
if (_backend != nullptr) {
return _backend->getDriverVersion();
}

return 0;
}

uint32_t NPUBackends::getDriverExtVersion() const {
if (_backend != nullptr) {
return _backend->getDriverExtVersion();
}

return 0;
}

std::shared_ptr<IDevice> NPUBackends::getDevice(const std::string& specificName) const {
_logger.debug("Searching for device %s to use started...", specificName.c_str());
// TODO iterate over all available backends
Expand Down
25 changes: 16 additions & 9 deletions src/plugins/intel_npu/src/plugin/src/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ std::string Metrics::GetBackendName() const {
return _backends->getBackendName();
}

uint32_t Metrics::GetDriverVersion() const {
if (_backends == nullptr) {
OPENVINO_THROW("No available backends");
}

return _backends->getDriverVersion();
}

uint32_t Metrics::GetDriverExtVersion() const {
if (_backends == nullptr) {
OPENVINO_THROW("No available backends");
}

return _backends->getDriverExtVersion();
}

uint64_t Metrics::GetDeviceAllocMemSize(const std::string& specifiedDeviceName) const {
const auto devName = getDeviceName(specifiedDeviceName);
auto device = _backends->getDevice(devName);
Expand All @@ -121,15 +137,6 @@ uint64_t Metrics::GetDeviceTotalMemSize(const std::string& specifiedDeviceName)
OPENVINO_THROW("No device with name '", specifiedDeviceName, "' is available");
}

uint32_t Metrics::GetDriverVersion(const std::string& specifiedDeviceName) const {
const auto devName = getDeviceName(specifiedDeviceName);
auto device = _backends->getDevice(devName);
if (device) {
return device->getDriverVersion();
}
OPENVINO_THROW("No device with name '", specifiedDeviceName, "' is available");
}

std::string Metrics::getDeviceName(const std::string& specifiedDeviceName) const {
std::vector<std::string> devNames;
if (_backends == nullptr || (devNames = _backends->getAvailableDevicesNames()).empty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/plugin/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ Plugin::Plugin()
{true,
ov::PropertyMutability::RO,
[&](const Config& config) {
return _metrics->GetDriverVersion(get_specified_device_name(config));
return _metrics->GetDriverVersion();
}}},
// NPU Private
// =========
Expand Down

0 comments on commit 0c78a8e

Please sign in to comment.