Skip to content

Commit 8f21e46

Browse files
BartoszDunajskiCompute-Runtime-Automation
authored andcommittedJul 2, 2021
Disallow creating unsupported devices
Signed-off-by: Bartosz Dunajski <[email protected]>
1 parent 2acc0fb commit 8f21e46

File tree

4 files changed

+93
-4
lines changed

4 files changed

+93
-4
lines changed
 

‎opencl/source/dll/get_devices.cpp

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,53 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#include "shared/source/execution_environment/execution_environment.h"
9+
#include "shared/source/execution_environment/root_device_environment.h"
10+
#include "shared/source/helpers/constants.h"
911
#include "shared/source/os_interface/device_factory.h"
1012

1113
#include "opencl/source/command_stream/create_command_stream_impl.h"
1214

1315
namespace NEO {
1416

1517
bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment) {
16-
return prepareDeviceEnvironmentsImpl(executionEnvironment);
18+
auto returnValue = prepareDeviceEnvironmentsImpl(executionEnvironment);
19+
20+
if (DebugManager.flags.Force32BitDriverSupport.get() != -1) {
21+
return returnValue;
22+
}
23+
24+
if (returnValue) {
25+
auto i = 0u;
26+
while (i < executionEnvironment.rootDeviceEnvironments.size()) {
27+
bool unsupportedDeviceDetected = false;
28+
29+
auto &featureTable = executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo()->featureTable;
30+
if (!featureTable.ftrRcsNode && !featureTable.ftrCCSNode) {
31+
unsupportedDeviceDetected = true;
32+
}
33+
34+
if (is32bit) {
35+
#ifdef SUPPORT_XEHP
36+
if (executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo()->platform.eProductFamily == IGFX_XE_HP_SDV) {
37+
unsupportedDeviceDetected = true;
38+
}
39+
#endif
40+
}
41+
42+
if (unsupportedDeviceDetected) {
43+
executionEnvironment.rootDeviceEnvironments.erase(executionEnvironment.rootDeviceEnvironments.begin() + i);
44+
} else {
45+
i++;
46+
}
47+
}
48+
}
49+
50+
return returnValue && executionEnvironment.rootDeviceEnvironments.size() > 0;
1751
}
1852

1953
} // namespace NEO

‎opencl/test/unit_test/test_files/igdrcl.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,4 @@ EnableUserFenceUseCtxId = -1
299299
EnableResourceTags = 0
300300
SetKmdWaitTimeout = -1
301301
OverrideNotifyEnableForTagUpdatePostSync = -1
302+
Force32BitDriverSupport = -1

‎opencl/test/unit_test/windows/get_devices_tests.cpp

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#include "shared/source/execution_environment/execution_environment.h"
99
#include "shared/source/execution_environment/root_device_environment.h"
10+
#include "shared/source/helpers/constants.h"
1011
#include "shared/source/helpers/hw_info.h"
1112
#include "shared/source/os_interface/device_factory.h"
13+
#include "shared/source/os_interface/hw_info_config.h"
14+
#include "shared/test/common/helpers/debug_manager_state_restore.h"
15+
#include "shared/test/common/helpers/default_hw_info.h"
16+
#include "shared/test/common/test_macros/test_checks_shared.h"
1217

1318
#include "test.h"
1419

15-
using namespace NEO;
20+
namespace NEO {
21+
bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment);
1622

1723
using PrepareDeviceEnvironmentsTests = ::testing::Test;
1824

@@ -35,3 +41,50 @@ HWTEST_F(PrepareDeviceEnvironmentsTests, whenPrepareDeviceEnvironmentsIsCalledTh
3541
EXPECT_TRUE(returnValue);
3642
EXPECT_NE(nullptr, executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper());
3743
}
44+
45+
HWTEST_F(PrepareDeviceEnvironmentsTests, Given32bitApplicationWhenPrepareDeviceEnvironmentsIsCalledThenFalseIsReturned) {
46+
REQUIRE_32BIT_OR_SKIP();
47+
DebugManagerStateRestore restore;
48+
DebugManager.flags.NodeOrdinal.set(0); // Dont disable RCS
49+
50+
NEO::ExecutionEnvironment executionEnviornment;
51+
52+
auto returnValue = NEO::prepareDeviceEnvironments(executionEnviornment);
53+
54+
switch (::productFamily) {
55+
case IGFX_UNKNOWN:
56+
#ifdef SUPPORT_XEHP
57+
case IGFX_XE_HP_SDV:
58+
#endif
59+
EXPECT_FALSE(returnValue);
60+
break;
61+
default:
62+
EXPECT_TRUE(returnValue);
63+
break;
64+
}
65+
}
66+
67+
HWTEST_F(PrepareDeviceEnvironmentsTests, givenRcsAndCcsNotSupportedWhenInitializingThenReturnFalse) {
68+
REQUIRE_64BIT_OR_SKIP();
69+
70+
NEO::ExecutionEnvironment executionEnviornment;
71+
HardwareInfo hwInfo = *defaultHwInfo;
72+
73+
auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily);
74+
hwInfoConfig->configureHardwareCustom(&hwInfo, nullptr);
75+
76+
bool expectedValue = false;
77+
if (hwInfo.featureTable.ftrRcsNode || hwInfo.featureTable.ftrCCSNode) {
78+
expectedValue = true;
79+
}
80+
81+
EXPECT_EQ(expectedValue, NEO::prepareDeviceEnvironments(executionEnviornment));
82+
}
83+
84+
HWTEST_F(PrepareDeviceEnvironmentsTests, Given32bitApplicationWhenDebugKeyIsSetThenSupportIsReported) {
85+
NEO::ExecutionEnvironment executionEnviornment;
86+
DebugManagerStateRestore restorer;
87+
DebugManager.flags.Force32BitDriverSupport.set(true);
88+
EXPECT_TRUE(NEO::prepareDeviceEnvironments(executionEnviornment));
89+
}
90+
} // namespace NEO

‎shared/source/debug_settings/debug_variables_base.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableUserFenceForCompletionWait, -1, "-1: defau
282282
DECLARE_DEBUG_VARIABLE(int32_t, EnableUserFenceUseCtxId, -1, "-1: default (enabled), 0: disable, 1: enable : Use Context Id in Wait User Fence when waiting for completion tag")
283283
DECLARE_DEBUG_VARIABLE(int32_t, SetKmdWaitTimeout, -1, "-1: default (infinity), >0: amount of time units for wait function timeout")
284284
DECLARE_DEBUG_VARIABLE(int32_t, OverrideNotifyEnableForTagUpdatePostSync, -1, "-1: default (usage determined by user fence wait call), 0: disable use of NotifyEnable flag, 1: enable use NotifyEnable flag")
285+
DECLARE_DEBUG_VARIABLE(int32_t, Force32BitDriverSupport, -1, "-1: default, 0: disable, 1: enable, Forces the driver to support 32 bit.")
285286

286287
/*EXPERIMENTAL TOGGLES*/
287288
DECLARE_DEBUG_VARIABLE(int32_t, ExperimentalEnableCustomLocalMemoryAlignment, 0, "Align local memory allocations to a given value. Works only with allocations at least as big as the value. 0: no effect, 2097152: 2 megabytes, 1073741824: 1 gigabyte")

0 commit comments

Comments
 (0)