-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Fix device assertion bug on windows (#15232)
This PR fixes a device assertion bug on Windows where the assertion message and information are not printed when an assertion is triggered. Also re-enabled some tests failing because of it. See #12797.
- Loading branch information
Showing
12 changed files
with
100 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//== ----------------<assert.h> wrapper around STL--------------------------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// Must not be guarded. C++ standard says the macro assert is redefined | ||
// according to the current state of NDEBUG each time that <cassert> is | ||
// included. | ||
|
||
#if defined(__has_include_next) | ||
#include_next <assert.h> | ||
#else | ||
#include <../ucrt/assert.h> | ||
#endif | ||
|
||
#ifdef __SYCL_DEVICE_ONLY__ | ||
#include <CL/__spirv/spirv_vars.hpp> | ||
|
||
// Device assertions on Windows do not work properly so we define these wrappers | ||
// around the STL assertion headers cassert and assert.h where we redefine | ||
// the assert macro to call __devicelib_assert_fail directly and bypass | ||
// _wassert. | ||
#if defined(_WIN32) && defined(assert) | ||
extern "C" __DPCPP_SYCL_EXTERNAL void | ||
__devicelib_assert_fail(const char *, const char *, int32_t, const char *, | ||
uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, | ||
uint64_t); | ||
#undef assert | ||
#if defined(NDEBUG) | ||
#define assert(e) ((void)0) | ||
#else | ||
#define assert(e) \ | ||
((e) ? void(0) \ | ||
: __devicelib_assert_fail( \ | ||
#e, __FILE__, __LINE__, nullptr, __spirv_GlobalInvocationId_x(), \ | ||
__spirv_GlobalInvocationId_y(), __spirv_GlobalInvocationId_z(), \ | ||
__spirv_LocalInvocationId_x(), __spirv_LocalInvocationId_y(), \ | ||
__spirv_LocalInvocationId_z())) | ||
#endif | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//==---------------- <cassert> wrapper around STL --------------------------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// Must not be guarded. C++ standard says the macro assert is redefined | ||
// according to the current state of NDEBUG each time that <cassert> is | ||
// included. | ||
|
||
#if defined(__has_include_next) | ||
#include_next <cassert> | ||
#else | ||
#include <../include/cassert> | ||
#endif | ||
|
||
#ifdef __SYCL_DEVICE_ONLY__ | ||
#include <CL/__spirv/spirv_vars.hpp> | ||
|
||
// Device assertions on Windows do not work properly so we define these wrappers | ||
// around the STL assertion headers cassert and assert.h where we redefine | ||
// the assert macro to call __devicelib_assert_fail directly and bypass | ||
// _wassert. | ||
#if defined(_WIN32) && defined(assert) | ||
extern "C" __DPCPP_SYCL_EXTERNAL void | ||
__devicelib_assert_fail(const char *, const char *, int32_t, const char *, | ||
uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, | ||
uint64_t); | ||
#undef assert | ||
#if defined(NDEBUG) | ||
#define assert(e) ((void)0) | ||
#else | ||
#define assert(e) \ | ||
((e) ? void(0) \ | ||
: __devicelib_assert_fail( \ | ||
#e, __FILE__, __LINE__, nullptr, __spirv_GlobalInvocationId_x(), \ | ||
__spirv_GlobalInvocationId_y(), __spirv_GlobalInvocationId_z(), \ | ||
__spirv_LocalInvocationId_x(), __spirv_LocalInvocationId_y(), \ | ||
__spirv_LocalInvocationId_z())) | ||
#endif | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
sycl/test-e2e/Assert/assert_in_multiple_tus_one_ndebug_win.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters