Drop support for NDEBUG

This commit is contained in:
Ole Schütt 2023-12-13 21:49:22 +01:00 committed by Ole Schütt
parent 49d82271f9
commit 0dfeee1108
10 changed files with 25 additions and 26 deletions

View file

@ -58,6 +58,12 @@ endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 11)
# remove NDEBUG flag
string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
string(REPLACE "-DNDEBUG" "" CMAKE_Fortran_FLAGS_RELEASE
${CMAKE_Fortran_FLAGS_RELEASE})
find_package(PkgConfig)
# ##############################################################################
@ -549,11 +555,11 @@ elseif(CP2K_USE_ACCEL MATCHES "HIP")
set(CMAKE_HIP_ARCHITECTURES gfx801 gfx900 gfx90a)
if(NOT CMAKE_BUILD_TYPE)
set(HIP_RELEASE_OPTIONS "-O3 -DNDEBUG --std=c++11")
set(HIP_RELEASE_OPTIONS "-O3 --std=c++11")
elseif(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
set(HIP_RELEASE_OPTIONS "-O2 -g --std=c++11")
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
set(HIP_RELEASE_OPTIONS "-O3 -DNDEBUG --std=c++11")
set(HIP_RELEASE_OPTIONS "-O3 --std=c++11")
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(HIP_RELEASE_OPTIONS "-O0 -g --std=c++11")
endif()

View file

@ -454,10 +454,6 @@ architectures can be found in [arch folder](./arch/). The names of these files m
Alternatively, <https://dashboard.cp2k.org> provides sample arch files as part of the testing
reports (click on the status field, search for 'ARCH-file').
- With -DNDEBUG assertions may be stripped ("compiled out").
- NDEBUG is the ANSI-conforming symbol name (not \_\_NDEBUG).
- Regular release builds may carry assertions for safety.
Conventionally, there are six versions:
| Acronym | Meaning |

View file

@ -1578,7 +1578,6 @@ target_compile_definitions(
__COMPILE_REVISION=\"${CP2K_GIT_HASH}\"
__DATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}/cp2k/data\"
__COMPILE_ARCH=\"${CMAKE_SYSTEM_PROCESSOR}\"
$<$<CONFIG:Release>:NDEBUG>
$<$<CONFIG:COVERAGE>:__NO_ABORT>
$<$<CONFIG:DEBUG>:__HAS_IEEE_EXCEPTIONS>
$<$<CONFIG:DEBUG>:__CHECK_DIAG>
@ -1690,9 +1689,8 @@ endforeach()
add_executable(dbm_miniapp dbm/dbm_miniapp.c ${CP2K_DBM_SRCS_C}
${CP2K_DBM_SRCS_GPU} ${CP2K_OFFLOAD_SRCS_C})
target_compile_definitions(
dbm_miniapp
PRIVATE $<$<CONFIG:Release>:NDEBUG> $<$<BOOL:${CP2K_USE_LIBXSMM}>:__LIBXSMM>
$<$<STREQUAL:${CP2K_BLAS_VENDOR},"MKL">:__MKL>)
dbm_miniapp PRIVATE $<$<BOOL:${CP2K_USE_LIBXSMM}>:__LIBXSMM>
$<$<STREQUAL:${CP2K_BLAS_VENDOR},"MKL">:__MKL>)
if(CP2K_DISABLE_DBM_GPU)
target_compile_definitions(dbm_miniapp PRIVATE __NO_OFFLOAD_DBM)
@ -1709,10 +1707,8 @@ foreach(__app grid_miniapp grid_unittest)
$<$<BOOL:${CP2K_USE_HIP}>:${CP2K_GRID_SRCS_HIP}>
${CP2K_OFFLOAD_SRCS_C})
target_compile_definitions(
${__app}
PRIVATE $<$<CONFIG:Release>:NDEBUG>
$<$<BOOL:${CP2K_USE_LIBXSMM}>:__LIBXSMM>
$<$<STREQUAL:${CP2K_BLAS_VENDOR},"MKL">:__MKL>)
${__app} PRIVATE $<$<BOOL:${CP2K_USE_LIBXSMM}>:__LIBXSMM>
$<$<STREQUAL:${CP2K_BLAS_VENDOR},"MKL">:__MKL>)
if(CP2K_DISABLE_GRID_GPU)
target_compile_definitions(${__app} PUBLIC __NO_OFFLOAD_GRID)

View file

@ -32,12 +32,7 @@
! In contrast to CPWARN, the warning counter is not increased
#define CPHINT(msg) CALL cp__h(__SHORT_FILE__,__LINE__,msg)
! CPASSERT can be elided if NDEBUG is defined.
#if defined(NDEBUG)
# define CPASSERT(cond)
#else
# define CPASSERT(cond) IF(.NOT.(cond))CALL cp__a(__SHORT_FILE__,__LINE__)
#endif
! The MARK_USED macro can be used to mark an argument/variable as used. It is intended to make
! it possible to switch on -Werror=unused-dummy-argument, but deal elegantly with, e.g.,

View file

@ -85,9 +85,6 @@ CONTAINS
tmp_str = ""
flags = TRIM(flags)//TRIM(tmp_str)
#if defined(NDEBUG)
flags = TRIM(flags)//" ndebug"
#endif
!$ flags = TRIM(flags)//" omp"
#if defined(__LIBINT)
flags = TRIM(flags)//" libint"

View file

@ -226,9 +226,14 @@ CONTAINS
" and is therefore no longer supported.")
#if !defined(__FORCE_USE_FAST_MATH)
#error -ffast-math (GCC) or -hfpN (N>0, Cray) can lead to wrong results and numerical instabilities and are therefore no longer supported
#error "-ffast-math (GCC) or -hfpN (N>0, Cray) can lead to wrong results and numerical instabilities and are therefore no longer supported"
#endif
#endif
#if defined(NDEBUG)
#error "Please do not build CP2K with NDEBUG. There is no performance advantage and asserts will save your neck."
#endif
END SUBROUTINE cp2k_init
! **************************************************************************************************

View file

@ -37,6 +37,11 @@ static grid_library_config config = {
#error "OpenMP is required. Please add -fopenmp to your C compiler flags."
#endif
#if defined(NDEBUG)
#error \
"Please do not build CP2K with NDEBUG. There is no performance advantage and asserts will save your neck."
#endif
/*******************************************************************************
* \brief Initializes the grid library.
* \author Ole Schuett

View file

@ -323,12 +323,10 @@ extern "C" void grid_hip_create_task_list(
assert(num_tasks == num_tasks_per_block[i]);
// check that all tasks point to the same block
#ifndef NDEBUG
for (int tk = 0; tk < num_tasks; tk++)
assert(
tasks_host[sorted_blocks[tk + sorted_blocks_offset[i]]].block_num ==
i);
#endif
}
for (auto &block : task_sorted_by_block)
block.clear();

View file

@ -54,7 +54,7 @@ else
echo -e "failed.\n\n"
tail -n 100 ninja.log
mkdir -p /workspace/artifacts/
cp ninja.out /workspace/artifacts/
cp ninja.log /workspace/artifacts/
echo -e "\nSummary: Compilation failed."
echo -e "Status: FAILED\n"
exit 0

View file

@ -29,6 +29,7 @@ FLAG_EXCEPTIONS = (
r"LIBINT_CONTRACTED_INTS",
r"XC_MAJOR_VERSION",
r"XC_MINOR_VERSION",
r"NDEBUG",
r"OMP_DEFAULT_NONE_WITH_OOP",
r"_OPENMP",
r"__COMPILE_ARCH",