Skip to content

Improve SYCL error handling - #58

Merged
szymon-zadworny merged 1 commit into
oneapi-src:mainfrom
bratpiorka:rrudnick_errors
Oct 29, 2026
Merged

szymon-zadworny merged 1 commit into
oneapi-src:mainfrom
bratpiorka:rrudnick_errors

Conversation

@bratpiorka

@bratpiorka bratpiorka commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Improve SYCL error handling

@bratpiorka
bratpiorka force-pushed the rrudnick_errors branch 4 times, most recently from 82a3a4f to 66eb5e5 Compare October 28, 2026 09:10

@szymon-zadworny szymon-zadworny left a comment

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.

Most of the provided queue constructors cannot fail as per the SYCL 2020 spec. Please revert the mentioned changes and any of their usage sites to the previous state.

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.

This change moves more logic to the C++ side without additional benefits. Revert this.

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.

This change moves more logic to the C++ side. Revert this.

Comment thread sycl/sycl-rs-sys/src/queue-sys.rs Outdated
fn new_queue() -> UniquePtr<Queue>;
fn new_queue_immediate() -> UniquePtr<Queue>;
fn new_queue_from_device(device: &Device) -> UniquePtr<Queue>;
fn new_queue() -> Result<UniquePtr<Queue>>;

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.

This cannot fail. Quoting the spec:

default_selector_v

Select a SYCL device from any supported SYCL
backend based on an implementation-defined
heuristic. Since all implementations must support
at least one device
, this selector must always
return a device.

Revert this.

Comment thread sycl/sycl-rs-sys/src/queue-sys.rs Outdated
fn new_queue_from_device(device: &Device) -> UniquePtr<Queue>;
fn new_queue() -> Result<UniquePtr<Queue>>;
fn new_queue_immediate() -> Result<UniquePtr<Queue>>;
fn new_queue_from_device(device: &Device) -> Result<UniquePtr<Queue>>;

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.

This cannot fail - the spec doesn't mention any exceptions for queue(device const &).

Revert this.

Comment thread sycl/sycl-rs-sys/src/queue-sys.rs Outdated
fn new_queue_immediate() -> UniquePtr<Queue>;
fn new_queue_from_device(device: &Device) -> UniquePtr<Queue>;
fn new_queue() -> Result<UniquePtr<Queue>>;
fn new_queue_immediate() -> Result<UniquePtr<Queue>>;

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.

This cannot fail. The spec doesn't mention any crashes w.r.t. creating an in-order queue, and the sycl_ext_intel_queue_immediate_command_list extension mentions that the immediate property is just a hint which is ignored on non-matching devices.

Revert this.

Comment thread sycl/sycl-rs/examples/sycl-ls.rs Outdated
use sycl_rs::prelude::*;

fn main() {
fn main() -> sycl_rs::Result<()> {

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.

Revert this.

Comment thread sycl/sycl-rs/examples/sycl-ls.rs Outdated
);
}
}
Ok(())

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.

Revert this.


fn main() -> sycl_rs::Result<()> {
let mut queue = Queue::new();
let mut queue = Queue::new()?;

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.

Revert this.

Comment thread sycl/sycl-rs/examples/kernel_launch.rs Outdated
#[tokio::main]
async fn main() -> sycl_rs::Result<()> {
let mut queue = Queue::new();
let mut queue = Queue::new()?;

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.

Revert this.

Comment thread sycl/sycl-rs/benches/batch_memcpy.rs Outdated
let copy_count = buf_count / 2;

let mut queue = Queue::new();
let mut queue = Queue::new()?;

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.

Revert this.

@bratpiorka

Copy link
Copy Markdown
Contributor Author

@szymon-zadworny please re-review

Comment thread sycl/sycl-rs/src/queue.rs Outdated
Comment on lines +33 to +43
impl Queue {
/// Construct a `Queue` based on the device returned from the default selector.
///
/// A C++ exception during device selection or queue construction terminates the process.
pub fn new() -> Self {
Self(ffi::new_queue())
}

/// Construct an immediate `Queue` based on the device returned from the default selector.
///
/// A C++ exception during device selection or queue construction terminates the process.

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.

These comments are redundant since these methods shouldn't throw exceptions in the first place as per the standard. If these methods cause a crash this is a SYCL runtime bug which shouldn't happen on conformant SYCL implementations.

@szymon-zadworny

Copy link
Copy Markdown
Contributor
jackpot

@szymon-zadworny
szymon-zadworny merged commit db1cd36 into oneapi-src:main Oct 29, 2026
10 checks passed
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