Support for L0 to read Device LUID from the WDDM driver using EXT Properties
- Added Support for reading the Device LUID of the given device used in Windows WDDM. - Added inital support for passing back the NodeMask of 1. Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
This commit is contained in:
parent
d0d1514f7a
commit
b5b9c3500f
|
@ -37,6 +37,7 @@ set(L0_RUNTIME_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/device/bcs_split.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/device/bcs_split.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/device/bcs_split.h
|
${CMAKE_CURRENT_SOURCE_DIR}/device/bcs_split.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/device/device.h
|
${CMAKE_CURRENT_SOURCE_DIR}/device/device.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/device/device_imp_${DRIVER_MODEL}/device_imp.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/device/device_imp.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/device/device_imp.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/device/device_imp.h
|
${CMAKE_CURRENT_SOURCE_DIR}/device/device_imp.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/driver/driver_handle.h
|
${CMAKE_CURRENT_SOURCE_DIR}/driver/driver_handle.h
|
||||||
|
|
|
@ -725,6 +725,19 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties)
|
||||||
}
|
}
|
||||||
memcpy_s(pDeviceProperties->name, ZE_MAX_DEVICE_NAME, name.c_str(), name.length() + 1);
|
memcpy_s(pDeviceProperties->name, ZE_MAX_DEVICE_NAME, name.c_str(), name.length() + 1);
|
||||||
|
|
||||||
|
if (pDeviceProperties->pNext) {
|
||||||
|
ze_base_properties_t *extendedProperties = reinterpret_cast<ze_base_properties_t *>(pDeviceProperties->pNext);
|
||||||
|
if (extendedProperties->stype == ZE_STRUCTURE_TYPE_DEVICE_LUID_EXT_PROPERTIES) {
|
||||||
|
ze_device_luid_ext_properties_t *deviceLuidProperties =
|
||||||
|
reinterpret_cast<ze_device_luid_ext_properties_t *>(extendedProperties);
|
||||||
|
ze_result_t result = queryDeviceLuid(deviceLuidProperties);
|
||||||
|
if (result != ZE_RESULT_SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
deviceLuidProperties->nodeMask = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ZE_RESULT_SUCCESS;
|
return ZE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,9 @@ struct DeviceImp : public Device {
|
||||||
CmdListCreateFunPtrT getCmdListCreateFunc(const ze_command_list_desc_t *desc);
|
CmdListCreateFunPtrT getCmdListCreateFunc(const ze_command_list_desc_t *desc);
|
||||||
std::unique_ptr<FabricVertex> fabricVertex;
|
std::unique_ptr<FabricVertex> fabricVertex;
|
||||||
|
|
||||||
|
ze_result_t queryDeviceLuid(ze_device_luid_ext_properties_t *deviceLuidProperties);
|
||||||
|
ze_result_t setDeviceLuid(ze_device_luid_ext_properties_t *deviceLuidProperties);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void adjustCommandQueueDesc(uint32_t &ordinal, uint32_t &index);
|
void adjustCommandQueueDesc(uint32_t &ordinal, uint32_t &index);
|
||||||
NEO::EngineGroupType getEngineGroupTypeForOrdinal(uint32_t ordinal) const;
|
NEO::EngineGroupType getEngineGroupTypeForOrdinal(uint32_t ordinal) const;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "level_zero/core/source/device/device_imp.h"
|
||||||
|
|
||||||
|
namespace L0 {
|
||||||
|
|
||||||
|
ze_result_t DeviceImp::queryDeviceLuid(ze_device_luid_ext_properties_t *deviceLuidProperties) {
|
||||||
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace L0
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "level_zero/core/source/device/device_imp.h"
|
||||||
|
|
||||||
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||||
|
#include "shared/source/os_interface/os_interface.h"
|
||||||
|
#include "shared/source/os_interface/windows/hw_device_id.h"
|
||||||
|
#include "shared/source/os_interface/windows/os_context_win.h"
|
||||||
|
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||||
|
|
||||||
|
namespace L0 {
|
||||||
|
|
||||||
|
ze_result_t DeviceImp::queryDeviceLuid(ze_device_luid_ext_properties_t *deviceLuidProperties) {
|
||||||
|
NEO::Device *activeDevice = getActiveDevice();
|
||||||
|
if (activeDevice->getRootDeviceEnvironment().osInterface) {
|
||||||
|
NEO::DriverModelType driverType = neoDevice->getRootDeviceEnvironment().osInterface->getDriverModel()->getDriverModelType();
|
||||||
|
if (driverType == NEO::DriverModelType::WDDM) {
|
||||||
|
NEO::CommandStreamReceiver *csr = activeDevice->getDefaultEngine().commandStreamReceiver;
|
||||||
|
NEO::OsContextWin *context = static_cast<NEO::OsContextWin *>(&csr->getOsContext());
|
||||||
|
std::vector<uint8_t> luidData;
|
||||||
|
context->getDeviceLuidArray(luidData, ZE_MAX_DEVICE_LUID_SIZE_EXT);
|
||||||
|
std::copy_n(luidData.begin(), ZE_MAX_DEVICE_LUID_SIZE_EXT, std::begin(deviceLuidProperties->luid.id));
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace L0
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "level_zero/core/source/device/device_imp.h"
|
||||||
|
|
||||||
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||||
|
#include "shared/source/os_interface/os_context.h"
|
||||||
|
#include "shared/source/os_interface/windows/hw_device_id.h"
|
||||||
|
#include "shared/source/os_interface/windows/os_context_win.h"
|
||||||
|
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||||
|
|
||||||
|
namespace L0 {
|
||||||
|
|
||||||
|
ze_result_t DeviceImp::queryDeviceLuid(ze_device_luid_ext_properties_t *deviceLuidProperties) {
|
||||||
|
NEO::Device *activeDevice = getActiveDevice();
|
||||||
|
NEO::CommandStreamReceiver *csr = activeDevice->getDefaultEngine().commandStreamReceiver;
|
||||||
|
NEO::OsContextWin *context = static_cast<NEO::OsContextWin *>(&csr->getOsContext());
|
||||||
|
std::vector<uint8_t> luidData;
|
||||||
|
context->getDeviceLuidArray(luidData, ZE_MAX_DEVICE_LUID_SIZE_EXT);
|
||||||
|
std::copy_n(luidData.begin(), ZE_MAX_DEVICE_LUID_SIZE_EXT, std::begin(deviceLuidProperties->luid.id));
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace L0
|
|
@ -99,7 +99,8 @@ struct DriverHandleImp : public DriverHandle {
|
||||||
{ZE_DEVICE_MEMORY_PROPERTIES_EXT_NAME, ZE_DEVICE_MEMORY_PROPERTIES_EXT_VERSION_CURRENT},
|
{ZE_DEVICE_MEMORY_PROPERTIES_EXT_NAME, ZE_DEVICE_MEMORY_PROPERTIES_EXT_VERSION_CURRENT},
|
||||||
{ZE_RAYTRACING_EXT_NAME, ZE_RAYTRACING_EXT_VERSION_CURRENT},
|
{ZE_RAYTRACING_EXT_NAME, ZE_RAYTRACING_EXT_VERSION_CURRENT},
|
||||||
{ZE_CONTEXT_POWER_SAVING_HINT_EXP_NAME, ZE_POWER_SAVING_HINT_EXP_VERSION_CURRENT},
|
{ZE_CONTEXT_POWER_SAVING_HINT_EXP_NAME, ZE_POWER_SAVING_HINT_EXP_VERSION_CURRENT},
|
||||||
{ZE_CACHE_RESERVATION_EXT_NAME, ZE_CACHE_RESERVATION_EXT_VERSION_CURRENT}};
|
{ZE_CACHE_RESERVATION_EXT_NAME, ZE_CACHE_RESERVATION_EXT_VERSION_CURRENT},
|
||||||
|
{ZE_DEVICE_LUID_EXT_NAME, ZE_DEVICE_LUID_EXT_VERSION_CURRENT}};
|
||||||
|
|
||||||
uint64_t uuidTimestamp = 0u;
|
uint64_t uuidTimestamp = 0u;
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,6 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test_device.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test_device.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test_device_pci_speed_info.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test_device_pci_speed_info.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test_device_pci_speed_info.h
|
${CMAKE_CURRENT_SOURCE_DIR}/test_device_pci_speed_info.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/device_${DRIVER_MODEL}/test_device.cpp
|
||||||
)
|
)
|
||||||
add_subdirectories()
|
add_subdirectories()
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2020-2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shared/test/common/mocks/mock_device.h"
|
||||||
|
#include "shared/test/common/mocks/mock_driver_info.h"
|
||||||
|
#include "shared/test/common/mocks/mock_driver_model.h"
|
||||||
|
#include "shared/test/common/test_macros/hw_test.h"
|
||||||
|
|
||||||
|
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
namespace L0 {
|
||||||
|
namespace ult {
|
||||||
|
|
||||||
|
using LuidDeviceTest = Test<DeviceFixture>;
|
||||||
|
|
||||||
|
TEST_F(LuidDeviceTest, givenLuidDevicePropertiesStructureAndDRMDriverTypeThenUnsupportedReturned) {
|
||||||
|
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface());
|
||||||
|
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::make_unique<NEO::MockDriverModelDRM>());
|
||||||
|
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||||
|
ze_device_luid_ext_properties_t deviceLuidProperties = {ZE_STRUCTURE_TYPE_DEVICE_LUID_EXT_PROPERTIES};
|
||||||
|
deviceProperties.pNext = &deviceLuidProperties;
|
||||||
|
ze_result_t result = device->getProperties(&deviceProperties);
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ult
|
||||||
|
} // namespace L0
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shared/source/os_interface/windows/gdi_interface.h"
|
||||||
|
#include "shared/source/os_interface/windows/hw_device_id.h"
|
||||||
|
#include "shared/source/os_interface/windows/os_context_win.h"
|
||||||
|
#include "shared/source/os_interface/windows/os_environment_win.h"
|
||||||
|
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||||
|
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||||
|
#include "shared/test/common/mocks/mock_device.h"
|
||||||
|
#include "shared/test/common/mocks/mock_driver_info.h"
|
||||||
|
#include "shared/test/common/mocks/mock_driver_model.h"
|
||||||
|
#include "shared/test/common/test_macros/hw_test.h"
|
||||||
|
|
||||||
|
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
namespace L0 {
|
||||||
|
namespace ult {
|
||||||
|
|
||||||
|
#define ADAPTER_HANDLE_WDDM_FAKE (static_cast<D3DKMT_HANDLE>(0x40001234))
|
||||||
|
|
||||||
|
struct CloseAdapterMock {
|
||||||
|
static NTSTATUS(APIENTRY closeAdapter)(
|
||||||
|
const D3DKMT_CLOSEADAPTER *closeAdapter) {
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MockHwDeviceIdWddm : public HwDeviceIdWddm {
|
||||||
|
using HwDeviceIdWddm::osEnvironment;
|
||||||
|
MockHwDeviceIdWddm(D3DKMT_HANDLE adapterIn, LUID adapterLuidIn, OsEnvironment *osEnvironmentIn, std::unique_ptr<UmKmDataTranslator> umKmDataTranslator) : HwDeviceIdWddm(adapterIn, adapterLuidIn, osEnvironmentIn, std::move(umKmDataTranslator)) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MockDriverModelWDDMLUID : public NEO::Wddm {
|
||||||
|
public:
|
||||||
|
MockDriverModelWDDMLUID(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::move(hwDeviceId), rootDeviceEnvironment) {
|
||||||
|
}
|
||||||
|
bool init() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isDriverAvaliable() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool skipResourceCleanup() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MockDriverModelWDDMLUID(RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::make_unique<MockHwDeviceIdWddm>(ADAPTER_HANDLE_WDDM_FAKE, LUID{0x12, 0x1234}, rootDeviceEnvironment.executionEnvironment.osEnvironment.get(), std::make_unique<UmKmDataTranslator>()), rootDeviceEnvironment) {
|
||||||
|
if (!rootDeviceEnvironment.executionEnvironment.osEnvironment.get()) {
|
||||||
|
rootDeviceEnvironment.executionEnvironment.osEnvironment = std::make_unique<OsEnvironmentWin>();
|
||||||
|
}
|
||||||
|
static_cast<MockHwDeviceIdWddm *>(this->hwDeviceId.get())->osEnvironment = rootDeviceEnvironment.executionEnvironment.osEnvironment.get();
|
||||||
|
OsEnvironmentWin *osEnvWin = reinterpret_cast<OsEnvironmentWin *>(static_cast<MockHwDeviceIdWddm *>(this->hwDeviceId.get())->osEnvironment);
|
||||||
|
osEnvWin->gdi.get()->closeAdapter.mFunc = CloseAdapterMock::closeAdapter;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MockOsContextWin : public OsContextWin {
|
||||||
|
public:
|
||||||
|
MockOsContextWin(MockDriverModelWDDMLUID &wddm, uint32_t contextId, const EngineDescriptor &engineDescriptor)
|
||||||
|
: OsContextWin(wddm, contextId, engineDescriptor) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
using LuidDeviceTest = Test<DeviceFixture>;
|
||||||
|
|
||||||
|
TEST_F(LuidDeviceTest, givenOsContextWinAndGetLUIDArrayThenLUIDisValid) {
|
||||||
|
auto luidMock = new MockDriverModelWDDMLUID(*neoDevice->executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
auto defaultEngine = defaultHwInfo->capabilityTable.defaultEngineType;
|
||||||
|
OsContextWin osContext(*luidMock, 0u, EngineDescriptorHelper::getDefaultDescriptor({defaultEngine, EngineUsage::Regular}));
|
||||||
|
std::vector<uint8_t> luidData;
|
||||||
|
size_t arraySize = 8;
|
||||||
|
osContext.getDeviceLuidArray(luidData, arraySize);
|
||||||
|
uint64_t luid = 0;
|
||||||
|
memcpy_s(&luid, sizeof(uint64_t), luidData.data(), sizeof(uint8_t) * luidData.size());
|
||||||
|
EXPECT_NE(luid, (uint64_t)0);
|
||||||
|
delete luidMock;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(LuidDeviceTest, givenLuidDevicePropertiesStructureAndWDDMDriverTypeThenSuccessReturned) {
|
||||||
|
auto defaultEngine = defaultHwInfo->capabilityTable.defaultEngineType;
|
||||||
|
auto luidMock = new MockDriverModelWDDMLUID(*neoDevice->executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface());
|
||||||
|
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(luidMock));
|
||||||
|
MockOsContextWin mockContext(*luidMock, 0u, EngineDescriptorHelper::getDefaultDescriptor({defaultEngine, EngineUsage::Regular}));
|
||||||
|
auto &deviceRegularEngines = neoDevice->getRegularEngineGroups();
|
||||||
|
auto &deviceEngine = deviceRegularEngines[0].engines[0];
|
||||||
|
auto csr = deviceEngine.commandStreamReceiver;
|
||||||
|
csr->setupContext(mockContext);
|
||||||
|
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||||
|
ze_device_luid_ext_properties_t deviceLuidProperties = {ZE_STRUCTURE_TYPE_DEVICE_LUID_EXT_PROPERTIES};
|
||||||
|
deviceProperties.pNext = &deviceLuidProperties;
|
||||||
|
ze_result_t result = device->getProperties(&deviceProperties);
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
|
uint64_t luid = 0;
|
||||||
|
LUID adapterLuid{0x12, 0x1234};
|
||||||
|
memcpy_s(&luid, sizeof(uint64_t), &deviceLuidProperties.luid, sizeof(deviceLuidProperties.luid));
|
||||||
|
uint32_t lowLUID = luid & 0xFFFFFFFF;
|
||||||
|
uint32_t highLUID = ((luid & 0xFFFFFFFF00000000) >> 32);
|
||||||
|
EXPECT_EQ(lowLUID, (uint32_t)adapterLuid.LowPart);
|
||||||
|
EXPECT_EQ(highLUID, (uint32_t)adapterLuid.HighPart);
|
||||||
|
EXPECT_NE(deviceLuidProperties.nodeMask, (uint32_t)0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(LuidDeviceTest, givenLuidDevicePropertiesStructureAndDRMDriverTypeThenUnsupportedReturned) {
|
||||||
|
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface());
|
||||||
|
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::make_unique<NEO::MockDriverModelDRM>());
|
||||||
|
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||||
|
ze_device_luid_ext_properties_t deviceLuidProperties = {ZE_STRUCTURE_TYPE_DEVICE_LUID_EXT_PROPERTIES};
|
||||||
|
deviceProperties.pNext = &deviceLuidProperties;
|
||||||
|
ze_result_t result = device->getProperties(&deviceProperties);
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(LuidDeviceTest, givenLuidDevicePropertiesStructureAndAndNoOsInterfaceThenUninitReturned) {
|
||||||
|
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(nullptr);
|
||||||
|
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||||
|
ze_device_luid_ext_properties_t deviceLuidProperties = {ZE_STRUCTURE_TYPE_DEVICE_LUID_EXT_PROPERTIES};
|
||||||
|
deviceProperties.pNext = &deviceLuidProperties;
|
||||||
|
ze_result_t result = device->getProperties(&deviceProperties);
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_ERROR_UNINITIALIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ult
|
||||||
|
} // namespace L0
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shared/source/command_container/implicit_scaling.h"
|
||||||
|
#include "shared/source/command_stream/wait_status.h"
|
||||||
|
#include "shared/source/device/root_device.h"
|
||||||
|
#include "shared/source/helpers/bindless_heaps_helper.h"
|
||||||
|
#include "shared/source/helpers/hw_helper.h"
|
||||||
|
#include "shared/source/helpers/hw_info.h"
|
||||||
|
#include "shared/source/helpers/preamble.h"
|
||||||
|
#include "shared/source/os_interface/hw_info_config.h"
|
||||||
|
#include "shared/source/os_interface/os_inc_base.h"
|
||||||
|
#include "shared/source/os_interface/os_time.h"
|
||||||
|
#include "shared/source/os_interface/windows/hw_device_id.h"
|
||||||
|
#include "shared/source/os_interface/windows/os_context_win.h"
|
||||||
|
#include "shared/source/os_interface/windows/os_environment_win.h"
|
||||||
|
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||||
|
#include "shared/source/os_interface/windows/wddm/wddm_interface.h"
|
||||||
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||||
|
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||||
|
#include "shared/test/common/helpers/mock_hw_info_config_hw.h"
|
||||||
|
#include "shared/test/common/libult/ult_command_stream_receiver.h"
|
||||||
|
#include "shared/test/common/mock_gdi/mock_gdi.h"
|
||||||
|
#include "shared/test/common/mocks/mock_compilers.h"
|
||||||
|
#include "shared/test/common/mocks/mock_device.h"
|
||||||
|
#include "shared/test/common/mocks/mock_driver_info.h"
|
||||||
|
#include "shared/test/common/mocks/mock_driver_model.h"
|
||||||
|
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||||
|
#include "shared/test/common/mocks/mock_os_context.h"
|
||||||
|
#include "shared/test/common/mocks/mock_sip.h"
|
||||||
|
#include "shared/test/common/mocks/mock_wddm.h"
|
||||||
|
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||||
|
#include "shared/test/common/mocks/windows/mock_gdi_interface.h"
|
||||||
|
#include "shared/test/common/test_macros/hw_test.h"
|
||||||
|
|
||||||
|
#include "level_zero/core/source/cache/cache_reservation.h"
|
||||||
|
#include "level_zero/core/source/cmdqueue/cmdqueue_imp.h"
|
||||||
|
#include "level_zero/core/source/context/context_imp.h"
|
||||||
|
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||||
|
#include "level_zero/core/source/driver/host_pointer_manager.h"
|
||||||
|
#include "level_zero/core/source/image/image.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/mocks/mock_context.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||||
|
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
std::unique_ptr<HwDeviceIdWddm> createHwDeviceIdFromAdapterLuid(OsEnvironmentWin &osEnvironment, LUID adapterLuid);
|
||||||
|
} // namespace NEO
|
||||||
|
|
||||||
|
namespace L0 {
|
||||||
|
namespace ult {
|
||||||
|
|
||||||
|
struct LuidDeviceTest : public ::testing::Test {
|
||||||
|
void SetUp() override {}
|
||||||
|
void TearDown() override {}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(LuidDeviceTest, givenLuidDevicePropertiesStructureThenLuidAndNodeMaskSetForWDDMDriverType) {
|
||||||
|
NEO::MockDevice *neoDevice = nullptr;
|
||||||
|
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||||
|
L0::Device *device = nullptr;
|
||||||
|
WddmMock *luidMock = nullptr;
|
||||||
|
|
||||||
|
auto gdi = new MockGdi();
|
||||||
|
auto osEnvironment = new OsEnvironmentWin();
|
||||||
|
osEnvironment->gdi.reset(gdi);
|
||||||
|
|
||||||
|
auto mockBuiltIns = new MockBuiltins();
|
||||||
|
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(NEO::defaultHwInfo.get(), 0u);
|
||||||
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
|
||||||
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||||
|
|
||||||
|
executionEnvironment->osEnvironment.reset(osEnvironment);
|
||||||
|
auto osInterface = new OSInterface();
|
||||||
|
luidMock = new WddmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
LUID adapterLuid = {0x12, 0x1234};
|
||||||
|
luidMock->hwDeviceId = NEO::createHwDeviceIdFromAdapterLuid(*osEnvironment, adapterLuid);
|
||||||
|
executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(osInterface);
|
||||||
|
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(luidMock));
|
||||||
|
luidMock->init();
|
||||||
|
neoDevice = NEO::MockDevice::createWithExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get(), executionEnvironment, 0u);
|
||||||
|
|
||||||
|
NEO::DeviceVector devices;
|
||||||
|
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||||
|
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||||
|
driverHandle->initialize(std::move(devices));
|
||||||
|
device = driverHandle->devices[0];
|
||||||
|
|
||||||
|
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||||
|
ze_device_luid_ext_properties_t deviceLuidProperties = {ZE_STRUCTURE_TYPE_DEVICE_LUID_EXT_PROPERTIES};
|
||||||
|
deviceProperties.pNext = &deviceLuidProperties;
|
||||||
|
ze_result_t result = device->getProperties(&deviceProperties);
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
|
uint64_t luid = 0;
|
||||||
|
memcpy_s(&luid, sizeof(uint64_t), &deviceLuidProperties.luid, sizeof(deviceLuidProperties.luid));
|
||||||
|
uint32_t lowLUID = luid & 0xFFFFFFFF;
|
||||||
|
uint32_t highLUID = ((luid & 0xFFFFFFFF00000000) >> 32);
|
||||||
|
EXPECT_EQ(lowLUID, (uint32_t)adapterLuid.LowPart);
|
||||||
|
EXPECT_EQ(highLUID, (uint32_t)adapterLuid.HighPart);
|
||||||
|
EXPECT_NE(deviceLuidProperties.nodeMask, (uint32_t)0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ult
|
||||||
|
} // namespace L0
|
|
@ -1102,6 +1102,15 @@ TEST_F(DeviceTest, givenNodeOrdinalFlagWhenCallAdjustCommandQueueDescThenDescOrd
|
||||||
EXPECT_EQ(desc.ordinal, expectedOrdinal);
|
EXPECT_EQ(desc.ordinal, expectedOrdinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using InvalidExtensionTest = DeviceTest;
|
||||||
|
TEST_F(InvalidExtensionTest, givenInvalidExtensionPropertiesDuringDeviceGetPropertiesThenPropertiesIgnoredWithSuccess) {
|
||||||
|
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||||
|
ze_device_properties_t invalidExtendedProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||||
|
deviceProperties.pNext = &invalidExtendedProperties;
|
||||||
|
ze_result_t result = device->getProperties(&deviceProperties);
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
HWTEST_F(DeviceTest, givenNodeOrdinalFlagWhenCallAdjustCommandQueueDescThenDescOrdinalAndDescIndexProperlySet) {
|
HWTEST_F(DeviceTest, givenNodeOrdinalFlagWhenCallAdjustCommandQueueDescThenDescOrdinalAndDescIndexProperlySet) {
|
||||||
DebugManagerStateRestore restore;
|
DebugManagerStateRestore restore;
|
||||||
struct MockHwHelper : NEO::HwHelperHw<FamilyType> {
|
struct MockHwHelper : NEO::HwHelperHw<FamilyType> {
|
||||||
|
|
|
@ -52,6 +52,23 @@ void OsContextWin::reInitializeContext() {
|
||||||
UNRECOVERABLE_IF(!wddm.createContext(*this));
|
UNRECOVERABLE_IF(!wddm.createContext(*this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void OsContextWin::getDeviceLuidArray(std::vector<uint8_t> &luidData, size_t arraySize) {
|
||||||
|
auto *wddm = this->getWddm();
|
||||||
|
auto *hwDeviceID = wddm->getHwDeviceId();
|
||||||
|
auto luid = hwDeviceID->getAdapterLuid();
|
||||||
|
luidData.reserve(arraySize);
|
||||||
|
for (size_t i = 0; i < arraySize; i++) {
|
||||||
|
char *luidArray = nullptr;
|
||||||
|
if (i < 4) {
|
||||||
|
luidArray = (char *)&luid.LowPart;
|
||||||
|
luidData.emplace(luidData.end(), luidArray[i]);
|
||||||
|
} else {
|
||||||
|
luidArray = (char *)&luid.HighPart;
|
||||||
|
luidData.emplace(luidData.end(), luidArray[i - 4]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
OsContextWin::~OsContextWin() {
|
OsContextWin::~OsContextWin() {
|
||||||
if (contextInitialized && (false == this->wddm.skipResourceCleanup())) {
|
if (contextInitialized && (false == this->wddm.skipResourceCleanup())) {
|
||||||
wddm.getWddmInterface()->destroyHwQueue(hardwareQueue.handle);
|
wddm.getWddmInterface()->destroyHwQueue(hardwareQueue.handle);
|
||||||
|
|
|
@ -35,6 +35,7 @@ class OsContextWin : public OsContext {
|
||||||
MOCKABLE_VIRTUAL WddmResidencyController &getResidencyController() { return residencyController; }
|
MOCKABLE_VIRTUAL WddmResidencyController &getResidencyController() { return residencyController; }
|
||||||
static OsContext *create(OSInterface *osInterface, uint32_t contextId, const EngineDescriptor &engineDescriptor);
|
static OsContext *create(OSInterface *osInterface, uint32_t contextId, const EngineDescriptor &engineDescriptor);
|
||||||
void reInitializeContext() override;
|
void reInitializeContext() override;
|
||||||
|
void getDeviceLuidArray(std::vector<uint8_t> &luidData, size_t arraySize);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initializeContext() override;
|
void initializeContext() override;
|
||||||
|
|
|
@ -61,6 +61,38 @@ struct WddmFixture : public Test<MockExecutionEnvironmentGmmFixture> {
|
||||||
MockWddmResidentAllocationsContainer *mockTemporaryResources;
|
MockWddmResidentAllocationsContainer *mockTemporaryResources;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct WddmFixtureLuid : public Test<MockExecutionEnvironmentGmmFixture> {
|
||||||
|
void SetUp() override {
|
||||||
|
MockExecutionEnvironmentGmmFixture::setUp();
|
||||||
|
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
||||||
|
osEnvironment = new OsEnvironmentWin();
|
||||||
|
gdi = new MockGdi();
|
||||||
|
osEnvironment->gdi.reset(gdi);
|
||||||
|
executionEnvironment->osEnvironment.reset(osEnvironment);
|
||||||
|
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
|
||||||
|
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
||||||
|
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
||||||
|
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
|
||||||
|
osInterface = rootDeviceEnvironment->osInterface.get();
|
||||||
|
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
|
||||||
|
wddm->init();
|
||||||
|
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
|
||||||
|
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
|
||||||
|
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engine, preemptionMode));
|
||||||
|
osContext->ensureContextInitialized();
|
||||||
|
mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(wddm->temporaryResources.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
WddmMock *wddm = nullptr;
|
||||||
|
OSInterface *osInterface;
|
||||||
|
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
|
||||||
|
OsEnvironmentWin *osEnvironment = nullptr;
|
||||||
|
std::unique_ptr<OsContextWin> osContext;
|
||||||
|
|
||||||
|
MockGdi *gdi = nullptr;
|
||||||
|
MockWddmResidentAllocationsContainer *mockTemporaryResources;
|
||||||
|
};
|
||||||
|
|
||||||
struct WddmFixtureWithMockGdiDll : public GdiDllFixture, public MockExecutionEnvironmentGmmFixture {
|
struct WddmFixtureWithMockGdiDll : public GdiDllFixture, public MockExecutionEnvironmentGmmFixture {
|
||||||
void setUp() {
|
void setUp() {
|
||||||
MockExecutionEnvironmentGmmFixture::setUp();
|
MockExecutionEnvironmentGmmFixture::setUp();
|
||||||
|
|
|
@ -6,11 +6,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "shared/source/gmm_helper/gmm.h"
|
#include "shared/source/gmm_helper/gmm.h"
|
||||||
|
#include "shared/source/helpers/string.h"
|
||||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||||
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
|
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
|
||||||
#include "shared/test/common/test_macros/hw_test.h"
|
#include "shared/test/common/test_macros/hw_test.h"
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
std::unique_ptr<HwDeviceIdWddm> createHwDeviceIdFromAdapterLuid(OsEnvironmentWin &osEnvironment, LUID adapterLuid);
|
||||||
|
|
||||||
using WddmTests = WddmTestWithMockGdiDll;
|
using WddmTests = WddmTestWithMockGdiDll;
|
||||||
|
|
||||||
|
@ -379,6 +381,17 @@ TEST_F(WddmTests, GivenPlatformNotSupportEvictIfNecessaryWhenAdjustingEvictNeede
|
||||||
bool value = wddm->adjustEvictNeededParameter(false);
|
bool value = wddm->adjustEvictNeededParameter(false);
|
||||||
EXPECT_TRUE(value);
|
EXPECT_TRUE(value);
|
||||||
}
|
}
|
||||||
|
using WddmOsContextDeviceLuidTests = WddmFixtureLuid;
|
||||||
|
TEST_F(WddmFixtureLuid, givenValidOsContextAndLuidDataRequestThenValidDataReturned) {
|
||||||
|
LUID adapterLuid = {0x12, 0x1234};
|
||||||
|
wddm->hwDeviceId = NEO::createHwDeviceIdFromAdapterLuid(*osEnvironment, adapterLuid);
|
||||||
|
std::vector<uint8_t> luidData;
|
||||||
|
size_t arraySize = 8;
|
||||||
|
osContext->getDeviceLuidArray(luidData, arraySize);
|
||||||
|
uint64_t luid = 0;
|
||||||
|
memcpy_s(&luid, sizeof(uint64_t), luidData.data(), sizeof(uint8_t) * luidData.size());
|
||||||
|
EXPECT_NE(luid, (uint64_t)0);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t waitForSynchronizationObjectFromCpuCounter = 0u;
|
uint64_t waitForSynchronizationObjectFromCpuCounter = 0u;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue