-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discuss ALPAKA_ASSERT_OFFLOAD
#2186
Comments
IMO the strange behavior is a BUG and should be fixed, the macro should be guarded by |
If it is guarded only by |
Looks like I'm a repetitive person... this is mostly a duplicate of #2001 . |
I think |
fix alpaka-group#2186 fix alpaka-group#2001 Provide a device side assert `ALPAKA_ASSERT_ACC` which can be disabled by defining `ALPAKA_DISABLE_ASSERT_ACC` in the C++ code or by the CMake option `alpaka_ASSERT_ACC_ENABLE`
I opened #2199 to solve the issue. |
fix alpaka-group#2186 fix alpaka-group#2001 Provide a device side assert `ALPAKA_ASSERT_ACC` which can be disabled by defining `ALPAKA_DISABLE_ASSERT_ACC` the C++ code or by the CMake option `alpaka_ASSERT_ACC_ENABLE`. For CPU devices or host side code the assert behaves like`ALPAKA_ASSERT`. Co-authored-by: Andrea Bocci <[email protected]>
fix alpaka-group#2186 fix alpaka-group#2001 Provide a device side assert `ALPAKA_ASSERT_ACC` which can be disabled by defining `ALPAKA_DISABLE_ASSERT_ACC` the C++ code or by the CMake option `alpaka_ASSERT_ACC_ENABLE`. For CPU devices or host side code the assert behaves like`ALPAKA_ASSERT`. Co-authored-by: Andrea Bocci <[email protected]>
fix #2186 fix #2001 Provide a device side assert `ALPAKA_ASSERT_ACC` which can be disabled by defining `ALPAKA_DISABLE_ASSERT_ACC` the C++ code or by the CMake option `alpaka_ASSERT_ACC_ENABLE`. For CPU devices or host side code the assert behaves like`ALPAKA_ASSERT`. Co-authored-by: Andrea Bocci <[email protected]>
I find the current implementation of
ALPAKA_ASSERT_OFFLOAD
very confusing.It's currently defined as
My understanding is that
ALPAKA_ASSERT_OFFLOAD()
becomesassert()
, that is controlled byNDEBUG
;ALPAKA_ASSERT_OFFLOAD()
is always disabled;ALPAKA_ASSERT_OFFLOAD()
is controlled byNDEBUG
;ALPAKA_ASSERT_OFFLOAD()
becomesassert()
, that is controlled byNDEBUG
.However, if
ALPAKA_DEBUG_OFFLOAD_ASSUME_HOST
is defined,ALPAKA_ASSERT_OFFLOAD()
always becomesassert()
, and is controlled byNDEBUG
.I find two aspects problematic:
ALPAKA_ASSERT_OFFLOAD()
is disabled by default for CUDA targets, and it can only be enabled by settingALPAKA_DEBUG_OFFLOAD_ASSUME_HOST
;ALPAKA_ASSERT_OFFLOAD()
cannot be disabled for GPU targets without settingNDEBUG
, which disabled asserts also for the standard CPU compilation.In the CMS software we are using a somewhat different approach:
assert()
are always enabled for CPU code (because we never defineNDEBUG
);assert()
are disabled by default in CUDA code, and can be enabled by setting theGPU_DEBUG
macro.The rationale is that in host code
assert()
are cheap enough and the benefit from the error checking outweighs the minor performance hit we may have, while in CUDA code the impact can be significant1 so we enableassert()
only while debugging.As we are porting our code from CUDA to Alpaka, we are looking to implement a similar functionality:
assert()
are always enabled for CPU code (because we never defineNDEBUG
);assert()
are disabled by default in CUDA, HIP/ROCm and SYCL/oneAPI code, and can be enabled setting an appropriate preprocessor macro.Is this an approach that would be useful in general for Alpaka ?
If so, we can make a PR to rework
ALPAKA_ASSERT_OFFLOAD()
; otherwise we can implement it in CMSSW.Footnotes
this is due in part due to the extra checks and
trap()
functionality, in part due to the impact on register usage caused by potentially printing messages. ↩The text was updated successfully, but these errors were encountered: