[OneAPI GPU] Add OneAPI (SYCL) GPU Runtime Functions.#38134
Conversation
…e mapped to vendor.h
|
CC @penpornk |
There was a problem hiding this comment.
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.
| inline std::error_code SyclSuccess() { | ||
| return sycl::make_error_code(sycl::errc::success); | ||
| } |
There was a problem hiding this comment.
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.
| 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()); | |
| } |
| // 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. |
There was a problem hiding this comment.
Update the comment to reflect the standard-compliant implementation of SyclSuccess() using sycl::sycl_category() and fix the typos ('sucess' -> 'success', 'therfore' -> 'therefore').
| // 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`. |
| // 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. |
There was a problem hiding this comment.
Fix typos in the comment ('has be added' -> 'has been added', 'elif DEFINED' -> 'elif defined') to improve readability and maintain professional code quality.
| // 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. |
This PR introduces following changes.
./jaxlib/oneapi/contains runtime files and necessary type aliases undervendor.handgpu_kernel_helpers.hoverloads.gpu_kernel_helpers.ccfor those functions where OneAPI/SYCL has no equivalent.