From 902a454e6e74a432a8844283fe85f98f4561641d Mon Sep 17 00:00:00 2001 From: Levi Zhou <31941107+ZhouXY-PKU@users.noreply.github.com> Date: Tue, 9 Dec 2025 20:12:37 +0800 Subject: [PATCH 1/4] Update device.cpp --- source/module_base/module_device/device.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source/module_base/module_device/device.cpp b/source/module_base/module_device/device.cpp index b20ea9f3ad..08cc6e90c7 100644 --- a/source/module_base/module_device/device.cpp +++ b/source/module_base/module_device/device.cpp @@ -12,6 +12,7 @@ #if defined(__CUDA) #include +#include #endif #if defined(__ROCM) @@ -299,6 +300,7 @@ void print_device_info( sprintf(msg, " CUDA Capability Major/Minor version number: %d.%d\n", deviceProp.major, deviceProp.minor); ofs_device << msg << std::endl; +#if defined(CUDA_VERSION) && CUDA_VERSION < 13000 sprintf(msg, " GPU Max Clock rate: %.0f MHz (%0.2f " "GHz)\n", @@ -312,6 +314,7 @@ void print_device_info( sprintf(msg, " Memory Bus Width: %d-bit\n", deviceProp.memoryBusWidth); ofs_device << msg << std::endl; +#endif sprintf(msg, " Maximum Texture Dimension Size (x,y,z) 1D=(%d), 2D=(%d, " "%d), 3D=(%d, %d, %d)\n", @@ -366,6 +369,7 @@ void print_device_info( sprintf(msg, " Texture alignment: %zu bytes\n", deviceProp.textureAlignment); ofs_device << msg << std::endl; +#if defined(CUDA_VERSION) && CUDA_VERSION < 13000 sprintf(msg, " Concurrent copy and kernel execution: %s with %d copy " "engine(s)\n", @@ -375,6 +379,7 @@ void print_device_info( sprintf(msg, " Run time limit on kernels: %s\n", deviceProp.kernelExecTimeoutEnabled ? "Yes" : "No"); ofs_device << msg << std::endl; +#endif sprintf(msg, " Integrated GPU sharing Host Memory: %s\n", deviceProp.integrated ? "Yes" : "No"); ofs_device << msg << std::endl; @@ -399,13 +404,15 @@ void print_device_info( sprintf(msg, " Supports Cooperative Kernel Launch: %s\n", deviceProp.cooperativeLaunch ? "Yes" : "No"); ofs_device << msg << std::endl; - sprintf(msg, " Supports MultiDevice Co-op Kernel Launch: %s\n", - deviceProp.cooperativeMultiDeviceLaunch ? "Yes" : "No"); - ofs_device << msg << std::endl; sprintf(msg, " Device PCI Domain ID / Bus ID / location ID: %d / %d / %d\n", deviceProp.pciDomainID, deviceProp.pciBusID, deviceProp.pciDeviceID); ofs_device << msg << std::endl; +#if defined(CUDA_VERSION) && CUDA_VERSION < 13000 + sprintf(msg, " Supports MultiDevice Co-op Kernel Launch: %s\n", + deviceProp.cooperativeMultiDeviceLaunch ? "Yes" : "No"); + ofs_device << msg << std::endl; + const char *sComputeMode[] = { "Default (multiple host threads can use ::cudaSetDevice() with device " "simultaneously)", @@ -421,7 +428,7 @@ void print_device_info( ofs_device << msg << std::endl; ofs_device << " " << sComputeMode[deviceProp.computeMode] << std::endl << std::endl; - +#endif // If there are 2 or more GPUs, query to determine whether RDMA is supported if (deviceCount >= 2) { cudaDeviceProp prop[64]; @@ -711,4 +718,4 @@ void record_device_memory( #endif } // end of namespace information -} // end of namespace base_device \ No newline at end of file +} // end of namespace base_device From 684cce74759bf61cd77286ce019f37a6f201e641 Mon Sep 17 00:00:00 2001 From: Levi Zhou <31941107+ZhouXY-PKU@users.noreply.github.com> Date: Wed, 10 Dec 2025 07:56:45 +0800 Subject: [PATCH 2/4] Update helper_cuda.h --- .../module_hsolver/kernels/cuda/helper_cuda.h | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/source/module_hsolver/kernels/cuda/helper_cuda.h b/source/module_hsolver/kernels/cuda/helper_cuda.h index e61e4597f6..afdc774705 100644 --- a/source/module_hsolver/kernels/cuda/helper_cuda.h +++ b/source/module_hsolver/kernels/cuda/helper_cuda.h @@ -137,30 +137,33 @@ static const char *_cudaGetErrorEnum(cufftResult error) { case CUFFT_UNALIGNED_DATA: return "CUFFT_UNALIGNED_DATA"; - - case CUFFT_INCOMPLETE_PARAMETER_LIST: - return "CUFFT_INCOMPLETE_PARAMETER_LIST"; - + case CUFFT_INVALID_DEVICE: return "CUFFT_INVALID_DEVICE"; - case CUFFT_PARSE_ERROR: - return "CUFFT_PARSE_ERROR"; - case CUFFT_NO_WORKSPACE: return "CUFFT_NO_WORKSPACE"; case CUFFT_NOT_IMPLEMENTED: return "CUFFT_NOT_IMPLEMENTED"; +#if defined(CUDA_VERSION) && CUDA_VERSION < 13000 + case CUFFT_INCOMPLETE_PARAMETER_LIST: + return "CUFFT_INCOMPLETE_PARAMETER_LIST"; + + case CUFFT_PARSE_ERROR: + return "CUFFT_PARSE_ERROR"; + case CUFFT_LICENSE_ERROR: return "CUFFT_LICENSE_ERROR"; +#endif case CUFFT_NOT_SUPPORTED: return "CUFFT_NOT_SUPPORTED"; + + default: + return ""; } - - return ""; } #endif @@ -965,4 +968,4 @@ inline bool checkCudaCapabilities(int major_version, int minor_version) { // end of CUDA Helper Functions -#endif // COMMON_HELPER_CUDA_H_ \ No newline at end of file +#endif // COMMON_HELPER_CUDA_H_ From 3410f7c088f1d250fd7cfb4bbdff68c0eeb62a2b Mon Sep 17 00:00:00 2001 From: Levi Zhou <31941107+ZhouXY-PKU@users.noreply.github.com> Date: Thu, 18 Dec 2025 20:14:28 +0800 Subject: [PATCH 3/4] Update CMakeLists.txt --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f29d74f18..77761e7dc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,7 +153,9 @@ set(ABACUS_BIN_PATH ${CMAKE_CURRENT_BINARY_DIR}/${ABACUS_BIN_NAME}) include_directories(${ABACUS_SOURCE_DIR}) include_directories(${ABACUS_SOURCE_DIR}/module_base/module_container) -set(CMAKE_CXX_STANDARD 11) +if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 11) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) add_executable(${ABACUS_BIN_NAME} source/main.cpp) @@ -294,6 +296,10 @@ endif() if(USE_CUDA) cmake_minimum_required(VERSION 3.18) # required by `CUDA_ARCHITECTURES` below set_if_higher(CMAKE_CXX_STANDARD 14) + if(CUDA_VERSION VERSION_GREATER_EQUAL "13.0") + message(STATUS "CUDA ${CUDA_VERSION} detected. Setting CMAKE_CUDA_STANDARD to 17.") + set_if_higher(CMAKE_CXX_STANDARD 17) + endif() set(CMAKE_CXX_EXTENSIONS ON) set(CMAKE_CUDA_STANDARD ${CMAKE_CXX_STANDARD}) set(CMAKE_CUDA_STANDARD_REQUIRED ON) From 0941fc95c7381ab5489455bcedff701132a64e6f Mon Sep 17 00:00:00 2001 From: Levi Zhou <31941107+ZhouXY-PKU@users.noreply.github.com> Date: Thu, 18 Dec 2025 20:24:37 +0800 Subject: [PATCH 4/4] Update global.h --- source/module_hamilt_pw/hamilt_pwdft/global.h | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/source/module_hamilt_pw/hamilt_pwdft/global.h b/source/module_hamilt_pw/hamilt_pwdft/global.h index 4a00fd5f12..779bc2c758 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/global.h +++ b/source/module_hamilt_pw/hamilt_pwdft/global.h @@ -15,6 +15,7 @@ #include "module_hamilt_general/module_xc/xc_functional.h" #ifdef __CUDA #include "cublas_v2.h" +#include // for CUDA_VERSION #include "cufft.h" static const char* _cublasGetErrorString(cublasStatus_t error) @@ -65,22 +66,27 @@ static const char* _cufftGetErrorString(cufftResult_t error) return "CUFFT_INVALID_SIZE"; case CUFFT_UNALIGNED_DATA: return "CUFFT_UNALIGNED_DATA"; - case CUFFT_INCOMPLETE_PARAMETER_LIST: - return "CUFFT_INCOMPLETE_PARAMETER_LIST"; case CUFFT_INVALID_DEVICE: return "CUFFT_INVALID_DEVICE"; - case CUFFT_PARSE_ERROR: - return "CUFFT_PARSE_ERROR"; case CUFFT_NO_WORKSPACE: return "CUFFT_NO_WORKSPACE"; case CUFFT_NOT_IMPLEMENTED: return "CUFFT_NOT_IMPLEMENTED"; - case CUFFT_LICENSE_ERROR: - return "CUFFT_LICENSE_ERROR"; case CUFFT_NOT_SUPPORTED: return "CUFFT_NOT_SUPPORTED"; + +#if defined(CUDA_VERSION) && CUDA_VERSION < 13000 + case CUFFT_INCOMPLETE_PARAMETER_LIST: + return "CUFFT_INCOMPLETE_PARAMETER_LIST"; + case CUFFT_PARSE_ERROR: + return "CUFFT_PARSE_ERROR"; + case CUFFT_LICENSE_ERROR: + return "CUFFT_LICENSE_ERROR"; +#endif + + default: + return ""; } - return ""; } #define CHECK_CUDA(func) \