-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for L0 to read Device LUID from the WDDM driver using EXT Pro…
…perties - 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 <[email protected]>
- Loading branch information
1 parent
f0888fe
commit af3dd28
Showing
16 changed files
with
458 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
level_zero/core/source/device/device_imp_drm/device_imp.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
36 changes: 36 additions & 0 deletions
36
level_zero/core/source/device/device_imp_drm_or_wddm/device_imp.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
28 changes: 28 additions & 0 deletions
28
level_zero/core/source/device/device_imp_wddm/device_imp.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
level_zero/core/test/unit_tests/sources/device/device_drm/test_device.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
135 changes: 135 additions & 0 deletions
135
level_zero/core/test/unit_tests/sources/device/device_drm_or_wddm/test_device.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.