Skip to content

Commit b671165

Browse files
steffenlarsenbader
andauthored
[SYCL] Remove fallback assertions (#18310)
This commit removes the fallback assertion implementation for SYCL kernels. The expected behavior after this is that backends that do not support native asserts, as reported through the ext_oneapi_native_assert aspect, will ignore assertions in kernel code. This commit also makes the L0 adapter report support for native assert, as it was incorrectly reporting false before. --------- Signed-off-by: Larsen, Steffen <[email protected]> Co-authored-by: Alexey Bader <[email protected]>
1 parent fcd35c0 commit b671165

39 files changed

+148
-943
lines changed

devops/compat_ci_exclude.sycl-rel-6_2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ KernelCompiler/opencl.cpp
2828
KernelCompiler/opencl_cache_eviction.cpp
2929
KernelCompiler/opencl_queries.cpp
3030

31+
# https://github.com/intel/llvm/pull/18310 removed fallback assertions, but due
32+
# to a bug in the L0 drivers, one test causes the implementation to continue
33+
# after assertions are triggered. We allow this regression while the drivers bug
34+
# gets addressed.
35+
# See GSD-11097.
36+
Assert/assert_in_kernels.cpp
37+
3138
# Likely OK, but need author to provide justification, get approval/confirmation
3239
# from someone:
3340

devops/compat_ci_exclude.sycl-rel-6_3

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Matrix/joint_matrix_bf16_fill_k_cache_arg_dim.cpp
33
Matrix/joint_matrix_bf16_fill_k_cache_runtime_dim.cpp
44

5+
# https://github.com/intel/llvm/pull/18310 removed fallback assertions, but due
6+
# to a bug in the L0 drivers, one test causes the implementation to continue
7+
# after assertions are triggered. We allow this regression while the drivers bug
8+
# gets addressed.
9+
# See GSD-11097.
10+
Assert/assert_in_kernels.cpp
11+
512
# Likely OK, but need author to provide justification, get approval/confirmation
613
# from someone:
714

sycl/doc/PreprocessorMacros.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,6 @@ This file describes macros that have effect on SYCL compiler and run-time.
3939
Disable warning diagnostic issued when including `<sycl/sycl.hpp>` without
4040
`-fsycl` compiler flag.
4141

42-
- **SYCL_FALLBACK_ASSERT**
43-
44-
Defining as non-zero enables the fallback assert feature even on devices
45-
without native support. Be aware that this will add some overhead that is
46-
associated with submitting kernels that call `assert()`. When this macro is
47-
defined as 0 or is not defined, the logic for detecting assertion failures in kernels is
48-
disabled, so a failed assert will not cause a message to be printed and will
49-
not cause the program to abort. Some devices have native support for
50-
assertions. The logic for detecting assertion failures is always enabled on
51-
these devices regardless of whether this macro is defined because that logic
52-
does not add any extra overhead. One can check to see if a device has native
53-
support for `assert()` via `aspect::ext_oneapi_native_assert`.
54-
This macro is undefined by default.
55-
5642
- **SYCL2020_CONFORMANT_APIS (deprecated)**
5743
This macro is used to comply with the SYCL 2020 specification, as some of the current
5844
implementations may be widespread and not conform to it.

sycl/doc/design/Assert.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ The following sequence of events describes how user code gets notified:
126126
127127
## Fallback approach
128128
129+
**The fallback approach has been deprecated and will be removed in the future.**
130+
129131
If Device-side Runtime doesn't support `__devicelib_assert_fail` (as reported
130132
via "cl_intel_devicelib_assert" extension query) then a fallback approach comes
131133
in place. The approach doesn't require any support from Device-side Runtime and

sycl/doc/extensions/supported/sycl_ext_oneapi_assert.asciidoc

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,11 @@ and `+__LINE__+`, and the value of the standard variable `+__func__+`. If the
6262
failing assert comes from an `nd_range` `parallel_for` it will also include the
6363
global ID and the local ID of the failing work item.
6464

