Skip to content

Commit

Permalink
Fix: CUDA Host-Side -O3 with CMake
Browse files Browse the repository at this point in the history
`-O3` was only set for CUDA if we ran CMake at least twice. This was
an intialization logic bug and should be set from the beginning, but
we initialized CUDA too late / applied the transform too early.

We now change the default build type to `Release` to avoid changing
defaults and avoid further surprises.

We will add optional `-g` for optimized builds again on a later PR.
  • Loading branch information
ax3l committed Jul 12, 2021
1 parent cfcccdc commit 2d12ea7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ endif()
option(HiPACE_amrex_internal "Download & build AMReX" ON)

# change the default build type to RelWithDebInfo (or Release) instead of Debug
set_default_build_type("RelWithDebInfo")
set_default_build_type("Release")

# this defined the variable BUILD_TESTING which is ON by default
include(CTest)
Expand Down
7 changes: 0 additions & 7 deletions cmake/HiPACEFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ macro(set_default_build_type default_build_type)
set_property(CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES})
endif()

# RelWithDebInfo uses -O2 which is sub-ideal for how it is intended to be used
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/591
list(TRANSFORM CMAKE_C_FLAGS_RELWITHDEBINFO REPLACE "-O2" "-O3")
list(TRANSFORM CMAKE_CXX_FLAGS_RELWITHDEBINFO REPLACE "-O2" "-O3")
# FIXME: due to the "AMReX inits CUDA first" logic we will first see this with -O2 in output
list(TRANSFORM CMAKE_CUDA_FLAGS_RELWITHDEBINFO REPLACE "-O2" "-O3")
endif()
endmacro()

Expand Down
2 changes: 1 addition & 1 deletion docs/source/building/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ or by providing arguments to the CMake call
============================= ======================================== =====================================================
CMake Option Default & Values Description
----------------------------- ---------------------------------------- -----------------------------------------------------
``CMAKE_BUILD_TYPE`` **RelWithDebInfo**/Release/Debug Type of build, symbols & optimizations
``CMAKE_BUILD_TYPE`` RelWithDebInfo/**Release**/Debug Type of build, symbols & optimizations
``HiPACE_COMPUTE`` **NOACC**/CUDA/SYCL/HIP/OMP On-node, accelerated computing backend
``HiPACE_MPI`` **ON**/OFF Multi-node support (message-passing)
``HiPACE_PRECISION`` SINGLE/**DOUBLE** Floating point precision (single/double)
Expand Down

0 comments on commit 2d12ea7

Please sign in to comment.