Skip to content

Commit 95c0a46

Browse files
authored
Merge pull request #1498 from LLNL/feature/han12/hip_assert
Enable HIP assert in SLIC macros
2 parents c70f36f + 07477e0 commit 95c0a46

13 files changed

+28
-87
lines changed

.gitlab/build_ruby.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# This is the shared configuration of jobs for ruby
88
.on_ruby:
99
variables:
10-
SCHEDULER_PARAMETERS: "--res=ci --exclusive=user --deadline=now+1hour -N1 -t ${ALLOC_TIME}"
10+
SCHEDULER_PARAMETERS: "--reservation=ci --exclusive=user --deadline=now+1hour -N1 -t ${ALLOC_TIME}"
1111
tags:
1212
- batch
1313
- ruby

RELEASE-NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ to use Open Cascade's file I/O capabilities in support of Quest applications.
4949
- `MFEMSidreDataCollection::LoadExternalData` now takes two optional string parameters, one that is a
5050
filename (defaults to the `name` member variable) and the other is a `Group` path relative to the base of
5151
the Data Collection itself (defaults to the root of the `DataStore`).
52+
- `SLIC_ASSERT`,`SLIC_ASSERT_MSG`,`SLIC_CHECK`, and `SLIC_CHECK_MSG` macros delegate to assert() within HIP device kernels.
5253

5354
### Deprecated
5455

host-configs/[email protected]_hip.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ set(CMAKE_Fortran_FLAGS "-ef" CACHE STRING "")
4141

4242
set(ENABLE_FORTRAN ON CACHE BOOL "")
4343

44-
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -g -DNDEBUG" CACHE STRING "")
44+
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -g" CACHE STRING "")
4545

4646
#------------------------------------------------------------------------------
4747
# MPI

host-configs/[email protected]_hip.cmake

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ set(CMAKE_Fortran_FLAGS "-Mfreeform" CACHE STRING "")
4141

4242
set(ENABLE_FORTRAN ON CACHE BOOL "")
4343

44-
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -g -DNDEBUG" CACHE STRING "")
45-
4644
#------------------------------------------------------------------------------
4745
# MPI
4846
#------------------------------------------------------------------------------

host-configs/[email protected]_hip.cmake

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ set(CMAKE_Fortran_FLAGS "-Mfreeform" CACHE STRING "")
4141

4242
set(ENABLE_FORTRAN ON CACHE BOOL "")
4343

44-
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -g -DNDEBUG" CACHE STRING "")
45-
4644
#------------------------------------------------------------------------------
4745
# MPI
4846
#------------------------------------------------------------------------------

host-configs/[email protected]_hip.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ set(CMAKE_Fortran_FLAGS "-ef" CACHE STRING "")
4141

4242
set(ENABLE_FORTRAN ON CACHE BOOL "")
4343

44-
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -g -DNDEBUG" CACHE STRING "")
44+
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -g" CACHE STRING "")
4545

4646
#------------------------------------------------------------------------------
4747
# MPI

host-configs/[email protected]_hip.cmake

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ set(CMAKE_Fortran_FLAGS "-Mfreeform" CACHE STRING "")
4141

4242
set(ENABLE_FORTRAN ON CACHE BOOL "")
4343

44-
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -g -DNDEBUG" CACHE STRING "")
45-
4644
#------------------------------------------------------------------------------
4745
# MPI
4846
#------------------------------------------------------------------------------

host-configs/[email protected]_hip.cmake

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ set(CMAKE_Fortran_FLAGS "-Mfreeform" CACHE STRING "")
4141

4242
set(ENABLE_FORTRAN ON CACHE BOOL "")
4343

44-
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -g -DNDEBUG" CACHE STRING "")
45-
4644
#------------------------------------------------------------------------------
4745
# MPI
4846
#------------------------------------------------------------------------------

scripts/spack/packages/axom/package.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ def initconfig_compiler_entries(self):
288288
if "+cpp14" in spec and spec.satisfies("@:0.6.1"):
289289
entries.append(cmake_cache_string("BLT_CXX_STD", "c++14", ""))
290290

