Skip to content

[SYCL] Add "ext_oneapi_offload" backend enum value #18683

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

Merged
merged 2 commits into from
Jun 5, 2025
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
6 changes: 6 additions & 0 deletions sycl/include/sycl/backend_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum class backend : char {
// ext_intel_esimd_emulator = 5,
ext_oneapi_hip = 6,
ext_oneapi_native_cpu = 7,
ext_oneapi_offload = 8,
};

template <backend Backend> class backend_traits;
Expand Down Expand Up @@ -56,6 +57,9 @@ inline std::ostream &operator<<(std::ostream &Out, backend be) {
case backend::ext_oneapi_native_cpu:
Out << "ext_oneapi_native_cpu";
break;
case backend::ext_oneapi_offload:
Out << "ext_oneapi_offload";
break;
case backend::all:
Out << "all";
}
Expand All @@ -77,6 +81,8 @@ inline std::string_view get_backend_name_no_vendor(backend Backend) {
return "hip";
case backend::ext_oneapi_native_cpu:
return "native_cpu";
case backend::ext_oneapi_offload:
return "offload";
case backend::all:
return "all";
}
Expand Down
2 changes: 2 additions & 0 deletions sycl/source/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ backend convertUrBackend(ur_backend_t UrBackend) {
return backend::ext_oneapi_hip;
case UR_BACKEND_NATIVE_CPU:
return backend::ext_oneapi_native_cpu;
case UR_BACKEND_OFFLOAD:
return backend::ext_oneapi_offload;
default:
throw exception(make_error_code(errc::runtime),
"convertBackend: Unsupported backend");
Expand Down
7 changes: 5 additions & 2 deletions sycl/source/detail/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,17 @@ void dumpConfig() {
// ONEAPI_DEVICE_SELECTOR
// TODO: host device type will be removed once sycl_ext_oneapi_filter_selector
// is removed.
const std::array<std::pair<std::string, backend>, 7> &getSyclBeMap() {
static const std::array<std::pair<std::string, backend>, 7> SyclBeMap = {
const std::array<std::pair<std::string, backend>, 8> &getSyclBeMap() {
static const std::array<std::pair<std::string, backend>, 8> SyclBeMap = {
{{"host", backend::host},
{"opencl", backend::opencl},
{"level_zero", backend::ext_oneapi_level_zero},
{"cuda", backend::ext_oneapi_cuda},
{"hip", backend::ext_oneapi_hip},
{"native_cpu", backend::ext_oneapi_native_cpu},
// Note: Offload is intentionally excluded from our documentation - it's
// only used for internal testing
{"offload", backend::ext_oneapi_offload},
{"*", backend::all}}};
return SyclBeMap;
}
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ getSyclDeviceTypeMap() {

// Array is used by SYCL_DEVICE_FILTER and SYCL_DEVICE_ALLOWLIST and
// ONEAPI_DEVICE_SELECTOR
const std::array<std::pair<std::string, backend>, 7> &getSyclBeMap();
const std::array<std::pair<std::string, backend>, 8> &getSyclBeMap();

// ---------------------------------------
// ONEAPI_DEVICE_SELECTOR support
Expand Down
2 changes: 2 additions & 0 deletions sycl/source/detail/ur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ static void initializeAdapters(std::vector<AdapterPtr> &Adapters,
return backend::ext_oneapi_hip;
case UR_BACKEND_NATIVE_CPU:
return backend::ext_oneapi_native_cpu;
case UR_BACKEND_OFFLOAD:
return backend::ext_oneapi_offload;
default:
// Throw an exception, this should be unreachable.
CHECK_UR_SUCCESS(UR_RESULT_ERROR_INVALID_ENUMERATION)
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/Basic/get_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bool check(backend be) {
case backend::ext_oneapi_cuda:
case backend::ext_oneapi_hip:
case backend::ext_oneapi_native_cpu:
case backend::ext_oneapi_offload:
return true;
default:
return false;
Expand Down
3 changes: 2 additions & 1 deletion sycl/test-e2e/Regression/device_num.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const std::map<backend, std::string> BackendStringMap = {
{backend::ext_oneapi_level_zero, "ext_oneapi_level_zero"},
{backend::ext_oneapi_cuda, "ext_oneapi_cuda"},
{backend::ext_oneapi_hip, "ext_oneapi_hip"},
{backend::ext_oneapi_native_cpu, "ext_oneapi_native_cpu"}};
{backend::ext_oneapi_native_cpu, "ext_oneapi_native_cpu"},
{backend::ext_oneapi_offload, "ext_oneapi_offload"}};

std::string getDeviceTypeName(const device &d) {
auto DeviceType = d.get_info<info::device::device_type>();
Expand Down
2 changes: 1 addition & 1 deletion sycl/unittests/allowlist/ParseAllowList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ TEST(ParseAllowListTests, CheckAllValidBackendNameValuesAreProcessed) {
{{"BackendName", "host"}}, {{"BackendName", "opencl"}},
{{"BackendName", "level_zero"}}, {{"BackendName", "cuda"}},
{{"BackendName", "hip"}}, {{"BackendName", "native_cpu"}},
{{"BackendName", "*"}}};
{{"BackendName", "offload"}}, {{"BackendName", "*"}}};
EXPECT_EQ(ExpectedValue, ActualValue);
}

Expand Down
2 changes: 2 additions & 0 deletions sycl/unittests/helpers/UrMock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ template <sycl::backend Backend = backend::opencl> class UrMock {
return UR_BACKEND_HIP;
case sycl::backend::ext_oneapi_native_cpu:
return UR_BACKEND_NATIVE_CPU;
case sycl::backend::ext_oneapi_offload:
return UR_BACKEND_OFFLOAD;
default:
return UR_BACKEND_UNKNOWN;
}
Expand Down