diff --git a/CMakeLists.txt b/CMakeLists.txt index c0d4a8a52cc..4315912e5e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ project( LANGUAGES CXX) option(ENABLE_MPI "Enable MPI" ON) -option(USE_OPENMP "Enable OpenMP" ON) +option(ENABLE_OPENMP "Enable OpenMP" ON) option(USE_CUDA "Enable CUDA" OFF) option(USE_CUDA_MPI "Enable CUDA-aware MPI" OFF) option(USE_CUDA_ON_DCU "Enable CUDA on DCU" OFF) @@ -23,27 +23,23 @@ option(USE_DSP "Enable DSP" OFF) option(USE_KML "Enable Kunpeng Math Library" OFF) option(USE_SW "Enable SW Architecture" OFF) -option(USE_ABACUS_LIBM "Build libmath from source to speed up" OFF) +option(ENABLE_ABACUS_LIBM "Build libmath from source to speed up" OFF) option(ENABLE_LIBXC "Enable using the LibXC package" OFF) option(ENABLE_FLOAT_FFTW "Enable using single-precision FFTW library." OFF) -# option(ENABLE_DEEPKS "Enable the DeePKS algorithm" OFF) -# option(ENABLE_MLKEDF "Enable the Machine-Learning-based KEDF for OFDFT" OFF) - option(ENABLE_MLALGO "Enable the machine learning algorithms" OFF) option(ENABLE_LCAO "Enable LCAO algorithm" ON) -option(USE_ELPA "Enable ELPA for LCAO" ON) +option(ENABLE_ELPA "Enable ELPA for LCAO" ON) option(ENABLE_LIBRI "Enable LibRI for hybrid functional" OFF) option(EXX_DEV "Enable LibRI developing features" OFF) -option(ENABLE_LIBCOMM "Enable LibComm" OFF) option(ENABLE_PEXSI "Enable PEXSI for LCAO" OFF) option(ENABLE_DFTD4 "Enable DFT-D4 dispersion correction" OFF) option(BUILD_TESTING "Build unittests" OFF) option(DEBUG_INFO "Print message to debug" OFF) option(ENABLE_ASAN "Enable AddressSanitizer" OFF) -option(INFO "Enable gathering math library information" OFF) +option(MATH_INFO "Enable gathering math library information" OFF) option(ENABLE_COVERAGE "Enable coverage build" OFF) option(GIT_SUBMODULE "Check submodules during build" ON) @@ -59,6 +55,43 @@ option(ENABLE_CNPY "Enable cnpy usage" OFF) option(ENABLE_CUSOLVERMP "Enable cusolvermp" OFF) option(ENABLE_NCCL_PARALLEL_DEVICE "Enable NCCL-backed collectives in parallel_device" OFF) +# ============================================================================== +# Deprecated options (TODO: Remove this section in the future release) +# ============================================================================== +function(abacus_rename_option old_name new_name) + get_property(_old_defined CACHE "${old_name}" PROPERTY TYPE SET) + if(NOT _old_defined) + return() + endif() + message(WARNING "${old_name} has been renamed to ${new_name}.") + get_property(_type CACHE "${new_name}" PROPERTY TYPE) + get_property(_help CACHE "${new_name}" PROPERTY HELPSTRING) + set("${new_name}" "${${old_name}}" CACHE "${_type}" "${_help}" FORCE) + unset("${old_name}" CACHE) +endfunction() +abacus_rename_option(USE_OPENMP ENABLE_OPENMP) +abacus_rename_option(USE_ABACUS_LIBM ENABLE_ABACUS_LIBM) +abacus_rename_option(USE_ELPA ENABLE_ELPA) +abacus_rename_option(INFO MATH_INFO) + +if(DEFINED CACHE{ENABLE_LIBCOMM}) + message( + WARNING + "Option ENABLE_LIBCOMM is deprecated and will be ignored in a future release. " + "LibComm is now treated as an implementation dependency of LibRI; " + "please use -DENABLE_LIBRI=ON instead." + ) + if(ENABLE_LIBCOMM AND NOT ENABLE_LIBRI) + message( + FATAL_ERROR + "ENABLE_LIBCOMM was set, but LibComm is not a standalone ABACUS feature. " + "Please use -DENABLE_LIBRI=ON instead." + ) + endif() + unset(ENABLE_LIBCOMM CACHE) +endif() +# ============================================================================== + # CTest defines BUILD_TESTING when it is first included. Include it only after # ABACUS has declared its OFF-by-default option above. include(CTest) @@ -139,7 +172,7 @@ endif() # Serial version of ABACUS will not use ELPA if(NOT ENABLE_MPI) - set(USE_ELPA OFF) + set(ENABLE_ELPA OFF) set(ENABLE_MLALGO OFF) endif() @@ -203,7 +236,7 @@ endif() # Use DSP hardware if (USE_DSP) - set(USE_ELPA OFF) + set(ENABLE_ELPA OFF) set(ABACUS_BIN_NAME abacus_dsp) endif() @@ -288,14 +321,14 @@ endif() if(CMAKE_CXX_COMPILER_ID MATCHES Intel) # stick to strict floating point model on Intel Compiler add_compile_options(-fp-model=strict) - set(USE_ABACUS_LIBM OFF) # Force turn off USE_ABACUS_LIBM on Intel Compiler + set(ENABLE_ABACUS_LIBM OFF) # Force turn off ENABLE_ABACUS_LIBM on Intel Compiler set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings " ) endif() -if(USE_ABACUS_LIBM) - abacus_add_feature_definitions(USE_ABACUS_LIBM) +if(ENABLE_ABACUS_LIBM) + abacus_add_feature_definitions(__ABACUS_LIBM) endif() if(ENABLE_NATIVE_OPTIMIZATION) @@ -311,9 +344,8 @@ if(WIN32) endif() if(ENABLE_LCAO) - find_package(cereal CONFIG REQUIRED) abacus_add_feature_definitions(__LCAO) - if(USE_ELPA) + if(ENABLE_ELPA) find_package(ELPA REQUIRED) abacus_add_feature_definitions(__ELPA) endif() @@ -364,7 +396,7 @@ endif() find_package(Threads REQUIRED) -if(USE_OPENMP) +if(ENABLE_OPENMP) find_package(OpenMP REQUIRED) endif() @@ -484,7 +516,7 @@ if(USE_CUDA) if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -g -G" CACHE STRING "CUDA flags for debug build" FORCE) endif() - if (USE_OPENMP AND OpenMP_CXX_FOUND) + if (ENABLE_OPENMP AND OpenMP_CXX_FOUND) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=${OpenMP_CXX_FLAGS}" CACHE STRING "CUDA flags" FORCE) endif() if (ENABLE_NCCL_PARALLEL_DEVICE) @@ -654,15 +686,11 @@ function(git_submodule_update) endif() endfunction() -if(DEFINED LIBRI_DIR) - set(ENABLE_LIBRI ON) -endif() if(ENABLE_LIBRI) set_if_higher(CMAKE_CXX_STANDARD 14) - if(LIBRI_DIR) - else() - find_package(LibRI REQUIRED) - endif() + find_package(LibRI REQUIRED) + find_package(LibComm REQUIRED) + find_package(cereal REQUIRED CONFIG) abacus_add_feature_definitions(__EXX EXX_DM=3 EXX_H_COMM=2 TEST_EXX_LCAO=0 TEST_EXX_RADIAL=1) if(EXX_DEV) @@ -670,17 +698,6 @@ if(ENABLE_LIBRI) endif() endif() -if(ENABLE_LIBRI OR DEFINED LIBCOMM_DIR) - set(ENABLE_LIBCOMM ON) -endif() -if(ENABLE_LIBCOMM) - if(LIBCOMM_DIR) - else() - find_package(LibComm REQUIRED) - endif() -endif() - - if(ENABLE_LIBXC) find_package(Libxc CONFIG REQUIRED) if(Libxc_VERSION VERSION_LESS "5.1.7") @@ -712,7 +729,7 @@ endif() abacus_add_feature_definitions(__FFTW3 __SELINV METIS) -if(INFO) +if(MATH_INFO) message(STATUS "Will gather math lib info.") abacus_add_feature_definitions(GATHER_INFO) # modifications on blas_connector and lapack_connector diff --git a/cmake/CollectBuildInfoVars.cmake b/cmake/CollectBuildInfoVars.cmake index 962054a3f8d..61246e3a61d 100644 --- a/cmake/CollectBuildInfoVars.cmake +++ b/cmake/CollectBuildInfoVars.cmake @@ -136,16 +136,16 @@ if(ENABLE_MPI) endif() # OpenMP Version -if(USE_OPENMP AND OpenMP_CXX_VERSION) +if(ENABLE_OPENMP AND OpenMP_CXX_VERSION) set(ABACUS_OPENMP_VERSION "yes (v${OpenMP_CXX_VERSION})") -elseif(USE_OPENMP) +elseif(ENABLE_OPENMP) set(ABACUS_OPENMP_VERSION "yes (version unknown)") else() set(ABACUS_OPENMP_VERSION "no") endif() # Core Math Libraries -if(ENABLE_LCAO AND USE_ELPA) +if(ENABLE_LCAO AND ENABLE_ELPA) set(ABACUS_ELPA_VERSION "yes (version unknown)") if(ELPA_VERSION) set(ABACUS_ELPA_VERSION "yes (v${ELPA_VERSION})") @@ -208,30 +208,6 @@ else() set(ABACUS_FFTW_VERSION "no (using MKL or SW)") endif() -# Cereal Version (Enhanced) -if(ENABLE_LCAO) - set(ABACUS_CEREAL_VERSION "yes (version unknown)") - if(NOT CEREAL_INCLUDE_DIR) - find_path(CEREAL_INCLUDE_DIR cereal/version.hpp) - endif() - if(CEREAL_INCLUDE_DIR AND EXISTS "${CEREAL_INCLUDE_DIR}/cereal/version.hpp") - file(STRINGS "${CEREAL_INCLUDE_DIR}/cereal/version.hpp" CEREAL_MAJOR_LINE REGEX "^#define CEREAL_VERSION_MAJOR") - file(STRINGS "${CEREAL_INCLUDE_DIR}/cereal/version.hpp" CEREAL_MINOR_LINE REGEX "^#define CEREAL_VERSION_MINOR") - file(STRINGS "${CEREAL_INCLUDE_DIR}/cereal/version.hpp" CEREAL_PATCH_LINE REGEX "^#define CEREAL_VERSION_PATCH") - string(REGEX REPLACE "^#define CEREAL_VERSION_MAJOR +([0-9]+).*" "\\1" CEREAL_MAJOR "${CEREAL_MAJOR_LINE}") - string(REGEX REPLACE "^#define CEREAL_VERSION_MINOR +([0-9]+).*" "\\1" CEREAL_MINOR "${CEREAL_MINOR_LINE}") - string(REGEX REPLACE "^#define CEREAL_VERSION_PATCH +([0-9]+).*" "\\1" CEREAL_PATCH "${CEREAL_PATCH_LINE}") - if(CEREAL_MAJOR AND CEREAL_MINOR AND CEREAL_PATCH) - set(ABACUS_CEREAL_VERSION "yes (v${CEREAL_MAJOR}.${CEREAL_MINOR}.${CEREAL_PATCH})") - endif() - endif() - if(ABACUS_CEREAL_VERSION STREQUAL "yes (version unknown)" AND CEREAL_INCLUDE_DIR) - set(ABACUS_CEREAL_VERSION "yes (path: ${CEREAL_INCLUDE_DIR})") - endif() -else() - set(ABACUS_CEREAL_VERSION "no") -endif() - # Accelerators if(USE_CUDA AND CUDAToolkit_VERSION) set(ABACUS_CUDA_VERSION "yes (v${CUDAToolkit_VERSION})") @@ -292,12 +268,37 @@ else() set(ABACUS_LIBRI_VERSION "no") endif() -if(ENABLE_LIBCOMM AND LIBCOMM_DIR) - set(ABACUS_LIBCOMM_VERSION "yes (path: ${LIBCOMM_DIR})") -elseif(ENABLE_LIBCOMM) - set(ABACUS_LIBCOMM_VERSION "yes (version unknown)") +# LibComm Version +if(ENABLE_LIBRI AND LIBCOMM_DIR) + set(ABACUS_LIBCOMM_VERSION "yes (path: ${LIBCOMM_DIR})") +elseif(ENABLE_LIBRI) + set(ABACUS_LIBCOMM_VERSION "yes (version unknown)") else() - set(ABACUS_LIBCOMM_VERSION "no") + set(ABACUS_LIBCOMM_VERSION "no") +endif() + +# Cereal Version (Enhanced) +if(ENABLE_LIBRI) + set(ABACUS_CEREAL_VERSION "yes (version unknown)") + if(NOT CEREAL_INCLUDE_DIR) + find_path(CEREAL_INCLUDE_DIR cereal/version.hpp) + endif() + if(CEREAL_INCLUDE_DIR AND EXISTS "${CEREAL_INCLUDE_DIR}/cereal/version.hpp") + file(STRINGS "${CEREAL_INCLUDE_DIR}/cereal/version.hpp" CEREAL_MAJOR_LINE REGEX "^#define CEREAL_VERSION_MAJOR") + file(STRINGS "${CEREAL_INCLUDE_DIR}/cereal/version.hpp" CEREAL_MINOR_LINE REGEX "^#define CEREAL_VERSION_MINOR") + file(STRINGS "${CEREAL_INCLUDE_DIR}/cereal/version.hpp" CEREAL_PATCH_LINE REGEX "^#define CEREAL_VERSION_PATCH") + string(REGEX REPLACE "^#define CEREAL_VERSION_MAJOR +([0-9]+).*" "\\1" CEREAL_MAJOR "${CEREAL_MAJOR_LINE}") + string(REGEX REPLACE "^#define CEREAL_VERSION_MINOR +([0-9]+).*" "\\1" CEREAL_MINOR "${CEREAL_MINOR_LINE}") + string(REGEX REPLACE "^#define CEREAL_VERSION_PATCH +([0-9]+).*" "\\1" CEREAL_PATCH "${CEREAL_PATCH_LINE}") + if(CEREAL_MAJOR AND CEREAL_MINOR AND CEREAL_PATCH) + set(ABACUS_CEREAL_VERSION "yes (v${CEREAL_MAJOR}.${CEREAL_MINOR}.${CEREAL_PATCH})") + endif() + endif() + if(ABACUS_CEREAL_VERSION STREQUAL "yes (version unknown)" AND CEREAL_INCLUDE_DIR) + set(ABACUS_CEREAL_VERSION "yes (path: ${CEREAL_INCLUDE_DIR})") + endif() +else() + set(ABACUS_CEREAL_VERSION "no") endif() # ML & AI Libraries @@ -384,11 +385,11 @@ endif() # --- 5. Collect CMake Configuration Summary --- set(ABACUS_CMAKE_OPTIONS "Build Options:") list(APPEND CMAKE_OPTIONS_LIST " ENABLE_MPI=${ENABLE_MPI}") -list(APPEND CMAKE_OPTIONS_LIST " USE_OPENMP=${USE_OPENMP}") +list(APPEND CMAKE_OPTIONS_LIST " ENABLE_OPENMP=${ENABLE_OPENMP}") list(APPEND CMAKE_OPTIONS_LIST " USE_CUDA=${USE_CUDA}") list(APPEND CMAKE_OPTIONS_LIST " USE_ROCM=${USE_ROCM}") list(APPEND CMAKE_OPTIONS_LIST " ENABLE_LCAO=${ENABLE_LCAO}") -list(APPEND CMAKE_OPTIONS_LIST " USE_ELPA=${USE_ELPA}") +list(APPEND CMAKE_OPTIONS_LIST " ENABLE_ELPA=${ENABLE_ELPA}") list(APPEND CMAKE_OPTIONS_LIST " ENABLE_LIBXC=${ENABLE_LIBXC}") list(APPEND CMAKE_OPTIONS_LIST " ENABLE_MLALGO=${ENABLE_MLALGO}") list(APPEND CMAKE_OPTIONS_LIST " ENABLE_ASAN=${ENABLE_ASAN}") diff --git a/cmake/modules/FindELPA.cmake b/cmake/modules/FindELPA.cmake index 75689a73641..672543877de 100644 --- a/cmake/modules/FindELPA.cmake +++ b/cmake/modules/FindELPA.cmake @@ -30,7 +30,7 @@ if(ELPA_INCLUDE_DIRS MATCHES "^/usr/include/elpa/.*") unset(ELPA_INCLUDE_DIRS) endif() endif() -if(USE_OPENMP) +if(ENABLE_OPENMP) find_library(ELPA_LINK_LIBRARIES NAMES elpa_openmp elpa HINTS ${ELPA_DIR} @@ -51,7 +51,7 @@ if(NOT ELPA_INCLUDE_DIRS AND PKG_CONFIG_FOUND) if(DEFINED ELPA_DIR) string(APPEND CMAKE_PREFIX_PATH ";${ELPA_DIR}") endif() - if(USE_OPENMP) + if(ENABLE_OPENMP) pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp) else() pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa) diff --git a/cmake/modules/FindFFTW3.cmake b/cmake/modules/FindFFTW3.cmake index 6491aebf136..2cf8625f72a 100644 --- a/cmake/modules/FindFFTW3.cmake +++ b/cmake/modules/FindFFTW3.cmake @@ -26,7 +26,7 @@ if(ENABLE_FLOAT_FFTW) endif() # Both libfftw3.so and libfftw3_omp.so are required for OpenMP builds. -if (USE_OPENMP) +if (ENABLE_OPENMP) find_library(FFTW3_OMP_LIBRARY NAMES fftw3_omp HINTS ${FFTW3_DIR} @@ -38,7 +38,7 @@ endif() # set FFTW3_FOUND to TRUE if all variables are non-zero. include(FindPackageHandleStandardArgs) set(_fftw3_required_vars FFTW3_LIBRARY FFTW3_INCLUDE_DIR) -if(USE_OPENMP) +if(ENABLE_OPENMP) list(APPEND _fftw3_required_vars FFTW3_OMP_LIBRARY) endif() if(ENABLE_FLOAT_FFTW) @@ -49,7 +49,7 @@ find_package_handle_standard_args(FFTW3 DEFAULT_MSG ${_fftw3_required_vars}) # Copy the results to the output variables and target. if(FFTW3_FOUND) set(FFTW3_LIBRARIES ${FFTW3_LIBRARY}) - if (USE_OPENMP) + if (ENABLE_OPENMP) list(APPEND FFTW3_LIBRARIES ${FFTW3_OMP_LIBRARY}) endif() @@ -77,7 +77,7 @@ if(FFTW3_FOUND) IMPORTED_LOCATION "${FFTW3_FLOAT_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIRS}") endif() - if (USE_OPENMP) + if (ENABLE_OPENMP) if(NOT TARGET FFTW3::FFTW3_OMP) add_library(FFTW3::FFTW3_OMP UNKNOWN IMPORTED) set_target_properties(FFTW3::FFTW3_OMP PROPERTIES diff --git a/cmake/modules/FindKML.cmake b/cmake/modules/FindKML.cmake index 3952463a9e8..90aeed49257 100644 --- a/cmake/modules/FindKML.cmake +++ b/cmake/modules/FindKML.cmake @@ -20,7 +20,7 @@ # KML_BLAS_THREADING kblas variant: auto, multi, locking, or nolocking # (default: auto) # -# The default threading selection uses the caller's USE_OPENMP option when it +# The default threading selection uses the caller's ENABLE_OPENMP option when it # is available: multi for OpenMP builds and nolocking otherwise. Projects can # select a KML_BLAS_THREADING variant explicitly. # @@ -46,7 +46,7 @@ endif() set(_kml_thread_variants multi locking nolocking) if(KML_BLAS_THREADING STREQUAL "auto") - if(DEFINED USE_OPENMP AND USE_OPENMP) + if(ENABLE_OPENMP) set(_kml_blas_threading multi) else() set(_kml_blas_threading nolocking) diff --git a/cmake/modules/FindMKL.cmake b/cmake/modules/FindMKL.cmake index 5f1980e990f..8d324666bc1 100644 --- a/cmake/modules/FindMKL.cmake +++ b/cmake/modules/FindMKL.cmake @@ -61,7 +61,7 @@ endif() # Keep MKL threading internal: derive it from ABACUS OpenMP support and the # known compiler/runtime combinations. Unknown OpenMP runtimes use sequential MKL. set(_mkl_threading sequential) -if(USE_OPENMP) +if(ENABLE_OPENMP) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(_mkl_threading gnu_thread) elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") diff --git a/docs/advanced/acceleration/cuda.md b/docs/advanced/acceleration/cuda.md index 64d47532750..42c09859d78 100644 --- a/docs/advanced/acceleration/cuda.md +++ b/docs/advanced/acceleration/cuda.md @@ -29,7 +29,7 @@ To compile and use ABACUS in CUDA mode, you currently need to have an NVIDIA GPU Check the [Advanced Installation Options](https://abacus-rtd.readthedocs.io/en/latest/advanced/install.html#build-with-cuda-support) for the installation of CUDA version support. -Setting both USE_ELPA and USE_CUDA to ON does not automatically enable ELPA to run on GPUs. ELPA support for GPUs needs to be enabled when ELPA is compiled. [enable GPU support](https://github.com/marekandreas/elpa/blob/master/documentation/INSTALL.md). +Setting both `ENABLE_ELPA` and `USE_CUDA` to ON does not automatically enable ELPA to run on GPUs. ELPA support for GPUs needs to be enabled when ELPA is compiled. [enable GPU support](https://github.com/marekandreas/elpa/blob/master/documentation/INSTALL.md). The ABACUS program will automatically determine whether the current ELPA supports GPU based on the elpa/elpa_configured_options.h header file. Users can also check this header file to determine the GPU support of ELPA in their environment. ELPA introduced a new API elpa_setup_gpu in version 2023.11.001. So if you want to enable ELPA GPU in ABACUS, the ELPA version must be greater than or equal to 2023.11.001. diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index 504c4df731a..deb798ad9d0 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -1163,7 +1163,7 @@ - scalapack_gvx: Use Scalapack to diagonalize the Hamiltonian. - cusolver: Use CUSOLVER to diagonalize the Hamiltonian, at least one GPU is needed. - cusolvermp: Use CUSOLVER to diagonalize the Hamiltonian, supporting multi-GPU devices. Note that you should set the number of MPI processes equal to the number of GPUs. - - elpa: The ELPA solver supports both CPU and GPU. By setting the `device` to GPU, you can launch the ELPA solver with GPU acceleration (provided that you have installed a GPU-supported version of ELPA, which requires you to manually compile and install ELPA, and the ABACUS should be compiled with -DUSE_ELPA=ON and -DUSE_CUDA=ON). The ELPA solver also supports multi-GPU acceleration. + - elpa: The ELPA solver supports both CPU and GPU. By setting the `device` to GPU, you can launch the ELPA solver with GPU acceleration (provided that you have installed a GPU-supported version of ELPA, which requires you to manually compile and install ELPA, and the ABACUS should be compiled with -DENABLE_ELPA=ON and -DUSE_CUDA=ON). The ELPA solver also supports multi-GPU acceleration. If you set ks_solver=`genelpa` for basis_type=`pw`, the program will stop with an error message: @@ -1173,9 +1173,9 @@ - **Default**: - PW basis: cg. - LCAO basis: - - genelpa (if compiling option `USE_ELPA` has been set) + - genelpa (if compiling option `ENABLE_ELPA` has been set) - lapack (if compiling option `ENABLE_MPI` has not been set) - - scalapack_gvx (if compiling option `USE_ELPA` has not been set and compiling option `ENABLE_MPI` has been set) + - scalapack_gvx (if compiling option `ENABLE_ELPA` has not been set and compiling option `ENABLE_MPI` has been set) - cusolver (if compiling option `USE_CUDA` has been set) ### nbands diff --git a/docs/advanced/install.md b/docs/advanced/install.md index 798e38fd3a5..ed1e783ff0d 100644 --- a/docs/advanced/install.md +++ b/docs/advanced/install.md @@ -73,7 +73,9 @@ The new EXX implementation depends on two external libraries: These two libraries are added as submodules in the [deps](https://github.com/deepmodeling/abacus-develop/tree/develop/deps) folder. Set `-DENABLE_LIBRI=ON` to build with these two libraries. -If you prefer using manually downloaded libraries, provide `-DLIBRI_DIR=${path to your LibRI folder} -DLIBCOMM_DIR=${path to your LibComm folder}`. +```{note} +`ENABLE_LIBCOMM` is deprecated because LibComm is not a standalone ABACUS feature. CMake locates it automatically as a dependency of LibRI. If you prefer using manually downloaded libraries, enable LibRI and provide their locations via `-DLIBRI_DIR=/path/to/LibRI` and `-DLIBCOMM_DIR=/path/to/LibComm`. +``` ## Build with DFT-D4 support @@ -134,13 +136,13 @@ If you are confident that your MPI supports CUDA Aware, you can add `-DUSE_CUDA_ > Note: We recommend using the latest available compiler sets, since they offer faster implementations of math functions. -This flag is disabled by default. To build math functions from source code, define `USE_ABACUS_LIBM` flag. It is expected to get a better performance on legacy versions of `gcc` and `clang`. +This flag is disabled by default. To build math functions from source code, define `ENABLE_ABACUS_LIBM` flag. It is expected to get a better performance on legacy versions of `gcc` and `clang`. Currently supported math functions: `sin`, `cos`, `sincos`, `exp`, `cexp` ```bash -cmake -B build -DUSE_ABACUS_LIBM=1 +cmake -B build -DENABLE_ABACUS_LIBM=1 ``` ## Build with PEXSI support diff --git a/docs/parameters.yaml b/docs/parameters.yaml index bcb562fa693..3856d1c7af9 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -544,14 +544,14 @@ parameters: * scalapack_gvx: Use Scalapack to diagonalize the Hamiltonian. * cusolver: Use CUSOLVER to diagonalize the Hamiltonian, at least one GPU is needed. * cusolvermp: Use CUSOLVER to diagonalize the Hamiltonian, supporting multi-GPU devices. Note that you should set the number of MPI processes equal to the number of GPUs. - * elpa: The ELPA solver supports both CPU and GPU. By setting the `device` to GPU, you can launch the ELPA solver with GPU acceleration (provided that you have installed a GPU-supported version of ELPA, which requires you to manually compile and install ELPA, and the ABACUS should be compiled with -DUSE_ELPA=ON and -DUSE_CUDA=ON). The ELPA solver also supports multi-GPU acceleration. + * elpa: The ELPA solver supports both CPU and GPU. By setting the `device` to GPU, you can launch the ELPA solver with GPU acceleration (provided that you have installed a GPU-supported version of ELPA, which requires you to manually compile and install ELPA, and the ABACUS should be compiled with -DENABLE_ELPA=ON and -DUSE_CUDA=ON). The ELPA solver also supports multi-GPU acceleration. If you set ks_solver=`genelpa` for basis_type=`pw`, the program will stop with an error message: ``text genelpa can not be used with plane wave basis. `` Then the user has to correct the input file and restart the calculation. - default_value: "\n - PW basis: cg.\n - LCAO basis:\n - genelpa (if compiling option `USE_ELPA` has been set)\n - lapack (if compiling option `ENABLE_MPI` has not been set)\n - scalapack_gvx (if compiling option `USE_ELPA` has not been set and compiling option `ENABLE_MPI` has been set)\n - cusolver (if compiling option `USE_CUDA` has been set)" + default_value: "\n - PW basis: cg.\n - LCAO basis:\n - genelpa (if compiling option `ENABLE_ELPA` has been set)\n - lapack (if compiling option `ENABLE_MPI` has not been set)\n - scalapack_gvx (if compiling option `ENABLE_ELPA` has not been set and compiling option `ENABLE_MPI` has been set)\n - cusolver (if compiling option `USE_CUDA` has been set)" unit: "" availability: "" - name: nbands diff --git a/docs/quick_start/easy_install.md b/docs/quick_start/easy_install.md index 80a047d97de..9f2aa166eeb 100644 --- a/docs/quick_start/easy_install.md +++ b/docs/quick_start/easy_install.md @@ -163,7 +163,7 @@ Here, 'build' is the path for building ABACUS; and '-D' is used for setting up s - `FFTW3_DIR`: Path to FFTW3. - `LIBRI_DIR`: (Optional) Path to LibRI. - - `LIBCOMM_DIR`: (Optional) Path to LibComm. + - `LIBCOMM_DIR`: (Optional) Path to LibComm when `ENABLE_LIBRI=ON`. ```{important} For some dependencies built with CMake, such as Libxc, dftd4, cereal, and RapidJSON, you'll have to add their prefix paths to the environment variable `CMAKE_PREFIX_PATH` so that CMake can correctly find and use their CMake configuration files. A non-general variable such as `PKG_DIR` is discouraged for these packages. @@ -172,14 +172,14 @@ For some dependencies built with CMake, such as Libxc, dftd4, cereal, and RapidJ - Components: The values of these variables should be 'ON', '1' or 'OFF', '0'. The default values are given below. - `ENABLE_LCAO=ON`: Enable LCAO calculation. If SCALAPACK, ELPA or CEREAL is absent and only require plane-wave calculations, the feature of calculating LCAO basis can be turned off. - `ENABLE_LIBXC=OFF`: [Enable Libxc](../advanced/install.md#add-libxc-support) to suppport variety of functionals. - - `ENABLE_LIBRI=OFF`: [Enable LibRI](../advanced/install.md#add-libri-support) to suppport variety of functionals. If `LIBRI_DIR` and `LIBCOMM_DIR` are defined, `ENABLE_LIBRI` will set to 'ON'. - - `USE_OPENMP=ON`: Enable OpenMP support. Building ABACUS without OpenMP is not fully tested yet. + - `ENABLE_LIBRI=OFF`: [Enable LibRI](../advanced/install.md#add-libri-support) and its LibComm dependency for hybrid-functional calculations. Set `LIBRI_DIR` and `LIBCOMM_DIR` to use manually installed libraries. + - `ENABLE_OPENMP=ON`: Enable OpenMP support. Building ABACUS without OpenMP is not fully tested yet. - `BUILD_TESTING=OFF`: [Build unit tests](../advanced/install.md#build-unit-tests). - `ENABLE_GOOGLEBENCH=OFF`: [Build performance tests](../advanced/install.md#build-performance-tests) - `ENABLE_MPI=ON`: Enable MPI parallel compilation. If set to `OFF`, a serial version of ABACUS will be compiled. It now supports both PW and LCAO. - `ENABLE_COVERAGE=OFF`: Build ABACUS executable supporting [coverage analysis](../CONTRIBUTING.md#generating-code-coverage-report). This feature has a drastic impact on performance. - `ENABLE_ASAN=OFF`: Build with Address Sanitizer. This feature would help detecting memory problems. - - `USE_ELPA=ON`: Use ELPA library in LCAO calculations. If this value is set to OFF, ABACUS can be compiled without ELPA library. + - `ENABLE_ELPA=ON`: Use ELPA library in LCAO calculations. If this value is set to OFF, ABACUS can be compiled without ELPA library. Here is an example: diff --git a/generate_build_info.sh b/generate_build_info.sh index d7a2075cfd2..d892c532772 100755 --- a/generate_build_info.sh +++ b/generate_build_info.sh @@ -63,7 +63,7 @@ CUDA_FLAGS="${CUDAFLAGS:-}" # Detect Platform based on environment variables if [ "${USE_ROCM}" == "ON" ]; then PLATFORM_NAME="CPU + AMD ROCm"; fi if [ "${USE_CUDA}" == "ON" ]; then PLATFORM_NAME="CPU + NVIDIA CUDA"; fi -if [ "${USE_ELPA}" == "ON" ] && [ "${ENABLE_LCAO}" == "ON" ]; then PLATFORM_NAME="${PLATFORM_NAME} + ELPA"; fi +if [ "${ENABLE_ELPA}" == "ON" ] && [ "${ENABLE_LCAO}" == "ON" ]; then PLATFORM_NAME="${PLATFORM_NAME} + ELPA"; fi # 2. MPI MPI_IMPLEMENTATION="no" @@ -188,7 +188,7 @@ fi # 9. ELPA ELPA_VERSION="no" -if [ "${USE_ELPA}" == "ON" ] && [ -n "$ELPA_DIR" ]; then +if [ "${ENABLE_ELPA}" == "ON" ] && [ -n "$ELPA_DIR" ]; then ELPA_VERSION="yes (version unknown)" if [ -f "$ELPA_DIR/bin/elpa2_print_version" ]; then version=$("$ELPA_DIR/bin/elpa2_print_version" 2>/dev/null) diff --git a/python/pyabacus/CMakeLists.txt b/python/pyabacus/CMakeLists.txt index 222a294dd67..5c3035ee408 100644 --- a/python/pyabacus/CMakeLists.txt +++ b/python/pyabacus/CMakeLists.txt @@ -34,8 +34,8 @@ if(MKLROOT) #add_compile_definitions(__MPI) endif() - set(USE_OPENMP ON) - if(USE_OPENMP) + set(ENABLE_OPENMP ON) + if(ENABLE_OPENMP) find_package(OpenMP REQUIRED) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") add_link_options(${OpenMP_CXX_LIBRARIES}) diff --git a/python/pyabacus/CONTRIBUTING.md b/python/pyabacus/CONTRIBUTING.md index 9f943ceebab..a9a7198bc6a 100644 --- a/python/pyabacus/CONTRIBUTING.md +++ b/python/pyabacus/CONTRIBUTING.md @@ -96,8 +96,8 @@ if(MKLROOT) include_directories(${MPI_CXX_INCLUDE_PATH}) endif() - set(USE_OPENMP ON) - if(USE_OPENMP) + set(ENABLE_OPENMP ON) + if(ENABLE_OPENMP) find_package(OpenMP REQUIRED) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") add_link_options(${OpenMP_CXX_LIBRARIES}) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index d43888feebd..caa18cac9c8 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -124,7 +124,7 @@ else() if(ENABLE_MPI) list(APPEND _abacus_linalg_libs ScaLAPACK::ScaLAPACK) endif() - if(USE_OPENMP) + if(ENABLE_OPENMP) list(APPEND _abacus_linalg_libs FFTW3::FFTW3_OMP) endif() list(APPEND _abacus_linalg_libs @@ -146,7 +146,7 @@ endif() if(ENABLE_MPI) list(APPEND _abacus_linalg_libs MPI::MPI_CXX) endif() -if(USE_OPENMP) +if(ENABLE_OPENMP) list(APPEND _abacus_linalg_libs OpenMP::OpenMP_CXX) endif() list(APPEND _abacus_linalg_libs Threads::Threads) @@ -193,13 +193,10 @@ if(ENABLE_RAPIDJSON) endif() if(ENABLE_LCAO) - list(APPEND _abacus_feature_libs cereal::cereal) - - if(USE_ELPA) + if(ENABLE_ELPA) list(APPEND _abacus_feature_libs ELPA::ELPA) list(APPEND _abacus_feature_include_dirs ${ELPA_INCLUDE_DIR}) endif() - if(ENABLE_PEXSI) list(APPEND _abacus_feature_libs PEXSI::PEXSI) endif() @@ -230,11 +227,11 @@ if(ENABLE_CNPY) endif() if(ENABLE_LIBRI) - list(APPEND _abacus_feature_include_dirs ${LIBRI_DIR}/include) -endif() - -if(ENABLE_LIBCOMM) - list(APPEND _abacus_feature_include_dirs ${LIBCOMM_DIR}/include) + list(APPEND _abacus_feature_include_dirs + ${LIBRI_DIR}/include + ${LIBCOMM_DIR}/include + ) + list(APPEND _abacus_feature_libs cereal::cereal) endif() if(ENABLE_LIBXC) @@ -634,7 +631,7 @@ if(ENABLE_LCAO) numerical_atomic_orbitals lr rdmft) - if(USE_ELPA) + if(ENABLE_ELPA) target_link_libraries(${ABACUS_BIN_NAME} PRIVATE genelpa) endif() if(ENABLE_PEXSI) diff --git a/source/source_base/CMakeLists.txt b/source/source_base/CMakeLists.txt index f940ba77cf1..596b3f3b463 100644 --- a/source/source_base/CMakeLists.txt +++ b/source/source_base/CMakeLists.txt @@ -1,4 +1,4 @@ -if (USE_ABACUS_LIBM) +if (ENABLE_ABACUS_LIBM) list (APPEND LIBM_SRC libm/branred.cpp libm/cexp.cpp @@ -86,7 +86,7 @@ if(BUILD_TESTING) add_subdirectory(module_mixing/test) add_subdirectory(module_device/test) add_subdirectory(module_grid/test) - if (USE_ABACUS_LIBM) + if (ENABLE_ABACUS_LIBM) add_subdirectory(libm/test) endif() endif() diff --git a/source/source_base/gather_math_lib_info.cpp b/source/source_base/gather_math_lib_info.cpp index 3cd89a94ebb..99b41ba21f6 100644 --- a/source/source_base/gather_math_lib_info.cpp +++ b/source/source_base/gather_math_lib_info.cpp @@ -1,7 +1,7 @@ // This file defines the math lib wrapper for output information before executing computations. /* -When INFO is defined in cmake configure, a macro of GATHER_INFO will be defined. +When MATH_INFO is enabled in CMake, the GATHER_INFO macro will be defined. This macro will be used to output information before executing computations. Results will output to OUT/math_info.log, see ModuleBase::Global_File::make_dir_out . */ diff --git a/source/source_base/libm/libm.h b/source/source_base/libm/libm.h index 13bf65de5c7..d6e9f852199 100644 --- a/source/source_base/libm/libm.h +++ b/source/source_base/libm/libm.h @@ -14,7 +14,7 @@ namespace ModuleBase namespace libm { -#ifdef USE_ABACUS_LIBM +#ifdef __ABACUS_LIBM double __exp (double x); double __cos (double x); diff --git a/source/source_cell/module_neighlist/test/CMakeLists.txt b/source/source_cell/module_neighlist/test/CMakeLists.txt index 114fb287f9d..281b4fc5fcb 100644 --- a/source/source_cell/module_neighlist/test/CMakeLists.txt +++ b/source/source_cell/module_neighlist/test/CMakeLists.txt @@ -52,7 +52,7 @@ if(ENABLE_MPI) PRIVATE Threads::Threads MPI::MPI_CXX ) - if(USE_OPENMP) + if(ENABLE_OPENMP) target_link_libraries(MODULE_CELL_NEIGHBOR_neighbor_search_mpi_benchmark PRIVATE OpenMP::OpenMP_CXX) endif() install(TARGETS MODULE_CELL_NEIGHBOR_neighbor_search_mpi_benchmark DESTINATION ${CMAKE_BINARY_DIR}/tests) diff --git a/source/source_hsolver/CMakeLists.txt b/source/source_hsolver/CMakeLists.txt index 64c1f2d3485..5a442d4ac3a 100644 --- a/source/source_hsolver/CMakeLists.txt +++ b/source/source_hsolver/CMakeLists.txt @@ -30,7 +30,7 @@ if(ENABLE_LCAO) diago_lapack.cpp ) endif () - if (USE_ELPA) + if (ENABLE_ELPA) list(APPEND objects diago_elpa.cpp diago_elpa_native.cpp @@ -80,7 +80,7 @@ if(ENABLE_COVERAGE) add_coverage(hsolver) endif() -if(ENABLE_LCAO AND USE_ELPA) +if(ENABLE_LCAO AND ENABLE_ELPA) add_subdirectory(module_genelpa) endif() diff --git a/source/source_io/module_parameter/read_input_item_elec_stru.cpp b/source/source_io/module_parameter/read_input_item_elec_stru.cpp index acef262729c..fd7d4cf2c7b 100644 --- a/source/source_io/module_parameter/read_input_item_elec_stru.cpp +++ b/source/source_io/module_parameter/read_input_item_elec_stru.cpp @@ -64,7 +64,7 @@ For numerical atomic orbitals basis, * scalapack_gvx: Use Scalapack to diagonalize the Hamiltonian. * cusolver: Use CUSOLVER to diagonalize the Hamiltonian, at least one GPU is needed. * cusolvermp: Use CUSOLVER to diagonalize the Hamiltonian, supporting multi-GPU devices. Note that you should set the number of MPI processes equal to the number of GPUs. -* elpa: The ELPA solver supports both CPU and GPU. By setting the `device` to GPU, you can launch the ELPA solver with GPU acceleration (provided that you have installed a GPU-supported version of ELPA, which requires you to manually compile and install ELPA, and the ABACUS should be compiled with -DUSE_ELPA=ON and -DUSE_CUDA=ON). The ELPA solver also supports multi-GPU acceleration. +* elpa: The ELPA solver supports both CPU and GPU. By setting the `device` to GPU, you can launch the ELPA solver with GPU acceleration (provided that you have installed a GPU-supported version of ELPA, which requires you to manually compile and install ELPA, and the ABACUS should be compiled with -DENABLE_ELPA=ON and -DUSE_CUDA=ON). The ELPA solver also supports multi-GPU acceleration. If you set ks_solver=`genelpa` for basis_type=`pw`, the program will stop with an error message: @@ -74,9 +74,9 @@ Then the user has to correct the input file and restart the calculation.)"; item.default_value = R"( - PW basis: cg. - LCAO basis: - - genelpa (if compiling option `USE_ELPA` has been set) + - genelpa (if compiling option `ENABLE_ELPA` has been set) - lapack (if compiling option `ENABLE_MPI` has not been set) - - scalapack_gvx (if compiling option `USE_ELPA` has not been set and compiling option `ENABLE_MPI` has been set) + - scalapack_gvx (if compiling option `ENABLE_ELPA` has not been set and compiling option `ENABLE_MPI` has been set) - cusolver (if compiling option `USE_CUDA` has been set))"; item.unit = ""; item.availability = ""; diff --git a/toolchain/build_abacus_aocc-aocl.sh b/toolchain/build_abacus_aocc-aocl.sh index c8a991f17d5..bec57f47427 100755 --- a/toolchain/build_abacus_aocc-aocl.sh +++ b/toolchain/build_abacus_aocc-aocl.sh @@ -71,8 +71,8 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DCEREAL_INCLUDE_DIR=$CEREAL \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ - -DUSE_OPENMP=ON \ - -DUSE_ELPA=ON \ + -DENABLE_OPENMP=ON \ + -DENABLE_ELPA=ON \ -DENABLE_RAPIDJSON=ON \ -DENABLE_LIBRI=ON \ -DLIBRI_DIR=$LIBRI \ diff --git a/toolchain/build_abacus_gcc-aocl.sh b/toolchain/build_abacus_gcc-aocl.sh index fe7397f0543..ed707ca3542 100755 --- a/toolchain/build_abacus_gcc-aocl.sh +++ b/toolchain/build_abacus_gcc-aocl.sh @@ -67,8 +67,8 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DELPA_DIR=$ELPA \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ - -DUSE_OPENMP=ON \ - -DUSE_ELPA=ON \ + -DENABLE_OPENMP=ON \ + -DENABLE_ELPA=ON \ -DENABLE_RAPIDJSON=ON \ -DENABLE_LIBRI=ON \ -DLIBRI_DIR=$LIBRI \ diff --git a/toolchain/build_abacus_gcc-mkl.sh b/toolchain/build_abacus_gcc-mkl.sh index db6f104351f..9246c62906a 100755 --- a/toolchain/build_abacus_gcc-mkl.sh +++ b/toolchain/build_abacus_gcc-mkl.sh @@ -63,8 +63,8 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DELPA_DIR=$ELPA \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ - -DUSE_OPENMP=ON \ - -DUSE_ELPA=ON \ + -DENABLE_OPENMP=ON \ + -DENABLE_ELPA=ON \ -DENABLE_DFTD4=ON \ -DENABLE_RAPIDJSON=ON \ -DENABLE_LIBRI=ON \ diff --git a/toolchain/build_abacus_gnu.sh b/toolchain/build_abacus_gnu.sh index 11eebdd17b3..79104c22f24 100755 --- a/toolchain/build_abacus_gnu.sh +++ b/toolchain/build_abacus_gnu.sh @@ -65,8 +65,8 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DFFTW3_DIR=$FFTW3 \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ - -DUSE_OPENMP=ON \ - -DUSE_ELPA=ON \ + -DENABLE_OPENMP=ON \ + -DENABLE_ELPA=ON \ -DENABLE_DFTD4=ON \ -DENABLE_RAPIDJSON=ON \ -DENABLE_LIBRI=ON \ diff --git a/toolchain/build_abacus_intel.sh b/toolchain/build_abacus_intel.sh index 918ef9300d6..43da9e32e3e 100755 --- a/toolchain/build_abacus_intel.sh +++ b/toolchain/build_abacus_intel.sh @@ -64,8 +64,8 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DELPA_DIR=$ELPA \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ - -DUSE_OPENMP=ON \ - -DUSE_ELPA=ON \ + -DENABLE_OPENMP=ON \ + -DENABLE_ELPA=ON \ -DENABLE_DFTD4=ON \ -DENABLE_RAPIDJSON=ON \ -DENABLE_LIBRI=ON \ diff --git a/toolchain/build_abacus_windows.sh b/toolchain/build_abacus_windows.sh index 7df3faf1a0c..bce9071c01e 100644 --- a/toolchain/build_abacus_windows.sh +++ b/toolchain/build_abacus_windows.sh @@ -64,7 +64,7 @@ if [ "$ENABLE_MPI" = "ON" ]; then fi # Notes on the non-default options: -# * USE_ELPA/PEXSI/LIBRI/MLALGO/CUDA = OFF -> not available on Windows yet. +# * ENABLE_ELPA/PEXSI/LIBRI/MLALGO/CUDA = OFF -> not available on Windows yet. # When ENABLE_MPI=ON the LCAO solver is ScaLAPACK (found automatically); # when serial it is LAPACK (DiagoLapack). # * BLA_VENDOR=OpenBLAS -> let CMake's FindBLAS/FindLAPACK pick OpenBLAS. @@ -79,8 +79,8 @@ cmake -B $BUILD_DIR -G Ninja -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DCMAKE_CXX_COMPILER=g++ \ -DENABLE_MPI=$ENABLE_MPI \ -DENABLE_LCAO=$ENABLE_LCAO \ - -DUSE_OPENMP=OFF \ - -DUSE_ELPA=OFF \ + -DENABLE_OPENMP=ON \ + -DENABLE_ELPA=ON \ -DENABLE_PEXSI=OFF \ -DENABLE_LIBRI=OFF \ -DENABLE_MLALGO=OFF \