warning_handler Class#

Description

The warning_handler class is for thread-safe warning handling. oneIPL implementations shall be able to set warning 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 warning state, either for reading or for writing, use an object of the warning_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 WarningEnumT, WarningEnumT MinWarningEnum, WarningEnumT MaxWarningEnum>
class warning_handler#

This class is for thread-safe warning handling.

It allows to set a number of warning flags separately in any thread(s) on any SYCL device(s) and then to check them in another thread(s) on another device(s). To access the warning state (either for reading or for writing) use an object of warning_accessor class (it can be obtained via the call of get_access() method).

Template Parameters:
  • WarningEnumT – the type of the warning enumeration which items are used as warning flags set by this warning handler

  • MinWarningEnum – the minimal value of the warning flag handled by this handler

  • MaxWarningEnum – the maximal value of the warning flag handled by this handler

Public Types

using warning_enum_t = WarningEnumT#

Alias for the template parameter WarningEnumT (the type of the warning enumeration which items are used as warnings by this warning state accessor).

using warning_code_t = std::underlying_type_t<WarningEnumT>#

Alias for the underlying type of WarningEnumT enumeration type.

template<sycl::access_mode AccessMode, bool IsHost>
using warning_accessor_t = warning_accessor<WarningEnumT, MinWarningEnum, MaxWarningEnum, AccessMode, IsHost>#

Alias template for warning state accessor.

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

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

template<sycl::access_mode AccessMode>
using host_warning_accessor_t = warning_accessor_t<AccessMode, true>#

Alias template for host warning state accessor.

Template Parameters:

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

template<sycl::access_mode AccessMode>
using device_warning_accessor_t = warning_accessor_t<AccessMode, false>#

Alias template for device (non-host) warning state accessor.

Template Parameters:

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

Public Functions

warning_handler()#

Default constructor (no warning flag is set by default).

bool has(WarningEnumT warning_enum)#

Checks whether the flag for the given warning warning_enum is set.

Parameters:

warning_enum – the given warning which flag is to be checked

Returns:

true if the flag for the given warning warning_enum is set, or false otherwise

bool all()#

Checks whether all warning flags handled by this handler are set.

Returns:

true if all warning flags are set, or false otherwise

bool any()#

Checks whether any of warning flags handled by this handler is set.

Returns:

true if any of warning flags is set, or false otherwise

bool none()#

Checks whether no warning flag handled by this handler is set.

Returns:

true if no warning flag is set.

std::size_t count()#

Returns the number of warning flags handled by this handler that are set.

Returns:

the number of warning flags handled by this handler that are set

constexpr std::size_t size() const#

Returns the number of warning flags handled by this handler.

Returns:

the number of warning flags handled by this handler

void set()#

Sets all warning flags handled by this handler.

void set(WarningEnumT warning_enum)#

Sets the flag for the given warning warning_enum.

Parameters:

warning_enum[in] the given warning which flag is to be set

void reset()#

Sets all warning flags handled by this handler to false.

void merge(warning_handler &other_warning_handler)#

Merges the state of this warning handler with the state of the other warning handler other_warning_handler.

Performs this action on host.

Parameters:

other_warning_handler[inout] the given other warning handler

void merge(sycl::queue &queue, warning_handler &other_warning_handler)#

Merges the state of this warning handler with the state of the other warning handler other_warning_handler.

Enqueues this action to the given queue queue.

Parameters:
  • queue[inout] the given queue on which the merging will be executed

  • other_warning_handler[inout] the given other warning handler

template<typename ForEachFunctorT>
void for_each_warning(ForEachFunctorT &&for_each_functor)#

Executes the given functor for_each_functor for all warning flags handled by this handler that are set.

Performs this action on host.

Template Parameters:

ForEachFunctorT – the type of the given functor for_each_functor

Parameters:

for_each_functor[inout] the given functor of the type ForEachFunctorT to be executed for all warning flags that are set

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

Constructs a host warning state accessor corresponding to this handler.

Template Parameters:

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

Returns:

a host warning state accessor corresponding to this handler

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

Constructs a device (non-host) warning state 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) warning state accessor corresponding to this handler

Public Static Attributes

static constexpr auto number_of_warnings_v = {static_cast<std::size_t>(static_cast<warning_code_t>(MaxWarningEnum) - static_cast<warning_code_t>(MinWarningEnum)) + 1}#

The number of warnings (from MinWarningEnum to MaxWarningEnum) handled by this handler.