error_handler Class#

Description

The error_handler class is for thread-safe error handling. oneIPL implementations shall be able to set error flags separately in any thread(s) on any SYCL device(s) and check them in other thread(s) on other device(s). To access the error flag, either for reading or for writing, use an object of the error_accessor class class. It can be obtained via a call to the get_access() method.

Include Files

oneapi/ipl.hpp

Domain Dependencies

Headers: oneapi/ipl.hpp

Libraries: oneipl.lib

Syntax

template<typename ErrorEnumT>
class error_handler#

This class is for thread-safe error handling.

It allows to set an error flag in any thread on any SYCL device and then to check it in another thread on another device. To access the error flag (either for reading or for writing) use an object of error_accessor class (it can be obtained via the call of get_access() method).

Template Parameters:

ErrorEnumT – the type of the error enumeration which items are used as errors by this error handler

Public Types

using error_enum_t = ErrorEnumT#

Alias for the template parameter ErrorEnumT (the type of the error enumeration).

template<sycl::access_mode AccessMode, bool IsHost>
using error_accessor_t = error_accessor<ErrorEnumT, AccessMode, IsHost>#

Alias template for error flag accessor.

Template Parameters:
  • AccessMode – the given access mode (sycl::access_mode)

  • IsHost – the flag that specifies whether this error flag accessor is host (true), or not (false)

template<sycl::access_mode AccessMode>
using host_error_accessor_t = error_accessor_t<AccessMode, true>#

Alias template for host error flag accessor.

Template Parameters:

AccessMode – the given access mode (sycl::access_mode)

template<sycl::access_mode AccessMode>
using device_error_accessor_t = error_accessor_t<AccessMode, false>#

Alias template for device (non-host) error flag accessor.

Template Parameters:

AccessMode – the given access mode (sycl::access_mode)

Public Functions

explicit error_handler(ErrorEnumT default_error_enum)#

Constructs an object of this class and sets the error flag to the given default value default_error_enum.

Parameters:

default_error_enum[in] the value to be used as the default for the error flag

auto get_error() -> ErrorEnumT#

Returns the current value of the error flag on host.

Returns:

the current value of the error flag on host

void set_error(ErrorEnumT error_enum)#

Sets the given value error_enum to the error flag.

Parameters:

error_enum[in] the given value to be set to the error flag

template<sycl::access_mode AccessMode = sycl::access_mode::atomic>
auto get_access() -> host_error_accessor_t<AccessMode>#

Constructs a host error flag accessor corresponding to this handler.

Template Parameters:

AccessMode – the given access mode (sycl::access_mode)

Returns:

a host error flag accessor corresponding to this handler

template<sycl::access_mode AccessMode = sycl::access_mode::atomic>
auto get_access(sycl::handler &command_group_handler) -> device_error_accessor_t<AccessMode>#

Constructs a device (non-host) error flag accessor corresponding to this handler using the given command group handler command_group_handler.

Parameters:

command_group_handler[inout] the given command group handler

Returns:

a device (non-host) error flag accessor corresponding to this handler