1
- // REQUIRES: opencl && cpu
2
1
// RUN: %{build} -o %t.out
3
2
//
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
8
5
//
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
11
8
//
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
14
11
15
12
#include " ../helpers.hpp"
16
13
#include < algorithm>
20
17
#include < string>
21
18
#include < sycl/detail/core.hpp>
22
19
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
+
23
30
static void replaceSpecialCharacters (std::string &Str) {
24
31
// Replace common special symbols with '.' which matches to any character
25
32
std::replace_if (
@@ -48,7 +55,7 @@ int main() {
48
55
49
56
return 0 ;
50
57
}
51
- throw std::runtime_error (" No device is found" );
58
+ throw std::runtime_error (" No platform is found" );
52
59
}
53
60
54
61
// Expected that the allowlist filter is not set
@@ -74,12 +81,15 @@ int main() {
74
81
// Expected the allowlist to be set with the "PRINT_DEVICE_INFO" run result
75
82
if (env::isDefined (" TEST_DEVICE_AVAILABLE" )) {
76
83
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)))
78
89
throw std::runtime_error (" Expected only one device." );
79
90
80
91
return 0 ;
81
92
}
82
- throw std::runtime_error (" No device is found" );
83
93
}
84
94
85
95
// Expected the allowlist to be set but empty
@@ -89,26 +99,28 @@ int main() {
89
99
return 0 ;
90
100
}
91
101
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
+
92
113
if (env::isDefined (" TEST_INCORRECT_VALUE" )) {
93
114
try {
94
115
sycl::platform::get_platforms ();
95
116
} 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{
102
118
" Unrecognized key in SYCL_DEVICE_ALLOWLIST" };
103
119
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 ;
110
122
}
111
- return CorrectMsg ? 0 : 1 ;
123
+ return 1 ;
112
124
}
113
125
}
114
126
0 commit comments