Exceptions

sycl::exception

class exception;

See also

SYCL Specification Section 4.15.2

Container for an exception that occurs during execution. Synchronous API’s throw exceptions that may be caught with C++ exception handling methods. The SYCL runtime holds exceptions that occur during asynchronous operations until wait_and_throw or throw_asynchronous is called. They runtime delivers the exception as a list to the sycl::async_handler associated with the sycl::queue.

what

const char *what() const;

Returns string that describes the error that triggered the exception.

has_context

bool has_context() const;

Returns true if error has an associated sycl::context.

get_context

sycl::context get_context() const;

Returns sycl::context associated with this error.

get_cl_code

cl_int get_cl_code() const;

Returns OpenCL error code if the error is an OpenCL error, otherwise CL_SUCCESS.

sycl::exception_list

class exception_list;

An exContainer for a list of asychronous exceptions that occur in the same queue. Re

Member types

value_type

reference

const_reference

size_type

iterator

const_iterator

size

size_type size() const;

Returns number of elements in the list.

begin

iterator begin() const;

Returns an iterator to the beginning of the list of exceptions.

end

iterator end() const;

Returns an iterator to the beginning of the list of exceptions.

Derived exceptions

sycl::runtime_error

class runtime_error : public exception;

sycl::kernel_error

class kernel_error : public runtime_error;

Error that occured before or while enqueuing the SYCL kernel.

sycl::accessor_error

class accessor_error : public runtime_error;

Error regarding Accessors.

sycl::nd_range_error

class nd_range_error : public runtime_error;

Error regarding the sycl::nd_range for a SYCL kernel.

sycl::event_error

class event_error : public runtime_error;

Error regarding an sycl::event.

sycl::invalid_parameter_error

class invalid_parameter_error : public runtime_error;

Error regarding parameters to a SYCL kernel, including captured parameters to a lambda.

sycl::device_error

class device_error : public exception;

sycl::compile_program_error

class compile_program_error : public sycl::device_error;

Error while compiling a SYCL kernel.

sycl::invalid_object_error

class invalid_object_error : public sycl::device_error;

Error regarding memory objects used inside a kernel.

sycl::memory_allocation_error

class memory_allocation_error : public sycl::device_error;

Error regarding memory allocation on the SYCL device.

sycl::platform_error

class platform_error : public sycl::device_error;

Error triggered by the sycl::platform.

sycl::profiling_error

class profiling_error : public sycl::device_error;

Error triggered while profiling is enabled.

sycl::async_handler

void handler(sycl::exception_list e);

Parameters

e

List of asynchronous exceptions. See sycl::exception_list

The SYCL runtime delivers asynchronous exceptions by invoking an async_handler. The handler is passed to a sycl::queue constructor. The SYCL runtime delivers asynchronous exceptions to the handler when wait_and_throw or throw_asynchronous is called.