Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HIP as language in CMake #3646

Merged
merged 23 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
34ea8e8
Remove hip_add_library
quantumsteve Dec 8, 2021
905ba2c
remove unnecessary lines
quantumsteve Dec 8, 2021
35f4a27
Use CMAKE HIP language variables
quantumsteve Dec 8, 2021
ba8878e
Missing space after -fopenmp
quantumsteve Dec 8, 2021
d609998
Message contained incorrect CMake version
quantumsteve Dec 9, 2021
626050c
Don't using HIP linker with C++ code
quantumsteve Dec 10, 2021
77442a6
Correct HIP source properties.
ye-luo Dec 11, 2021
4add523
Remove dependence on FindHIP.cmake
ye-luo Dec 11, 2021
0a60b8e
Merge remote-tracking branch 'origin/develop' into cmake_hip_language
ye-luo Jun 29, 2022
0dfb393
Minor fix
ye-luo Jun 29, 2022
9b41cf8
Merge remote-tracking branch 'origin/develop' into cmake_hip_language
ye-luo Jun 29, 2022
2052aa5
Merge branch 'develop' into cmake_hip_language
ye-luo Nov 15, 2022
20798d1
Pick up CMAKE_HIP_ARCHITECTURES.
ye-luo Nov 16, 2022
ef7b5ad
Still need to supply hip::xxx
ye-luo Nov 19, 2022
fd5feef
Merge branch 'develop' into cmake_hip_language
ye-luo Nov 28, 2022
15d499a
Point ROCM installation via ROCM_ROOT in CI.
ye-luo Nov 28, 2022
735f64f
Look for the hip runtime and libraries next to the compiler by default
ye-luo Nov 28, 2022
560d34b
Revert "Point ROCM installation via ROCM_ROOT in CI."
ye-luo Nov 28, 2022
2f59539
Update crusher recipe. Minor expansion of Summit recipe.
ye-luo Nov 29, 2022
e3822b3
Update documentation.
ye-luo Nov 29, 2022
84abc52
Trap outdated HIP_ARCH option.
ye-luo Nov 29, 2022
34ad46e
Mention neede CMake version.
ye-luo Nov 29, 2022
c2cfab1
Merge branch 'develop' into cmake_hip_language
ye-luo Nov 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMake/ClangCompilers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ if(QMC_OMP)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
if(ENABLE_ROCM)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markdewing Does adding another variable to this check fix the linking error your experiencing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had offload enabled. If I disable that, then it works.

string(APPEND CMAKE_HIP_FLAGS "-fopenmp ")
endif()
endif(QMC_OMP)

# Set clang specific flags (which we always want)
Expand Down
27 changes: 14 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,9 @@ set(HAVE_CUDA 0)
if(QMC_CUDA OR ENABLE_CUDA)
if(QMC_CUDA2HIP)
message(STATUS "CUDA2HIP enabled") # all the HIP and ROCm settings will be handled by ENABLE_ROCM
if(CMAKE_VERSION VERSION_LESS 3.21.0)
message(FATAL_ERROR "ENABLE_ROCM or QMC_CUDA2HIP require CMake 3.18.0 or later")
quantumsteve marked this conversation as resolved.
Show resolved Hide resolved
endif()
else(QMC_CUDA2HIP)
if(CMAKE_VERSION VERSION_LESS 3.18.0)
message(FATAL_ERROR "QMC_CUDA or ENABLE_CUDA require CMake 3.18.0 or later")
Expand Down Expand Up @@ -788,24 +791,22 @@ if(ENABLE_ROCM)

