Skip to content

Commit 67aa1ad

Browse files
jchodorCompute-Runtime-Automation
authored andcommitted
Refactoring HwDeviceId
Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
1 parent b2fae34 commit 67aa1ad

36 files changed

+126
-85
lines changed

level_zero/core/test/unit_tests/sources/driver/linux/test_driver_handle_imp_linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const uint32_t numSubDevices = 2u;
2525
constexpr int mockFd = 0;
2626
class TestDriverMockDrm : public Drm {
2727
public:
28-
TestDriverMockDrm(std::string &bdf, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceId>(mockFd, bdf.c_str()), rootDeviceEnvironment) {}
28+
TestDriverMockDrm(std::string &bdf, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, bdf.c_str()), rootDeviceEnvironment) {}
2929
};
3030

3131
class DriverLinuxFixture : public ::testing::Test {

level_zero/tools/test/unit_tests/sources/sysman/engine/linux/mock_engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class EngineNeoDrm : public Drm {
3434
public:
3535
using Drm::getEngineInfo;
3636
const int mockFd = 0;
37-
EngineNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceId>(mockFd, ""), rootDeviceEnvironment) {}
37+
EngineNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
3838
};
3939
template <>
4040
struct Mock<EngineNeoDrm> : public EngineNeoDrm {

level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace ult {
2626
constexpr int mockFd = 0;
2727
class SysmanMockDrm : public Drm {
2828
public:
29-
SysmanMockDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceId>(mockFd, ""), rootDeviceEnvironment) {}
29+
SysmanMockDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
3030
};
3131

3232
class PublicLinuxSysmanImp : public L0::LinuxSysmanImp {

level_zero/tools/test/unit_tests/sources/sysman/memory/linux/mock_memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class MemoryNeoDrm : public Drm {
3535
public:
3636
using Drm::memoryInfo;
3737
const int mockFd = 33;
38-
MemoryNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceId>(mockFd, ""), rootDeviceEnvironment) {}
38+
MemoryNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
3939
};
4040

4141
template <>

opencl/source/dll/linux/drm_neo_create.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const DeviceDescriptor deviceDescriptorTable[] = {
3131
#undef NAMEDDEVICE
3232
{0, nullptr, nullptr, GTTYPE_UNDEFINED}};
3333

34-
Drm *Drm::create(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
34+
Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
3535
std::unique_ptr<Drm> drmObject;
3636
if (DebugManager.flags.EnableNullHardware.get() == true) {
3737
drmObject.reset(new DrmNullDevice(std::move(hwDeviceId), rootDeviceEnvironment));

opencl/test/unit_test/fixtures/windows/memory_allocator_multi_device_fixture_windows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void MemoryAllocatorMultiDeviceSystemSpecificFixture::SetUp(ExecutionEnvironment
2727
for (auto i = 0u; i < executionEnvironment.rootDeviceEnvironments.size(); i++) {
2828
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[i]->getGmmClientContext(), nullptr, 0, 0, false);
2929
auto wddm = static_cast<WddmMock *>(executionEnvironment.rootDeviceEnvironments[i]->osInterface->getDriverModel()->as<Wddm>());
30-
wddm->hwDeviceId = std::make_unique<HwDeviceId>(ADAPTER_HANDLE, LUID{}, osEnvironment, std::make_unique<UmKmDataTranslator>());
30+
wddm->hwDeviceId = std::make_unique<HwDeviceIdWddm>(ADAPTER_HANDLE, LUID{}, osEnvironment, std::make_unique<UmKmDataTranslator>());
3131
wddm->callBaseMapGpuVa = false;
3232

3333
allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle();

opencl/test/unit_test/linux/drm_wrap.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -9,6 +9,7 @@
99

1010
#include "shared/source/execution_environment/root_device_environment.h"
1111
#include "shared/source/os_interface/linux/drm_neo.h"
12+
#include "shared/source/os_interface/linux/hw_device_id.h"
1213
#include "shared/source/os_interface/os_interface.h"
1314

1415
#include "drm/i915_drm.h"
@@ -20,7 +21,7 @@ class DrmWrap : public NEO::Drm {
2021
static std::unique_ptr<NEO::Drm> createDrm(RootDeviceEnvironment &rootDeviceEnvironment) {
2122
auto hwDeviceIds = OSInterface::discoverDevices(rootDeviceEnvironment.executionEnvironment);
2223
if (!hwDeviceIds.empty()) {
23-
return std::unique_ptr<Drm>{NEO::Drm::create(std::move(hwDeviceIds[0]), rootDeviceEnvironment)};
24+
return std::unique_ptr<Drm>{NEO::Drm::create(std::unique_ptr<HwDeviceIdDrm>(hwDeviceIds[0].release()->as<HwDeviceIdDrm>()), rootDeviceEnvironment)};
2425
}
2526
return nullptr;
2627
}

opencl/test/unit_test/linux/main_linux_dll.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,16 @@ TEST(DrmTest, GivenSelectedExistingDeviceWhenOpenDirSuccedsThenHwDeviceIdsHavePr
122122
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
123123
EXPECT_EQ(1u, hwDeviceIds.size());
124124
EXPECT_NE(nullptr, hwDeviceIds[0].get());
125-
EXPECT_STREQ("test1", hwDeviceIds[0]->getPciPath());
125+
EXPECT_STREQ("test1", hwDeviceIds[0]->as<HwDeviceIdDrm>()->getPciPath());
126126

127127
entryIndex = 0;
128128
openCounter = 2;
129129
hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
130130
EXPECT_EQ(2u, hwDeviceIds.size());
131131
EXPECT_NE(nullptr, hwDeviceIds[0].get());
132-
EXPECT_STREQ("test1", hwDeviceIds[0]->getPciPath());
132+
EXPECT_STREQ("test1", hwDeviceIds[0]->as<HwDeviceIdDrm>()->getPciPath());
133133
EXPECT_NE(nullptr, hwDeviceIds[1].get());
134-
EXPECT_STREQ("test2", hwDeviceIds[1]->getPciPath());
134+
EXPECT_STREQ("test2", hwDeviceIds[1]->as<HwDeviceIdDrm>()->getPciPath());
135135
}
136136

137137
TEST(DrmTest, GivenSelectedExistingDeviceWhenOpenDirFailsThenRetryOpeningRenderDevices) {
@@ -146,16 +146,16 @@ TEST(DrmTest, GivenSelectedExistingDeviceWhenOpenDirFailsThenRetryOpeningRenderD
146146
EXPECT_STREQ("/dev/dri/renderD128", lastOpenedPath.c_str());
147147
EXPECT_EQ(1u, hwDeviceIds.size());
148148
EXPECT_NE(nullptr, hwDeviceIds[0].get());
149-
EXPECT_STREQ("00:02.0", hwDeviceIds[0]->getPciPath());
149+
EXPECT_STREQ("00:02.0", hwDeviceIds[0]->as<HwDeviceIdDrm>()->getPciPath());
150150

151151
openCounter = 2;
152152
hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
153153
EXPECT_STREQ("/dev/dri/renderD129", lastOpenedPath.c_str());
154154
EXPECT_EQ(2u, hwDeviceIds.size());
155155
EXPECT_NE(nullptr, hwDeviceIds[0].get());
156-
EXPECT_STREQ("00:02.0", hwDeviceIds[0]->getPciPath());
156+
EXPECT_STREQ("00:02.0", hwDeviceIds[0]->as<HwDeviceIdDrm>()->getPciPath());
157157
EXPECT_NE(nullptr, hwDeviceIds[1].get());
158-
EXPECT_STREQ("00:03.0", hwDeviceIds[1]->getPciPath());
158+
EXPECT_STREQ("00:03.0", hwDeviceIds[1]->as<HwDeviceIdDrm>()->getPciPath());
159159
}
160160

161161
TEST(DrmTest, givenPrintIoctlEntriesWhenCallIoctlThenIoctlIsPrinted) {
@@ -286,9 +286,9 @@ TEST(DrmTest, GivenFailingOpenDirAndMultipleAvailableDevicesWhenCreateMultipleRo
286286
EXPECT_STREQ("/dev/dri/renderD129", lastOpenedPath.c_str());
287287
EXPECT_EQ(requestedNumRootDevices, hwDeviceIds.size());
288288
EXPECT_NE(nullptr, hwDeviceIds[0].get());
289-
EXPECT_STREQ("00:02.0", hwDeviceIds[0]->getPciPath());
289+
EXPECT_STREQ("00:02.0", hwDeviceIds[0]->as<HwDeviceIdDrm>()->getPciPath());
290290
EXPECT_NE(nullptr, hwDeviceIds[1].get());
291-
EXPECT_STREQ("00:03.0", hwDeviceIds[1]->getPciPath());
291+
EXPECT_STREQ("00:03.0", hwDeviceIds[1]->as<HwDeviceIdDrm>()->getPciPath());
292292
}
293293

294294
TEST(DrmTest, GivenMultipleAvailableDevicesWhenCreateMultipleRootDevicesFlagIsSetThenTheFlagIsRespected) {
@@ -304,9 +304,9 @@ TEST(DrmTest, GivenMultipleAvailableDevicesWhenCreateMultipleRootDevicesFlagIsSe
304304
EXPECT_STREQ("/dev/dri/by-path/pci-0000:test2-render", lastOpenedPath.c_str());
305305
EXPECT_EQ(requestedNumRootDevices, hwDeviceIds.size());
306306
EXPECT_NE(nullptr, hwDeviceIds[0].get());
307-
EXPECT_STREQ("test1", hwDeviceIds[0]->getPciPath());
307+
EXPECT_STREQ("test1", hwDeviceIds[0]->as<HwDeviceIdDrm>()->getPciPath());
308308
EXPECT_NE(nullptr, hwDeviceIds[1].get());
309-
EXPECT_STREQ("test2", hwDeviceIds[1]->getPciPath());
309+
EXPECT_STREQ("test2", hwDeviceIds[1]->as<HwDeviceIdDrm>()->getPciPath());
310310
}
311311

312312
TEST(DrmTest, GivenSelectedIncorectDeviceWhenGetDeviceFdThenFail) {

opencl/test/unit_test/mocks/mock_wddm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
using namespace NEO;
2424

25-
struct mockHwDeviceId : public HwDeviceId {
26-
using HwDeviceId::osEnvironment;
25+
struct mockHwDeviceId : public HwDeviceIdWddm {
26+
using HwDeviceIdWddm::osEnvironment;
2727
};
2828

29-
WddmMock::WddmMock(RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::make_unique<HwDeviceId>(ADAPTER_HANDLE, LUID{}, rootDeviceEnvironment.executionEnvironment.osEnvironment.get(), std::make_unique<UmKmDataTranslator>()), rootDeviceEnvironment) {
29+
WddmMock::WddmMock(RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::make_unique<HwDeviceIdWddm>(ADAPTER_HANDLE, LUID{}, rootDeviceEnvironment.executionEnvironment.osEnvironment.get(), std::make_unique<UmKmDataTranslator>()), rootDeviceEnvironment) {
3030
if (!rootDeviceEnvironment.executionEnvironment.osEnvironment.get()) {
3131
rootDeviceEnvironment.executionEnvironment.osEnvironment = std::make_unique<OsEnvironmentWin>();
3232
}

opencl/test/unit_test/mocks/mock_wddm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class WddmMock : public Wddm {
4848
using Wddm::timestampFrequency;
4949
using Wddm::wddmInterface;
5050

51-
WddmMock(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::move(hwDeviceId), rootDeviceEnvironment) {}
51+
WddmMock(std::unique_ptr<HwDeviceIdWddm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::move(hwDeviceId), rootDeviceEnvironment) {}
5252
WddmMock(RootDeviceEnvironment &rootDeviceEnvironment);
5353
~WddmMock();
5454

0 commit comments

Comments
 (0)