mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Disable asserts for CUDA architecture builds
`assert` is supported on recent CUDA cards, but compiling it appears to be very slow. By default, the `VTKM_ASSERT` macro has been disabled whenever compiling for a CUDA device (i.e. when `__CUDA_ARCH__` is defined). Asserts for CUDA devices can be turned back on by turning the `VTKm_NO_ASSERT_CUDA` CMake variable off. Turning this CMake variable off will enable assertions in CUDA kernels unless there is another reason turning off all asserts (such as a release build).
This commit is contained in:
parent
765fa6da22
commit
270ba214d5
@ -108,6 +108,11 @@ vtkm_option(VTKm_ENABLE_LOGGING "Enable VTKm Logging" ON)
|
||||
# performance.
|
||||
vtkm_option(VTKm_NO_ASSERT "Disable assertions in debugging builds." OFF)
|
||||
|
||||
# The CUDA compiler (as of CUDA 11) takes a surprising long time to compile
|
||||
# kernels with assert in them. By default we turn off asserts when compiling
|
||||
# for CUDA devices.
|
||||
vtkm_option(VTKm_NO_ASSERT_CUDA "Disable assertions for CUDA 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.
|
||||
@ -135,6 +140,7 @@ vtkm_option(VTKm_NO_INSTALL_README_LICENSE "disable the installation of README a
|
||||
mark_as_advanced(
|
||||
VTKm_ENABLE_LOGGING
|
||||
VTKm_NO_ASSERT
|
||||
VTKm_NO_ASSERT_CUDA
|
||||
VTKm_INSTALL_ONLY_LIBRARIES
|
||||
VTKm_HIDE_PRIVATE_SYMBOLS
|
||||
VTKm_ENABLE_DEVELOPER_FLAGS
|
||||
|
10
docs/changelog/cuda-no-assert.md
Normal file
10
docs/changelog/cuda-no-assert.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Disable asserts for CUDA architecture builds
|
||||
|
||||
`assert` is supported on recent CUDA cards, but compiling it appears to be
|
||||
very slow. By default, the `VTKM_ASSERT` macro has been disabled whenever
|
||||
compiling for a CUDA device (i.e. when `__CUDA_ARCH__` is defined).
|
||||
|
||||
Asserts for CUDA devices can be turned back on by turning the
|
||||
`VTKm_NO_ASSERT_CUDA` CMake variable off. Turning this CMake variable off
|
||||
will enable assertions in CUDA kernels unless there is another reason
|
||||
turning off all asserts (such as a release build).
|
@ -15,6 +15,15 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
// Pick up conditions where we want to turn on/off assert.
|
||||
#ifndef VTKM_NO_ASSERT
|
||||
#if defined(NDEBUG)
|
||||
#define VTKM_NO_ASSERT
|
||||
#elif defined(__CUDA_ARCH__) && defined(VTKM_NO_ASSERT_CUDA)
|
||||
#define VTKM_NO_ASSERT
|
||||
#endif
|
||||
#endif // VTKM_NO_ASSERT
|
||||
|
||||
/// \def VTKM_ASSERT(condition)
|
||||
///
|
||||
/// Asserts that \a condition resolves to true. If \a condition is false,
|
||||
@ -28,11 +37,7 @@
|
||||
///
|
||||
/// The VTKM_NO_ASSERT cmake and preprocessor option allows debugging builds
|
||||
/// to remove assertions for performance reasons.
|
||||
#if defined(VTKM_CUDA_VERSION_MAJOR) && (VTKM_CUDA_VERSION_MAJOR == 7)
|
||||
//CUDA 7.5 doesn't support assert in device code
|
||||
#define VTKM_ASSERT(condition) (void)(condition)
|
||||
#elif !defined(NDEBUG) && !defined(VTKM_NO_ASSERT)
|
||||
//Only assert if we are in debug mode and don't have VTKM_NO_ASSERT defined
|
||||
#ifndef VTKM_NO_ASSERT
|
||||
#define VTKM_ASSERT(condition) assert(condition)
|
||||
#define VTKM_ASSERTS_CHECKED
|
||||
#else
|
||||
|
@ -14,6 +14,7 @@
|
||||
# that we expect for our C++ defines.
|
||||
|
||||
set(VTKM_NO_ASSERT ${VTKm_NO_ASSERT})
|
||||
set(VTKM_NO_ASSERT_CUDA ${VTKm_NO_ASSERT_CUDA})
|
||||
set(VTKM_USE_DOUBLE_PRECISION ${VTKm_USE_DOUBLE_PRECISION})
|
||||
set(VTKM_USE_64BIT_IDS ${VTKm_USE_64BIT_IDS})
|
||||
|
||||
|
@ -62,6 +62,10 @@
|
||||
#cmakedefine VTKM_NO_ASSERT
|
||||
#endif
|
||||
|
||||
#if !defined(VTKM_NO_ASSERT_CUDA)
|
||||
#cmakedefine VTKM_NO_ASSERT_CUDA
|
||||
#endif
|
||||
|
||||
#if !defined(VTKM_USE_DOUBLE_PRECISION) && !defined(VTKM_NO_DOUBLE_PRECISION)
|
||||
#cmakedefine VTKM_USE_DOUBLE_PRECISION
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user