Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Make ONEAPI_DEVICE_SELECTOR reject an empty string #12851

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sycl/source/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ template <> class SYCLConfig<ONEAPI_DEVICE_SELECTOR> {
}
const char *ValStr = BaseT::getRawValue();
if (ValStr) {
// Throw if the input string is empty.
if (ValStr[0] == '\0')
throw invalid_parameter_error(
"Invalid value for ONEAPI_DEVICE_SELECTOR environment "
"variable: value should not be null.",
PI_ERROR_INVALID_VALUE);

DeviceTargets =
&GlobalHandler::instance().getOneapiDeviceSelectorTargets(ValStr);
}
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/OneapiDeviceSelector/illegal_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// RUN: env ONEAPI_DEVICE_SELECTOR="level_zero:" %{run-unfiltered-devices} %t.out
// RUN: env ONEAPI_DEVICE_SELECTOR="level_zero:::gpu" %{run-unfiltered-devices} %t.out
// RUN: env ONEAPI_DEVICE_SELECTOR="level_zero:.1" %{run-unfiltered-devices} %t.out
// RUN: env ONEAPI_DEVICE_SELECTOR="" %{run-unfiltered-devices} %t.out
// XFAIL: *

// Calling ONEAPI_DEVICE_SELECTOR with an illegal input should result in an
Expand Down
4 changes: 3 additions & 1 deletion sycl/test/basic_tests/device-selectors-exception.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER="" %t.out
// RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fsycl-targets=%sycl_triple -fpreview-breaking-changes %s -o %t.out %}
// RUN: %if preview-breaking-changes-supported %{ env ONEAPI_DEVICE_SELECTOR="" %t.out %}
// ONEAPI_DEVICE_SELECTOR="*:-1" causes this test to not select any device at
// all.
// RUN: %if preview-breaking-changes-supported %{ env ONEAPI_DEVICE_SELECTOR="*:-1" %t.out %}

#include <sycl/sycl.hpp>
using namespace sycl;
Expand Down
Loading