list(APPEND CMAKE_MODULE_PATH ${HIP_MODULE_FILE_DIR})
list(APPEND CMAKE_PREFIX_PATH ${ROCM_ROOT})
# need FindHIP for hip_add_library similar to deprecated FindCUDA style
find_package(HIP MODULE REQUIRED)
# need hip in config mode for hip::host target.
find_package(hip CONFIG REQUIRED)
find_package(hipblas CONFIG REQUIRED)
find_package(rocsolver CONFIG REQUIRED)
find_package(rocthrust CONFIG REQUIRED)
enable_language(HIP)
# architecture flags
set(HIP_ARCH
"gfx906,gfx908"
CACHE STRING "HIP architecture gfxXXX")
list(APPEND HIP_HIPCC_FLAGS "-fPIC -ffast-math -O3 -std=c++14")
list(APPEND HIP_HIPCC_FLAGS "--amdgpu-target=${HIP_ARCH}")
list(APPEND HIP_HIPCC_FLAGS "--gpu-max-threads-per-block=256")
#set(HIP_ARCH
# "gfx906,gfx908"
# CACHE STRING "HIP architecture gfxXXX")
set(CMAKE_HIP_ARCHITECTURES "gfx906;gfx908")
string(APPEND CMAKE_HIP_FLAGS "-fPIC -ffast-math -O3 -std=c++14")
#list(APPEND HIP_HIPCC_FLAGS "--amdgpu-target=${HIP_ARCH}")
string(APPEND CMAKE_HIP_FLAGS "--gpu-max-threads-per-block=256")
# warning suppression
list(APPEND HIP_HIPCC_FLAGS "-Wno-vla")
list(APPEND HIP_HIPCC_FLAGS "-Wno-deprecated-declarations")
list(APPEND HIP_HIPCC_FLAGS "-Wno-unused-command-line-argument")
string(APPEND CMAKE_HIP_FLAGS "-Wno-vla")
string(APPEND CMAKE_HIP_FLAGS "-Wno-deprecated-declarations")
string(APPEND CMAKE_HIP_FLAGS "-Wno-unused-command-line-argument")

