diff --git a/level_zero/core/source/cache/linux/cache_reservation_impl_prelim.cpp b/level_zero/core/source/cache/linux/cache_reservation_impl_prelim.cpp index 0e01df16df..68ec42be2f 100644 --- a/level_zero/core/source/cache/linux/cache_reservation_impl_prelim.cpp +++ b/level_zero/core/source/cache/linux/cache_reservation_impl_prelim.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2024 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -22,7 +22,7 @@ std::unique_ptr CacheReservation::create(Device &device) { } bool CacheReservationImpl::reserveCache(size_t cacheLevel, size_t cacheReservationSize) { - auto drm = device.getOsInterface().getDriverModel()->as(); + auto drm = device.getOsInterface()->getDriverModel()->as(); auto cacheInfo = drm->getL3CacheInfo(); @@ -58,7 +58,7 @@ bool CacheReservationImpl::setCacheAdvice(void *ptr, [[maybe_unused]] size_t reg return false; } - auto drm = device.getOsInterface().getDriverModel()->as(); + auto drm = device.getOsInterface()->getDriverModel()->as(); auto gpuAllocation = allocData->gpuAllocations.getGraphicsAllocation(device.getRootDeviceIndex()); auto drmAllocation = static_cast(gpuAllocation); @@ -67,7 +67,7 @@ bool CacheReservationImpl::setCacheAdvice(void *ptr, [[maybe_unused]] size_t reg } size_t CacheReservationImpl::getMaxCacheReservationSize() { - auto drm = device.getOsInterface().getDriverModel()->as(); + auto drm = device.getOsInterface()->getDriverModel()->as(); auto cacheInfo = drm->getL3CacheInfo(); return cacheInfo->getMaxReservationCacheSize(); diff --git a/level_zero/core/source/device/device.h b/level_zero/core/source/device/device.h index 39f54f9d2f..df13064060 100644 --- a/level_zero/core/source/device/device.h +++ b/level_zero/core/source/device/device.h @@ -111,7 +111,7 @@ struct Device : _ze_device_handle_t { return implicitScalingCapable; } virtual const NEO::HardwareInfo &getHwInfo() const = 0; - virtual NEO::OSInterface &getOsInterface() = 0; + virtual NEO::OSInterface *getOsInterface() = 0; virtual uint32_t getPlatformInfo() const = 0; virtual MetricDeviceContext &getMetricDeviceContext() = 0; virtual DebugSession *getDebugSession(const zet_debug_config_t &config) = 0; diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index a3fa123766..dd3bccc9be 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -1345,7 +1345,7 @@ ze_result_t DeviceImp::getDeviceImageProperties(ze_device_image_properties_t *pD } ze_result_t DeviceImp::getDebugProperties(zet_device_debug_properties_t *pDebugProperties) { - bool isDebugAttachAvailable = getOsInterface().isDebugAttachAvailable(); + bool isDebugAttachAvailable = getOsInterface() ? getOsInterface()->isDebugAttachAvailable() : false; auto &stateSaveAreaHeader = NEO::SipKernel::getDebugSipKernel(*this->getNEODevice()).getStateSaveAreaHeader(); if (stateSaveAreaHeader.size() == 0) { @@ -1415,7 +1415,7 @@ const NEO::CompilerProductHelper &DeviceImp::getCompilerProductHelper() { return this->neoDevice->getCompilerProductHelper(); } -NEO::OSInterface &DeviceImp::getOsInterface() { return *neoDevice->getRootDeviceEnvironment().osInterface; } +NEO::OSInterface *DeviceImp::getOsInterface() { return neoDevice->getRootDeviceEnvironment().osInterface.get(); } uint32_t DeviceImp::getPlatformInfo() const { const auto &hardwareInfo = neoDevice->getHardwareInfo(); diff --git a/level_zero/core/source/device/device_imp.h b/level_zero/core/source/device/device_imp.h index 0674d086f5..8f7f41bd9c 100644 --- a/level_zero/core/source/device/device_imp.h +++ b/level_zero/core/source/device/device_imp.h @@ -83,7 +83,7 @@ struct DeviceImp : public Device, NEO::NonCopyableOrMovableClass { const NEO::ProductHelper &getProductHelper() override; const NEO::CompilerProductHelper &getCompilerProductHelper() override; const NEO::HardwareInfo &getHwInfo() const override; - NEO::OSInterface &getOsInterface() override; + NEO::OSInterface *getOsInterface() override; uint32_t getPlatformInfo() const override; MetricDeviceContext &getMetricDeviceContext() override; DebugSession *getDebugSession(const zet_debug_config_t &config) override; diff --git a/level_zero/core/source/semaphore/external_semaphore_imp.cpp b/level_zero/core/source/semaphore/external_semaphore_imp.cpp index c72ed1c782..e69d9b0328 100644 --- a/level_zero/core/source/semaphore/external_semaphore_imp.cpp +++ b/level_zero/core/source/semaphore/external_semaphore_imp.cpp @@ -100,7 +100,7 @@ ze_result_t ExternalSemaphoreImp::initialize(ze_device_handle_t device, const ze return ZE_RESULT_ERROR_INVALID_ARGUMENT; } - this->neoExternalSemaphore = NEO::ExternalSemaphore::create(&deviceImp->getOsInterface(), externalSemaphoreType, handle, fd); + this->neoExternalSemaphore = NEO::ExternalSemaphore::create(deviceImp->getOsInterface(), externalSemaphoreType, handle, fd); if (!this->neoExternalSemaphore) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/level_zero/core/test/unit_tests/mocks/mock_device.h b/level_zero/core/test/unit_tests/mocks/mock_device.h index aa8fa147a3..46b3166cfa 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_device.h +++ b/level_zero/core/test/unit_tests/mocks/mock_device.h @@ -60,7 +60,7 @@ struct MockDevice : public Device { ADDMETHOD_NOBASE(getBuiltinFunctionsLib, BuiltinFunctionsLib *, nullptr, ()); ADDMETHOD_CONST_NOBASE(getMaxNumHwThreads, uint32_t, 16u, ()); ADDMETHOD_NOBASE(activateMetricGroupsDeferred, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t count, zet_metric_group_handle_t *phMetricGroups)); - ADDMETHOD_NOBASE_REFRETURN(getOsInterface, NEO::OSInterface &, ()); + ADDMETHOD_NOBASE_REFRETURN(getOsInterface, NEO::OSInterface *, ()); ADDMETHOD_CONST_NOBASE(getPlatformInfo, uint32_t, 0u, ()); ADDMETHOD_NOBASE_REFRETURN(getMetricDeviceContext, MetricDeviceContext &, ()); ADDMETHOD_CONST_NOBASE_REFRETURN(getHwInfo, const NEO::HardwareInfo &, ()); diff --git a/level_zero/tools/source/debug/debug_session_imp.cpp b/level_zero/tools/source/debug/debug_session_imp.cpp index f0f8748f3a..39b02cf8ff 100644 --- a/level_zero/tools/source/debug/debug_session_imp.cpp +++ b/level_zero/tools/source/debug/debug_session_imp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2024 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -27,7 +27,7 @@ DebugSession::DebugSession(const zet_debug_config_t &config, Device *device) : c } const NEO::TopologyMap &DebugSession::getTopologyMap() { - return connectedDevice->getOsInterface().getDriverModel()->getTopologyMap(); + return connectedDevice->getOsInterface()->getDriverModel()->getTopologyMap(); }; void DebugSession::createEuThreads() { diff --git a/level_zero/tools/source/debug/linux/debug_session.cpp b/level_zero/tools/source/debug/linux/debug_session.cpp index b07d6b2e24..8e96251434 100644 --- a/level_zero/tools/source/debug/linux/debug_session.cpp +++ b/level_zero/tools/source/debug/linux/debug_session.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2024 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -30,11 +30,11 @@ DebugSessionLinuxAllocatorFn debugSessionLinuxFactory[DEBUG_SESSION_LINUX_TYPE_M DebugSession *DebugSession::create(const zet_debug_config_t &config, Device *device, ze_result_t &result, bool isRootAttach) { - if (!device->getOsInterface().isDebugAttachAvailable()) { + if (!device->getOsInterface()->isDebugAttachAvailable()) { result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; return nullptr; } - auto drm = device->getOsInterface().getDriverModel()->as(); + auto drm = device->getOsInterface()->getDriverModel()->as(); auto drmVersion = NEO::Drm::getDrmVersion(drm->getFileDescriptor()); DebugSessionLinuxAllocatorFn allocator = nullptr; diff --git a/level_zero/tools/source/debug/linux/drm_helper.cpp b/level_zero/tools/source/debug/linux/drm_helper.cpp index da41177c7e..952c71f131 100644 --- a/level_zero/tools/source/debug/linux/drm_helper.cpp +++ b/level_zero/tools/source/debug/linux/drm_helper.cpp @@ -16,33 +16,33 @@ namespace L0 { int DrmHelper::ioctl(Device *device, NEO::DrmIoctl request, void *arg) { - auto drm = device->getOsInterface().getDriverModel()->as(); + auto drm = device->getOsInterface()->getDriverModel()->as(); return drm->getIoctlHelper()->ioctl(request, arg); } int DrmHelper::getTileIdFromGtId(Device *device, int gtId) { - auto drm = device->getOsInterface().getDriverModel()->as(); + auto drm = device->getOsInterface()->getDriverModel()->as(); return drm->getIoctlHelper()->getTileIdFromGtId(gtId); } std::string DrmHelper::getSysFsPciPath(Device *device) { - auto drm = device->getOsInterface().getDriverModel()->as(); + auto drm = device->getOsInterface()->getDriverModel()->as(); return drm->getSysFsPciPath(); } int DrmHelper::getErrno(Device *device) { - auto drm = device->getOsInterface().getDriverModel()->as(); + auto drm = device->getOsInterface()->getDriverModel()->as(); return drm->getErrno(); } uint32_t DrmHelper::getEngineTileIndex(Device *device, const NEO::EngineClassInstance &engine) { - auto drm = device->getOsInterface().getDriverModel()->as(); + auto drm = device->getOsInterface()->getDriverModel()->as(); auto engineInfo = drm->getEngineInfo(); return engineInfo->getEngineTileIndex(engine); } const NEO::EngineClassInstance *DrmHelper::getEngineInstance(Device *device, uint32_t tile, aub_stream::EngineType engineType) { - auto drm = device->getOsInterface().getDriverModel()->as(); + auto drm = device->getOsInterface()->getDriverModel()->as(); auto engineInfo = drm->getEngineInfo(); return engineInfo->getEngineInstance(tile, engineType); } diff --git a/level_zero/tools/source/debug/windows/debug_session.cpp b/level_zero/tools/source/debug/windows/debug_session.cpp index b0b20a4154..03f2e4acab 100644 --- a/level_zero/tools/source/debug/windows/debug_session.cpp +++ b/level_zero/tools/source/debug/windows/debug_session.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2024 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -28,7 +28,7 @@ DebugSessionWindows::~DebugSessionWindows() { } DebugSession *DebugSession::create(const zet_debug_config_t &config, Device *device, ze_result_t &result, bool isRootAttach) { - if (!device->getOsInterface().isDebugAttachAvailable() || !isRootAttach) { + if (!device->getOsInterface()->isDebugAttachAvailable() || !isRootAttach) { result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; return nullptr; } @@ -55,7 +55,7 @@ DebugSession *DebugSession::create(const zet_debug_config_t &config, Device *dev } ze_result_t DebugSessionWindows::initialize() { - wddm = connectedDevice->getOsInterface().getDriverModel()->as(); + wddm = connectedDevice->getOsInterface()->getDriverModel()->as(); UNRECOVERABLE_IF(wddm == nullptr); KM_ESCAPE_INFO escapeInfo = {}; diff --git a/level_zero/tools/source/metrics/linux/os_metric_ip_sampling_imp_linux.cpp b/level_zero/tools/source/metrics/linux/os_metric_ip_sampling_imp_linux.cpp index 575886df12..79f97c596f 100644 --- a/level_zero/tools/source/metrics/linux/os_metric_ip_sampling_imp_linux.cpp +++ b/level_zero/tools/source/metrics/linux/os_metric_ip_sampling_imp_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -68,7 +68,7 @@ ze_result_t MetricIpSamplingLinuxImp::getNearestSupportedSamplingUnit(uint32_t & ze_result_t MetricIpSamplingLinuxImp::startMeasurement(uint32_t ¬ifyEveryNReports, uint32_t &samplingPeriodNs) { - const auto drm = device.getOsInterface().getDriverModel()->as(); + const auto drm = device.getOsInterface()->getDriverModel()->as(); uint32_t samplingUnit = 0; if (getNearestSupportedSamplingUnit(samplingPeriodNs, samplingUnit) != ZE_RESULT_SUCCESS) { @@ -104,7 +104,7 @@ ze_result_t MetricIpSamplingLinuxImp::startMeasurement(uint32_t ¬ifyEveryNRep } ze_result_t MetricIpSamplingLinuxImp::stopMeasurement() { - const auto drm = device.getOsInterface().getDriverModel()->as(); + const auto drm = device.getOsInterface()->getDriverModel()->as(); auto ioctlHelper = drm->getIoctlHelper(); bool result = ioctlHelper->perfDisableEuStallStream(&stream); @@ -174,7 +174,7 @@ bool MetricIpSamplingLinuxImp::isDependencyAvailable() { return false; } - const auto drm = device.getOsInterface().getDriverModel()->as(); + const auto drm = device.getOsInterface()->getDriverModel()->as(); auto ioctlHelper = drm->getIoctlHelper(); return ioctlHelper->isEuStallSupported(); } @@ -182,7 +182,7 @@ bool MetricIpSamplingLinuxImp::isDependencyAvailable() { ze_result_t MetricIpSamplingLinuxImp::getMetricsTimerResolution(uint64_t &timerResolution) { ze_result_t result = ZE_RESULT_SUCCESS; - const auto drm = device.getOsInterface().getDriverModel()->as(); + const auto drm = device.getOsInterface()->getDriverModel()->as(); int32_t gpuTimeStampfrequency = 0; int32_t ret = drm->getTimestampFrequency(gpuTimeStampfrequency); if (ret < 0 || gpuTimeStampfrequency == 0) { diff --git a/level_zero/tools/source/metrics/linux/os_metric_oa_enumeration_imp_linux.cpp b/level_zero/tools/source/metrics/linux/os_metric_oa_enumeration_imp_linux.cpp index 1ac63fee1e..0985ea4aea 100644 --- a/level_zero/tools/source/metrics/linux/os_metric_oa_enumeration_imp_linux.cpp +++ b/level_zero/tools/source/metrics/linux/os_metric_oa_enumeration_imp_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -29,7 +29,7 @@ void MetricEnumeration::getMetricsDiscoveryFilename(std::vector &n } bool getDrmAdapterId(uint32_t &adapterMajor, uint32_t &adapterMinor, Device &device) { - auto &osInterface = device.getOsInterface(); + auto &osInterface = *device.getOsInterface(); auto drm = osInterface.getDriverModel()->as(); auto drmFile = drm->getFileDescriptor(); struct stat drmStat = {}; @@ -90,7 +90,7 @@ MetricOALinuxImp::MetricOALinuxImp(Device &device) : device(device) {} ze_result_t MetricOALinuxImp::getMetricsTimerResolution(uint64_t &timerResolution) { ze_result_t result = ZE_RESULT_SUCCESS; - const auto drm = device.getOsInterface().getDriverModel()->as(); + const auto drm = device.getOsInterface()->getDriverModel()->as(); int32_t timestampFrequency; int32_t ret = drm->getOaTimestampFrequency(timestampFrequency); if (ret < 0 || timestampFrequency == 0) { diff --git a/level_zero/tools/source/metrics/linux/os_metric_oa_query_imp_linux.cpp b/level_zero/tools/source/metrics/linux/os_metric_oa_query_imp_linux.cpp index 0c9822ca01..03bb298d9c 100644 --- a/level_zero/tools/source/metrics/linux/os_metric_oa_query_imp_linux.cpp +++ b/level_zero/tools/source/metrics/linux/os_metric_oa_query_imp_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -20,7 +20,7 @@ const char *MetricsLibrary::getFilename() { return "libigdml.so.1"; } bool MetricsLibrary::getContextData(Device &device, ContextCreateData_1_0 &contextData) { - auto &osInterface = device.getOsInterface(); + auto &osInterface = *device.getOsInterface(); auto drm = osInterface.getDriverModel()->as(); auto drmFileDescriptor = drm->getFileDescriptor(); auto &osData = contextData.ClientData->Linux; diff --git a/level_zero/tools/source/metrics/wddm/os_metric_oa_enumeration_imp_wddm.cpp b/level_zero/tools/source/metrics/wddm/os_metric_oa_enumeration_imp_wddm.cpp index 6e0a76e7f2..a58d4a42c3 100644 --- a/level_zero/tools/source/metrics/wddm/os_metric_oa_enumeration_imp_wddm.cpp +++ b/level_zero/tools/source/metrics/wddm/os_metric_oa_enumeration_imp_wddm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,7 +15,7 @@ namespace L0 { bool getWddmAdapterId(uint32_t &major, uint32_t &minor, Device &device) { - auto wddm = device.getOsInterface().getDriverModel()->as(); + auto wddm = device.getOsInterface()->getDriverModel()->as(); auto luid = wddm->getAdapterLuid(); major = luid.HighPart; diff --git a/level_zero/tools/source/metrics/windows/os_metric_ip_sampling_imp_windows.cpp b/level_zero/tools/source/metrics/windows/os_metric_ip_sampling_imp_windows.cpp index 86855f14a1..ca0c4be727 100644 --- a/level_zero/tools/source/metrics/windows/os_metric_ip_sampling_imp_windows.cpp +++ b/level_zero/tools/source/metrics/windows/os_metric_ip_sampling_imp_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -42,7 +42,7 @@ std::unique_ptr MetricIpSamplingOsInterface::create MetricIpSamplingWindowsImp::MetricIpSamplingWindowsImp(Device &device) : device(device) {} ze_result_t MetricIpSamplingWindowsImp::startMeasurement(uint32_t ¬ifyEveryNReports, uint32_t &samplingPeriodNs) { - const auto wddm = device.getOsInterface().getDriverModel()->as(); + const auto wddm = device.getOsInterface()->getDriverModel()->as(); uint32_t samplingUnit = 0u; if (getNearestSupportedSamplingUnit(samplingPeriodNs, samplingUnit) != ZE_RESULT_SUCCESS) { @@ -62,14 +62,14 @@ ze_result_t MetricIpSamplingWindowsImp::startMeasurement(uint32_t ¬ifyEveryNR } ze_result_t MetricIpSamplingWindowsImp::readData(uint8_t *pRawData, size_t *pRawDataSize) { - const auto wddm = device.getOsInterface().getDriverModel()->as(); + const auto wddm = device.getOsInterface()->getDriverModel()->as(); bool result = wddm->perfReadEuStallStream(pRawData, pRawDataSize); return result ? ZE_RESULT_SUCCESS : ZE_RESULT_ERROR_UNKNOWN; } ze_result_t MetricIpSamplingWindowsImp::stopMeasurement() { - const auto wddm = device.getOsInterface().getDriverModel()->as(); + const auto wddm = device.getOsInterface()->getDriverModel()->as(); bool result = wddm->perfDisableEuStallStream(); return result ? ZE_RESULT_SUCCESS : ZE_RESULT_ERROR_UNKNOWN; @@ -88,7 +88,7 @@ uint32_t MetricIpSamplingWindowsImp::getUnitReportSize() { bool MetricIpSamplingWindowsImp::isNReportsAvailable() { size_t bytesAvailable = 0u; - const auto wddm = device.getOsInterface().getDriverModel()->as(); + const auto wddm = device.getOsInterface()->getDriverModel()->as(); bool result = wddm->perfReadEuStallStream(nullptr, &bytesAvailable); if (!result) { METRICS_LOG_ERR("wddm perfReadEuStallStream() call falied."); @@ -108,7 +108,7 @@ bool MetricIpSamplingWindowsImp::isDependencyAvailable() { ze_result_t MetricIpSamplingWindowsImp::getMetricsTimerResolution(uint64_t &timerResolution) { ze_result_t result = ZE_RESULT_SUCCESS; - const auto wddm = device.getOsInterface().getDriverModel()->as(); + const auto wddm = device.getOsInterface()->getDriverModel()->as(); uint32_t gpuTimeStampfrequency = 0; gpuTimeStampfrequency = wddm->getTimestampFrequency(); if (gpuTimeStampfrequency == 0) { diff --git a/level_zero/tools/source/metrics/windows/os_metric_oa_query_imp_windows.cpp b/level_zero/tools/source/metrics/windows/os_metric_oa_query_imp_windows.cpp index 5061049f14..c98011cb80 100644 --- a/level_zero/tools/source/metrics/windows/os_metric_oa_query_imp_windows.cpp +++ b/level_zero/tools/source/metrics/windows/os_metric_oa_query_imp_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -27,7 +27,7 @@ const char *MetricsLibrary::getFilename() { return METRICS_LIBRARY_NAME; } bool MetricsLibrary::getContextData(Device &device, ContextCreateData_1_0 &contextData) { - auto wddm = device.getOsInterface().getDriverModel()->as(); + auto wddm = device.getOsInterface()->getDriverModel()->as(); auto &osData = contextData.ClientData->Windows; // Copy escape data (adapter/device/escape function). diff --git a/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp b/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp index c1ee3840a0..e6d54250c9 100644 --- a/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp +++ b/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -118,7 +118,7 @@ SysfsAccess &LinuxSysmanImp::getSysfsAccess() { ze_result_t LinuxSysmanImp::initLocalDeviceAndDrmHandles() { pDevice = Device::fromHandle(pParentSysmanDeviceImp->hCoreDevice); DEBUG_BREAK_IF(nullptr == pDevice); - NEO::OSInterface &osInterface = pDevice->getOsInterface(); + NEO::OSInterface &osInterface = *pDevice->getOsInterface(); if (osInterface.getDriverModel()->getDriverModelType() != NEO::DriverModelType::drm) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/level_zero/tools/source/sysman/windows/os_sysman_imp.cpp b/level_zero/tools/source/sysman/windows/os_sysman_imp.cpp index ef3f2990cc..dd10f5a164 100644 --- a/level_zero/tools/source/sysman/windows/os_sysman_imp.cpp +++ b/level_zero/tools/source/sysman/windows/os_sysman_imp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -20,7 +20,7 @@ ze_result_t WddmSysmanImp::init() { pDevice = Device::fromHandle(pParentSysmanDeviceImp->hCoreDevice); UNRECOVERABLE_IF(nullptr == pDevice); - NEO::OSInterface &osInterface = pDevice->getOsInterface(); + NEO::OSInterface &osInterface = *pDevice->getOsInterface(); auto driverModel = osInterface.getDriverModel(); if (driverModel) { pWddm = driverModel->as(); diff --git a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp index 6a28d434a5..54728b83e6 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -123,7 +123,7 @@ class MetricIpSamplingLinuxTestPrelim : public DeviceFixture, void SetUp() override { DeviceFixture::setUp(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); - auto &osInterface = device->getOsInterface(); + auto &osInterface = *device->getOsInterface(); osInterface.setDriverModel(std::make_unique(const_cast(neoDevice->getRootDeviceEnvironment()))); metricIpSamplingOsInterface = MetricIpSamplingOsInterface::create(static_cast(*device)); @@ -147,7 +147,7 @@ HWTEST2_F(MetricIpSamplingLinuxTestPrelim, givenCorrectArgumentsWhenStartMeasure HWTEST2_F(MetricIpSamplingLinuxTestPrelim, givenGetTimestampFrequencyFailsWhenStartMeasurementIsCalledThenReturnFailure, IsPVC) { - auto drm = static_cast(device->getOsInterface().getDriverModel()->as()); + auto drm = static_cast(device->getOsInterface()->getDriverModel()->as()); VariableBackup backupCsTimeStampFrequency(&drm->storedCsTimestampFrequency, 0); VariableBackup backupStoredRetVal(&drm->storedRetVal, -1); @@ -157,7 +157,7 @@ HWTEST2_F(MetricIpSamplingLinuxTestPrelim, givenGetTimestampFrequencyFailsWhenSt HWTEST2_F(MetricIpSamplingLinuxTestPrelim, givenGetTimestampFrequencyReturnsFrequencyEqualZeroWhenStartMeasurementIsCalledThenReturnFailure, IsPVC) { - auto drm = static_cast(device->getOsInterface().getDriverModel()->as()); + auto drm = static_cast(device->getOsInterface()->getDriverModel()->as()); VariableBackup backupCsTimeStampFrequency(&drm->storedCsTimestampFrequency, 0); uint32_t notifyEveryNReports = 0, samplingPeriodNs = 10000; @@ -191,7 +191,7 @@ HWTEST2_F(MetricIpSamplingLinuxTestPrelim, givenI915PerfIoctlEnableFailsWhenStar HWTEST2_F(MetricIpSamplingLinuxTestPrelim, givenGetEuStallPropertiesWhenStartMeasurementIsCalledThenReturnFailure, IsPVC) { - auto drm = static_cast(device->getOsInterface().getDriverModel()->as()); + auto drm = static_cast(device->getOsInterface()->getDriverModel()->as()); drm->setIoctlHelperPrelim20Mock(); uint32_t notifyEveryNReports = 0, samplingPeriodNs = 10000; EXPECT_EQ(metricIpSamplingOsInterface->startMeasurement(notifyEveryNReports, samplingPeriodNs), ZE_RESULT_ERROR_UNKNOWN); @@ -326,7 +326,7 @@ HWTEST2_F(MetricIpSamplingLinuxMultiDeviceTest, GivenCombinationOfAffinityMaskWh auto rootDevice = std::unique_ptr(L0::Device::create(driverHandle.get(), deviceFactory->rootDevices[0], false, &returnValue)); auto metricIpSamplingOsInterface = MetricIpSamplingOsInterface::create(static_cast(*rootDevice)); uint32_t notifyEveryNReports = 0, samplingPeriodNs = 10000; - auto drm = static_cast(rootDevice->getOsInterface().getDriverModel()->as()); + auto drm = static_cast(rootDevice->getOsInterface()->getDriverModel()->as()); drm->queryEngineInfo(); VariableBackup mockIoctl(&SysCalls::sysCallsIoctl, [](int fileDescriptor, unsigned long int request, void *arg) -> int { if (request == DRM_IOCTL_I915_PERF_OPEN) { @@ -353,7 +353,7 @@ HWTEST2_F(MetricIpSamplingLinuxMultiDeviceTest, GivenCombinationOfAffinityMaskWh rootDevice->getSubDevices(&subDeviceCount, subDevices); auto metricIpSamplingOsInterface = MetricIpSamplingOsInterface::create(static_cast(*subDevices[0])); uint32_t notifyEveryNReports = 0, samplingPeriodNs = 10000; - auto drm = static_cast(rootDevice->getOsInterface().getDriverModel()->as()); + auto drm = static_cast(rootDevice->getOsInterface()->getDriverModel()->as()); drm->queryEngineInfo(); { @@ -392,7 +392,7 @@ HWTEST2_F(MetricIpSamplingLinuxMultiDeviceTest, GivenEngineInfoIsNullWhenStartMe auto rootDevice = std::unique_ptr(L0::Device::create(driverHandle.get(), deviceFactory->rootDevices[0], false, &returnValue)); auto metricIpSamplingOsInterface = MetricIpSamplingOsInterface::create(static_cast(*rootDevice)); uint32_t notifyEveryNReports = 0, samplingPeriodNs = 10000; - auto drm = static_cast(rootDevice->getOsInterface().getDriverModel()->as()); + auto drm = static_cast(rootDevice->getOsInterface()->getDriverModel()->as()); drm->queryEngineInfo1SubDevice(); EXPECT_EQ(metricIpSamplingOsInterface->startMeasurement(notifyEveryNReports, samplingPeriodNs), ZE_RESULT_ERROR_UNKNOWN); } diff --git a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_upstream.cpp b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_upstream.cpp index f44a43eff5..6463565f60 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_upstream.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_upstream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -35,7 +35,7 @@ class MetricIpSamplingLinuxTestUpstream : public MetricContextFixture, void SetUp() override { MetricContextFixture::setUp(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); - auto &osInterface = device->getOsInterface(); + auto &osInterface = *device->getOsInterface(); osInterface.setDriverModel(std::make_unique(const_cast(neoDevice->getRootDeviceEnvironment()))); metricIpSamplingOsInterface = MetricIpSamplingOsInterface::create(static_cast(*device)); } diff --git a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_oa_query_pool_linux.cpp b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_oa_query_pool_linux.cpp index ed15750605..c607e3307d 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_oa_query_pool_linux.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_oa_query_pool_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -33,7 +33,7 @@ class MetricQueryPoolLinuxTest : public MetricContextFixture, void SetUp() override { MetricContextFixture::setUp(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); - auto &osInterface = device->getOsInterface(); + auto &osInterface = *device->getOsInterface(); osInterface.setDriverModel(std::make_unique(const_cast(neoDevice->getRootDeviceEnvironment()))); } @@ -57,7 +57,7 @@ TEST_F(MetricQueryPoolLinuxTest, givenCorrectArgumentsWhenGetContextDataIsCalled EXPECT_EQ(mockMetricsLibrary->metricsLibraryGetContextData(*device, contextData), true); - auto &osInterface = device->getOsInterface(); + auto &osInterface = *device->getOsInterface(); EXPECT_EQ(contextData.ClientData->Linux.Adapter->DrmFileDescriptor, osInterface.getDriverModel()->as()->getFileDescriptor()); EXPECT_EQ(contextData.ClientData->Linux.Adapter->Type, LinuxAdapterType::DrmFileDescriptor); @@ -248,7 +248,7 @@ class MetricEnumerationTestLinux : public MetricContextFixture, void SetUp() override { MetricContextFixture::setUp(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); - auto &osInterface = device->getOsInterface(); + auto &osInterface = *device->getOsInterface(); osInterface.setDriverModel(std::make_unique(const_cast(neoDevice->getRootDeviceEnvironment()))); } @@ -271,7 +271,7 @@ TEST_F(MetricEnumerationTestLinux, givenDrmFailureWhenGettingOATimerResolutionTh std::unique_ptr oaOsInterface = MetricOAOsInterface::create(*device); uint64_t timerResolution; oaOsInterface->getMetricsTimerResolution(timerResolution); - auto drm = static_cast(device->getOsInterface().getDriverModel()->as()); + auto drm = static_cast(device->getOsInterface()->getDriverModel()->as()); drm->storedRetVal = -1; EXPECT_EQ(oaOsInterface->getMetricsTimerResolution(timerResolution), ZE_RESULT_ERROR_UNKNOWN); diff --git a/level_zero/tools/test/unit_tests/sources/metrics/windows/test_metric_ip_sampling.cpp b/level_zero/tools/test/unit_tests/sources/metrics/windows/test_metric_ip_sampling.cpp index 52b36f3d26..a9e1c7eeb9 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/windows/test_metric_ip_sampling.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/windows/test_metric_ip_sampling.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -23,7 +23,7 @@ class MetricIpSamplingWindowsFixtureXe2 : public DeviceFixture, DeviceFixture::setUp(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); - auto &osInterface = device->getOsInterface(); + auto &osInterface = *device->getOsInterface(); wddm = new NEO::WddmMock(const_cast(neoDevice->getRootDeviceEnvironment())); wddm->init(); osInterface.setDriverModel(std::unique_ptr(wddm)); diff --git a/level_zero/tools/test/unit_tests/sources/metrics/windows/test_metric_oa_query_pool_windows.cpp b/level_zero/tools/test/unit_tests/sources/metrics/windows/test_metric_oa_query_pool_windows.cpp index 96fe777139..1100b6d0f8 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/windows/test_metric_oa_query_pool_windows.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/windows/test_metric_oa_query_pool_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -23,10 +23,10 @@ class MetricQueryPoolWindowsTest : public MetricContextFixture, void SetUp() override { MetricContextFixture::setUp(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); - auto &osInterface = device->getOsInterface(); + auto osInterface = device->getOsInterface(); wddm = new NEO::WddmMock(const_cast(neoDevice->getRootDeviceEnvironment())); wddm->init(); - osInterface.setDriverModel(std::unique_ptr(wddm)); + osInterface->setDriverModel(std::unique_ptr(wddm)); } void TearDown() override { @@ -45,8 +45,8 @@ TEST_F(MetricQueryPoolWindowsTest, givenCorrectArgumentsWhenGetContextDataIsCall EXPECT_EQ(mockMetricsLibrary->metricsLibraryGetContextData(*device, contextData), true); - auto &osInterface = device->getOsInterface(); - auto wddm = osInterface.getDriverModel()->as(); + auto osInterface = device->getOsInterface(); + auto wddm = osInterface->getDriverModel()->as(); EXPECT_EQ(contextData.ClientData->Windows.KmdInstrumentationEnabled, true); EXPECT_EQ(contextData.ClientData->Windows.Device, reinterpret_cast(static_cast(wddm->getDeviceHandle()))); diff --git a/level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h b/level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h index ad370c37ce..432415df51 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -59,7 +59,7 @@ class SysmanDeviceFixture : public DeviceFixture, public ::testing::Test { } DeviceFixture::setUp(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); - auto &osInterface = device->getOsInterface(); + auto &osInterface = *device->getOsInterface(); osInterface.setDriverModel(std::make_unique(const_cast(neoDevice->getRootDeviceEnvironment()))); setenv("ZES_ENABLE_SYSMAN", "1", 1); device->setSysmanHandle(new SysmanDeviceImp(device->toHandle())); @@ -115,7 +115,7 @@ class SysmanMultiDeviceFixture : public MultiDeviceFixture, public ::testing::Te device = driverHandle->devices[0]; neoDevice = device->getNEODevice(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); - auto &osInterface = device->getOsInterface(); + auto &osInterface = *device->getOsInterface(); osInterface.setDriverModel(std::make_unique(const_cast(neoDevice->getRootDeviceEnvironment()))); setenv("ZES_ENABLE_SYSMAN", "1", 1); device->setSysmanHandle(new SysmanDeviceImp(device->toHandle())); diff --git a/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp b/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp index f7b14af605..ba93fd0b9d 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/linux/test_sysman.cpp @@ -228,7 +228,7 @@ TEST_F(SysmanDeviceFixture, GivenValidDeviceHandleWithSysmanOnlyInitSetAsTrueThe } TEST_F(SysmanDeviceFixture, GivenSetValidDrmHandleForDeviceWhenDoingOsSysmanDeviceInitThenSameDrmHandleIsRetrieved) { - EXPECT_EQ(&pLinuxSysmanImp->getDrm(), device->getOsInterface().getDriverModel()->as()); + EXPECT_EQ(&pLinuxSysmanImp->getDrm(), device->getOsInterface()->getDriverModel()->as()); } TEST_F(SysmanDeviceFixture, GivenCreateFsAccessHandleWhenCallinggetFsAccessThenCreatedFsAccessHandleWillBeRetrieved) { @@ -1011,7 +1011,7 @@ TEST_F(SysmanMultiDeviceFixture, GivenSysmanEnvironmentVariableSetWhenCreateL0De using SysmanUnknownDriverModelTest = Test; TEST_F(SysmanUnknownDriverModelTest, GivenDriverModelTypeIsNotDrmWhenExecutingSysmanOnLinuxThenErrorIsReturned) { neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); - auto &osInterface = device->getOsInterface(); + auto &osInterface = *device->getOsInterface(); osInterface.setDriverModel(std::make_unique()); auto pSysmanDeviceImp = std::make_unique(device->toHandle()); auto pLinuxSysmanImp = static_cast(pSysmanDeviceImp->pOsSysman);