Rewrote core CMakeLists.txt for cmake versions with proper CUDA & MPI support (3.9+)
This commit is contained in:
@@ -6,54 +6,32 @@
|
|||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wdouble-promotion -Wfloat-conversion -Wshadow")
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wdouble-promotion -Wfloat-conversion -Wshadow")
|
||||||
#set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||||
#set(CMAKE_CXX_FLAGS_RELEASE "-O3") # Leads to very bad performance on my local machine for some reason
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||||
|
|
||||||
## Find packages
|
# Require CUDA
|
||||||
find_package(CUDA REQUIRED)
|
set(CMAKE_CUDA_FLAGS "-gencode arch=compute_70,code=sm_70 -ftz=true --restrict")
|
||||||
set(CUDA_SEPARABLE_COMPILATION ON)
|
|
||||||
# find_package(OpenMP REQUIRED)
|
|
||||||
|
|
||||||
## Architecture and optimization flags
|
# Compile kernels
|
||||||
set(CUDA_ARCH_FLAGS -gencode arch=compute_37,code=sm_37
|
add_library(astaroth_kernels STATIC kernels/boundconds.cu kernels/integration.cu kernels/reductions.cu)
|
||||||
-gencode arch=compute_50,code=sm_50
|
target_include_directories(astaroth_kernels PRIVATE .)
|
||||||
-gencode arch=compute_60,code=sm_60
|
target_compile_features(astaroth_kernels PRIVATE cxx_std_11)
|
||||||
-gencode arch=compute_61,code=sm_61
|
set_target_properties(astaroth_kernels PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
||||||
-gencode arch=compute_70,code=sm_70
|
add_dependencies(astaroth_kernels dsl_headers)
|
||||||
-lineinfo
|
|
||||||
-ftz=true # Flush denormalized floats to zero
|
|
||||||
-std=c++11
|
|
||||||
)# --compiler-options ${OpenMP_CXX_FLAGS})
|
|
||||||
#--maxrregcount=255
|
|
||||||
# -Xptxas -dlcm=ca opt-in to cache all global loads to L1/texture cache
|
|
||||||
# =cg to opt out
|
|
||||||
|
|
||||||
set(CUDA_WARNING_FLAGS --compiler-options -Wall,-Wextra,-Werror,-Wdouble-promotion,-Wfloat-conversion,-Wshadow)
|
# Compile core
|
||||||
|
add_library(astaroth_core STATIC astaroth.cc node.cc device.cc)
|
||||||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${CUDA_ARCH_FLAGS} ${CUDA_WARNING_FLAGS})
|
|
||||||
|
|
||||||
# Workaround for CMake bug https://gitlab.kitware.com/cmake/cmake/issues/16411
|
|
||||||
if (CMAKE_BUILD_TYPE_UPPER STREQUAL "RELEASE")
|
|
||||||
set(CUDA_NVCC_FLAGS_RELEASE -O3)
|
|
||||||
elseif (CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG")
|
|
||||||
set(CUDA_NVCC_FLAGS_DEBUG --device-debug --generate-line-info --ptxas-options=-v)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
## Create and link the library
|
|
||||||
#set(CMAKE_POSITION_INDEPENDENT_CODE ON) # fpic for shared libraries
|
|
||||||
cuda_add_library(astaroth_core STATIC astaroth.cc node.cc device.cc kernels/boundconds.cu kernels/integration.cu kernels/reductions.cu)
|
|
||||||
target_include_directories(astaroth_core PRIVATE . ${CUDA_INCLUDE_DIRS})
|
target_include_directories(astaroth_core PRIVATE . ${CUDA_INCLUDE_DIRS})
|
||||||
target_link_libraries(astaroth_core m ${CUDA_LIBRARIES})
|
target_link_libraries(astaroth_core m cudart astaroth_kernels)
|
||||||
target_compile_definitions(astaroth_core PRIVATE AC_USE_CUDA_RUNTIME_API)
|
target_compile_definitions(astaroth_core PRIVATE AC_USE_CUDA_RUNTIME_API)
|
||||||
add_dependencies(astaroth_core dsl_headers)
|
set_target_properties(astaroth_core PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
|
add_dependencies(astaroth_kernels dsl_headers)
|
||||||
|
|
||||||
## Definitions
|
|
||||||
if (MULTIGPU_ENABLED)
|
if (MULTIGPU_ENABLED)
|
||||||
add_definitions(-DAC_MULTIGPU_ENABLED=1)
|
target_compile_definitions(astaroth_core PRIVATE AC_MULTIGPU_ENABLED=1)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (MPI_ENABLED)
|
if (MPI_ENABLED)
|
||||||
find_package(MPI REQUIRED)
|
target_link_libraries(astaroth_core astaroth_utils)
|
||||||
target_link_libraries(astaroth_core astaroth_utils MPI::MPI_CXX)
|
|
||||||
target_compile_definitions(astaroth_core PRIVATE AC_MPI_ENABLED=1)
|
target_compile_definitions(astaroth_core PRIVATE AC_MPI_ENABLED=1)
|
||||||
endif ()
|
endif ()
|
||||||
|
Reference in New Issue
Block a user