diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b12223d8..bab37198f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,12 @@ vtkm_option(VTKm_NO_ASSERT "Disable assertions in debugging builds." OFF) # for CUDA devices. vtkm_option(VTKm_NO_ASSERT_CUDA "Disable assertions for CUDA devices." ON) +# The HIP compiler (as of ROCm 3.7) takes a surprising long time to compile +# kernels with assert in them they generate `printf` calls which are very +# slow ( cause massive register spillage). By default we turn off asserts when +# compiling for HIP devices. +vtkm_option(VTKm_NO_ASSERT_HIP "Disable assertions for HIP devices." ON) + # When VTK-m is embedded into larger projects that wish to make end user # applications they want to only install libraries and don't want CMake/headers # installed. diff --git a/docs/changelog/hip-no-assert.md b/docs/changelog/hip-no-assert.md new file mode 100644 index 000000000..ff448b0f1 --- /dev/null +++ b/docs/changelog/hip-no-assert.md @@ -0,0 +1,12 @@ +# Disable asserts for HIP architecture builds + +`assert` is supported on recent HIP cards, but compiling it is very slow, +as it triggers the usage of `printf` which. Currently (ROCm 3.7) `printf` +has a severe performance penalty and should be avoided when possible. +By default, the `VTKM_ASSERT` macro has been disabled whenever compiling +for a HIP device via kokkos. + +Asserts for HIP devices can be turned back on by turning the +`VTKm_NO_ASSERT_HIP` CMake variable off. Turning this CMake variable off +will enable assertions in HIP kernels unless there is another reason +turning off all asserts (such as a release build). diff --git a/vtkm/Assert.h b/vtkm/Assert.h index 646ef5ec1..f26c1e322 100644 --- a/vtkm/Assert.h +++ b/vtkm/Assert.h @@ -21,6 +21,8 @@ #define VTKM_NO_ASSERT #elif defined(VTKM_CUDA_DEVICE_PASS) && defined(VTKM_NO_ASSERT_CUDA) #define VTKM_NO_ASSERT +#elif defined(VTKM_HIP) && defined(VTKM_NO_ASSERT_HIP) +#define VTKM_NO_ASSERT #endif #endif // VTKM_NO_ASSERT diff --git a/vtkm/internal/CMakeLists.txt b/vtkm/internal/CMakeLists.txt index 4224aaa2c..b40fa2c17 100755 --- a/vtkm/internal/CMakeLists.txt +++ b/vtkm/internal/CMakeLists.txt @@ -15,6 +15,7 @@ set(VTKM_NO_ASSERT ${VTKm_NO_ASSERT}) set(VTKM_NO_ASSERT_CUDA ${VTKm_NO_ASSERT_CUDA}) +set(VTKM_NO_ASSERT_HIP ${VTKm_NO_ASSERT_HIP}) set(VTKM_USE_DOUBLE_PRECISION ${VTKm_USE_DOUBLE_PRECISION}) set(VTKM_USE_64BIT_IDS ${VTKm_USE_64BIT_IDS}) diff --git a/vtkm/internal/Configure.h.in b/vtkm/internal/Configure.h.in index 79b7af339..06dd2b676 100644 --- a/vtkm/internal/Configure.h.in +++ b/vtkm/internal/Configure.h.in @@ -71,6 +71,10 @@ #cmakedefine VTKM_NO_ASSERT_CUDA #endif +#if !defined(VTKM_NO_ASSERT_HIP) +#cmakedefine VTKM_NO_ASSERT_HIP +#endif + #if !defined(VTKM_USE_DOUBLE_PRECISION) && !defined(VTKM_NO_DOUBLE_PRECISION) #cmakedefine VTKM_USE_DOUBLE_PRECISION #endif