Skip to content
21 changes: 11 additions & 10 deletions sycl/doc/PreprocessorMacros.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ This file describes macros that have effect on SYCL compiler and run-time.

Disables a message which warns about unsupported C++ version.

- **SYCL_DISABLE_FALLBACK_ASSERT**

Defining this macro eliminates some overhead that is associated with
submitting kernels that call `assert()`. When this macro is defined, the logic
for detecting assertion failures in kernels is disabled, so a failed assert
will not cause a message to be printed and will not cause the program to
abort. However, this macro only affects kernels that are submitted to devices
that do **not** have native support for `assert()` because devices with native
support do not impose any extra overhead. One can check to see if a device has
native support for `assert()` via `aspect::ext_oneapi_native_assert`.
- **SYCL_ENABLE_FALLBACK_ASSERT**

Defining this macro enables fallback assert feature. Be aware that this will
add some overhead that is associated with submitting kernels that call
`assert()`. When this macro is not defined, the logic for detecting assertion
failures in kernels is disabled, so a failed assert will not cause a message
to be printed and will not cause the program to abort. However, this macro
only affects kernels that are submitted to devices that do **not** have native
support for `assert()` because devices with native support do not impose any
extra overhead. One can check to see if a device has native support for
`assert()` via `aspect::ext_oneapi_native_assert`.

## Version macros

Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

// Helper macro to identify if fallback assert is needed
// FIXME remove __NVPTX__ condition once devicelib supports CUDA
#if !defined(SYCL_DISABLE_FALLBACK_ASSERT) && !defined(__NVPTX__)
#if defined(SYCL_ENABLE_FALLBACK_ASSERT) && !defined(__NVPTX__)
#define __SYCL_USE_FALLBACK_ASSERT 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if defined(SYCL_ENABLE_FALLBACK_ASSERT) && !defined(__NVPTX__)
#define __SYCL_USE_FALLBACK_ASSERT 1
#if defined(SYCL_ENABLE_FALLBACK_ASSERT)
#if defined(__NVPTX__)
#warning "Fallback assert is not supported on NVPTX target"
#define __SYCL_USE_FALLBACK_ASSERT 0
#else
#define __SYCL_USE_FALLBACK_ASSERT 1
#endif

Defining this macro enables the fallback assert feature even on devices without native support.

I suggest we add a note to the documentation that fallback assert is not supported on CUDA back-end.
BTW, is it supported on HIP?

#else
#define __SYCL_USE_FALLBACK_ASSERT 0
Expand Down