Skip to content

Commit

Permalink
Move driver version to backend and create getDriverExtVersion method (#…
Browse files Browse the repository at this point in the history
…23835)

### Details:
- *Moving getDriverVersion to the backend makes more sense, and creating
a new helper, getDriverExtVersion that would be used for plugin batching
feature to decide when to use batching on auto mode or only on compile.*
- *Because of E-117498 we need to decide when Compiler or Auto mode for
batching to be used.*
- *DriverExtVersion should be also updated by the driver team for this
to work as expected.*

### Tickets:
 - *E-117498*
  • Loading branch information
pereanub authored Apr 5, 2024
1 parent 9660502 commit 48d2536
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 37 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
2 changes: 2 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,6 +21,8 @@ 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;
Expand Down
2 changes: 0 additions & 2 deletions 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 All @@ -44,7 +43,6 @@ class ZeroDevice : public IDevice {
ze_graph_dditable_ext_curr_t* _graph_ddi_table_ext = nullptr;

ze_device_properties_t device_properties = {};
ze_driver_properties_t driver_properties = {};

uint32_t _group_ordinal;

Expand Down
9 changes: 9 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,12 @@ class ZeroInitStructsHolder final {
inline ze_graph_profiling_dditable_ext_t* getProfilingDdiTable() const {
return _graph_profiling_ddi_table_ext;
}
inline uint32_t getDriverVersion() const {
return driver_properties.driverVersion;
}
inline uint32_t getDriverExtVersion() const {
return driver_ext_version;
}

private:
static const ze_driver_uuid_t uuid;
Expand All @@ -52,6 +58,9 @@ 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;

ze_driver_properties_t driver_properties = {};
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 _instance->getDriverVersion();
}

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

ZeroEngineBackend::~ZeroEngineBackend() = default;

const std::shared_ptr<IDevice> ZeroEngineBackend::getDevice() const {
Expand Down
7 changes: 0 additions & 7 deletions src/plugins/intel_npu/src/backend/src/zero_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ ZeroDevice::ZeroDevice(const std::shared_ptr<ZeroInitStructsHolder>& initStructs
device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
zeroUtils::throwOnFail("zeDeviceGetProperties",
zeDeviceGetProperties(_initStructs->getDevice(), &device_properties));
driver_properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES;
zeroUtils::throwOnFail("zeDriverGetProperties",
zeDriverGetProperties(_initStructs->getDriver(), &driver_properties));

std::vector<ze_command_queue_group_properties_t> command_group_properties;
uint32_t command_queue_group_count = 0;
Expand Down Expand Up @@ -89,10 +86,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
22 changes: 10 additions & 12 deletions src/plugins/intel_npu/src/backend/src/zero_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",
zeroUtils::throwOnFail("zeDriverGet", zeDriverGet(&drivers, all_drivers.data()));

// Get our target driver
ze_driver_properties_t props = {};
props.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES;
driver_properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES;
for (uint32_t i = 0; i < drivers; ++i) {
zeDriverGetProperties(all_drivers[i], &props);
zeDriverGetProperties(all_drivers[i], &driver_properties);

if (memcmp(&props.uuid, &uuid, sizeof(uuid)) == 0) {
if (memcmp(&driver_properties.uuid, &uuid, sizeof(uuid)) == 0) {
driver_handle = all_drivers[i];
break;
}
Expand Down Expand Up @@ -105,25 +104,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();
}

OPENVINO_THROW("No available backend");
}

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

OPENVINO_THROW("No available backend");
}

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 48d2536

Please sign in to comment.