From 453111d18caafd12d3d6dcf1217c3c8db485961b Mon Sep 17 00:00:00 2001 From: Brian Manh Hien Han Date: Mon, 4 Dec 2023 13:05:53 -0800 Subject: [PATCH] Enable assert for HIP --- src/axom/core/Macros.hpp | 5 +++ src/axom/slic/interface/slic_macros.hpp | 58 +++---------------------- 2 files changed, 11 insertions(+), 52 deletions(-) diff --git a/src/axom/core/Macros.hpp b/src/axom/core/Macros.hpp index 51ab21cdf4..145cbcdf22 100644 --- a/src/axom/core/Macros.hpp +++ b/src/axom/core/Macros.hpp @@ -15,6 +15,11 @@ #include "axom/config.hpp" #include // for assert() +// Header for assert() in HIP device kernels +#if defined(AXOM_USE_HIP) + #include +#endif + // _guarding_macros_start /*! * \def AXOM_USE_GPU diff --git a/src/axom/slic/interface/slic_macros.hpp b/src/axom/slic/interface/slic_macros.hpp index 16b73ab3b5..af1033c1ce 100644 --- a/src/axom/slic/interface/slic_macros.hpp +++ b/src/axom/slic/interface/slic_macros.hpp @@ -491,59 +491,13 @@ /// @} -// Use assert when on device (HIP does not yet support assert()) +// Use assert when on device #elif defined(AXOM_DEBUG) && defined(AXOM_DEVICE_CODE) - #if !defined(__HIP_DEVICE_COMPILE__) - #define SLIC_ASSERT(EXP) assert(EXP) - #define SLIC_ASSERT_MSG(EXP, msg) assert(EXP) - #define SLIC_CHECK(EXP) assert(EXP) - #define SLIC_CHECK_MSG(EXP, msg) assert(EXP) - #else -// AXOM_DEBUG is defined so the expression and message cannot be ignored -// as they probably contain parameters that were decorated with AXOM_UNUSED_PARAM -// which will require the expression and message to be used to avoid warnings. -// Here we use them in a way that will not really have a runtime effect. -// The msg code block may contain << operators so we need a stream-like object -// but we enclose it in "if(false)" so it never executes. -namespace axom -{ -namespace slic -{ -namespace internal -{ -class blackhole -{ }; -// Write an object to a blackhole. -template -AXOM_HOST_DEVICE inline blackhole &operator<<(blackhole &bh, T) -{ - return bh; -} -} // namespace internal -} // namespace slic -} // namespace axom - - #define SLIC_ASSERT(EXP) ((void)(EXP)) - #define SLIC_ASSERT_MSG(EXP, msg) \ - { \ - if(false) \ - { \ - ((void)(EXP)); \ - axom::slic::internal::blackhole __oss; \ - __oss << msg; \ - } \ - } - #define SLIC_CHECK(EXP) ((void)(EXP)) - #define SLIC_CHECK_MSG(EXP, msg) \ - { \ - if(false) \ - { \ - ((void)(EXP)); \ - axom::slic::internal::blackhole __oss; \ - __oss << msg; \ - } \ - } - #endif + #define SLIC_ASSERT(EXP) assert(EXP) + #define SLIC_ASSERT_MSG(EXP, msg) assert(EXP) + #define SLIC_CHECK(EXP) assert(EXP) + #define SLIC_CHECK_MSG(EXP, msg) assert(EXP) + #else // turn off debug macros and asserts #define SLIC_ASSERT(ignore_EXP) ((void)0)