Skip to content

Commit 8f04eb2

Browse files
authored
[SYCL] Remove unnecessary fallback-cassert file for CUDA/AMD assert (#20967)
We have removed fallback device library jit-link path, so there is no need to have separate libsycl-fallback-* library files. The only exception is imf libraries for SPIRV targets. This PR is a series of patches to clean up all unnecessary libsycl-fallback-* library files exposing __devicelib_* APIs, we clean up libsycl-fallback-cassert for CUDA/AMD target. For Intel Target, the __devicelib_assert_fail is provided by IGC or OpenCL CPU runtime and for AMD/CUDA target, underlying runtime provides similar function '__assertfail'. --------- Signed-off-by: jinge90 <[email protected]>
1 parent 4decbf0 commit 8f04eb2

File tree

3 files changed

+13
-36
lines changed

3 files changed

+13
-36
lines changed

libdevice/cmake/modules/SYCLLibdevice.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,6 @@ else()
580580
endif()
581581
endif()
582582

583-
add_devicelibs(libsycl-fallback-cassert
584-
SRC fallback-cassert.cpp
585-
BUILD_ARCHS ${full_build_archs}
586-
DEPENDENCIES ${crt_obj_deps}
587-
EXTRA_OPTS -fno-sycl-instrument-device-code)
588583
add_devicelibs(libsycl-fallback-cstring
589584
SRC fallback-cstring.cpp
590585
BUILD_ARCHS ${full_build_archs}

libdevice/crt_wrapper.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ void srand(unsigned int seed) {
134134
RAND_NEXT_ACC[gid1] = seed;
135135
}
136136

137+
#if defined(__NVPTX__) || defined(__AMDGCN__)
138+
DEVICE_EXTERN_C void __assertfail(const char *__message, const char *__file,
139+
unsigned __line, const char *__function,
140+
size_t charSize);
141+
#endif
137142
#if defined(_WIN32)
138143
// Truncates a wide (16 or 32 bit) string (wstr) into an ASCII string (str).
139144
// Any non-ASCII characters are replaced by question mark '?'.
@@ -157,21 +162,29 @@ void _wassert(const wchar_t *wexpr, const wchar_t *wfile, unsigned line) {
157162
char expr[256];
158163
__truncate_wchar_char_str(wexpr, expr, sizeof(expr));
159164

165+
#if defined(__NVPTX__) || defined(__AMDGCN__)
166+
__assertfail(expr, file, line, nullptr, 1);
167+
#else
160168
__devicelib_assert_fail(
161169
expr, file, line, /*func=*/nullptr, __spirv_BuiltInGlobalInvocationId(0),
162170
__spirv_BuiltInGlobalInvocationId(1),
163171
__spirv_BuiltInGlobalInvocationId(2), __spirv_BuiltInLocalInvocationId(0),
164172
__spirv_BuiltInLocalInvocationId(1), __spirv_BuiltInLocalInvocationId(2));
173+
#endif
165174
}
166175
#else
167176
DEVICE_EXTERN_C
168177
void __assert_fail(const char *expr, const char *file, unsigned int line,
169178
const char *func) {
179+
#if defined(__NVPTX__) || defined(__AMDGCN__)
180+
__assertfail(expr, file, line, func, 1);
181+
#else
170182
__devicelib_assert_fail(
171183
expr, file, line, func, __spirv_BuiltInGlobalInvocationId(0),
172184
__spirv_BuiltInGlobalInvocationId(1),
173185
__spirv_BuiltInGlobalInvocationId(2), __spirv_BuiltInLocalInvocationId(0),
174186
__spirv_BuiltInLocalInvocationId(1), __spirv_BuiltInLocalInvocationId(2));
187+
#endif
175188
}
176189

177190
// In GCC-15, std::__glibcxx_assert_fail is added to do runtime check for some

libdevice/fallback-cassert.cpp

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

0 commit comments

Comments
 (0)