291-
# Add optimization flag workaround for Debug builds with cray compiler or newer HIP
292-
if "+rocm" in spec:
293-
entries.append(cmake_cache_string("CMAKE_CXX_FLAGS_DEBUG", "-O1 -g -DNDEBUG"))
291+
# Add optimization flag workaround for builds with cray compiler
292+
if spec.satisfies("%cce"):
293+
entries.append(cmake_cache_string("CMAKE_CXX_FLAGS_DEBUG", "-O1 -g"))
294294

295295
return entries
296296

src/axom/core/Macros.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
#include "axom/config.hpp"
1616
#include <cassert> // for assert()
1717

18+
// Header for assert() in HIP device kernels
19+
#if defined(AXOM_USE_HIP)
20+
#include <hip/hip_runtime.h>
21+
#endif
22+
1823
// _guarding_macros_start
1924
/*!
2025
* \def AXOM_USE_GPU

src/axom/slic/interface/slic_macros.hpp

+8-52
Original file line numberDiff line numberDiff line change
@@ -491,59 +491,15 @@
491491

492492
/// @}
493493

494-
// Use assert when on device (HIP does not yet support assert())
494+
// Use assert when on device (note that messages are omitted).
495+
// Device HIP assert() tested with [email protected]
496+
// (ROCm support for device assert() begins with version 5.1.0).
495497
#elif defined(AXOM_DEBUG) && defined(AXOM_DEVICE_CODE)
496-
#if !defined(__HIP_DEVICE_COMPILE__)
497-
#define SLIC_ASSERT(EXP) assert(EXP)
498-
#define SLIC_ASSERT_MSG(EXP, msg) assert(EXP)
499-
#define SLIC_CHECK(EXP) assert(EXP)
500-
#define SLIC_CHECK_MSG(EXP, msg) assert(EXP)
501-
#else
502-
// AXOM_DEBUG is defined so the expression and message cannot be ignored
503-
// as they probably contain parameters that were decorated with AXOM_UNUSED_PARAM
504-
// which will require the expression and message to be used to avoid warnings.
505-
// Here we use them in a way that will not really have a runtime effect.
506-
// The msg code block may contain << operators so we need a stream-like object
507-
// but we enclose it in "if(false)" so it never executes.
508-
namespace axom
509-
{
510-
namespace slic
511-
{
512-
namespace internal
513-
{
514-
class blackhole
515-
{ };
516-
// Write an object to a blackhole.
517-
template <typename T>
518-
AXOM_HOST_DEVICE inline blackhole &operator<<(blackhole &bh, T)
519-
{
520-
return bh;
521-
}
522-
} // namespace internal
523-
} // namespace slic
524-
} // namespace axom
525-
526-
#define SLIC_ASSERT(EXP) ((void)(EXP))
527-
#define SLIC_ASSERT_MSG(EXP, msg) \
528-
{ \
529-
if(false) \
530-
{ \
531-
((void)(EXP)); \
532-
axom::slic::internal::blackhole __oss; \
533-
__oss << msg; \
534-
} \
535-
}
536-
#define SLIC_CHECK(EXP) ((void)(EXP))
537-
#define SLIC_CHECK_MSG(EXP, msg) \
538-
{ \
539-
if(false) \
540-
{ \
541-
((void)(EXP)); \
542-
axom::slic::internal::blackhole __oss; \
543-
__oss << msg; \
544-
} \
545-
}
546-
#endif
498+
#define SLIC_ASSERT(EXP) assert(EXP)
499+
#define SLIC_ASSERT_MSG(EXP, msg) assert(EXP)
500+
#define SLIC_CHECK(EXP) assert(EXP)
501+
#define SLIC_CHECK_MSG(EXP, msg) assert(EXP)
502+
547503
#else // turn off debug macros and asserts
548504

549505
#define SLIC_ASSERT(ignore_EXP) ((void)0)

src/tools/CMakeLists.txt

+1-14
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,7 @@ if(AXOM_ENABLE_QUEST)
8383
set (_policies "raja_seq")
8484
blt_list_append(TO _policies ELEMENTS "raja_omp" IF AXOM_ENABLE_OPENMP)
8585
blt_list_append(TO _policies ELEMENTS "raja_cuda" IF AXOM_ENABLE_CUDA)
86-
87-
# Test with HIP policy for select optimization flags.
88-
# Check for Debug flags that have been overwritten.
89-
if(AXOM_ENABLE_HIP)
90-
if((CMAKE_BUILD_TYPE MATCHES "(Release|RelWithDebInfo)") OR
91-
(CMAKE_BUILD_TYPE MATCHES "Debug" AND
92-
CMAKE_CXX_FLAGS_DEBUG MATCHES "\-O1 \-g \-DNDEBUG"))
93-
list(APPEND _policies "raja_hip")
94-
else()
95-
message(STATUS
96-
"HIP policy for mesh_tester executable is not being tested"
97-
)
98-
endif()
99-
endif()
86+
blt_list_append(TO _policies ELEMENTS "raja_hip" IF AXOM_ENABLE_HIP)
10087

10188
foreach(_method ${_methods})
10289
foreach(_policy ${_policies})

src/tools/mesh_tester.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ using seq_exec = axom::SEQ_EXEC;
5151
using cuda_exec = seq_exec;
5252
#endif
5353

54-
#if defined(AXOM_USE_HIP) && defined(AXOM_USE_UMPIRE) && defined(NDEBUG)
54+
#if defined(AXOM_USE_HIP) && defined(AXOM_USE_UMPIRE)
5555
constexpr int HIP_BLOCK_SIZE = 256;
5656
using hip_exec = axom::HIP_EXEC<HIP_BLOCK_SIZE>;
5757
#else
@@ -139,7 +139,7 @@ const std::map<std::string, RuntimePolicy> Input::s_validPolicies({
139139
#ifdef AXOM_USE_CUDA
140140
, {"raja_cuda", raja_cuda}
141141
#endif
142-
#if defined(AXOM_USE_HIP) && defined(NDEBUG)
142+
#if defined(AXOM_USE_HIP)
143143
, {"raja_hip", raja_hip}
144144
#endif
145145
#endif
@@ -181,7 +181,7 @@ void Input::parse(int argc, char** argv, axom::CLI::App& app)
181181
#ifdef AXOM_USE_CUDA
182182
pol_sstr << "\nSet to 'raja_cuda' or 3 to use the RAJA CUDA policy.";
183183
#endif
184-
#if defined(AXOM_USE_HIP) && defined(NDEBUG)
184+
#if defined(AXOM_USE_HIP)
185185
pol_sstr << "\nSet to 'raja_hip' or 4 to use the RAJA HIP policy.";
186186
#endif
187187
#endif
@@ -705,7 +705,7 @@ int main(int argc, char** argv)
705705
params.intersectionThreshold);
706706
break;
707707
#endif
708-
#if defined(AXOM_USE_HIP) && defined(NDEBUG)
708+
#if defined(AXOM_USE_HIP)
709709
case raja_hip:
710710
collisions =
711711
naiveIntersectionAlgorithm<hip_exec>(surface_mesh,
@@ -762,7 +762,7 @@ int main(int argc, char** argv)
762762
params.intersectionThreshold);
763763
break;
764764
#endif
765-
#if defined(AXOM_USE_HIP) && defined(NDEBUG)
765+
#if defined(AXOM_USE_HIP)
766766
case raja_hip:
767767
quest::findTriMeshIntersectionsBVH<hip_exec, double>(
768768
surface_mesh,
@@ -823,7 +823,7 @@ int main(int argc, char** argv)
823823
params.intersectionThreshold);
824824
break;
825825
#endif
826-
#if defined(AXOM_USE_HIP) && defined(AXOM_USE_UMPIRE) && defined(NDEBUG)
826+
#if defined(AXOM_USE_HIP) && defined(AXOM_USE_UMPIRE)
827827
case raja_hip:
828828
quest::findTriMeshIntersectionsImplicitGrid<hip_exec, double>(
829829
surface_mesh,
@@ -882,7 +882,7 @@ int main(int argc, char** argv)
882882
params.intersectionThreshold);
883883
break;
884884
#endif
885-
#if defined(AXOM_USE_HIP) && defined(AXOM_USE_UMPIRE) && defined(NDEBUG)
885+
#if defined(AXOM_USE_HIP) && defined(AXOM_USE_UMPIRE)
886886
case raja_hip:
887887
quest::findTriMeshIntersectionsUniformGrid<hip_exec, double>(
888888
surface_mesh,

0 commit comments

Comments
 (0)