if(BUILD_AFQMC)
find_package(rocrand CONFIG REQUIRED)
Expand Down
4 changes: 2 additions & 2 deletions src/AFQMC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ if(ENABLE_CUDA)
add_library(afqmc ${AFQMC_SRCS})
target_link_libraries(afqmc PRIVATE CUDA::curand CUDA::cusparse CUDA::cusolver CUDA::cublas)
elseif(ENABLE_HIP)
set_source_files_properties(${AFQMC_HIP_SRCS} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
hip_add_library(afqmc_hip_lib ${AFQMC_HIP_SRCS})
set_source_files_properties(${AFQMC_HIP_SRCS} PROPERTIES LANGUAGE HIP)
add_library(afqmc_hip_lib ${AFQMC_HIP_SRCS})
target_link_libraries(afqmc_hip_lib PUBLIC HIP::HIP ROCM::libraries Boost::boost)
target_include_directories(afqmc_hip_lib PUBLIC ${PROJECT_SOURCE_DIR}/external_codes/thrust)
add_library(afqmc ${AFQMC_SRCS})
Expand Down
3 changes: 2 additions & 1 deletion src/Particle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ if(QMC_CUDA)
if(NOT QMC_CUDA2HIP)
add_library(qmcparticle_cuda accept_kernel.cu)
else()
hip_add_library(qmcparticle_cuda accept_kernel.cu)
set_source_files_properties(accept_kernel.cu PROPERTIES LANGUAGE HIP)
add_library(qmcparticle_cuda accept_kernel.cu)
endif(NOT QMC_CUDA2HIP)
target_link_libraries(qmcparticle_cuda PRIVATE platform_runtime)
target_link_libraries(qmcparticle PRIVATE qmcparticle_cuda)
Expand Down
8 changes: 4 additions & 4 deletions src/Platforms/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
set(CUDA_RT_SRCS CUDAfill.cpp CUDAallocator.cpp CUDAruntime.cpp)
set(CUDA_LA_SRCS cuBLAS_missing_functions.cu)

add_library(platform_cuda_runtime ${CUDA_RT_SRCS})
add_library(platform_cuda_LA ${CUDA_LA_SRCS})

if(NOT QMC_CUDA2HIP)
add_library(platform_cuda_runtime ${CUDA_RT_SRCS})
target_link_libraries(platform_cuda_runtime PUBLIC CUDA::cudart)
add_library(platform_cuda_LA ${CUDA_LA_SRCS})
target_link_libraries(platform_cuda_LA PUBLIC CUDA::cublas CUDA::cusolver)
else()
hip_add_library(platform_cuda_runtime ${CUDA_RT_SRCS})
set_source_files_properties(${CUDA_RT_SRCS} ${CUDA_LA_SRCS} PROPERTIES LANGUAGE HIP)
target_link_libraries(platform_cuda_runtime PUBLIC platform_rocm_runtime)
hip_add_library(platform_cuda_LA ${CUDA_LA_SRCS})
target_link_libraries(platform_cuda_LA PUBLIC platform_rocm_LA)
endif()

Expand Down
5 changes: 2 additions & 3 deletions src/Platforms/CUDA_legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#//////////////////////////////////////////////////////////////////////////////////////

set(CUDA_LEGACY_SRCS cuda_inverse.cu gpu_vector.cpp gpu_misc.cpp)

add_library(platform_cuda_legacy ${CUDA_LEGACY_SRCS})
if(NOT QMC_CUDA2HIP)
add_library(platform_cuda_legacy ${CUDA_LEGACY_SRCS})
target_link_libraries(platform_cuda_legacy PUBLIC CUDA::cublas CUDA::cudart)
else()
hip_add_library(platform_cuda_legacy ${CUDA_LEGACY_SRCS})
set_source_files_properties(${CUDA_LEGACY_SRCS} PROPERTIES LANGUAGE HIP)
target_link_libraries(platform_cuda_legacy PUBLIC platform_rocm_runtime platform_rocm_LA)
endif(NOT QMC_CUDA2HIP)
4 changes: 2 additions & 2 deletions src/Platforms/ROCm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ add_library(platform_rocm_runtime INTERFACE)
target_link_libraries(platform_rocm_runtime INTERFACE hip::host)

set(ROCM_LA_SRCS hipBLAS.hip.cpp)
set_source_files_properties(${ROCM_LA_SRCS} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
hip_add_library(platform_rocm_LA ${ROCM_LA_SRCS})
set_source_files_properties(${ROCM_LA_SRCS} PROPERTIES LANGUAGE HIP)
add_library(platform_rocm_LA ${ROCM_LA_SRCS})
target_link_libraries(platform_rocm_LA PUBLIC roc::hipblas roc::rocsolver)
target_include_directories(platform_rocm_LA PUBLIC ${PROJECT_SOURCE_DIR}/external_codes/thrust)
target_link_libraries(platform_rocm_LA PRIVATE platform_rocm_runtime)
7 changes: 3 additions & 4 deletions src/Platforms/tests/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ set(SRC_DIR CUDA)
set(UTEST_EXE test_${SRC_DIR})
set(UTEST_NAME deterministic-unit_test_${SRC_DIR})

if(NOT QMC_CUDA2HIP)
add_library(cuda_device_value_test_kernels test_device_value_kernels.cu)
else()
hip_add_library(cuda_device_value_test_kernels test_device_value_kernels.cu)
add_library(cuda_device_value_test_kernels test_device_value_kernels.cu)
if(QMC_CUDA2HIP)
set_source_files_properties(test_device_value_kernels.cu PROPERTIES LANGUAGE HIP)
endif()
target_link_libraries(cuda_device_value_test_kernels PUBLIC platform_runtime)

Expand Down
9 changes: 4 additions & 5 deletions src/QMCHamiltonians/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ else()
add_library(qmcham_unit ${HAMSRCS})
endif()
if(QMC_CUDA)
if(NOT QMC_CUDA2HIP)
add_library(qmcham_cuda ${HAMSRCS_CUDA})
else()
hip_add_library(qmcham_cuda ${HAMSRCS_CUDA})
endif(NOT QMC_CUDA2HIP)
add_library(qmcham_cuda ${HAMSRCS_CUDA})
if(QMC_CUDA2HIP)
set_source_files_properties(${HAMSRCS_CUDA} PROPERTIES LANGUAGE HIP)
endif()
target_link_libraries(qmcham PRIVATE qmcham_cuda)
target_link_libraries(qmcham_unit PRIVATE qmcham_cuda)
endif(QMC_CUDA)
Expand Down
15 changes: 5 additions & 10 deletions src/QMCWaveFunctions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,8 @@ else(USE_OBJECT_TARGET)
endif(USE_OBJECT_TARGET)

if(QMC_CUDA OR ENABLE_CUDA)
if(NOT QMC_CUDA2HIP)
add_library(qmcwfs_cuda ${WFSSRCS_CUDA})
else()
hip_add_library(qmcwfs_cuda ${WFSSRCS_CUDA})
target_link_libraries(qmcwfs_cuda PUBLIC platform_LA)
endif(NOT QMC_CUDA2HIP)
add_library(qmcwfs_cuda ${WFSSRCS_CUDA})
target_link_libraries(qmcwfs_cuda PUBLIC platform_LA)
if(QMC_CUDA)
target_include_directories(qmcwfs_cuda PUBLIC ${PROJECT_SOURCE_DIR}/external_codes/thrust)
target_link_libraries(qmcwfs_cuda PUBLIC qmcparticle platform_LA)
Expand All @@ -208,10 +204,9 @@ target_link_libraries(qmcwfs PRIVATE einspline platform_LA Math::FFTW3)
# do not merge with qmcwfs target unless all qmcwfs unit tests pass santitizers.
if(ENABLE_CUDA)
set(DIRECT_INVERSION_SRCS detail/CUDA/cuBLAS_LU.cu)
if(NOT QMC_CUDA2HIP)
add_library(qmcwfs_direct_inversion_cuda "${DIRECT_INVERSION_SRCS}")
else()
hip_add_library(qmcwfs_direct_inversion_cuda "${DIRECT_INVERSION_SRCS}")
add_library(qmcwfs_direct_inversion_cuda "${DIRECT_INVERSION_SRCS}")
if(QMC_CUDA2HIP)
set_source_files_properties(${DIRECT_INVERSION_SRCS} PROPERTIES LANGUAGE HIP)
endif()
target_link_libraries(qmcwfs_direct_inversion_cuda PUBLIC platform_LA)
# CUDA_ADD_LIBRARY is from deprecated FindCuda and ignores TARGET_INCLUDE_DIRECTORIES so
Expand Down
6 changes: 1 addition & 5 deletions src/einspline/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ set(SRCS

if(QMC_CUDA)
set(SRCS ${SRCS} multi_bspline_create_cuda.cu bspline_create_cuda.cu)
if(NOT QMC_CUDA2HIP)
add_library(einspline ${SRCS})
else()
hip_add_library(einspline ${SRCS})
endif(NOT QMC_CUDA2HIP)
add_library(einspline ${SRCS})
target_link_libraries(einspline PRIVATE platform_runtime)
else(QMC_CUDA)
add_library(einspline ${SRCS})
Expand Down
6 changes: 1 addition & 5 deletions src/einspline/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ set(UTEST_NAME deterministic-unit_test_${SRC_DIR})
set(SRCS test_one.cpp test_3d.cpp)
if(QMC_CUDA)
set(SRCS ${SRCS} test_cuda.cu)
if(NOT QMC_CUDA2HIP)
add_library(cudatests test_cuda.cu)
else()
hip_add_library(cudatests test_cuda.cu)
endif(NOT QMC_CUDA2HIP)
add_library(cudatests test_cuda.cu)
set(CUDATESTLIB cudatests)
endif()

Expand Down