Skip to content

Commit

Permalink
Apply changes recommended by @ye-lou.
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Hahn <hahnse@ornl.gov>
  • Loading branch information
quantumsteve committed Sep 29, 2021
1 parent b607510 commit 761745b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
22 changes: 7 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ cmake_policy(SET CMP0075 NEW)
######################################################################
# QMCPACK project
######################################################################

project(
qmcpack
VERSION 3.11.9
Expand Down Expand Up @@ -42,17 +41,6 @@ if(NOT QMC_CXX_STANDARD EQUAL 17)
"Using other versions of the C++ standard is unsupported and done entirely at user's own risk.")
endif()

#--------------------------------------------------------------------
# Set CUDA standard
#--------------------------------------------------------------------
set(QMC_CUDA_STANDARD
14
CACHE STRING "QMCPACK CUDA C++ language standard")
if(NOT QMC_CUDA_STANDARD EQUAL 14)
message(WARNING "C++14 is the only CUDA language standard officially supported by this QMCPACK version. "
"Using other versions of the CUDA C++ standard is unsupported and done entirely at user's own risk.")
endif()

#--------------------------------------------------------------------
# Programmind model related build options
# MPI, OpenMP, GPU acceleration
Expand Down Expand Up @@ -272,8 +260,9 @@ endif()
set(CMAKE_CXX_STANDARD ${QMC_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CUDA_STANDARD ${QMC_CUDA_STANDARD})
set(CMAKE_CUDA_STANDARD ${QMC_CXX_STANDARD})
set(CMAKE_CUDA_STANDARD_REQUIRED TRUE)
set(CMAKE_CUDA_EXTENSIONS OFF)

# Check that a C++ compiler is compatible with the underlying libstdc++
include(Testlibstdc++)
Expand Down Expand Up @@ -679,11 +668,14 @@ if(QMC_CUDA OR ENABLE_CUDA)
if (CMAKE_VERSION VERSION_LESS 3.17.0)
message(FATAL_ERROR "QMC_CUDA or ENABLE_CUDA require CMake 3.17.0 or later")
endif()
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
if(DEFINED CUDA_ARCH)
message(FATAL_ERROR "Use CMAKE_CUDA_ARCHITECTURES instead of CUDA_ARCH variable")
endif()
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 70)
endif()
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
# Automatically set the default NVCC flags
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Drestrict=__restrict__ -DNO_CUDA_MAIN")
if(QMC_COMPLEX)
Expand Down
7 changes: 3 additions & 4 deletions src/Platforms/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ set(CUDA_LA_SRCS cuBLAS_missing_functions.cu)
if(NOT QMC_CUDA2HIP)
add_library(platform_cuda_runtime ${CUDA_RT_SRCS})
add_library(platform_cuda_LA ${CUDA_LA_SRCS})
target_link_libraries(platform_cuda_LA PRIVATE CUDA::cublas)
target_include_directories(platform_cuda_runtime PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_link_libraries(platform_cuda_runtime PRIVATE CUDA::cudart)
target_link_libraries(platform_cuda_LA PRIVATE CUDA::cublas CUDA::cusolver)
target_link_libraries(platform_cuda_runtime PUBLIC CUDA::cudart)
else()
hip_add_library(platform_cuda_runtime ${CUDA_RT_SRCS})
hip_add_library(platform_cuda_LA ${CUDA_LA_SRCS})
target_link_libraries(platform_cuda_runtime PUBLIC platform_rocm_runtime)
target_link_libraries(platform_cuda_LA PUBLIC platform_rocm_LA)
endif()

target_link_libraries(platform_cuda_LA PRIVATE ${CUDA_cusolver_LIBRARY} platform_cuda_runtime)
target_link_libraries(platform_cuda_LA PRIVATE platform_cuda_runtime)
3 changes: 1 addition & 2 deletions src/Platforms/CUDA_legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ set(CUDA_LEGACY_SRCS cuda_inverse.cu gpu_vector.cpp gpu_misc.cpp)

if(NOT QMC_CUDA2HIP)
add_library(platform_cuda_legacy ${CUDA_LEGACY_SRCS})
target_include_directories(platform_cuda_legacy PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_link_libraries(platform_cuda_legacy PRIVATE CUDA::cublas)
target_link_libraries(platform_cuda_legacy PUBLIC CUDA::cublas)
else()
hip_add_library(platform_cuda_legacy ${CUDA_LEGACY_SRCS})
target_link_libraries(platform_cuda_legacy PUBLIC platform_rocm_runtime platform_rocm_LA)
Expand Down

0 comments on commit 761745b

Please sign in to comment.