Skip to content

Commit 74610cc

Browse files
[SYCL][E2E] Remove WA (device selector usage) for allowlist test (#16623)
Signed-off-by: Tikhomirova, Kseniya <[email protected]>
1 parent f43153f commit 74610cc

File tree

1 file changed

+37
-25
lines changed

1 file changed

+37
-25
lines changed

sycl/test-e2e/Config/allowlist.cpp

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
// REQUIRES: opencl && cpu
21
// RUN: %{build} -o %t.out
32
//
4-
// FIXME: Using ONEAPI_DEVICE_SELECTOR=\*:cpu results in seg. faults that I
5-
// cannot reproduce under gdb.
6-
// RUN: env PRINT_DEVICE_INFO=1 ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run-unfiltered-devices} %t.out > %t1.conf
7-
// RUN: env TEST_DEVICE_AVAILABLE=1 env SYCL_CONFIG_FILE_NAME=%t1.conf ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run-unfiltered-devices} %t.out
3+
// RUN: env PRINT_DEVICE_INFO=1 %{run-unfiltered-devices} %t.out > %t1.conf
4+
// RUN: env TEST_DEVICE_AVAILABLE=1 env SYCL_CONFIG_FILE_NAME=%t1.conf %{run-unfiltered-devices} %t.out
85
//
9-
// RUN: env PRINT_PLATFORM_INFO=1 ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run-unfiltered-devices} %t.out > %t2.conf
10-
// RUN: env TEST_DEVICE_AVAILABLE=1 env SYCL_CONFIG_FILE_NAME=%t2.conf ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run-unfiltered-devices} %t.out
6+
// RUN: env PRINT_PLATFORM_INFO=1 %{run-unfiltered-devices} %t.out > %t2.conf
7+
// RUN: env TEST_PLATFORM_AVAILABLE=1 env SYCL_CONFIG_FILE_NAME=%t2.conf %{run-unfiltered-devices} %t.out
118
//
12-
// RUN: env TEST_DEVICE_IS_NOT_AVAILABLE=1 env SYCL_DEVICE_ALLOWLIST="PlatformName:{{SUCH NAME DOESN'T EXIST}}" ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run-unfiltered-devices} %t.out
13-
// RUN: env TEST_INCORRECT_VALUE=1 env SYCL_DEVICE_ALLOWLIST="IncorrectKey:{{.*}}" ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run-unfiltered-devices} %t.out
9+
// RUN: env TEST_DEVICE_IS_NOT_AVAILABLE=1 env SYCL_DEVICE_ALLOWLIST="PlatformName:{{SUCH NAME DOESN'T EXIST}}" %{run-unfiltered-devices} %t.out
10+
// RUN: env TEST_INCORRECT_VALUE=1 env SYCL_DEVICE_ALLOWLIST="IncorrectKey:{{.*}}" %{run-unfiltered-devices} %t.out
1411

1512
#include "../helpers.hpp"
1613
#include <algorithm>
@@ -20,6 +17,16 @@
2017
#include <string>
2118
#include <sycl/detail/core.hpp>
2219

20+
static bool isIdenticalDevices(const std::vector<sycl::device> &Devices) {
21+
return std::all_of(
22+
Devices.cbegin(), Devices.cend(), [&](const sycl::device &Dev) {
23+
return (Dev.get_info<sycl::info::device::name>() ==
24+
Devices.at(0).get_info<sycl::info::device::name>()) &&
25+
(Dev.get_info<sycl::info::device::driver_version>() ==
26+
Devices.at(0).get_info<sycl::info::device::driver_version>());
27+
});
28+
}
29+
2330
static void replaceSpecialCharacters(std::string &Str) {
2431
// Replace common special symbols with '.' which matches to any character
2532
std::replace_if(
@@ -48,7 +55,7 @@ int main() {
4855

4956
return 0;
5057
}
51-
throw std::runtime_error("No device is found");
58+
throw std::runtime_error("No platform is found");
5259
}
5360

5461
// Expected that the allowlist filter is not set
@@ -74,12 +81,15 @@ int main() {
7481
// Expected the allowlist to be set with the "PRINT_DEVICE_INFO" run result
7582
if (env::isDefined("TEST_DEVICE_AVAILABLE")) {
7683
for (const sycl::platform &Platform : sycl::platform::get_platforms()) {
77-
if (Platform.get_devices().size() != 1)
84+
auto Devices = Platform.get_devices();
85+
if (Devices.empty())
86+
throw std::runtime_error("No device is found");
87+
88+
if (!(Devices.size() == 1 || isIdenticalDevices(Devices)))
7889
throw std::runtime_error("Expected only one device.");
7990

8091
return 0;
8192
}
82-
throw std::runtime_error("No device is found");
8393
}
8494

8595
// Expected the allowlist to be set but empty
@@ -89,26 +99,28 @@ int main() {
8999
return 0;
90100
}
91101

102+
// Expected the allowlist to be set with the "PRINT_PLATFORM_INFO" run result
103+
if (env::isDefined("TEST_PLATFORM_AVAILABLE")) {
104+
auto Platforms = sycl::platform::get_platforms();
105+
if (Platforms.empty())
106+
throw std::runtime_error("No platform is found");
107+
else if (Platforms.size() != 1)
108+
throw std::runtime_error("Expected only one platform.");
109+
110+
return 0;
111+
}
112+
92113
if (env::isDefined("TEST_INCORRECT_VALUE")) {
93114
try {
94115
sycl::platform::get_platforms();
95116
} catch (sycl::exception &E) {
96-
// Workaround to make CI pass.
97-
// TODO: after the submission of PR intel/llvm:3826, create PR to
98-
// intel/llvm-test-suite with removal of 1st parameter of the vector,
99-
// and transformation of std::vector<std::string> to std::string
100-
const std::vector<std::string> ExpectedMsgs{
101-
"Unrecognized key in device allowlist",
117+
const std::string ExpectedMsg{
102118
"Unrecognized key in SYCL_DEVICE_ALLOWLIST"};
103119
const std::string GotMessage(E.what());
104-
bool CorrectMsg = false;
105-
for (const auto &ExpectedMsg : ExpectedMsgs) {
106-
if (GotMessage.find(ExpectedMsg) != std::string::npos) {
107-
CorrectMsg = true;
108-
break;
109-
}
120+
if (GotMessage.find(ExpectedMsg) != std::string::npos) {
121+
return 0;
110122
}
111-
return CorrectMsg ? 0 : 1;
123+
return 1;
112124
}
113125
}
114126

0 commit comments

Comments
 (0)