@@ -14,6 +14,7 @@ project(ABACUS
1414option (ENABLE_DEEPKS "Enable DeePKS functionality" OFF )
1515option (ENABLE_LIBXC "Enable LibXC functionality" OFF )
1616option (USE_CUDA "Enable support to CUDA." OFF )
17+ option (USE_ROCM "Enable support to ROCm." OFF )
1718option (USE_OPENMP " Enable OpenMP in abacus." ON )
1819option (ENABLE_ASAN "Enable AddressSanitizer" OFF )
1920option (BUILD_TESTING "Build ABACUS unit tests" OFF )
@@ -80,6 +81,8 @@ if(USE_CUDA)
8081 -lcufft
8182 -lcublas
8283 -lcudart
84+ -lcusolver
85+ -lnvToolsExt
8386 )
8487 set_property (TARGET ${ABACUS_BIN_NAME}
8588 PROPERTY CUDA_ARCHITECTURES
@@ -91,6 +94,33 @@ if(USE_CUDA)
9194 add_compile_definitions (__CUDA)
9295endif ()
9396
97+ # Warning: CMake add support to HIP in version 3.21. This is rather a new version.
98+ # Use cmake with AMD-ROCm: https://rocmdocs.amd.com/en/latest/Installation_Guide/Using-CMake-with-AMD-ROCm.html
99+ if (USE_ROCM)
100+ set (CMAKE_CXX_STANDARD 11)
101+ SET (CMAKE_HIP_STANDARD 11)
102+ # set(CMAKE_CXX_STANDARD_REQUIRED True)
103+ list (APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
104+ list (APPEND CMAKE_SYSTEM_PREFIX_PATH "/opt/rocm/hip" )
105+
106+ # find_package(ROCM REQUIRED)
107+ find_package (hip REQUIRED)
108+ find_package (hipfft REQUIRED)
109+ find_package (hipblas REQUIRED)
110+ include_directories (
111+ /opt/rocm/hip/include
112+ /opt/rocm/hipfft/include
113+ /opt/rocm/hipblas/include
114+ )
115+ target_link_libraries (${ABACUS_BIN_NAME}
116+ hip::device
117+ hip::host
118+ hip::hipfft
119+ roc::hipblas
120+ )
121+ add_compile_definitions (__ROCM)
122+ endif ()
123+
94124if (ENABLE_ASAN)
95125 add_compile_options (
96126 -O1
0 commit comments