Skip to content

[OneAPI GPU] Add OneAPI (SYCL) GPU Runtime Functions.#38134

Open
kranipa wants to merge 1 commit into
jax-ml:mainfrom
Intel-tensorflow:oneapi_sycl_runtime
Open

[OneAPI GPU] Add OneAPI (SYCL) GPU Runtime Functions.#38134
kranipa wants to merge 1 commit into
jax-ml:mainfrom
Intel-tensorflow:oneapi_sycl_runtime

Conversation

@kranipa
Copy link
Copy Markdown
Contributor

@kranipa kranipa commented Jun 2, 2026

This PR introduces following changes.

  1. It adds the OneAPI (SYCL) GPU runtime.
  2. ./jaxlib/oneapi/ contains runtime files and necessary type aliases under vendor.h and gpu_kernel_helpers.h overloads.
  3. OneAPI guards area added in gpu_kernel_helpers.cc for those functions where OneAPI/SYCL has no equivalent.

@agramesh1 agramesh1 requested a review from hawkinsp June 2, 2026 16:00
@agramesh1
Copy link
Copy Markdown

CC @penpornk

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces OneAPI/SYCL GPU runtime wrappers for JAX, adding runtime helper functions, Bazel build targets, and mapping GPU abstractions to SYCL equivalents. The review feedback highlights a standard-compliance issue in SyclSuccess() where sycl::errc::success is used instead of the standard std::error_code(0, ::sycl::sycl_category()). Additionally, minor improvements are suggested to fix typos and update documentation comments to align with this standard-compliant implementation.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +144 to +146
inline std::error_code SyclSuccess() {
return sycl::make_error_code(sycl::errc::success);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The SYCL 2020 standard (sycl::errc enum class) does not define a success error code. Using sycl::errc::success is non-standard and will cause compilation failures on standard-compliant SYCL implementations (such as OpenSYCL/hipSYCL or future conforming toolchains).

To construct a standard-compliant success std::error_code in the SYCL category, you should use std::error_code(0, sycl::sycl_category()) instead.

Suggested change
inline std::error_code SyclSuccess() {
return sycl::make_error_code(sycl::errc::success);
}
inline std::error_code SyclSuccess() {
return std::error_code(0, ::sycl::sycl_category());
}

Comment thread jaxlib/gpu/vendor.h
Comment on lines +886 to +892
// Reference:
// https://github.khronos.org/SYCL_Reference/iface/exception.html#standard-sycl-error-codes
// SYCL application never throws an exception with "sucess" error code, and no
// other code has the value zero therfore, construct a std::error_code with
// sycl::errc::success to represent gpuSuccess ("not an error"). Success paths
// must return gpuSuccess (sycl category); a bare std::error_code{} is generic
// category and will fail CHECK_EQ.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Update the comment to reflect the standard-compliant implementation of SyclSuccess() using sycl::sycl_category() and fix the typos ('sucess' -> 'success', 'therfore' -> 'therefore').

Suggested change
// Reference:
// https://github.khronos.org/SYCL_Reference/iface/exception.html#standard-sycl-error-codes
// SYCL application never throws an exception with "sucess" error code, and no
// other code has the value zero therfore, construct a std::error_code with
// sycl::errc::success to represent gpuSuccess ("not an error"). Success paths
// must return gpuSuccess (sycl category); a bare std::error_code{} is generic
// category and will fail CHECK_EQ.
// Reference:
// https://github.khronos.org/SYCL_Reference/iface/exception.html#standard-sycl-error-codes
// A standard SYCL application uses `sycl::sycl_category()` for SYCL errors.
// Since a default-constructed `std::error_code` uses the generic category,
// it would fail `CHECK_EQ` when compared against a SYCL error code.
// Therefore, we construct a `std::error_code` with value `0` and the
// `sycl::sycl_category()` to represent `gpuSuccess`.

Comment on lines +254 to +258
// OneAPI/SYCL has no equivalent of cusolver/cublas/cusparse status types;
// no ErrorString overloads will be added here.
// The HIP ErrorString overloads were in #else rather than under a
// JAX_GPU_HIP guard, which has be added above elif DEFINED(JAX_GPU_HIP) to
// avoid compiling for OneAPI/SYCL.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Fix typos in the comment ('has be added' -> 'has been added', 'elif DEFINED' -> 'elif defined') to improve readability and maintain professional code quality.

Suggested change
// OneAPI/SYCL has no equivalent of cusolver/cublas/cusparse status types;
// no ErrorString overloads will be added here.
// The HIP ErrorString overloads were in #else rather than under a
// JAX_GPU_HIP guard, which has be added above elif DEFINED(JAX_GPU_HIP) to
// avoid compiling for OneAPI/SYCL.
// OneAPI/SYCL has no equivalent of cusolver/cublas/cusparse status types;
// no ErrorString overloads will be added here.
// The HIP ErrorString overloads were in #else rather than under a
// JAX_GPU_HIP guard, which has been added above with elif defined(JAX_GPU_HIP)
// to avoid compiling for OneAPI/SYCL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants