Repository navigation
Pass the SYCL submission error to SyclKernelSubmitError - #2414
antonwolfy wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change that exposes SYCL submission failure details in Python exceptions.
No open issues 🎉
What changed in this PR
This PR carries SYCL kernel submission failure details from the C API into Python exceptions, making launch errors diagnosable without enabling verbose logging.
Changes:
- Adds thread-local submission error storage and a C API accessor, clearing the error on successful submission.
- Includes the runtime error reason in
SyclKernelSubmitErrorand adds C API and Python regression tests. - Documents the compiler option for larger launch ranges and records the changes in the changelog.
| File | Description |
|---|---|
libsyclinterface/tests/test_sycl_queue_submit.cpp |
Tests error retrieval and clearing after successful submission. |
libsyclinterface/source/dpctl_sycl_queue_interface.cpp |
Stores submission errors per thread and implements the accessor. |
libsyclinterface/include/syclinterface/dpctl_sycl_queue_interface.h |
Declares the accessor and documents string ownership and lifetime. |
dpctl/tests/test_sycl_kernel_submit.py |
Checks that submission exceptions include an error reason. |
dpctl/compiler/_compiler.pyx |
Documents the compiler option for larger launch ranges. |
dpctl/_sycl_queue.pyx |
Appends submission error details to Python exceptions. |
dpctl/_backend.pxd |
Exposes the new C API accessor to Cython. |
CHANGELOG.md |
Records the new accessor, improved exceptions, and documentation. |
Review effort: Balanced
|
View rendered docs @ https://intelpython.github.io/dpctl/pulls/2414/index.html |
DPCTLQueue_SubmitRange and DPCTLQueue_SubmitNDRange catch the exception thrown by sycl::queue::submit and return NULL, so Python only got "Kernel submission to Sycl queue failed." and the reason was printed only with DPCTL_VERBOSITY set. Both functions now keep the reason in a thread-local string, available through the new DPCTLQueue_GetLastSubmitError C-API function, and SyclQueue.submit_async appends it to the SyclKernelSubmitError message. Also document in create_kernel_bundle_from_sycl_source that, starting with DPC++ 2026.2, kernels launched over more than INT_MAX work-items must be compiled with -fno-sycl-id-queries-fit-in-int in copts.
d9f2ded to
a718e18
Compare
A global range that is not a multiple of the local range is accepted by OpenCL devices supporting non-uniform work-groups, e.g. the OpenCL CPU device used in CI, so the submission did not fail there. A local range twice the device's maximum work-group size is rejected on every device.
| * Removed the deprecated `dpctl.program` submodule, use `dpctl.compiler` instead [gh-2407](https://github.com/IntelPython/dpctl/pull/2407) | ||
|
|
||
| ### Fixed | ||
| * `dpctl.SyclKernelSubmitError` raised by `dpctl.SyclQueue.submit` and `dpctl.SyclQueue.submit_async` now includes the reason reported by the SYCL runtime, and the `dpctl.compiler.create_kernel_bundle_from_sycl_source` docstring documents the `-fno-sycl-id-queries-fit-in-int` option needed with DPC++ 2026.2 to launch kernels over more than `INT_MAX` work-items [gh-2414](https://github.com/IntelPython/dpctl/pull/2414) |
There was a problem hiding this comment.
These are two separate changes, can we split them into two entries?
| * `dpctl.SyclKernelSubmitError` raised by `dpctl.SyclQueue.submit` and `dpctl.SyclQueue.submit_async` now includes the reason reported by the SYCL runtime, and the `dpctl.compiler.create_kernel_bundle_from_sycl_source` docstring documents the `-fno-sycl-id-queries-fit-in-int` option needed with DPC++ 2026.2 to launch kernels over more than `INT_MAX` work-items [gh-2414](https://github.com/IntelPython/dpctl/pull/2414) | |
| * `dpctl.SyclKernelSubmitError` raised by `dpctl.SyclQueue.submit` and `dpctl.SyclQueue.submit_async` now includes the reason reported by the SYCL runtime [gh-2414](https://github.com/IntelPython/dpctl/pull/2414) | |
| * `dpctl.compiler.create_kernel_bundle_from_sycl_source` docstring now documents the `-fno-sycl-id-queries-fit-in-int` option needed with DPC++ 2026.2 to launch kernels over more than `INT_MAX` work-items [gh-2414](https://github.com/IntelPython/dpctl/pull/2414) |
| #include <exception> | ||
| #include <sstream> | ||
| #include <stdexcept> | ||
| #include <string> |
There was a problem hiding this comment.
std::nullptr_t is from <cstddef>, which only comes in through <string> transitively. Might as well include it
| #include <string> | |
| #include <cstddef> | |
| #include <string> |
| std::nullptr_t | ||
| submit_failed(const std::string &Msg, const char *func_name, int line_num) | ||
| { | ||
| last_submit_error = Msg; |
There was a problem hiding this comment.
This runs inside the catch handlers, so a bad_alloc here would escape through the extern "C" functions. Not new, error_handler already builds a stringstream in the same spot, but a try/catch (...) around the assignment would cover it
| EXPECT_NO_FATAL_FAILURE( | ||
| ERef = DPCTLQueue_SubmitNDRange(kernel, QRef, args, argTypes, 4, gRange, | ||
| lRange, RANGE_NDIMS, nullptr, 0)); | ||
| ASSERT_TRUE(ERef == nullptr); |
There was a problem hiding this comment.
If this or the ASSERT_TRUE(ERef != nullptr) below fails, the test returns early and leaks a, b, c and the kernel. Only matters when the test is already failing, and other tests here do the same, so minor
|
|
||
| if Eref is NULL: | ||
| # the C API keeps the reason, e.g. the text of the SYCL exception | ||
| reason = DPCTLQueue_GetLastSubmitError().decode( |
There was a problem hiding this comment.
Nothing between the submit and this read touches the thread-local now, but reading the error right after DPCTLQueue_Submit* (before the free calls) would make that ordering explicit
Kernels built by
dpctl.compiler.create_kernel_bundle_from_sycl_sourceget the defaultintID range. With DPC++ 2026.2 the runtime checks it at each launch, so a launch over more thanINT_MAXwork-items fails unless-fno-sycl-id-queries-fit-in-intis passed incopts. From Python the failure looked like this:The reason was printed only with
DPCTL_VERBOSITY=warning, becauseDPCTLQueue_SubmitRangeandDPCTLQueue_SubmitNDRangecatch the SYCL exception and returnNULL. Other submission errors were hidden the same way.This PR:
DPCTLQueue_SubmitRange/DPCTLQueue_SubmitNDRangecall in a thread-local string and adds theDPCTLQueue_GetLastSubmitErrorC-API function to read it. A successful call clears it. The existing function signatures don't change.SyclKernelSubmitErrormessage raised bySyclQueue.submit_asyncandSyclQueue.submit. The same launch now raises:-fno-sycl-id-queries-fit-in-intundercoptsin thecreate_kernel_bundle_from_sycl_sourcedocstring.Tested with DPC++ 2026.2 on OpenCL CPU and Level Zero GPU: an
nd_rangelaunch over 2,147,483,712 work-items raises the message above without the option, and runs with the right result with it. New tests: the C-API testTestQueueSubmit.CheckLastSubmitErrorand the Python testtest_submit_error_message, which submit annd_rangewhose global range is not a multiple of the local range. The full test suites pass: C-API tests 2505 passed, Python 3178 passed, 1120 skipped, 1 xfailed.