Skip to content

Commit

Permalink
Enable assert for HIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bmhan12 committed Jan 29, 2025
1 parent 11dd613 commit 453111d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 52 deletions.
5 changes: 5 additions & 0 deletions src/axom/core/Macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
#include "axom/config.hpp"
#include <cassert> // for assert()

// Header for assert() in HIP device kernels
#if defined(AXOM_USE_HIP)
#include <hip/hip_runtime.h>
#endif

// _guarding_macros_start
/*!
* \def AXOM_USE_GPU
Expand Down
58 changes: 6 additions & 52 deletions src/axom/slic/interface/slic_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
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)
Expand Down

0 comments on commit 453111d

Please sign in to comment.