65-
Some devices implement `assert()` natively while others use a fallback
66-
implementation, and the two implementations provide different guarantees. The
67-
native implementation is most similar to the way `assert()` works on the host. If
68-
an assertion fails in the native implementation, the assertion message is
69-
immediately printed to stderr and the program terminates by calling
70-
`std::abort()`. If an assertion fails with the fallback implementation, the
71-
failing assert() returns back to its caller and the device code must continue
72-
executing (without deadlocking) until the kernel completes. The implementation
73-
prints the assertion message to stderr and terminates with `std::abort()` only
74-
after the kernel completes execution. An application can determine which of the
75-
two mechanisms a device uses by testing the device aspect
76-
`aspect::ext_oneapi_native_assert`.
65+
Only some devices support `assert()` natively, as determinable by querying the
66+
new `aspect::ext_oneapi_native_assert` aspect. If an assertion fails in devices
67+
that support these natively, the assertion message is immediately printed to
68+
stderr and the program terminates by calling `std::abort()`. Failures in calls
69+
to `assert()` on devices that do not natively support it are ignored.
7770

7871
The `assert()` macro is defined in system include headers, not in SYCL headers.
7972
On most of systems it is `<cassert>` and/or `<assert.h>` header files.
@@ -137,9 +130,8 @@ enum class aspect {
137130
----
138131

139132
If device has the `ext_oneapi_native_assert` aspect, then its Device-Side
140-
Runtime is capable of native support of `assert`. That is, safe implementation
141-
is used. If device doesn't have the aspect, then fallback implementation is
142-
used.
133+
Runtime is capable of native support of `assert`. If device doesn't have the
134+
aspect, then assertions on the device will be silently ignored.
143135

144136
== Version
145137

sycl/include/sycl/detail/assert_happened.hpp

Lines changed: 0 additions & 42 deletions
This file was deleted.

sycl/include/sycl/detail/defines_elementary.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,10 @@
9999
static_assert(__cplusplus >= 201703L,
100100
"DPCPP does not support C++ version earlier than C++17.");
101101

102-
// Helper macro to identify if fallback assert is needed
103-
#if defined(SYCL_FALLBACK_ASSERT)
104-
#define __SYCL_USE_FALLBACK_ASSERT SYCL_FALLBACK_ASSERT
105-
#else
106-
#define __SYCL_USE_FALLBACK_ASSERT 0
102+
// MSVC doesn't support #warning and we cannot use other methods to report a
103+
// warning from inside a system header (which SYCL is considered to be).
104+
#if defined(SYCL_FALLBACK_ASSERT) && (!defined(_MSC_VER) || defined(__clang__))
105+
#warning "SYCL_FALLBACK_ASSERT has been removed and no longer has any effect."
107106
#endif
108107

109108
#if defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__)

sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,14 @@ template <typename LCRangeT, typename LCPropertiesT> struct LaunchConfigAccess {
100100
template <typename CommandGroupFunc, typename PropertiesT>
101101
void submit_impl(const queue &Q, PropertiesT Props, CommandGroupFunc &&CGF,
102102
const sycl::detail::code_location &CodeLoc) {
103-
Q.submit_without_event<__SYCL_USE_FALLBACK_ASSERT>(
104-
Props, detail::type_erased_cgfo_ty{CGF}, CodeLoc);
103+
Q.submit_without_event(Props, detail::type_erased_cgfo_ty{CGF}, CodeLoc);
105104
}
106105

107106
template <typename CommandGroupFunc, typename PropertiesT>
108107
event submit_with_event_impl(const queue &Q, PropertiesT Props,
109108
CommandGroupFunc &&CGF,
110109
const sycl::detail::code_location &CodeLoc) {
111-
return Q.submit_with_event<__SYCL_USE_FALLBACK_ASSERT>(
112-
Props, detail::type_erased_cgfo_ty{CGF}, CodeLoc);
110+
return Q.submit_with_event(Props, detail::type_erased_cgfo_ty{CGF}, CodeLoc);
113111
}
114112
} // namespace detail
115113

0 commit comments

Comments
 (0)