Skip to content

Commit cce700d

Browse files
authored
[SYCL] Add diagnostic on invalid device list (#1906)
1 parent 855d214 commit cce700d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

sycl/source/detail/platform_impl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ static std::vector<DevDescT> getAllowListDesc() {
126126
valuePtr = &decDescs.back().devDriverVer;
127127
size = &decDescs.back().devDriverVerSize;
128128
str += sizeof(driverVerStr) - 1;
129+
} else {
130+
throw sycl::runtime_error("Unrecognized key in device allowlist",
131+
PI_INVALID_VALUE);
129132
}
130133

131134
if (':' != *str)

sycl/test/config/allowlist.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// RUN: env TEST_DEVICE_AVAILABLE=1 env SYCL_CONFIG_FILE_NAME=%t2.conf %t.out
99
//
1010
// RUN: env TEST_DEVICE_IS_NOT_AVAILABLE=1 env SYCL_DEVICE_ALLOWLIST="PlatformName:{{SUCH NAME DOESN'T EXIST}}" %t.out
11+
// RUN: env TEST_INCORRECT_VALUE=1 env SYCL_DEVICE_ALLOWLIST="IncorrectKey:{{.*}}" %t.out
1112

1213
#include <CL/sycl.hpp>
1314
#include <iostream>
@@ -86,5 +87,16 @@ int main() {
8687
return 0;
8788
}
8889

90+
if (getenv("TEST_INCORRECT_VALUE")) {
91+
try {
92+
sycl::platform::get_platforms();
93+
} catch (sycl::runtime_error &E) {
94+
const std::string ExpectedMsg("Unrecognized key in device allowlist");
95+
const std::string GotMessage(E.what());
96+
const bool CorrectMeg = GotMessage.find(ExpectedMsg) != std::string::npos;
97+
return CorrectMeg ? 0 : 1;
98+
}
99+
}
100+
89101
throw std::runtime_error("Unhandled situation");
90102
}

0 commit comments

Comments
 (0)