diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fd317c146c..91b6ba748f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,17 +58,18 @@ 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) +# CTest defines BUILD_TESTING when it is first included. Include it only after +# ABACUS has declared its OFF-by-default option above. +include(CTest) + if(NOT DEFINED NVHPC_ROOT_DIR AND DEFINED ENV{NVHPC_ROOT}) set(NVHPC_ROOT_DIR "$ENV{NVHPC_ROOT}" CACHE PATH "Path to NVIDIA HPC SDK root directory.") endif() -# Collect external dependency usage requirements. Feature macros are applied -# explicitly to targets below so tests can opt out through target-level settings. -add_library(abacus_external_deps INTERFACE) -add_library(abacus::external_deps ALIAS abacus_external_deps) - +# Feature definitions are collected while options and dependencies are resolved +# below. They are applied to targets in source/CMakeLists.txt. set_property(GLOBAL PROPERTY ABACUS_FEATURE_DEFINITIONS "") function(abacus_normalize_definitions out_var) @@ -88,81 +89,10 @@ function(abacus_add_feature_definitions) set_property(GLOBAL APPEND PROPERTY ABACUS_FEATURE_DEFINITIONS ${_defs}) endfunction() -define_property( - DIRECTORY - PROPERTY ABACUS_DISABLED_FEATURE_DEFINITIONS - INHERITED - BRIEF_DOCS "ABACUS feature definitions disabled for targets in this directory" - FULL_DOCS "Feature definitions disabled for targets created in this directory.") - -define_property( - DIRECTORY - PROPERTY ABACUS_LOCAL_FEATURE_DEFINITIONS - INHERITED - BRIEF_DOCS "Additional ABACUS feature definitions for targets in this directory" - FULL_DOCS "Additional feature definitions for targets created in this directory.") - -function(abacus_disable_feature_definitions) - abacus_normalize_definitions(_defs ${ARGN}) - set_property(DIRECTORY APPEND PROPERTY ABACUS_DISABLED_FEATURE_DEFINITIONS ${_defs}) -endfunction() - -function(abacus_add_local_feature_definitions) - abacus_normalize_definitions(_defs ${ARGN}) - set_property(DIRECTORY APPEND PROPERTY ABACUS_LOCAL_FEATURE_DEFINITIONS ${_defs}) -endfunction() - -function(abacus_apply_build_options target) - if(NOT TARGET "${target}") - return() - endif() - - get_target_property(_type "${target}" TYPE) - if(_type STREQUAL "INTERFACE_LIBRARY" OR _type STREQUAL "UTILITY") - return() - endif() - - get_target_property(_imported "${target}" IMPORTED) - if(_imported) - return() - endif() - - get_target_property(_source_dir "${target}" SOURCE_DIR) - get_property(_defs GLOBAL PROPERTY ABACUS_FEATURE_DEFINITIONS) - get_property(_disabled DIRECTORY "${_source_dir}" PROPERTY ABACUS_DISABLED_FEATURE_DEFINITIONS) - get_property(_local DIRECTORY "${_source_dir}" PROPERTY ABACUS_LOCAL_FEATURE_DEFINITIONS) - - if(_disabled) - list(REMOVE_ITEM _defs ${_disabled}) - endif() - if(_local) - list(APPEND _defs ${_local}) - endif() - if(_defs) - list(REMOVE_DUPLICATES _defs) - target_compile_definitions("${target}" PRIVATE ${_defs}) - endif() - - target_link_libraries("${target}" PRIVATE abacus::external_deps) -endfunction() - -function(abacus_apply_build_options_to_dir dir) - get_property(_targets DIRECTORY "${dir}" PROPERTY BUILDSYSTEM_TARGETS) - foreach(_target IN LISTS _targets) - abacus_apply_build_options("${_target}") - endforeach() - - get_property(_subdirs DIRECTORY "${dir}" PROPERTY SUBDIRECTORIES) - foreach(_subdir IN LISTS _subdirs) - abacus_apply_build_options_to_dir("${_subdir}") - endforeach() -endfunction() - # enable json support if(ENABLE_RAPIDJSON) find_package(RapidJSON CONFIG REQUIRED) abacus_add_feature_definitions(__RAPIDJSON) - target_link_libraries(abacus_external_deps INTERFACE RapidJSON) endif() # get commit info @@ -191,7 +121,7 @@ You can install Git first and reinstall abacus.") abacus_add_feature_definitions(COMMIT_INFO) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/commit.h" "#define COMMIT \"${GIT_COMMIT_HASH} (${GIT_COMMIT_DATE})\"\n") - target_include_directories(abacus_external_deps INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) + set(ABACUS_COMMIT_INFO_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}") message(STATUS "Current commit hash: ${GIT_COMMIT_HASH}") message(STATUS "Last commit date: ${GIT_COMMIT_DATE}") else() @@ -278,7 +208,9 @@ if (USE_CUDA_MPI) abacus_add_feature_definitions(__CUDA_MPI) endif() -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +list(APPEND CMAKE_MODULE_PATH + "${CMAKE_CURRENT_SOURCE_DIR}/cmake" + "${PROJECT_SOURCE_DIR}/cmake/modules") if(ENABLE_COVERAGE) find_package(codecov) @@ -299,24 +231,12 @@ if(ENABLE_COVERAGE) endif() set(ABACUS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source) -set(ABACUS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests) -set(ABACUS_BIN_PATH ${CMAKE_CURRENT_BINARY_DIR}/${ABACUS_BIN_NAME}) -target_include_directories( - abacus_external_deps - INTERFACE - ${ABACUS_SOURCE_DIR} - ${ABACUS_SOURCE_DIR}/source_base/module_container) if(NOT DEFINED CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_executable(${ABACUS_BIN_NAME} source/source_main/main.cpp) -if(ENABLE_COVERAGE) - add_coverage(${ABACUS_BIN_NAME}) -endif() - if(ENABLE_DFTD4) # DFTD4 requires enabling C and Fortran to work enable_language(C) @@ -390,11 +310,8 @@ endif() if(ENABLE_LCAO) find_package(cereal CONFIG REQUIRED) abacus_add_feature_definitions(__LCAO) - target_link_libraries(abacus_external_deps INTERFACE cereal::cereal) if(USE_ELPA) find_package(ELPA REQUIRED) - include_directories(${ELPA_INCLUDE_DIR}) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ELPA::ELPA) abacus_add_feature_definitions(__ELPA) endif() @@ -404,8 +321,6 @@ if(ENABLE_LCAO) if(ENABLE_PEXSI) find_package(PEXSI REQUIRED) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${PEXSI_LIBRARY} ${SuperLU_DIST_LIBRARY} ${ParMETIS_LIBRARY} ${METIS_LIBRARY} pexsi) - target_include_directories(abacus_external_deps INTERFACE ${PEXSI_INCLUDE_DIR} ${ParMETIS_INCLUDE_DIR}) abacus_add_feature_definitions(__PEXSI) set(CMAKE_CXX_STANDARD 14) endif() @@ -420,19 +335,12 @@ endif() if(ENABLE_MPI) find_package(MPI COMPONENTS CXX REQUIRED) - target_link_libraries(abacus_external_deps INTERFACE MPI::MPI_CXX) abacus_add_feature_definitions(__MPI) endif() if (USE_DSP) abacus_add_feature_definitions(__DSP) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${OMPI_LIBRARY1}) - target_include_directories(abacus_external_deps INTERFACE - ${MTBLAS_FFT_DIR}/libmtblas/include - ${MT_HOST_DIR}/include) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${MT_HOST_DIR}/hthreads/lib/libhthread_device.a) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${MT_HOST_DIR}/hthreads/lib/libhthread_host.a) endif() @@ -440,21 +348,12 @@ endif() if (USE_SW) abacus_add_feature_definitions(__SW) set(SW ON) - target_include_directories(abacus_external_deps INTERFACE - ${SW_MATH}/include - ${SW_FFT}/include) - - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${SW_FFT}/lib/libfftw3.a) endif() find_package(Threads REQUIRED) -target_link_libraries(${ABACUS_BIN_NAME} PRIVATE Threads::Threads) if(USE_OPENMP) find_package(OpenMP REQUIRED) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE OpenMP::OpenMP_CXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - add_link_options(${OpenMP_CXX_LIBRARIES}) endif() include(CheckLanguage) @@ -529,24 +428,9 @@ if(USE_CUDA) endif() endif() enable_language(CUDA) - # ${ABACUS_BIN_NAME} is added before CUDA is enabled - set_property(TARGET ${ABACUS_BIN_NAME} - PROPERTY CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES}) - if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL 12.9) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE cudart) - else () - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE cudart nvToolsExt) - endif () - target_include_directories(abacus_external_deps INTERFACE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) - if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 13.0) - if(EXISTS "${CUDAToolkit_ROOT}/include/cccl") - target_include_directories(abacus_external_deps INTERFACE "${CUDAToolkit_ROOT}/include/cccl") - endif() - endif() if(USE_CUDA) abacus_add_feature_definitions(__CUDA) abacus_add_feature_definitions(__UT_USE_CUDA) - target_compile_definitions(${ABACUS_BIN_NAME} PRIVATE __USE_NVTX) 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() @@ -559,13 +443,13 @@ if(USE_CUDA) "ENABLE_NCCL_PARALLEL_DEVICE requires ENABLE_MPI=ON.") endif() abacus_add_feature_definitions(__NCCL_PARALLEL_DEVICE) - include(cmake/SetupNccl.cmake) - abacus_setup_nccl(${ABACUS_BIN_NAME}) + include(cmake/modules/SetupNccl.cmake) + abacus_setup_nccl() endif() if (ENABLE_CUSOLVERMP) # Keep cuSOLVERMp discovery/linking logic in a dedicated module. - include(cmake/SetupCuSolverMp.cmake) - abacus_setup_cusolvermp(${ABACUS_BIN_NAME}) + include(cmake/modules/SetupCuSolverMp.cmake) + abacus_setup_cusolvermp() endif() if (ENABLE_CUBLASMP) # Enforcement 1: cuBLASMp requires cuSOLVERMp to be enabled @@ -582,8 +466,8 @@ if(USE_CUDA) "cuBLASMp 0.8.0+ requires NCCL Symmetric Memory, but cuSOLVERMp is using CAL backend." "Please upgrade cuSOLVERMp to >= 0.7.0 to use NCCL for both.") endif() - include(cmake/SetupCuBlasMp.cmake) - abacus_setup_cublasmp(${ABACUS_BIN_NAME}) + include(cmake/modules/SetupCuBlasMp.cmake) + abacus_setup_cublasmp() endif() endif() endif() @@ -627,9 +511,6 @@ if(USE_ROCM) ) endif() - target_include_directories(abacus_external_deps INTERFACE ${ROCM_PATH}/include) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE hip::host hip::device hip::hipfft - roc::hipblas roc::hipsolver) abacus_add_feature_definitions(__ROCM) abacus_add_feature_definitions(__UT_USE_ROCM) abacus_add_feature_definitions(__HIP_PLATFORM_HCC__) @@ -644,8 +525,6 @@ if(ENABLE_ASAN) endif() add_compile_options(-fsanitize=address -fno-omit-frame-pointer) add_link_options(-fsanitize=address) - # `add_link_options` only affects executables added after. - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE -fsanitize=address) endif() if(DEFINED ENV{MKLROOT} AND NOT DEFINED MKLROOT) @@ -661,56 +540,27 @@ if(USE_KML) endif() find_package(KML REQUIRED COMPONENTS ${_kml_components}) - if(ENABLE_MPI) - target_link_libraries(abacus_external_deps INTERFACE KML::ScaLAPACK) - else() - target_link_libraries(abacus_external_deps INTERFACE KML::LAPACK) - endif() - target_link_libraries(abacus_external_deps INTERFACE KML::FFTW3) - if(ENABLE_FLOAT_FFTW) - target_link_libraries(abacus_external_deps INTERFACE KML::FFTW3_FLOAT) - endif() abacus_add_feature_definitions(__KML) elseif(MKLROOT) set(MKL_INTERFACE lp64) set(ENABLE_SCALAPACK ON) find_package(MKL REQUIRED) abacus_add_feature_definitions(__MKL) - target_include_directories(abacus_external_deps INTERFACE ${MKL_INCLUDE}/fftw) - target_link_libraries(abacus_external_deps INTERFACE MKL::MKL) - if(CMAKE_CXX_COMPILER_ID MATCHES Intel) - list(APPEND math_libs ifcore) - endif() elseif(NOT USE_SW) find_package(Lapack REQUIRED) - target_link_libraries(abacus_external_deps INTERFACE LAPACK::LAPACK BLAS::BLAS) # ScaLAPACK is a distributed-memory library and is only needed for the # MPI build. A serial build (e.g. the native Windows serial version) # must not require it. if(ENABLE_MPI) find_package(ScaLAPACK REQUIRED) - target_link_libraries(abacus_external_deps INTERFACE ScaLAPACK::ScaLAPACK) endif() - if(CMAKE_CXX_COMPILER_ID MATCHES GNU) - list(APPEND math_libs gfortran) - elseif(CMAKE_CXX_COMPILER_ID MATCHES Intel) - list(APPEND math_libs ifcore) - elseif(CMAKE_CXX_COMPILER_ID MATCHES Clang) - list(APPEND math_libs gfortran) - else() - message(WARNING "Cannot find the correct library for Fortran.") + if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Intel|Clang") + message(WARNING "Cannot determine the required Fortran runtime.") endif() endif() if(NOT USE_KML AND NOT MKLROOT AND NOT USE_SW) find_package(FFTW3 REQUIRED) - target_link_libraries(abacus_external_deps INTERFACE FFTW3::FFTW3) - if(USE_OPENMP) - target_link_libraries(abacus_external_deps INTERFACE FFTW3::FFTW3_OMP) - endif() - if(ENABLE_FLOAT_FFTW) - target_link_libraries(abacus_external_deps INTERFACE FFTW3::FFTW3_FLOAT) - endif() endif() if(ENABLE_FLOAT_FFTW) @@ -718,9 +568,6 @@ if(ENABLE_FLOAT_FFTW) endif() if(ENABLE_MLALGO) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE deepks) # deepks - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE hamilt_mlkedf) # mlkedf - find_path(libnpy_SOURCE_DIR npy.hpp HINTS ${libnpy_INCLUDE_DIR}) if(NOT libnpy_SOURCE_DIR) include(FetchContent) @@ -731,9 +578,7 @@ if(ENABLE_MLALGO) GIT_PROGRESS TRUE) FetchContent_MakeAvailable(libnpy) else() - target_include_directories(abacus_external_deps INTERFACE ${libnpy_INCLUDE_DIR}) endif() - target_include_directories(abacus_external_deps INTERFACE ${libnpy_SOURCE_DIR}/include) abacus_add_feature_definitions(__MLALGO) endif() @@ -748,9 +593,7 @@ if(ENABLE_MLALGO OR DEFINED Torch_DIR) elseif(NOT Torch_VERSION VERSION_LESS "1.5.0") set_if_higher(CMAKE_CXX_STANDARD 14) endif() - target_include_directories(abacus_external_deps INTERFACE ${TORCH_INCLUDE_DIRS}) - target_link_libraries(abacus_external_deps INTERFACE ${TORCH_LIBRARIES}) - add_compile_options(${TORCH_CXX_FLAGS}) + set(ABACUS_TORCH_CXX_FLAGS "${TORCH_CXX_FLAGS}") endif() if (ENABLE_CNPY) @@ -767,13 +610,10 @@ if (ENABLE_CNPY) ) FetchContent_MakeAvailable(cnpy) else() - target_include_directories(abacus_external_deps INTERFACE ${cnpy_INCLUDE_DIR}) endif() - target_include_directories(abacus_external_deps INTERFACE ${cnpy_SOURCE_DIR}) # find ZLIB and link find_package(ZLIB REQUIRED) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE cnpy ZLIB::ZLIB) abacus_add_feature_definitions(__USECNPY) endif() @@ -809,8 +649,6 @@ if(ENABLE_LIBRI) else() find_package(LibRI REQUIRED) endif() - target_include_directories(abacus_external_deps INTERFACE ${LIBRI_DIR}/include) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ri module_exx_symmetry) abacus_add_feature_definitions(__EXX EXX_DM=3 EXX_H_COMM=2 TEST_EXX_LCAO=0 TEST_EXX_RADIAL=1) endif() @@ -823,7 +661,6 @@ if(ENABLE_LIBCOMM) else() find_package(LibComm REQUIRED) endif() - target_include_directories(abacus_external_deps INTERFACE ${LIBCOMM_DIR}/include) endif() @@ -832,7 +669,6 @@ if(ENABLE_LIBXC) if(Libxc_VERSION VERSION_LESS "5.1.7") message(FATAL_ERROR "Libxc >= 5.1.7 is required") endif() - target_link_libraries(abacus_external_deps INTERFACE Libxc::xc) abacus_add_feature_definitions(USE_LIBXC) endif() @@ -840,12 +676,8 @@ if(DEFINED DeePMD_DIR) abacus_add_feature_definitions(__DPMD HIGH_PREC) add_compile_options(-Wl,--no-as-needed) find_package(DeePMD REQUIRED) - target_include_directories(abacus_external_deps INTERFACE ${DeePMD_DIR}/include) if(DeePMDC_FOUND) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE DeePMD::deepmd_c) abacus_add_feature_definitions(__DPMDC) - else() - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE DeePMD::deepmd_cc) endif() endif() @@ -854,16 +686,11 @@ if(DEFINED NEP_DIR) if(NEP_FOUND) abacus_add_feature_definitions(__NEP) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE NEP::nep) endif() endif() if(DEFINED TensorFlow_DIR) find_package(TensorFlow REQUIRED) - target_include_directories(abacus_external_deps INTERFACE ${TensorFlow_DIR}/include) - if(TensorFlow_FOUND) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE TensorFlow::tensorflow_cc) - endif() endif() abacus_add_feature_definitions(__FFTW3 __SELINV METIS) @@ -874,98 +701,6 @@ if(INFO) # modifications on blas_connector and lapack_connector endif() -include(cmake/Testing.cmake) - +# Target construction, final link ordering, installation, and test targets are +# intentionally centralized in source/CMakeLists.txt. add_subdirectory(source) -abacus_apply_build_options_to_dir("${CMAKE_CURRENT_SOURCE_DIR}/source") -abacus_apply_build_options(${ABACUS_BIN_NAME}) - -include(cmake/BuildInfo.cmake) -setup_build_info() - -target_link_libraries( - ${ABACUS_BIN_NAME} - PRIVATE - base - parameter - cell - symmetry - md - planewave - surchem - neighbor - neighbor_search - io_input - io_basic - io_advanced - relax - driver - xc_ - hsolver - elecstate - hamilt_general - module_pwdft - module_ofdft - module_stodft - module_dfpt - psi - psi_initializer - psi_overall_init - esolver - vdw - device - container - dftu - deltaspin) -if(ENABLE_LCAO) - target_link_libraries( - ${ABACUS_BIN_NAME} - PRIVATE - hamilt_lcao - tddft - orb - gint - hcontainer - numerical_atomic_orbitals - lr - rdmft) - if(USE_ELPA) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE genelpa) - endif() - if(USE_CUDA) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE diag_cusolver) - endif() -endif() -if(ENABLE_RAPIDJSON) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE json_output) -endif() - -if (USE_SW) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${SW_MATH}/libswfft.a) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${SW_MATH}/libswscalapack.a) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${SW_MATH}/libswlapack.a) - target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${SW_MATH}/libswblas.a) - list(APPEND math_libs gfortran) -endif() - -# libm exists on Linux and MinGW-w64 but not in the MSVC CRT. -if(NOT MSVC) - list(APPEND math_libs m) -endif() -target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${math_libs}) - -install(PROGRAMS ${ABACUS_BIN_PATH} - TYPE BIN - # DESTINATION ${CMAKE_INSTALL_BINDIR} -) - -# Create a symbolic link 'abacus' pointing to the actual executable. -# Skipped on Windows: symlink creation needs elevated/developer-mode -# privileges there and the executable carries an .exe suffix anyway. -if(NOT WIN32) - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${ABACUS_BIN_NAME} ${CMAKE_INSTALL_PREFIX}/bin/abacus WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin)") -endif() - -if(ENABLE_COVERAGE) - coverage_evaluate() -endif() diff --git a/cmake/BuildInfo.cmake b/cmake/BuildInfo.cmake index 94a267e9c6a..80ce7df2e45 100644 --- a/cmake/BuildInfo.cmake +++ b/cmake/BuildInfo.cmake @@ -7,7 +7,7 @@ function(setup_build_info) message(STATUS "Setting up build information...") - include(cmake/CollectBuildInfoVars.cmake) + include(${PROJECT_SOURCE_DIR}/cmake/CollectBuildInfoVars.cmake) set(BUILD_INFO_TEMPLATE "${CMAKE_SOURCE_DIR}/source/source_io/build_info.h.in") set(BUILD_INFO_OUTPUT "${CMAKE_BINARY_DIR}/source/source_io/build_info.h") diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index 72d77084ade..fa120c1fa69 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -1,5 +1,5 @@ # ============================================================================= -# Setup Testing Environment (GTest, CTest, AddTest function) +# Setup unit-test dependencies and the AddTest helper # ============================================================================== # include_guard(GLOBAL) @@ -12,8 +12,9 @@ macro(set_if_higher VARIABLE VALUE) endmacro() # Add performance test in abacus -if(ENABLE_GOOGLEBENCH) - set(BUILD_TESTING ON) +# Benchmarks are test targets; do not make them implicitly enable the full +# unit-test tree for ordinary builds. +if(BUILD_TESTING AND ENABLE_GOOGLEBENCH) find_package(benchmark HINTS ${BENCHMARK_DIR}) if(NOT ${benchmark_FOUND}) set(BENCHMARK_USE_BUNDLED_GTEST OFF) @@ -38,17 +39,19 @@ endif() add_coverage(${UT_TARGET}) endif() - # dependencies & link library - target_link_libraries(${UT_TARGET} PRIVATE ${UT_LIBS} Threads::Threads - GTest::gtest_main GTest::gmock_main) - if(ENABLE_GOOGLEBENCH) + # Dependencies & link library + # Share the numerical/MPI/OpenMP runtime closure but not + # the optional feature closure of the final binary + target_link_libraries(${UT_TARGET} PRIVATE + ${UT_LIBS} + GTest::gtest_main + GTest::gmock_main + abacus::linalg_libs) + if(BUILD_TESTING AND ENABLE_GOOGLEBENCH) target_link_libraries( ${UT_TARGET} PRIVATE benchmark::benchmark) endif() - if(USE_OPENMP) - target_link_libraries(${UT_TARGET} PRIVATE OpenMP::OpenMP_CXX) - endif() # Link to build info if needed if("${UT_SOURCES}" MATCHES "parse_args.cpp") @@ -64,8 +67,6 @@ endif() if(BUILD_TESTING) set_if_higher(CMAKE_CXX_STANDARD 14) # Required in orbital - include(CTest) - enable_testing() find_package(GTest HINTS /usr/local/lib/ ${GTEST_DIR}) if(NOT ${GTest_FOUND}) include(FetchContent) @@ -77,7 +78,6 @@ if(BUILD_TESTING) GIT_PROGRESS TRUE) FetchContent_MakeAvailable(googletest) endif() - # TODO: Try the GoogleTest module. - # https://cmake.org/cmake/help/latest/module/GoogleTest.html - add_subdirectory(tests) # Contains integration tests + # Integration tests are registered from source/CMakeLists.txt after the + # final executable has been created. endif() diff --git a/cmake/FindBlas.cmake b/cmake/modules/FindBlas.cmake similarity index 100% rename from cmake/FindBlas.cmake rename to cmake/modules/FindBlas.cmake diff --git a/cmake/FindDeePMD.cmake b/cmake/modules/FindDeePMD.cmake similarity index 100% rename from cmake/FindDeePMD.cmake rename to cmake/modules/FindDeePMD.cmake diff --git a/cmake/FindELPA.cmake b/cmake/modules/FindELPA.cmake similarity index 100% rename from cmake/FindELPA.cmake rename to cmake/modules/FindELPA.cmake diff --git a/cmake/FindFFTW3.cmake b/cmake/modules/FindFFTW3.cmake similarity index 100% rename from cmake/FindFFTW3.cmake rename to cmake/modules/FindFFTW3.cmake diff --git a/cmake/FindKML.cmake b/cmake/modules/FindKML.cmake similarity index 100% rename from cmake/FindKML.cmake rename to cmake/modules/FindKML.cmake diff --git a/cmake/FindLapack.cmake b/cmake/modules/FindLapack.cmake similarity index 100% rename from cmake/FindLapack.cmake rename to cmake/modules/FindLapack.cmake diff --git a/cmake/FindLibComm.cmake b/cmake/modules/FindLibComm.cmake similarity index 100% rename from cmake/FindLibComm.cmake rename to cmake/modules/FindLibComm.cmake diff --git a/cmake/FindLibRI.cmake b/cmake/modules/FindLibRI.cmake similarity index 100% rename from cmake/FindLibRI.cmake rename to cmake/modules/FindLibRI.cmake diff --git a/cmake/FindMKL.cmake b/cmake/modules/FindMKL.cmake similarity index 100% rename from cmake/FindMKL.cmake rename to cmake/modules/FindMKL.cmake diff --git a/cmake/FindNEP.cmake b/cmake/modules/FindNEP.cmake similarity index 100% rename from cmake/FindNEP.cmake rename to cmake/modules/FindNEP.cmake diff --git a/cmake/FindPEXSI.cmake b/cmake/modules/FindPEXSI.cmake similarity index 100% rename from cmake/FindPEXSI.cmake rename to cmake/modules/FindPEXSI.cmake diff --git a/cmake/FindScaLAPACK.cmake b/cmake/modules/FindScaLAPACK.cmake similarity index 100% rename from cmake/FindScaLAPACK.cmake rename to cmake/modules/FindScaLAPACK.cmake diff --git a/cmake/FindTensorFlow.cmake b/cmake/modules/FindTensorFlow.cmake similarity index 100% rename from cmake/FindTensorFlow.cmake rename to cmake/modules/FindTensorFlow.cmake diff --git a/cmake/SetupCuBlasMp.cmake b/cmake/modules/SetupCuBlasMp.cmake similarity index 94% rename from cmake/SetupCuBlasMp.cmake rename to cmake/modules/SetupCuBlasMp.cmake index 2debec3c6bc..884bceffb00 100644 --- a/cmake/SetupCuBlasMp.cmake +++ b/cmake/modules/SetupCuBlasMp.cmake @@ -4,7 +4,7 @@ include_guard(GLOBAL) -function(abacus_setup_cublasmp target_name) +function(abacus_setup_cublasmp) abacus_add_feature_definitions(__CUBLASMP) # 1. Search for cuBLASMp library and header files @@ -72,7 +72,4 @@ function(abacus_setup_cublasmp target_name) INTERFACE_INCLUDE_DIRECTORIES "${CUBLASMP_INCLUDE_DIR}") endif() - # 5. Propagate library usage requirements to all ABACUS targets. - target_link_libraries(abacus_external_deps INTERFACE cublasMp::cublasMp) - endfunction() diff --git a/cmake/SetupCuSolverMp.cmake b/cmake/modules/SetupCuSolverMp.cmake similarity index 94% rename from cmake/SetupCuSolverMp.cmake rename to cmake/modules/SetupCuSolverMp.cmake index 132fb9c279b..7ad1af4789a 100644 --- a/cmake/SetupCuSolverMp.cmake +++ b/cmake/modules/SetupCuSolverMp.cmake @@ -4,7 +4,7 @@ include_guard(GLOBAL) -function(abacus_setup_cusolvermp target_name) +function(abacus_setup_cusolvermp) abacus_add_feature_definitions(__CUSOLVERMP) # Find cuSOLVERMp first, then decide communicator backend. @@ -126,10 +126,4 @@ function(abacus_setup_cusolvermp target_name) INTERFACE_INCLUDE_DIRECTORIES "${CUSOLVERMP_INCLUDE_DIR}") endif() - # === Link libraries and propagate include directories === - if(_use_cal) - target_link_libraries(abacus_external_deps INTERFACE CAL::CAL cusolverMp::cusolverMp) - else() - target_link_libraries(abacus_external_deps INTERFACE NCCL::NCCL cusolverMp::cusolverMp) - endif() endfunction() diff --git a/cmake/SetupNccl.cmake b/cmake/modules/SetupNccl.cmake similarity index 92% rename from cmake/SetupNccl.cmake rename to cmake/modules/SetupNccl.cmake index 6e44e358951..8eb0327845a 100644 --- a/cmake/SetupNccl.cmake +++ b/cmake/modules/SetupNccl.cmake @@ -2,7 +2,7 @@ include_guard(GLOBAL) include(CheckIncludeFileCXX) -function(abacus_setup_nccl target_name) +function(abacus_setup_nccl) find_library(NCCL_LIBRARY NAMES nccl HINTS ${NCCL_PATH} ${NVHPC_ROOT_DIR} PATH_SUFFIXES lib lib64 comm_libs/nccl/lib) @@ -39,5 +39,4 @@ function(abacus_setup_nccl target_name) endif() endif() - target_link_libraries(abacus_external_deps INTERFACE NCCL::NCCL) endfunction() diff --git a/python/pyabacus/CMakeLists.txt b/python/pyabacus/CMakeLists.txt index 621087125f5..222a294dd67 100644 --- a/python/pyabacus/CMakeLists.txt +++ b/python/pyabacus/CMakeLists.txt @@ -17,7 +17,9 @@ set(NAO_PATH "${ABACUS_SOURCE_DIR}/source_basis/module_nao") set(HSOLVER_PATH "${ABACUS_SOURCE_DIR}/source_hsolver") set(PSI_PATH "${ABACUS_SOURCE_DIR}/source_psi") set(ENABLE_LCAO ON) -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../cmake") +list(APPEND CMAKE_MODULE_PATH + "${PROJECT_SOURCE_DIR}/../../cmake" + "${PROJECT_SOURCE_DIR}/../../cmake/modules") # add math_libs if(DEFINED ENV{MKLROOT} AND NOT DEFINED MKLROOT) diff --git a/python/pyabacus/CONTRIBUTING.md b/python/pyabacus/CONTRIBUTING.md index acac6d98275..9f943ceebab 100644 --- a/python/pyabacus/CONTRIBUTING.md +++ b/python/pyabacus/CONTRIBUTING.md @@ -77,7 +77,9 @@ set(NAO_PATH "${ABACUS_SOURCE_DIR}/source_basis/module_nao") set(HSOLVER_PATH "${ABACUS_SOURCE_DIR}/source_hsolver") set(PSI_PATH "${ABACUS_SOURCE_DIR}/source_psi") set(ENABLE_LCAO ON) -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../cmake") +list(APPEND CMAKE_MODULE_PATH + "${PROJECT_SOURCE_DIR}/../../cmake" + "${PROJECT_SOURCE_DIR}/../../cmake/modules") ``` - This section sets various source paths and configuration options. It defines the paths to different modules and appends the custom CMake module path. diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a25773b0c92..0337707b61a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,3 +1,457 @@ +# ============================================================================== +# External dependency interfaces +# ============================================================================== +# +# This file is the only place where ABACUS target linkage is assembled. The +# top-level CMakeLists.txt resolves options and packages but deliberately does +# not construct or link ABACUS targets. +# +# Link order is part of the build contract. Static linkers resolve archives +# from left to right, so every consumer must precede the provider of its +# unresolved symbols. Keep the final link closure ordered as follows: +# +# 1. ABACUS internal targets, from high-level consumers to lower-level +# providers; +# 2. optional external feature libraries used by those internal targets; +# 3. numerical backends and their MPI, OpenMP, compiler-runtime, and system +# dependencies. +# +# Do not sort or globally deduplicate this closure. A package target must carry +# its own transitive requirements in INTERFACE_LINK_LIBRARIES. Cyclic static +# archives must be handled locally by the corresponding package target or +# adapter rather than by wrapping the entire ABACUS link line in a linker group. + +# This target intentionally carries compile usage requirements only. It must +# not link an external library: internal object libraries and unit tests consume +# it for headers, flags, and definitions, while the final executable owns the +# complete link closure below. +add_library(abacus_compile_requirements INTERFACE) +add_library(abacus::compile_requirements ALIAS abacus_compile_requirements) + +target_include_directories(abacus_compile_requirements INTERFACE + ${ABACUS_SOURCE_DIR} + ${ABACUS_SOURCE_DIR}/source_base/module_container) + +if(ABACUS_COMMIT_INFO_INCLUDE_DIR) + target_include_directories(abacus_compile_requirements INTERFACE + ${ABACUS_COMMIT_INFO_INCLUDE_DIR}) +endif() + +function(abacus_add_target_compile_requirements target) + if(NOT TARGET "${target}") + return() + endif() + + get_target_property(_include_dirs "${target}" INTERFACE_INCLUDE_DIRECTORIES) + if(_include_dirs) + target_include_directories(abacus_compile_requirements INTERFACE + ${_include_dirs}) + endif() + + get_target_property(_system_include_dirs "${target}" INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) + if(_system_include_dirs) + target_include_directories(abacus_compile_requirements SYSTEM INTERFACE + ${_system_include_dirs}) + endif() + + get_target_property(_compile_definitions "${target}" INTERFACE_COMPILE_DEFINITIONS) + if(_compile_definitions) + target_compile_definitions(abacus_compile_requirements INTERFACE + ${_compile_definitions}) + endif() + + get_target_property(_compile_options "${target}" INTERFACE_COMPILE_OPTIONS) + if(_compile_options) + target_compile_options(abacus_compile_requirements INTERFACE + ${_compile_options}) + endif() + + get_target_property(_compile_features "${target}" INTERFACE_COMPILE_FEATURES) + if(_compile_features) + target_compile_features(abacus_compile_requirements INTERFACE + ${_compile_features}) + endif() +endfunction() + +add_library(abacus_linalg_libs INTERFACE) +add_library(abacus::linalg_libs ALIAS abacus_linalg_libs) + +add_library(abacus_feature_libs INTERFACE) +add_library(abacus::feature_libs ALIAS abacus_feature_libs) + +add_library(abacus_link_libs INTERFACE) +add_library(abacus::link_libs ALIAS abacus_link_libs) + +target_link_libraries(abacus_link_libs INTERFACE + abacus::feature_libs + abacus::linalg_libs) + +# ------------------------------------------------------------------------------ +# Ordered numerical backends and runtime closure +# ------------------------------------------------------------------------------ + +set(_abacus_linalg_libs) +set(_abacus_linalg_include_dirs) + +if(USE_KML) + if(ENABLE_MPI) + list(APPEND _abacus_linalg_libs KML::ScaLAPACK) + else() + list(APPEND _abacus_linalg_libs KML::LAPACK) + endif() + list(APPEND _abacus_linalg_libs KML::FFTW3) + list(APPEND _abacus_linalg_include_dirs ${KML_INCLUDE_DIRS}) + if(ENABLE_FLOAT_FFTW) + list(APPEND _abacus_linalg_libs KML::FFTW3_FLOAT) + endif() +elseif(MKLROOT) + list(APPEND _abacus_linalg_libs MKL::MKL) + list(APPEND _abacus_linalg_include_dirs ${MKL_INCLUDE} ${MKL_INCLUDE}/fftw) + if(CMAKE_CXX_COMPILER_ID MATCHES Intel) + list(APPEND _abacus_linalg_libs ifcore) + endif() +elseif(USE_SW) + list(APPEND _abacus_linalg_include_dirs + ${SW_MATH}/include + ${SW_FFT}/include) + list(APPEND _abacus_linalg_libs + ${SW_FFT}/lib/libfftw3.a + ${SW_MATH}/libswfft.a + ${SW_MATH}/libswscalapack.a + ${SW_MATH}/libswlapack.a + ${SW_MATH}/libswblas.a + gfortran) +else() + if(ENABLE_MPI) + list(APPEND _abacus_linalg_libs ScaLAPACK::ScaLAPACK) + endif() + if(USE_OPENMP) + list(APPEND _abacus_linalg_libs FFTW3::FFTW3_OMP) + endif() + list(APPEND _abacus_linalg_libs + FFTW3::FFTW3 + LAPACK::LAPACK + BLAS::BLAS) + list(APPEND _abacus_linalg_include_dirs ${FFTW3_INCLUDE_DIRS}) + if(ENABLE_FLOAT_FFTW) + list(APPEND _abacus_linalg_libs FFTW3::FFTW3_FLOAT) + endif() + + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + list(APPEND _abacus_linalg_libs gfortran) + elseif(CMAKE_CXX_COMPILER_ID MATCHES Intel) + list(APPEND _abacus_linalg_libs ifcore) + endif() +endif() + +if(ENABLE_MPI) + list(APPEND _abacus_linalg_libs MPI::MPI_CXX) +endif() +if(USE_OPENMP) + list(APPEND _abacus_linalg_libs OpenMP::OpenMP_CXX) +endif() +list(APPEND _abacus_linalg_libs Threads::Threads) + +# libm exists on Linux and MinGW-w64 but not in the MSVC CRT. +if(NOT MSVC) + list(APPEND _abacus_linalg_libs m) +endif() + +target_link_libraries(abacus_linalg_libs INTERFACE ${_abacus_linalg_libs}) +target_include_directories(abacus_linalg_libs INTERFACE ${_abacus_linalg_include_dirs}) + +target_include_directories(abacus_compile_requirements INTERFACE + ${_abacus_linalg_include_dirs}) + +foreach(_abacus_linalg_target IN ITEMS + Threads::Threads + MPI::MPI_CXX + OpenMP::OpenMP_CXX + FFTW3::FFTW3 + FFTW3::FFTW3_OMP + FFTW3::FFTW3_FLOAT + KML::LAPACK + KML::ScaLAPACK + KML::FFTW3 + KML::FFTW3_FLOAT) + abacus_add_target_compile_requirements(${_abacus_linalg_target}) +endforeach() + +# ------------------------------------------------------------------------------ +# Optional external feature libraries +# ------------------------------------------------------------------------------ + +set(_abacus_feature_libs) +set(_abacus_feature_include_dirs) +set(_abacus_feature_compile_options) + +if(ENABLE_RAPIDJSON) + list(APPEND _abacus_feature_libs RapidJSON) +endif() + +if(ENABLE_LCAO) + list(APPEND _abacus_feature_libs cereal::cereal) + + if(USE_ELPA) + list(APPEND _abacus_feature_libs ELPA::ELPA) + list(APPEND _abacus_feature_include_dirs ${ELPA_INCLUDE_DIR}) + endif() + + if(ENABLE_PEXSI) + # Temporary adapter for the legacy FindPEXSI.cmake result. Replace this with + # PEXSI::PEXSI when config-package discovery is adopted. + list(APPEND _abacus_feature_libs + ${PEXSI_LIBRARY} + ${SuperLU_DIST_LIBRARY} + ${ParMETIS_LIBRARY} + ${METIS_LIBRARY}) + list(APPEND _abacus_feature_include_dirs + ${PEXSI_INCLUDE_DIR} + ${ParMETIS_INCLUDE_DIR}) + endif() +endif() + +if(ENABLE_MLALGO) + if(libnpy_INCLUDE_DIR) + list(APPEND _abacus_feature_include_dirs ${libnpy_INCLUDE_DIR}) + endif() + if(libnpy_SOURCE_DIR) + list(APPEND _abacus_feature_include_dirs ${libnpy_SOURCE_DIR}/include) + endif() +endif() + +if(ENABLE_MLALGO OR DEFINED Torch_DIR) + list(APPEND _abacus_feature_include_dirs ${TORCH_INCLUDE_DIRS}) + list(APPEND _abacus_feature_compile_options ${ABACUS_TORCH_CXX_FLAGS}) +endif() + +if(ENABLE_CNPY) + list(APPEND _abacus_feature_libs cnpy ZLIB::ZLIB) + if(cnpy_INCLUDE_DIR) + list(APPEND _abacus_feature_include_dirs ${cnpy_INCLUDE_DIR}) + endif() + if(cnpy_SOURCE_DIR) + list(APPEND _abacus_feature_include_dirs ${cnpy_SOURCE_DIR}) + endif() +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) +endif() + +if(ENABLE_LIBXC) + list(APPEND _abacus_feature_libs Libxc::xc) +endif() + +if(DEFINED DeePMD_DIR) + if(DeePMDC_FOUND) + list(APPEND _abacus_feature_libs DeePMD::deepmd_c) + else() + list(APPEND _abacus_feature_libs DeePMD::deepmd_cc) + endif() + list(APPEND _abacus_feature_include_dirs ${DeePMD_DIR}/include) +endif() + +if(DEFINED NEP_DIR AND NEP_FOUND) + list(APPEND _abacus_feature_libs NEP::nep) +endif() + +if(DEFINED TensorFlow_DIR AND TensorFlow_FOUND) + list(APPEND _abacus_feature_libs TensorFlow::tensorflow_cc) + list(APPEND _abacus_feature_include_dirs ${TensorFlow_DIR}/include) +endif() + +if(USE_DSP) + list(APPEND _abacus_feature_libs + ${OMPI_LIBRARY1} + ${MT_HOST_DIR}/hthreads/lib/libhthread_device.a + ${MT_HOST_DIR}/hthreads/lib/libhthread_host.a) + list(APPEND _abacus_feature_include_dirs + ${MTBLAS_FFT_DIR}/libmtblas/include + ${MT_HOST_DIR}/include) +endif() + +if(USE_CUDA) + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 12.9) + list(APPEND _abacus_feature_libs cudart) + else() + list(APPEND _abacus_feature_libs cudart nvToolsExt) + endif() + list(APPEND _abacus_feature_include_dirs ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 13.0 + AND EXISTS "${CUDAToolkit_ROOT}/include/cccl") + list(APPEND _abacus_feature_include_dirs "${CUDAToolkit_ROOT}/include/cccl") + endif() + + if(ENABLE_NCCL_PARALLEL_DEVICE) + list(APPEND _abacus_feature_libs NCCL::NCCL) + endif() + if(ENABLE_CUSOLVERMP) + if(_use_cal) + list(APPEND _abacus_feature_libs CAL::CAL cusolverMp::cusolverMp) + else() + list(APPEND _abacus_feature_libs NCCL::NCCL cusolverMp::cusolverMp) + endif() + endif() + if(ENABLE_CUBLASMP) + list(APPEND _abacus_feature_libs cublasMp::cublasMp) + endif() +endif() + +if(USE_ROCM) + list(APPEND _abacus_feature_libs + hip::host + hip::device + hip::hipfft + roc::hipblas + roc::hipsolver) + list(APPEND _abacus_feature_include_dirs ${ROCM_PATH}/include) +endif() + +if(ENABLE_ASAN) + list(APPEND _abacus_feature_libs -fsanitize=address) +endif() + +target_link_libraries(abacus_feature_libs INTERFACE ${_abacus_feature_libs}) + +target_include_directories(abacus_compile_requirements INTERFACE + ${_abacus_feature_include_dirs}) +target_compile_options(abacus_compile_requirements INTERFACE + ${_abacus_feature_compile_options}) + +foreach(_abacus_feature_target IN ITEMS + RapidJSON + cereal::cereal + ELPA::ELPA + Libxc::xc + dftd4::dftd4 + DeePMD::deepmd_c + DeePMD::deepmd_cc + NEP::nep + TensorFlow::tensorflow_cc + ZLIB::ZLIB + NCCL::NCCL + CAL::CAL + cusolverMp::cusolverMp + cublasMp::cublasMp + hip::host + hip::device + hip::hipfft + roc::hipblas + roc::hipsolver) + abacus_add_target_compile_requirements(${_abacus_feature_target}) +endforeach() + +# ------------------------------------------------------------------------------ +# Per-target feature definitions and common compile usage requirements +# ------------------------------------------------------------------------------ + +define_property( + DIRECTORY + PROPERTY ABACUS_DISABLED_FEATURE_DEFINITIONS + INHERITED + BRIEF_DOCS "ABACUS feature definitions disabled for targets in this directory" + FULL_DOCS "Feature definitions disabled for targets created in this directory.") + +define_property( + DIRECTORY + PROPERTY ABACUS_LOCAL_FEATURE_DEFINITIONS + INHERITED + BRIEF_DOCS "Additional ABACUS feature definitions for targets in this directory" + FULL_DOCS "Additional feature definitions for targets created in this directory.") + +function(abacus_disable_feature_definitions) + abacus_normalize_definitions(_defs ${ARGN}) + set_property(DIRECTORY APPEND PROPERTY ABACUS_DISABLED_FEATURE_DEFINITIONS ${_defs}) +endfunction() + +function(abacus_add_local_feature_definitions) + abacus_normalize_definitions(_defs ${ARGN}) + set_property(DIRECTORY APPEND PROPERTY ABACUS_LOCAL_FEATURE_DEFINITIONS ${_defs}) +endfunction() + +function(abacus_apply_build_options target) + if(NOT TARGET "${target}") + return() + endif() + + get_target_property(_type "${target}" TYPE) + if(_type STREQUAL "INTERFACE_LIBRARY" OR _type STREQUAL "UTILITY") + return() + endif() + + get_target_property(_imported "${target}" IMPORTED) + if(_imported) + return() + endif() + + get_target_property(_source_dir "${target}" SOURCE_DIR) + get_property(_defs GLOBAL PROPERTY ABACUS_FEATURE_DEFINITIONS) + get_property(_disabled DIRECTORY "${_source_dir}" PROPERTY ABACUS_DISABLED_FEATURE_DEFINITIONS) + get_property(_local DIRECTORY "${_source_dir}" PROPERTY ABACUS_LOCAL_FEATURE_DEFINITIONS) + + if(_disabled) + list(REMOVE_ITEM _defs ${_disabled}) + endif() + if(_local) + list(APPEND _defs ${_local}) + endif() + if(_defs) + list(REMOVE_DUPLICATES _defs) + target_compile_definitions("${target}" PRIVATE ${_defs}) + endif() + + target_link_libraries("${target}" PRIVATE abacus::compile_requirements) +endfunction() + +function(abacus_apply_build_options_to_dir dir) + # FetchContent adds third-party projects as subdirectories of its caller. + # Keep the recursive application strictly within ABACUS's own source tree so + # exported third-party targets never acquire ABACUS compile requirements. + set(_abacus_source_root "${PROJECT_SOURCE_DIR}/source/") + string(FIND "${dir}/" "${_abacus_source_root}" _abacus_source_pos) + if(NOT _abacus_source_pos EQUAL 0) + return() + endif() + + get_property(_targets DIRECTORY "${dir}" PROPERTY BUILDSYSTEM_TARGETS) + foreach(_target IN LISTS _targets) + abacus_apply_build_options("${_target}") + endforeach() + + get_property(_subdirs DIRECTORY "${dir}" PROPERTY SUBDIRECTORIES) + foreach(_subdir IN LISTS _subdirs) + abacus_apply_build_options_to_dir("${_subdir}") + endforeach() +endfunction() + +# ============================================================================== +# Executable, source tree, and tests +# ============================================================================== + +set(ABACUS_TEST_DIR "${PROJECT_SOURCE_DIR}/tests") +include(${PROJECT_SOURCE_DIR}/cmake/Testing.cmake) + +add_executable(${ABACUS_BIN_NAME} source_main/main.cpp) +set(ABACUS_BIN_PATH ${CMAKE_CURRENT_BINARY_DIR}/${ABACUS_BIN_NAME}) + +if(USE_CUDA) + set_property(TARGET ${ABACUS_BIN_NAME} + PROPERTY CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES}) + target_compile_definitions(${ABACUS_BIN_NAME} PRIVATE __USE_NVTX) +endif() + +if(ENABLE_COVERAGE) + add_coverage(${ABACUS_BIN_NAME}) +endif() + +include(${PROJECT_SOURCE_DIR}/cmake/BuildInfo.cmake) +setup_build_info() + add_subdirectory(source_base) add_subdirectory(source_cell) add_subdirectory(source_psi) @@ -17,16 +471,13 @@ add_subdirectory(source_relax) add_subdirectory(source_lcao/module_ri) add_subdirectory(source_io/module_parameter) add_subdirectory(source_lcao/module_lr) - -# add by jghan -add_subdirectory(source_lcao/module_rdmft) +add_subdirectory(source_lcao/module_rdmft) # add by jghan add_library( - driver - OBJECT - source_main/driver.cpp - source_main/driver_run.cpp -) + driver + OBJECT + source_main/driver.cpp + source_main/driver_run.cpp) list(APPEND device_srcs source_pw/module_pwdft/kernels/nonlocal_op.cpp @@ -39,9 +490,6 @@ list(APPEND device_srcs source_hsolver/kernels/bpcg_kernel_op.cpp source_estate/kernels/elecstate_op.cpp - # source_psi/kernels/psi_memory_op.cpp - # source_psi/kernels/device.cpp - source_base/module_device/device.cpp source_base/module_device/device_helpers.cpp source_base/module_device/output_device.cpp @@ -59,8 +507,7 @@ list(APPEND device_srcs source_pw/module_pwdft/kernels/cal_density_real_op.cpp source_pw/module_pwdft/kernels/mul_potential_op.cpp source_pw/module_pwdft/kernels/vec_mul_vec_complex_op.cpp - source_pw/module_pwdft/kernels/exx_cal_energy_op.cpp -) + source_pw/module_pwdft/kernels/exx_cal_energy_op.cpp) if(USE_CUDA) list(APPEND device_srcs @@ -74,10 +521,7 @@ if(USE_CUDA) source_hsolver/kernels/cuda/hegvd_op.cu source_hsolver/kernels/cuda/bpcg_kernel_op.cu source_estate/kernels/cuda/elecstate_op.cu - - # source_psi/kernels/cuda/memory_op.cu source_base/module_device/cuda/memory_op.cu - source_pw/module_pwdft/kernels/cuda/force_op.cu source_pw/module_pwdft/kernels/cuda/stress_op.cu source_pw/module_pwdft/kernels/cuda/wf_op.cu @@ -91,8 +535,7 @@ if(USE_CUDA) source_pw/module_pwdft/kernels/cuda/cal_density_real_op.cu source_pw/module_pwdft/kernels/cuda/mul_potential_op.cu source_pw/module_pwdft/kernels/cuda/vec_mul_vec_complex.cu - source_pw/module_pwdft/kernels/cuda/exx_cal_energy_op.cu - ) + source_pw/module_pwdft/kernels/cuda/exx_cal_energy_op.cu) endif() if(USE_ROCM) @@ -107,10 +550,7 @@ if(USE_ROCM) source_hsolver/kernels/rocm/hegvd_op.hip.cu source_hsolver/kernels/rocm/bpcg_kernel_op.hip.cu source_estate/kernels/rocm/elecstate_op.hip.cu - - # source_psi/kernels/rocm/memory_op.hip.cu source_base/module_device/rocm/memory_op.hip.cu - source_pw/module_pwdft/kernels/rocm/force_op.hip.cu source_pw/module_pwdft/kernels/rocm/stress_op.hip.cu source_pw/module_pwdft/kernels/rocm/wf_op.hip.cu @@ -118,43 +558,136 @@ if(USE_ROCM) source_base/kernels/rocm/math_kernel_op.hip.cu source_base/kernels/rocm/math_kernel_op_vec.hip.cu source_base/kernels/rocm/math_ylm_op.hip.cu - source_hamilt/module_xc/kernels/rocm/xc_functional_op.hip.cu - ) + source_hamilt/module_xc/kernels/rocm/xc_functional_op.hip.cu) endif() if(USE_DSP) list(APPEND device_srcs - source_base/kernels/dsp/dsp_connector.cpp - ) + source_base/kernels/dsp/dsp_connector.cpp) endif() - add_library(device OBJECT ${device_srcs}) if(USE_CUDA) - target_link_libraries( - device - PRIVATE - cusolver - cublas - cufft - ) + target_link_libraries(device PRIVATE cusolver cublas cufft) elseif(USE_ROCM) - target_link_libraries( - device - PRIVATE + target_link_libraries(device PRIVATE device_rocm hip::host hip::device hip::hipfft roc::hipblas - roc::hipsolver - ) + roc::hipsolver) endif() -# base library uses symbols from device library (memory_op, math_ylm_op) +# base uses symbols from device (memory_op and math_ylm_op). target_link_libraries(base PUBLIC device) if(ENABLE_COVERAGE) add_coverage(driver) endif() + +# ============================================================================== +# Final link closure and ordering +# ============================================================================== + +target_link_libraries( + ${ABACUS_BIN_NAME} + PRIVATE + # Internal ABACUS targets: consumers before providers. + driver + esolver + hsolver + hamilt_general + elecstate + module_pwdft + module_ofdft + module_stodft + module_dfpt + xc_ + vdw + relax + io_advanced + io_basic + io_input + surchem + neighbor_search + neighbor + md + planewave + symmetry + cell + parameter + psi_overall_init + psi_initializer + psi + dftu + deltaspin + container + device + base) + +if(ENABLE_LCAO) + target_link_libraries( + ${ABACUS_BIN_NAME} + PRIVATE + hamilt_lcao + tddft + orb + gint + hcontainer + numerical_atomic_orbitals + lr + rdmft) + if(USE_ELPA) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE genelpa) + endif() + if(ENABLE_PEXSI) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE pexsi) + endif() + if(USE_CUDA) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE diag_cusolver) + endif() +endif() + +if(ENABLE_MLALGO) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE deepks hamilt_mlkedf) +endif() +if(ENABLE_LIBRI) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ri module_exx_symmetry) +endif() +if(ENABLE_RAPIDJSON) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE json_output) +endif() + +# External closure: feature consumers precede numerical providers and runtimes. +target_link_libraries(${ABACUS_BIN_NAME} PRIVATE abacus::link_libs) + +# Torch includes some LAPACK routines, but with floating-point exceptions. +if(ENABLE_MLALGO OR DEFINED Torch_DIR) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${TORCH_LIBRARIES}) +endif() + +# Apply feature definitions and common compile usage requirements only after all +# source targets have been created. +abacus_apply_build_options_to_dir("${CMAKE_CURRENT_SOURCE_DIR}") +abacus_apply_build_options(${ABACUS_BIN_NAME}) + +# Register integration tests only after the final executable and its path are +# available. Unit tests are added by source subdirectories through AddTest(). +if(BUILD_TESTING) + add_subdirectory("${ABACUS_TEST_DIR}" "${PROJECT_BINARY_DIR}/tests") +endif() + +install(PROGRAMS ${ABACUS_BIN_PATH} TYPE BIN) + +# Create a symbolic link 'abacus' pointing to the actual executable. Skipped on +# Windows because symlink creation needs elevated/developer-mode privileges and +# the executable carries an .exe suffix anyway. +if(NOT WIN32) + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${ABACUS_BIN_NAME} ${CMAKE_INSTALL_PREFIX}/bin/abacus WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin)") +endif() + +if(ENABLE_COVERAGE) + coverage_evaluate() +endif() diff --git a/source/source_base/kernels/test/CMakeLists.txt b/source/source_base/kernels/test/CMakeLists.txt index e8d311cfdaf..9578b10a6fc 100644 --- a/source/source_base/kernels/test/CMakeLists.txt +++ b/source/source_base/kernels/test/CMakeLists.txt @@ -2,6 +2,6 @@ abacus_disable_feature_definitions(__MPI) AddTest( TARGET MODULE_BASE_KERNELS_Unittests - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES math_ylm_op_test.cpp math_kernel_test.cpp ) diff --git a/source/source_base/module_container/ATen/kernels/test/CMakeLists.txt b/source/source_base/module_container/ATen/kernels/test/CMakeLists.txt index 8fcfb667f5f..425e5044382 100644 --- a/source/source_base/module_container/ATen/kernels/test/CMakeLists.txt +++ b/source/source_base/module_container/ATen/kernels/test/CMakeLists.txt @@ -1,6 +1,6 @@ AddTest( TARGET MODULE_BASE_container_kernels_uts - LIBS parameter ${math_libs} + LIBS parameter SOURCES blas_test.cpp lapack_test.cpp memory_test.cpp linalg_test.cpp ) diff --git a/source/source_base/module_container/ATen/ops/test/CMakeLists.txt b/source/source_base/module_container/ATen/ops/test/CMakeLists.txt index 89babce953c..ccccb761880 100644 --- a/source/source_base/module_container/ATen/ops/test/CMakeLists.txt +++ b/source/source_base/module_container/ATen/ops/test/CMakeLists.txt @@ -1,6 +1,6 @@ AddTest( TARGET MODULE_BASE_container_ops_uts - LIBS parameter ${math_libs} + LIBS parameter SOURCES einsum_op_test.cpp linalg_op_test.cpp ../../kernels/lapack.cpp ) diff --git a/source/source_base/module_container/test/CMakeLists.txt b/source/source_base/module_container/test/CMakeLists.txt index 63aeec80aee..2b7974724db 100644 --- a/source/source_base/module_container/test/CMakeLists.txt +++ b/source/source_base/module_container/test/CMakeLists.txt @@ -2,7 +2,7 @@ abacus_disable_feature_definitions(__MPI) AddTest( TARGET MODULE_BASE_CONTAINER_Unittests - LIBS parameter container base device ${math_libs} + LIBS parameter container base device SOURCES tensor_test.cpp tensor_shape_test.cpp allocator_test.cpp tensor_buffer_test.cpp tensor_map_test.cpp tensor_utils_test.cpp tensor_accessor_test.cpp diff --git a/source/source_base/module_device/test/CMakeLists.txt b/source/source_base/module_device/test/CMakeLists.txt index 732b30fd1f8..78bdef3d5ff 100644 --- a/source/source_base/module_device/test/CMakeLists.txt +++ b/source/source_base/module_device/test/CMakeLists.txt @@ -1,5 +1,5 @@ AddTest( TARGET MODULE_BASE_DEVICE_Unittests - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES memory_test.cpp device_test.cpp ) \ No newline at end of file diff --git a/source/source_base/module_grid/test/CMakeLists.txt b/source/source_base/module_grid/test/CMakeLists.txt index 721658e1234..9f326729ecd 100644 --- a/source/source_base/module_grid/test/CMakeLists.txt +++ b/source/source_base/module_grid/test/CMakeLists.txt @@ -25,5 +25,5 @@ AddTest( TARGET MODULE_BASE_GRID_test_batch SOURCES test_batch.cpp ../batch.cpp - LIBS ${math_libs} + LIBS ) diff --git a/source/source_base/module_mixing/test/CMakeLists.txt b/source/source_base/module_mixing/test/CMakeLists.txt index c32640b9c64..b0034d80cc9 100644 --- a/source/source_base/module_mixing/test/CMakeLists.txt +++ b/source/source_base/module_mixing/test/CMakeLists.txt @@ -1,6 +1,6 @@ abacus_disable_feature_definitions(__MPI) AddTest( TARGET MODULE_BASE_MIXING_unittests - LIBS parameter base device ${math_libs} + LIBS parameter base device SOURCES mixing_test.cpp ) \ No newline at end of file diff --git a/source/source_base/test/CMakeLists.txt b/source/source_base/test/CMakeLists.txt index be21f047f67..2573f0cd979 100644 --- a/source/source_base/test/CMakeLists.txt +++ b/source/source_base/test/CMakeLists.txt @@ -2,27 +2,27 @@ abacus_disable_feature_definitions(__MPI) install(DIRECTORY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) AddTest( TARGET MODULE_BASE_blas_connector - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES blas_connector_test.cpp ) AddTest( TARGET MODULE_BASE_atom_in - LIBS parameter + LIBS parameter SOURCES atom_in_test.cpp ) AddTest( TARGET MODULE_BASE_timer - LIBS parameter + LIBS parameter SOURCES timer_test.cpp ../timer.cpp ../global_variable.cpp ) AddTest( TARGET MODULE_BASE_tool_quit - LIBS parameter + LIBS parameter SOURCES tool_quit_test.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_tool_check - LIBS parameter + LIBS parameter SOURCES tool_check_test.cpp ../tool_check.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp ) AddTest( @@ -31,192 +31,192 @@ AddTest( ) ADDTest( TARGET MODULE_BASE_global_function - LIBS parameter ${math_libs} + LIBS parameter SOURCES global_function_test.cpp ../global_function.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../memory_recorder.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_vector3 - LIBS parameter + LIBS parameter SOURCES vector3_test.cpp ) AddTest( TARGET MODULE_BASE_matrix3 - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES matrix3_test.cpp ) AddTest( TARGET MODULE_BASE_intarray - LIBS parameter + LIBS parameter SOURCES intarray_test.cpp ../intarray.cpp ) AddTest( TARGET MODULE_BASE_realarray - LIBS parameter + LIBS parameter SOURCES realarray_test.cpp ../realarray.cpp ) AddTest( TARGET MODULE_BASE_matrix - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES matrix_test.cpp ) AddTest( TARGET MODULE_BASE_complexarray - LIBS parameter + LIBS parameter SOURCES complexarray_test.cpp ../complexarray.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_complexmatrix - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES complexmatrix_test.cpp ) AddTest( TARGET MODULE_BASE_integral - LIBS parameter + LIBS parameter SOURCES math_integral_test.cpp ../math_integral.cpp ) AddTest( TARGET MODULE_BASE_sph_bessel_recursive - LIBS parameter + LIBS parameter SOURCES sph_bessel_recursive_test.cpp ../sph_bessel_recursive-d1.cpp ../sph_bessel_recursive-d2.cpp ../memory_recorder.cpp ../global_variable.cpp ) AddTest( TARGET MODULE_BASE_ylmreal - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES math_ylmreal_test.cpp ../libm/branred.cpp ../libm/sincos.cpp ) AddTest( TARGET MODULE_BASE_math_sphbes - LIBS parameter + LIBS parameter SOURCES math_sphbes_test.cpp ../math_sphbes.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_mathzone - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES mathzone_test.cpp ) AddTest( TARGET MODULE_BASE_mathzone_add1 - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES mathzone_add1_test.cpp ) AddTest( TARGET MODULE_BASE_math_polyint - LIBS parameter + LIBS parameter SOURCES math_polyint_test.cpp ../math_polyint.cpp ../realarray.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_gram_schmidt_orth - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES gram_schmidt_orth_test.cpp ) AddTest( TARGET MODULE_BASE_math_bspline - LIBS parameter + LIBS parameter SOURCES math_bspline_test.cpp ../math_bspline.cpp ) AddTest( TARGET MODULE_BASE_inverse_matrix - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES inverse_matrix_test.cpp ) AddTest( TARGET MODULE_BASE_mymath - LIBS parameter + LIBS parameter SOURCES mymath_test.cpp ../mymath.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_container - LIBS parameter + LIBS parameter SOURCES container_operator_test.cpp ../container_operator.h ) AddTest( TARGET MODULE_BASE_math_chebyshev - LIBS parameter ${math_libs} base device container + LIBS parameter base device container SOURCES math_chebyshev_test.cpp ) AddTest( TARGET MODULE_BASE_lapack_connector - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES lapack_connector_test.cpp ) AddTest( TARGET MODULE_BASE_opt_CG - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES opt_CG_test.cpp opt_test_tools.cpp ) AddTest( TARGET MODULE_BASE_opt_TN - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES opt_TN_test.cpp opt_test_tools.cpp ) AddTest( TARGET MODULE_BASE_ylm - LIBS parameter + LIBS parameter SOURCES ylm_test.cpp ../ylm.cpp ../timer.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ) AddTest( TARGET MODULE_BASE_global_file - LIBS parameter + LIBS parameter SOURCES global_file_test.cpp ../global_file.cpp ../global_function.cpp ../tool_quit.cpp ../global_variable.cpp ../memory_recorder.cpp ../timer.cpp ) AddTest( TARGET MODULE_BASE_tool_title - LIBS parameter + LIBS parameter SOURCES tool_title_test.cpp ../tool_title.cpp ../global_variable.cpp ../global_function.cpp ../timer.cpp ../tool_quit.cpp ../global_file.cpp ../memory_recorder.cpp ) AddTest( TARGET MODULE_BASE_element_basis_index - LIBS parameter + LIBS parameter SOURCES element_basis_index_test.cpp ../element_basis_index.cpp ) AddTest( TARGET MODULE_BASE_tool_threading - LIBS parameter + LIBS parameter SOURCES tool_threading_test.cpp ../tool_threading.h ) AddTest( TARGET MODULE_BASE_spherical_bessel_transformer SOURCES spherical_bessel_transformer_test.cpp - LIBS parameter ${math_libs} base device + LIBS parameter base device ) AddTest( TARGET MODULE_BASE_cubic_spline SOURCES cubic_spline_test.cpp - LIBS parameter ${math_libs} base device + LIBS parameter base device ) AddTest( TARGET MODULE_BASE_clebsch_gordan_coeff_test SOURCES clebsch_gordan_coeff_test.cpp - LIBS parameter ${math_libs} base device + LIBS parameter base device ) AddTest( TARGET MODULE_BASE_assoc_laguerre_test SOURCES assoc_laguerre_test.cpp - LIBS parameter ${math_libs} base device + LIBS parameter base device ) AddTest( TARGET MODULE_BASE_ndarray_test - LIBS parameter + LIBS parameter SOURCES ndarray_test.cpp ) AddTest( TARGET MODULE_BASE_formatter_test - LIBS parameter + LIBS parameter SOURCES formatter_test.cpp ) @@ -228,7 +228,7 @@ AddTest( if(ENABLE_GOOGLEBENCH) AddTest( TARGET MODULE_BASE_perf_sphbes - LIBS parameter + LIBS parameter SOURCES perf_sphbes_test.cpp ../math_sphbes.cpp ../timer.cpp ) endif() diff --git a/source/source_base/test_parallel/CMakeLists.txt b/source/source_base/test_parallel/CMakeLists.txt index 263be8422b6..e623826dd97 100644 --- a/source/source_base/test_parallel/CMakeLists.txt +++ b/source/source_base/test_parallel/CMakeLists.txt @@ -36,13 +36,13 @@ add_test(NAME MODULE_BASE_parallel_reduce_test AddTest( TARGET MODULE_BASE_para_gemm - LIBS MPI::MPI_CXX ${math_libs} base device parameter + LIBS MPI::MPI_CXX base device parameter SOURCES test_para_gemm.cpp ) AddTest( TARGET MODULE_BASE_math_chebyshev_mpi - LIBS MPI::MPI_CXX parameter ${math_libs} base device container + LIBS MPI::MPI_CXX parameter base device container SOURCES math_chebyshev_mpi_test.cpp ) @@ -54,7 +54,7 @@ add_test(NAME MODULE_BASE_para_gemm_parallel AddTest( TARGET MODULE_BASE_parallel_2d_test SOURCES parallel_2d_test.cpp ../parallel_2d.cpp - LIBS parameter ${math_libs} + LIBS parameter ) install(FILES parallel_2d_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/source/source_basis/module_ao/test/CMakeLists.txt b/source/source_basis/module_ao/test/CMakeLists.txt index dc3a5e458ff..d8a7f8fe010 100644 --- a/source/source_basis/module_ao/test/CMakeLists.txt +++ b/source/source_basis/module_ao/test/CMakeLists.txt @@ -50,21 +50,21 @@ AddTest( SOURCES ORB_nonlocal_test.cpp ../ORB_nonlocal.cpp ../ORB_nonlocal_lm.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( TARGET MODULE_AO_ORB_nonlocal_lm_test SOURCES ORB_nonlocal_lm_test.cpp ../ORB_nonlocal_lm.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( TARGET MODULE_AO_ORB_atomic_lm_test SOURCES ORB_atomic_lm_test.cpp ../ORB_atomic_lm.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( @@ -73,14 +73,14 @@ AddTest( ../ORB_read.cpp ../ORB_atomic.cpp ../ORB_atomic_lm.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( TARGET MODULE_AO_parallel_orbitals_test SOURCES parallel_orbitals_test.cpp ../parallel_orbitals.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) install(FILES parallel_orbitals_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/source/source_basis/module_nao/test/CMakeLists.txt b/source/source_basis/module_nao/test/CMakeLists.txt index 2e4674eed81..0c1b64f8fb8 100644 --- a/source/source_basis/module_nao/test/CMakeLists.txt +++ b/source/source_basis/module_nao/test/CMakeLists.txt @@ -4,7 +4,7 @@ AddTest( numerical_radial_test.cpp ../numerical_radial.cpp ../../module_ao/ORB_atomic_lm.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( @@ -17,7 +17,7 @@ AddTest( ../../module_ao/ORB_atomic_lm.cpp ../../module_ao/ORB_atomic.cpp ../../../source_io/module_output/orb_io.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( @@ -30,7 +30,7 @@ AddTest( ../../module_ao/ORB_atomic_lm.cpp ../../module_ao/ORB_atomic.cpp ../../../source_io/module_output/orb_io.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( @@ -43,7 +43,7 @@ AddTest( ../../module_ao/ORB_atomic_lm.cpp ../../module_ao/ORB_atomic.cpp ../../../source_io/module_output/orb_io.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( @@ -56,7 +56,7 @@ AddTest( ../../module_ao/ORB_atomic_lm.cpp ../../module_ao/ORB_atomic.cpp ../../../source_io/module_output/orb_io.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( @@ -69,7 +69,7 @@ AddTest( ../../module_ao/ORB_atomic_lm.cpp ../../module_ao/ORB_atomic.cpp ../../../source_io/module_output/orb_io.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( @@ -87,7 +87,7 @@ AddTest( ../../module_ao/ORB_atomic_lm.cpp ../../module_ao/ORB_atomic.cpp ../../../source_io/module_output/orb_io.cpp - LIBS parameter ${math_libs} device base + LIBS parameter device base ) AddTest( @@ -107,7 +107,7 @@ AddTest( ../two_center_integrator.cpp ../real_gaunt_table.cpp ../../../source_io/module_output/orb_io.cpp - LIBS parameter ${math_libs} device base container orb + LIBS parameter device base container orb ) AddTest( @@ -116,7 +116,7 @@ AddTest( real_gaunt_table_test.cpp ../real_gaunt_table.cpp ../../module_ao/ORB_gaunt_table.cpp - LIBS parameter ${math_libs} device base container + LIBS parameter device base container ) AddTest( @@ -136,7 +136,7 @@ AddTest( ../numerical_radial.cpp ../two_center_bundle.cpp ../../../source_io/module_output/orb_io.cpp - LIBS parameter ${math_libs} device base container orb + LIBS parameter device base container orb ) AddTest( @@ -156,7 +156,7 @@ AddTest( ../radial_set.cpp ../numerical_radial.cpp ../../../source_io/module_output/orb_io.cpp - LIBS parameter ${math_libs} device base container orb + LIBS parameter device base container orb ) AddTest( @@ -176,6 +176,6 @@ AddTest( ../radial_set.cpp ../numerical_radial.cpp ../../../source_io/module_output/orb_io.cpp - LIBS parameter ${math_libs} device base container orb + LIBS parameter device base container orb ) diff --git a/source/source_basis/module_pw/kernels/test/CMakeLists.txt b/source/source_basis/module_pw/kernels/test/CMakeLists.txt index 4cba49d5a2f..ba6b5b4946f 100644 --- a/source/source_basis/module_pw/kernels/test/CMakeLists.txt +++ b/source/source_basis/module_pw/kernels/test/CMakeLists.txt @@ -2,7 +2,7 @@ abacus_add_local_feature_definitions(__NORMAL) AddTest( TARGET MODULE_PW_PW_Kernels_UTs - LIBS parameter ${math_libs} psi device + LIBS parameter psi device SOURCES pw_op_test.cpp ../../../../source_base/tool_quit.cpp ../../../../source_base/global_variable.cpp ../../../../source_base/parallel_global.cpp ../../../../source_base/parallel_reduce.cpp diff --git a/source/source_basis/module_pw/test/CMakeLists.txt b/source/source_basis/module_pw/test/CMakeLists.txt index 41321a6450a..bdc57cc7d40 100644 --- a/source/source_basis/module_pw/test/CMakeLists.txt +++ b/source/source_basis/module_pw/test/CMakeLists.txt @@ -1,7 +1,7 @@ abacus_add_local_feature_definitions(__NORMAL) AddTest( TARGET MODULE_PW_pw_test - LIBS parameter ${math_libs} planewave device + LIBS parameter planewave device SOURCES ../../../source_base/matrix.cpp ../../../source_base/complexmatrix.cpp ../../../source_base/matrix3.cpp ../../../source_base/tool_quit.cpp ../../../source_base/mymath.cpp ../../../source_base/timer.cpp ../../../source_base/memory_recorder.cpp ../../../source_base/module_external/blas_connector_base.cpp ../../../source_base/module_external/blas_connector_vector.cpp ../../../source_base/module_external/blas_connector_matrix.cpp diff --git a/source/source_basis/module_pw/test_gpu/CMakeLists.txt b/source/source_basis/module_pw/test_gpu/CMakeLists.txt index 0adb3362ff9..456b30d0624 100644 --- a/source/source_basis/module_pw/test_gpu/CMakeLists.txt +++ b/source/source_basis/module_pw/test_gpu/CMakeLists.txt @@ -1,9 +1,9 @@ abacus_add_local_feature_definitions(__NORMAL) -if (USE_CUDA) -AddTest( - TARGET pw_test_gpu - LIBS parameter ${math_libs} base planewave device FFTW3::FFTW3_FLOAT - SOURCES pw_test.cpp pw_basis_C2R.cpp pw_basis_C2C.cpp pw_basis_k_C2C.cpp -) +if (USE_CUDA AND ENABLE_FLOAT_FFTW) + AddTest( + TARGET pw_test_gpu + LIBS parameter base planewave device FFTW3::FFTW3_FLOAT + SOURCES pw_test.cpp pw_basis_C2R.cpp pw_basis_C2C.cpp pw_basis_k_C2C.cpp + ) endif() diff --git a/source/source_basis/module_pw/test_serial/CMakeLists.txt b/source/source_basis/module_pw/test_serial/CMakeLists.txt index 34b0641ee45..865d32bab8b 100644 --- a/source/source_basis/module_pw/test_serial/CMakeLists.txt +++ b/source/source_basis/module_pw/test_serial/CMakeLists.txt @@ -25,12 +25,12 @@ add_library( AddTest( TARGET MODULE_PW_basis_pw_serial - LIBS parameter ${math_libs} planewave_serial device base + LIBS parameter planewave_serial device base SOURCES pw_basis_test.cpp ) AddTest( TARGET MODULE_PW_basis_pw_k_serial - LIBS parameter ${math_libs} planewave_serial device base + LIBS parameter planewave_serial device base SOURCES pw_basis_k_test.cpp ) diff --git a/source/source_cell/module_neighbor/test/CMakeLists.txt b/source/source_cell/module_neighbor/test/CMakeLists.txt index f06e4543edb..fa0f0038704 100644 --- a/source/source_cell/module_neighbor/test/CMakeLists.txt +++ b/source/source_cell/module_neighbor/test/CMakeLists.txt @@ -11,14 +11,14 @@ AddTest( AddTest( TARGET MODULE_CELL_NEIGHBOR_sltk_grid - LIBS parameter ${math_libs} base device cell_info + LIBS parameter base device cell_info SOURCES sltk_grid_test.cpp ../sltk_grid.cpp ../sltk_atom.cpp ) AddTest( TARGET MODULE_CELL_NEIGHBOR_sltk_atom_arrange - LIBS parameter ${math_libs} base device cell_info + LIBS parameter base device cell_info SOURCES sltk_atom_arrange_test.cpp ../sltk_atom_arrange.cpp ../sltk_grid_driver.cpp ../sltk_grid.cpp ../sltk_atom.cpp diff --git a/source/source_cell/module_neighlist/test/CMakeLists.txt b/source/source_cell/module_neighlist/test/CMakeLists.txt index 0164c1fabff..31bbd8de360 100644 --- a/source/source_cell/module_neighlist/test/CMakeLists.txt +++ b/source/source_cell/module_neighlist/test/CMakeLists.txt @@ -8,7 +8,7 @@ abacus_disable_feature_definitions(__EXX) AddTest( TARGET MODULE_CELL_NEIGHBOR_neighbor_search - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES neighbor_search_test.cpp ../neighbor_search.cpp @@ -19,7 +19,7 @@ AddTest( AddTest( TARGET MODULE_CELL_NEIGHBOR_bin_manager - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES bin_manager_test.cpp ../bin_manager.cpp @@ -28,7 +28,7 @@ AddTest( AddTest( TARGET MODULE_CELL_NEIGHBOR_allocator_and_list - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES neighbor_list_test.cpp ../page_allocator.cpp diff --git a/source/source_cell/module_symmetry/test/CMakeLists.txt b/source/source_cell/module_symmetry/test/CMakeLists.txt index a9764a46e13..f7030586d6e 100644 --- a/source/source_cell/module_symmetry/test/CMakeLists.txt +++ b/source/source_cell/module_symmetry/test/CMakeLists.txt @@ -4,11 +4,11 @@ abacus_disable_feature_definitions(__CUDA) abacus_disable_feature_definitions(__ROCM) AddTest( TARGET MODULE_CELL_SYMMETRY_analysis - LIBS parameter base ${math_libs} device symmetry + LIBS parameter base device symmetry SOURCES symmetry_test.cpp symmetry_test_analysis.cpp ) AddTest( TARGET MODULE_CELL_SYMMETRY_symtrz - LIBS parameter base ${math_libs} device symmetry + LIBS parameter base device symmetry SOURCES symmetry_test.cpp symmetry_test_symtrz.cpp ) \ No newline at end of file diff --git a/source/source_cell/test/CMakeLists.txt b/source/source_cell/test/CMakeLists.txt index ba1870e1985..881a0cc179c 100644 --- a/source/source_cell/test/CMakeLists.txt +++ b/source/source_cell/test/CMakeLists.txt @@ -44,41 +44,41 @@ add_library(cell_info OBJECT ${cell_simple_srcs}) AddTest( TARGET MODULE_CELL_read_pp - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES read_pp_test.cpp ../atom_pseudo.cpp ../pseudo.cpp ../read_pp.cpp ../read_pp_complete.cpp ../read_pp_upf201.cpp ../read_pp_upf100.cpp ../read_pp_vwr.cpp ../read_pp_blps.cpp ) AddTest( TARGET MODULE_CELL_pseudo_nc - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES pseudo_nc_test.cpp ../pseudo.cpp ../atom_pseudo.cpp ../read_pp.cpp ../read_pp_complete.cpp ../read_pp_upf201.cpp ../read_pp_upf100.cpp ../read_pp_vwr.cpp ../read_pp_blps.cpp ) AddTest( TARGET MODULE_CELL_atom_pseudo - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES atom_pseudo_test.cpp ../atom_pseudo.cpp ../pseudo.cpp ../read_pp.cpp ../read_pp_complete.cpp ../read_pp_upf201.cpp ../read_pp_upf100.cpp ../read_pp_vwr.cpp ../read_pp_blps.cpp ) AddTest( TARGET MODULE_CELL_atom_spec - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES atom_spec_test.cpp ../atom_spec.cpp ../atom_pseudo.cpp ../pseudo.cpp ../read_pp.cpp ../read_pp_complete.cpp ../read_pp_upf201.cpp ../read_pp_upf100.cpp ../read_pp_vwr.cpp ../read_pp_blps.cpp ) AddTest( TARGET MODULE_CELL_klist_test - LIBS parameter ${math_libs} base device symmetry + LIBS parameter base device symmetry SOURCES klist_test.cpp ../klist.cpp ../parallel_kpoints.cpp ../k_vector_utils.cpp ) AddTest( TARGET MODULE_CELL_klist_test_para1 - LIBS parameter ${math_libs} base device symmetry + LIBS parameter base device symmetry SOURCES klist_test_para.cpp ../klist.cpp ../parallel_kpoints.cpp ../k_vector_utils.cpp ) @@ -97,7 +97,7 @@ AddTest( # Add unit test for read_atoms_helper AddTest( TARGET MODULE_CELL_read_atoms_helper_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES read_atoms_helper_test.cpp ../read_atoms_helper.cpp ../read_stru.cpp @@ -138,26 +138,26 @@ add_test(NAME MODULE_CELL_parallel_kpoints_test AddTest( TARGET MODULE_CELL_unitcell_test - LIBS parameter ${math_libs} base device cell_info symmetry + LIBS parameter base device cell_info symmetry SOURCES unitcell_test.cpp ../../source_estate/cal_ux.cpp ) AddTest( TARGET MODULE_CELL_unitcell_test_readpp - LIBS parameter ${math_libs} base device cell_info + LIBS parameter base device cell_info SOURCES unitcell_test_readpp.cpp ) AddTest( TARGET MODULE_CELL_unitcell_test_para - LIBS parameter ${math_libs} base device cell_info + LIBS parameter base device cell_info SOURCES unitcell_test_para.cpp ) AddTest( TARGET MODULE_CELL_unitcell_test_setupcell - LIBS parameter ${math_libs} base device cell_info + LIBS parameter base device cell_info SOURCES unitcell_test_setupcell.cpp ) @@ -168,13 +168,13 @@ add_test(NAME MODULE_CELL_unitcell_test_parallel AddTest( TARGET MODULE_CELL_index_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES cell_index_test.cpp ../cell_index.cpp ) AddTest( TARGET MODULE_CELL_SEP_TEST - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES read_sep_test.cpp ../sep.cpp ) @@ -185,7 +185,7 @@ add_test(NAME MODULE_CELL_read_sep_parallel AddTest( TARGET MODULE_CELL_SEP_CELL_TEST - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES sepcell_test.cpp ../sep.cpp ../sep_cell.cpp ) diff --git a/source/source_cell/test_pw/CMakeLists.txt b/source/source_cell/test_pw/CMakeLists.txt index 6683756123b..941a7bb3eeb 100644 --- a/source/source_cell/test_pw/CMakeLists.txt +++ b/source/source_cell/test_pw/CMakeLists.txt @@ -9,7 +9,7 @@ install(FILES unitcell_test_pw_para.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) AddTest( TARGET MODULE_CELL_unitcell_test_pw - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES unitcell_test_pw.cpp ../unitcell.cpp ../read_atoms.cpp ../read_atoms_helper.cpp ../atom_spec.cpp ../update_cell.cpp ../bcast_cell.cpp ../atom_pseudo.cpp ../pseudo.cpp ../read_pp.cpp ../read_pp_complete.cpp ../read_pp_upf201.cpp ../read_pp_upf100.cpp ../read_stru.cpp ../read_atom_species.cpp diff --git a/source/source_esolver/test/CMakeLists.txt b/source/source_esolver/test/CMakeLists.txt index f666b206f59..6c1c031eeef 100644 --- a/source/source_esolver/test/CMakeLists.txt +++ b/source/source_esolver/test/CMakeLists.txt @@ -1,10 +1,27 @@ abacus_disable_feature_definitions(__MPI) abacus_disable_feature_definitions(__LCAO) +set(_esolver_dp_test_libs + parameter + base + device) + +if(DEFINED DeePMD_DIR) + if(DeePMDC_FOUND) + list(APPEND _esolver_dp_test_libs DeePMD::deepmd_c) + else() + list(APPEND _esolver_dp_test_libs DeePMD::deepmd_cc) + endif() +endif() + install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) AddTest( TARGET MODULE_ESOLVER_esolver_dp_test - LIBS parameter ${math_libs} base device - SOURCES esolver_dp_test.cpp ../esolver_dp.cpp ../../source_io/module_output/cif_io.cpp ../../source_io/module_output/output_log.cpp + LIBS ${_esolver_dp_test_libs} + SOURCES + esolver_dp_test.cpp + ../esolver_dp.cpp + ../../source_io/module_output/cif_io.cpp + ../../source_io/module_output/output_log.cpp ) diff --git a/source/source_estate/kernels/test/CMakeLists.txt b/source/source_estate/kernels/test/CMakeLists.txt index 5b938eaa79e..f6f63d3891a 100644 --- a/source/source_estate/kernels/test/CMakeLists.txt +++ b/source/source_estate/kernels/test/CMakeLists.txt @@ -6,6 +6,6 @@ abacus_disable_feature_definitions(__MLALGO) AddTest( TARGET Elecstate_Kernels_UTs - LIBS parameter ${math_libs} psi base device + LIBS parameter psi base device SOURCES elecstate_op_test.cpp ) diff --git a/source/source_estate/module_dm/test/CMakeLists.txt b/source/source_estate/module_dm/test/CMakeLists.txt index 8be9317f76b..8904c058d09 100644 --- a/source/source_estate/module_dm/test/CMakeLists.txt +++ b/source/source_estate/module_dm/test/CMakeLists.txt @@ -10,7 +10,7 @@ endif() AddTest( TARGET MODULE_ESTATE_dm_io_test_serial - LIBS parameter ${math_libs} base device cell_info + LIBS parameter base device cell_info SOURCES test_dm_io.cpp ../density_matrix.cpp ../density_matrix_io.cpp ${ABACUS_SOURCE_DIR}/source_lcao/module_hcontainer/base_matrix.cpp ${ABACUS_SOURCE_DIR}/source_lcao/module_hcontainer/hcontainer.cpp @@ -21,7 +21,7 @@ AddTest( AddTest( TARGET MODULE_ESTATE_dm_constructor_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES test_dm_constructor.cpp ../density_matrix.cpp ../density_matrix_io.cpp tmp_mocks.cpp ${ABACUS_SOURCE_DIR}/source_lcao/module_hcontainer/base_matrix.cpp ${ABACUS_SOURCE_DIR}/source_lcao/module_hcontainer/hcontainer.cpp @@ -31,7 +31,7 @@ AddTest( AddTest( TARGET MODULE_ESTATE_dm_init_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES test_dm_R_init.cpp ../density_matrix.cpp ../density_matrix_io.cpp tmp_mocks.cpp ${ABACUS_SOURCE_DIR}/source_lcao/module_hcontainer/base_matrix.cpp ${ABACUS_SOURCE_DIR}/source_lcao/module_hcontainer/hcontainer.cpp @@ -41,7 +41,7 @@ AddTest( AddTest( TARGET MODULE_ESTATE_dm_cal_DMR_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES test_cal_dm_R.cpp ../density_matrix.cpp ../density_matrix_io.cpp tmp_mocks.cpp ${ABACUS_SOURCE_DIR}/source_lcao/module_hcontainer/base_matrix.cpp ${ABACUS_SOURCE_DIR}/source_lcao/module_hcontainer/hcontainer.cpp diff --git a/source/source_estate/test/CMakeLists.txt b/source/source_estate/test/CMakeLists.txt index bb6657abee2..aa4a8825d45 100644 --- a/source/source_estate/test/CMakeLists.txt +++ b/source/source_estate/test/CMakeLists.txt @@ -13,44 +13,44 @@ install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) AddTest( TARGET MODULE_ESTATE_Elecstate_Op_UTs - LIBS parameter ${math_libs} psi base device + LIBS parameter psi base device SOURCES ../kernels/test/elecstate_op_test.cpp ) AddTest( TARGET MODULE_ESTATE_elecstate_occupy - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES elecstate_occupy_test.cpp ../occupy.cpp ) AddTest( TARGET MODULE_ESTATE_elecstate_magnetism - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES elecstate_magnetism_test.cpp ../../source_cell/magnetism.cpp ) AddTest( TARGET MODULE_ESTATE_elecstate_fp_energy - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES elecstate_fp_energy_test.cpp ../fp_energy.cpp ) AddTest( TARGET MODULE_ESTATE_elecstate_print - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES elecstate_print_test.cpp ../elecstate_print.cpp ../occupy.cpp ) AddTest( TARGET MODULE_ESTATE_elecstate_base - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES elecstate_base_test.cpp ../elecstate.cpp ../elecstate_tools.cpp ../occupy.cpp ../../source_psi/psi.cpp ../../source_base/module_fft/fft_bundle.cpp ../../source_base/module_fft/fft_cpu.cpp ) AddTest( TARGET MODULE_ESTATE_elecstate_pw - LIBS parameter ${math_libs} planewave_serial base device + LIBS parameter planewave_serial base device SOURCES elecstate_pw_test.cpp ../elecstate_pw.cpp ../elecstate_pw_cal_tau.cpp @@ -63,7 +63,7 @@ AddTest( AddTest( TARGET MODULE_ESTATE_elecstate_energy - LIBS parameter ${math_libs} base device planewave_serial + LIBS parameter base device planewave_serial SOURCES elecstate_energy_test.cpp ../elecstate_energy.cpp ../fp_energy.cpp @@ -78,20 +78,20 @@ AddTest( AddTest( TARGET MODULE_ESTATE_potentials_new - LIBS parameter ${math_libs} base device planewave_serial + LIBS parameter base device planewave_serial SOURCES potential_new_test.cpp ../module_pot/potential_new.cpp ) AddTest( TARGET MODULE_ESTATE_charge_test - LIBS parameter ${math_libs} planewave_serial base device cell_info + LIBS parameter planewave_serial base device cell_info SOURCES charge_test.cpp ../module_charge/charge.cpp ) AddTest( TARGET MODULE_ESTATE_charge_mixing - LIBS parameter base ${math_libs} psi device planewave_serial cell_info + LIBS parameter base psi device planewave_serial cell_info SOURCES charge_mixing_test.cpp ../module_charge/charge_mixing.cpp ../module_charge/charge_mixing_dmr.cpp ../module_charge/charge_mixing_residual.cpp ../module_charge/charge_mixing_preconditioner.cpp ../module_charge/charge_mixing_rho.cpp @@ -100,14 +100,14 @@ AddTest( AddTest( TARGET MODULE_ESTATE_charge_extra - LIBS parameter ${math_libs} base device cell_info + LIBS parameter base device cell_info SOURCES charge_extra_test.cpp ../module_charge/charge_extra.cpp ../../source_io/module_output/read_cube.cpp ../../source_io/module_output/write_cube.cpp ../../source_base/module_fft/fft_bundle.cpp ../../source_base/module_fft/fft_cpu.cpp ) AddTest( TARGET MODULE_ESTATE_gint_precision_controller - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES gint_precision_controller_test.cpp ../module_charge/gint_precision_controller.cpp ) diff --git a/source/source_estate/test_mpi/CMakeLists.txt b/source/source_estate/test_mpi/CMakeLists.txt index cc7ed7a4bb7..a6c068027f7 100644 --- a/source/source_estate/test_mpi/CMakeLists.txt +++ b/source/source_estate/test_mpi/CMakeLists.txt @@ -8,7 +8,7 @@ abacus_disable_feature_definitions(_OPENMP) AddTest( TARGET MODULE_ESTATE_charge_mpi_test - LIBS parameter ${math_libs} psi base device planewave + LIBS parameter psi base device planewave SOURCES charge_mpi_test.cpp ../module_charge/charge_mpi.cpp ) diff --git a/source/source_hamilt/module_surchem/test/CMakeLists.txt b/source/source_hamilt/module_surchem/test/CMakeLists.txt index 15964abd205..3c29b35123b 100644 --- a/source/source_hamilt/module_surchem/test/CMakeLists.txt +++ b/source/source_hamilt/module_surchem/test/CMakeLists.txt @@ -8,13 +8,13 @@ list(APPEND depend_files AddTest( TARGET MODULE_HAMILT_surchem_cal_epsilon - LIBS parameter ${math_libs} planewave device base + LIBS parameter planewave device base SOURCES cal_epsilon_test.cpp ../cal_epsilon.cpp ../surchem.cpp ) AddTest( TARGET MODULE_HAMILT_surchem_cal_pseudo - LIBS parameter ${math_libs} planewave device base psi + LIBS parameter planewave device base psi SOURCES cal_pseudo_test.cpp ../cal_pseudo.cpp ../surchem.cpp ../cal_epsilon.cpp ../../../source_pw/module_pwdft/structure_factor.cpp ../../../source_pw/module_pwdft/parallel_grid.cpp @@ -22,13 +22,13 @@ AddTest( AddTest( TARGET MODULE_HAMILT_surchem_cal_totn - LIBS parameter ${math_libs} planewave device base + LIBS parameter planewave device base SOURCES cal_totn_test.cpp ../cal_totn.cpp ../surchem.cpp ../../../source_pw/module_pwdft/parallel_grid.cpp ) AddTest( TARGET MODULE_HAMILT_surchem_cal_vcav - LIBS parameter ${math_libs} planewave device base container + LIBS parameter planewave device base container SOURCES cal_vcav_test.cpp ../cal_vcav.cpp ../surchem.cpp ../../../source_pw/module_pwdft/parallel_grid.cpp ../../module_xc/xc_grad.cpp ../../module_xc/xc_functional.cpp ../../module_xc/xc_lda_wrap.cpp ../../module_xc/xc_gga_wrap.cpp @@ -43,7 +43,7 @@ AddTest( AddTest( TARGET MODULE_HAMILT_surchem_cal_vel - LIBS parameter ${math_libs} planewave device base container + LIBS parameter planewave device base container SOURCES cal_vel_test.cpp ../cal_vel.cpp ../surchem.cpp ../cal_epsilon.cpp ../minimize_cg.cpp ../../../source_pw/module_pwdft/parallel_grid.cpp ../../module_xc/xc_grad.cpp ../../module_xc/xc_functional.cpp ../../module_xc/xc_lda_wrap.cpp ../../module_xc/xc_gga_wrap.cpp diff --git a/source/source_hamilt/module_vdw/test/CMakeLists.txt b/source/source_hamilt/module_vdw/test/CMakeLists.txt index e4242374554..b881037a4ee 100644 --- a/source/source_hamilt/module_vdw/test/CMakeLists.txt +++ b/source/source_hamilt/module_vdw/test/CMakeLists.txt @@ -7,7 +7,7 @@ install(FILES r0.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) AddTest( TARGET MODULE_HAMILT_vdwTest - LIBS parameter ${math_libs} base device vdw + LIBS parameter base device vdw SOURCES vdw_test.cpp ) diff --git a/source/source_hamilt/module_xc/kernels/test/CMakeLists.txt b/source/source_hamilt/module_xc/kernels/test/CMakeLists.txt index 37fd50ba87f..e5c0ac70e9b 100644 --- a/source/source_hamilt/module_xc/kernels/test/CMakeLists.txt +++ b/source/source_hamilt/module_xc/kernels/test/CMakeLists.txt @@ -1,5 +1,5 @@ AddTest( TARGET MODULE_HAMILT_XC_Functional_UTs - LIBS parameter ${math_libs} device base container + LIBS parameter device base container SOURCES xc_functional_op_test.cpp ) diff --git a/source/source_hamilt/module_xc/test/CMakeLists.txt b/source/source_hamilt/module_xc/test/CMakeLists.txt index a68538e646a..34634eae02a 100644 --- a/source/source_hamilt/module_xc/test/CMakeLists.txt +++ b/source/source_hamilt/module_xc/test/CMakeLists.txt @@ -27,7 +27,7 @@ list(APPEND FFT_SRC ../../../source_base/module_fft/fft_rocm.cpp) endif() AddTest( TARGET MODULE_HAMILT_XCTest_GRADCORR - LIBS parameter MPI::MPI_CXX Libxc::xc ${math_libs} psi device container + LIBS parameter MPI::MPI_CXX Libxc::xc psi device container SOURCES test_xc3.cpp ../xc_grad.cpp ../xc_functional.cpp ../xc_lda_wrap.cpp ../xc_gga_wrap.cpp ../libxc_setup.cpp @@ -48,7 +48,7 @@ AddTest( AddTest( TARGET MODULE_HAMILT_XCTest_SCAN - LIBS parameter MPI::MPI_CXX Libxc::xc + LIBS parameter MPI::MPI_CXX Libxc::xc SOURCES test_xc4.cpp ../xc_functional.cpp ../xc_lda_wrap.cpp ../xc_gga_wrap.cpp ../libxc_setup.cpp @@ -61,7 +61,7 @@ AddTest( AddTest( TARGET MODULE_HAMILT_XCTest_VXC - LIBS parameter MPI::MPI_CXX Libxc::xc ${math_libs} psi device container + LIBS parameter MPI::MPI_CXX Libxc::xc psi device container SOURCES test_xc5.cpp ../xc_grad.cpp ../xc_functional.cpp ../xc_lda_wrap.cpp ../xc_gga_wrap.cpp ../libxc_setup.cpp diff --git a/source/source_hamilt/test/CMakeLists.txt b/source/source_hamilt/test/CMakeLists.txt index 09672aab4b4..4d61c805387 100644 --- a/source/source_hamilt/test/CMakeLists.txt +++ b/source/source_hamilt/test/CMakeLists.txt @@ -5,6 +5,6 @@ AddTest( AddTest( TARGET MODULE_HAMILT_ewald_rgen - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES rgen_test.cpp ../module_ewald/H_Ewald_pw.cpp ../module_ewald/dnrm2.cpp ) diff --git a/source/source_hsolver/CMakeLists.txt b/source/source_hsolver/CMakeLists.txt index b115d6d4cd2..64c1f2d3485 100644 --- a/source/source_hsolver/CMakeLists.txt +++ b/source/source_hsolver/CMakeLists.txt @@ -84,7 +84,7 @@ if(ENABLE_LCAO AND USE_ELPA) add_subdirectory(module_genelpa) endif() -IF (BUILD_TESTING) +if(BUILD_TESTING) add_subdirectory(test) if(ENABLE_MPI) add_subdirectory(kernels/test) diff --git a/source/source_hsolver/kernels/test/CMakeLists.txt b/source/source_hsolver/kernels/test/CMakeLists.txt index 987f42da157..2109b4a4a04 100644 --- a/source/source_hsolver/kernels/test/CMakeLists.txt +++ b/source/source_hsolver/kernels/test/CMakeLists.txt @@ -4,7 +4,7 @@ abacus_disable_feature_definitions(__ROCM) if(USE_CUDA OR USE_ROCM) AddTest( TARGET MODULE_HSOLVER_KERNELS_Unittests - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES math_hegvd_test.cpp ) endif() @@ -12,7 +12,7 @@ endif() if(ENABLE_GOOGLEBENCH) AddTest( TARGET PERF_MODULE_HSOLVER_KERNELS - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES perf_math_kernel.cpp ) endif() \ No newline at end of file diff --git a/source/source_hsolver/test/CMakeLists.txt b/source/source_hsolver/test/CMakeLists.txt index e17e58d3941..771bce4c0db 100644 --- a/source/source_hsolver/test/CMakeLists.txt +++ b/source/source_hsolver/test/CMakeLists.txt @@ -5,12 +5,12 @@ abacus_disable_feature_definitions(__EXX) if (ENABLE_MPI) AddTest( TARGET MODULE_HSOLVER_parak2d_test - LIBS parameter ${math_libs} base device MPI::MPI_CXX + LIBS parameter base device MPI::MPI_CXX SOURCES parallel_k2d_test.cpp ../parallel_k2d.cpp ../../source_cell/parallel_kpoints.cpp ) AddTest( TARGET MODULE_HSOLVER_bpcg - LIBS parameter ${math_libs} base psi device container + LIBS parameter base psi device container SOURCES diago_bpcg_test.cpp ../diago_bpcg.cpp ../para_linear_transform.cpp ../diago_iter_assist.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp @@ -18,7 +18,7 @@ if (ENABLE_MPI) ) AddTest( TARGET MODULE_HSOLVER_cg - LIBS parameter ${math_libs} base psi device container + LIBS parameter base psi device container SOURCES diago_cg_test.cpp ../diago_cg.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp @@ -26,7 +26,7 @@ if (ENABLE_MPI) ) AddTest( TARGET MODULE_HSOLVER_cg_float - LIBS parameter ${math_libs} base psi device container + LIBS parameter base psi device container SOURCES diago_cg_float_test.cpp ../diago_cg.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp @@ -34,7 +34,7 @@ if (ENABLE_MPI) ) AddTest( TARGET MODULE_HSOLVER_dav - LIBS parameter ${math_libs} base psi device + LIBS parameter base psi device SOURCES diago_david_test.cpp ../diago_david.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp @@ -42,7 +42,7 @@ if (ENABLE_MPI) ) AddTest( TARGET MODULE_HSOLVER_dav_float - LIBS parameter ${math_libs} base psi device + LIBS parameter base psi device SOURCES diago_david_float_test.cpp ../diago_david.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp @@ -51,7 +51,7 @@ if (ENABLE_MPI) if(ENABLE_LCAO) AddTest( TARGET MODULE_HSOLVER_cg_real - LIBS parameter ${math_libs} base psi device container + LIBS parameter base psi device container SOURCES diago_cg_float_test.cpp ../diago_cg.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp @@ -59,7 +59,7 @@ if (ENABLE_MPI) ) AddTest( TARGET MODULE_HSOLVER_dav_real - LIBS parameter ${math_libs} base psi device + LIBS parameter base psi device SOURCES diago_david_real_test.cpp ../diago_david.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp @@ -69,35 +69,35 @@ if (ENABLE_MPI) AddTest( TARGET MODULE_HSOLVER_base - LIBS parameter ${math_libs} psi device base + LIBS parameter psi device base SOURCES test_hsolver.cpp ) AddTest( TARGET MODULE_HSOLVER_pw - LIBS parameter ${math_libs} psi device base container + LIBS parameter psi device base container SOURCES test_hsolver_pw.cpp ../hsolver_pw.cpp ../hsolver_lcaopw.cpp ../diago_bpcg.cpp ../diago_dav_subspace.cpp ../diag_const_nums.cpp ../diago_iter_assist.cpp ../para_linear_transform.cpp ../../source_estate/elecstate_tools.cpp ../../source_estate/occupy.cpp ../../source_base/module_fft/fft_bundle.cpp ../../source_base/module_fft/fft_cpu.cpp ) AddTest( TARGET MODULE_HSOLVER_sdft - LIBS parameter ${math_libs} psi device base container + LIBS parameter psi device base container SOURCES test_hsolver_sdft.cpp ../hsolver_pw_sdft.cpp ../hsolver_pw.cpp ../diago_bpcg.cpp ../diago_dav_subspace.cpp ../diag_const_nums.cpp ../diago_iter_assist.cpp ../para_linear_transform.cpp ../../source_estate/elecstate_tools.cpp ../../source_estate/occupy.cpp ../../source_base/module_fft/fft_bundle.cpp ../../source_base/module_fft/fft_cpu.cpp ) if(ENABLE_LCAO) - if(USE_ELPA) + if(TARGET ELPA::ELPA) AddTest( TARGET MODULE_HSOLVER_LCAO - LIBS parameter ${math_libs} ELPA::ELPA base genelpa psi device + LIBS parameter ELPA::ELPA base genelpa psi device SOURCES diago_lcao_test.cpp ../diago_elpa.cpp ../diago_scalapack.cpp ../diago_lapack.cpp ) else() AddTest( TARGET MODULE_HSOLVER_LCAO - LIBS parameter ${math_libs} base psi device + LIBS parameter base psi device SOURCES diago_lcao_test.cpp ../diago_scalapack.cpp ../diago_lapack.cpp ) endif() @@ -105,7 +105,7 @@ if (ENABLE_MPI) if (ENABLE_PEXSI) AddTest( TARGET MODULE_HSOLVER_LCAO_PEXSI - LIBS parameter ${math_libs} ${PEXSI_LIBRARY} ${SuperLU_DIST_LIBRARY} ${ParMETIS_LIBRARY} ${METIS_LIBRARY} MPI::MPI_CXX base psi device pexsi + LIBS parameter ${PEXSI_LIBRARY} ${SuperLU_DIST_LIBRARY} ${ParMETIS_LIBRARY} ${METIS_LIBRARY} MPI::MPI_CXX base psi device pexsi SOURCES diago_pexsi_test.cpp ../diago_pexsi.cpp ../../source_basis/module_ao/parallel_orbitals.cpp ) endif() @@ -113,7 +113,7 @@ if (ENABLE_MPI) if (USE_CUDA) AddTest( TARGET MODULE_HSOLVER_LCAO_cusolver - LIBS parameter ${math_libs} base psi device + LIBS parameter base psi device SOURCES diago_lcao_cusolver_test.cpp ../diago_cusolver.cpp ../diago_scalapack.cpp ../kernels/hegvd_op.cpp ../kernels/cuda/diag_cusolver.cu @@ -146,30 +146,42 @@ install(FILES diago_pexsi_parallel_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DI install(FILES parallel_k2d_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -if (USE_ELPA) - AddTest( - TARGET MODULE_HSOLVER_diago_hs_parallel - LIBS parameter ${math_libs} ELPA::ELPA base device MPI::MPI_CXX genelpa psi - SOURCES test_diago_hs_para.cpp ../diag_hs_para.cpp ../diago_pxxxgvx.cpp ../diago_elpa.cpp ../diago_scalapack.cpp - ) -else() - AddTest( +if(ENABLE_MPI) + if(TARGET ELPA::ELPA) + AddTest( TARGET MODULE_HSOLVER_diago_hs_parallel - LIBS parameter ${math_libs} base device MPI::MPI_CXX psi - SOURCES test_diago_hs_para.cpp ../diag_hs_para.cpp ../diago_pxxxgvx.cpp ../diago_scalapack.cpp + LIBS parameter ELPA::ELPA base device MPI::MPI_CXX genelpa psi + SOURCES + test_diago_hs_para.cpp + ../diag_hs_para.cpp + ../diago_pxxxgvx.cpp + ../diago_elpa.cpp + ../diago_scalapack.cpp ) -endif() + else() + AddTest( + TARGET MODULE_HSOLVER_diago_hs_parallel + LIBS parameter base device MPI::MPI_CXX psi + SOURCES + test_diago_hs_para.cpp + ../diag_hs_para.cpp + ../diago_pxxxgvx.cpp + ../diago_scalapack.cpp + ) + endif() -AddTest( - TARGET MODULE_HSOLVER_linear_trans - LIBS parameter ${math_libs} base device MPI::MPI_CXX - SOURCES test_para_linear_trans.cpp ../para_linear_transform.cpp -) + AddTest( + TARGET MODULE_HSOLVER_linear_trans + LIBS parameter base device MPI::MPI_CXX + SOURCES test_para_linear_trans.cpp ../para_linear_transform.cpp + ) -add_test(NAME MODULE_HSOLVER_para_linear_trans - COMMAND mpirun -np 4 ./MODULE_HSOLVER_linear_trans - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -) + add_test( + NAME MODULE_HSOLVER_para_linear_trans + COMMAND mpirun -np 4 ./MODULE_HSOLVER_linear_trans + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) +endif() find_program(BASH bash) if (ENABLE_MPI) @@ -197,4 +209,4 @@ if (ENABLE_MPI) ) endif() endif() -endif() \ No newline at end of file +endif() diff --git a/source/source_hsolver/test/diago_pexsi_test.cpp b/source/source_hsolver/test/diago_pexsi_test.cpp index 0d021166e11..7bc8f0c27ea 100644 --- a/source/source_hsolver/test/diago_pexsi_test.cpp +++ b/source/source_hsolver/test/diago_pexsi_test.cpp @@ -5,16 +5,21 @@ #undef private #include "source_base/global_variable.h" +#include "source_base/module_external/scalapack_connector.h" #include "source_base/parallel_global.h" #include "source_basis/module_ao/parallel_orbitals.h" #include "source_hsolver/module_pexsi/pexsi_solver.h" #include "source_hsolver/test/diago_elpa_utils.h" +#include +#include #include #include #include #include +#include #include +#include #include #include @@ -75,7 +80,7 @@ class PexsiPrepare std::vector h_local; std::vector s_local; psi::Psi psi; - hsolver::DiagoPexsi* dh = nullptr; + std::unique_ptr> dh; Parallel_Orbitals po; std::vector abc; int icontxt; @@ -155,7 +160,7 @@ class PexsiPrepare std::cout << "nrow: " << hmtest.nrow << ", ncol: " << hmtest.ncol << ", nb: " << nb2d << std::endl; } - dh = new hsolver::DiagoPexsi(&po); + dh = std::make_unique>(&po); } void distribute_data() @@ -315,13 +320,8 @@ class PexsiPrepare bool compare_ref(std::stringstream& out_info) { double maxerror = 0.0; - int iindex = 0; bool pass = true; - auto ofs = std::ofstream("dm_local" + std::to_string(myprow) + std::to_string(mypcol) + ".dat"); - - int SENDPROW = 0, SENDPCOL = 0, tag = 0; - // do iteration for matrix, distribute old_matrix to each process, pass a block each time for (int row = 0; row < nlocal; row++) { @@ -373,19 +373,29 @@ class PexsiPrepare out_info.clear(); } } - delete dh; return pass_all; } }; -class PexsiGammaOnlyTest : public ::testing::TestWithParam> +struct PexsiTestCase +{ + int nb2d; + const char* hfname; + const char* sfname; + const char* dmname; +}; + +class PexsiGammaOnlyTest : public ::testing::TestWithParam { }; TEST_P(PexsiGammaOnlyTest, LCAO) { + const auto& test_case = GetParam(); + PexsiPrepare dp( + 0, 0, test_case.nb2d, 0, test_case.hfname, test_case.sfname, test_case.dmname); + std::stringstream out_info; - PexsiPrepare dp = GetParam(); if (DETAILINFO && dp.myrank == 0) { std::cout << "nlocal: " << dp.nlocal << ", nbands: " << dp.nbands << ", nb2d: " << dp.nb2d @@ -407,7 +417,7 @@ TEST_P(PexsiGammaOnlyTest, LCAO) std::cout << "Time for hsolver: " << dp.hsolver_time << "s" << std::endl; } - bool pass = dp.compare_ref(out_info); + const bool pass = dp.compare_ref(out_info); EXPECT_TRUE(pass) << out_info.str(); MPI_Barrier(MPI_COMM_WORLD); @@ -416,40 +426,38 @@ TEST_P(PexsiGammaOnlyTest, LCAO) INSTANTIATE_TEST_SUITE_P( DiagoTest, PexsiGammaOnlyTest, - ::testing::Values( // int nlocal, int nbands, int nb2d, int sparsity, std::string ks_solver_in, std::string hfname, - // std::string sfname - PexsiPrepare< - double>(0, 0, 2, 0, "PEXSI-H-GammaOnly-Si2.dat", "PEXSI-S-GammaOnly-Si2.dat", "PEXSI-DM-GammaOnly-Si2.dat"), - PexsiPrepare< - double>(0, 0, 1, 0, "PEXSI-H-GammaOnly-Si2.dat", "PEXSI-S-GammaOnly-Si2.dat", "PEXSI-DM-GammaOnly-Si2.dat") - - )); + ::testing::Values( + PexsiTestCase{2, + "PEXSI-H-GammaOnly-Si2.dat", + "PEXSI-S-GammaOnly-Si2.dat", + "PEXSI-DM-GammaOnly-Si2.dat"}, + PexsiTestCase{1, + "PEXSI-H-GammaOnly-Si2.dat", + "PEXSI-S-GammaOnly-Si2.dat", + "PEXSI-DM-GammaOnly-Si2.dat"})); int main(int argc, char** argv) { MPI_Init(&argc, &argv); - int mypnum, dsize; - MPI_Comm_size(MPI_COMM_WORLD, &dsize); - MPI_Comm_rank(MPI_COMM_WORLD, &mypnum); + + int myrank; + MPI_Comm_rank(MPI_COMM_WORLD, &myrank); testing::InitGoogleTest(&argc, argv); ::testing::TestEventListeners& listeners = ::testing::UnitTest::GetInstance()->listeners(); - if (mypnum != 0) + if (myrank != 0) { delete listeners.Release(listeners.default_result_printer()); } - int result = RUN_ALL_TESTS(); - if (mypnum == 0 && result != 0) + const int result = RUN_ALL_TESTS(); + if (myrank == 0 && result != 0) { - std::cout << "ERROR:some tests are not passed" << std::endl; - return result; - } - else - { - MPI_Finalize(); - return 0; + std::cout << "ERROR: some tests are not passed" << std::endl; } + + MPI_Finalize(); + return myrank == 0 ? result : 0; } #endif // __PEXSI diff --git a/source/source_io/module_json/test/CMakeLists.txt b/source/source_io/module_json/test/CMakeLists.txt index 83b87bccc42..8998a4f1ea4 100644 --- a/source/source_io/module_json/test/CMakeLists.txt +++ b/source/source_io/module_json/test/CMakeLists.txt @@ -5,6 +5,6 @@ abacus_disable_feature_definitions(__EXX) AddTest( TARGET MODULE_IO_JSON_OUTPUT_TEST - LIBS parameter ${math_libs} base device cell_info json_output + LIBS parameter base device cell_info json_output SOURCES para_json_test.cpp ../para_json.cpp ) diff --git a/source/source_io/test/CMakeLists.txt b/source/source_io/test/CMakeLists.txt index 1a733d9e8ea..d8fd451aa56 100644 --- a/source/source_io/test/CMakeLists.txt +++ b/source/source_io/test/CMakeLists.txt @@ -8,7 +8,7 @@ configure_file(INPUTs ${CMAKE_CURRENT_BINARY_DIR}/INPUTs COPYONLY) AddTest( TARGET MODULE_IO_input_test_para - LIBS parameter ${math_libs} base device io_input + LIBS parameter base device io_input SOURCES read_input_ptest.cpp ) @@ -19,7 +19,7 @@ add_test(NAME MODULE_IO_input_test_para_4 AddTest( TARGET MODULE_IO_read_exit_file_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES read_exit_file_test.cpp ../module_output/read_exit_file.cpp ) @@ -30,7 +30,7 @@ add_test(NAME MODULE_IO_read_exit_file_test_para_4 AddTest( TARGET MODULE_IO_output_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES output_test.cpp ) @@ -41,32 +41,32 @@ AddTest( AddTest( TARGET MODULE_IO_write_eig_occ_test - LIBS parameter ${math_libs} base device symmetry + LIBS parameter base device symmetry SOURCES write_eig_occ_test.cpp ../module_energy/write_eig_occ.cpp ../../source_cell/parallel_kpoints.cpp ../../source_cell/klist.cpp ../../source_cell/k_vector_utils.cpp ../module_output/cif_io.cpp ) AddTest( TARGET MODULE_IO_cal_dos - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES cal_dos_test.cpp ../module_dos/cal_dos.cpp ) AddTest( TARGET MODULE_IO_write_dos_pw - LIBS parameter ${math_libs} base device symmetry + LIBS parameter base device symmetry SOURCES write_dos_pw_test.cpp ../module_dos/cal_dos.cpp ../module_dos/write_dos_pw.cpp ../../source_cell/parallel_kpoints.cpp ../../source_cell/klist.cpp ../module_energy/nscf_fermi_surf.cpp ../../source_cell/k_vector_utils.cpp ) AddTest( TARGET MODULE_IO_print_info - LIBS parameter ${math_libs} base device symmetry cell_info + LIBS parameter base device symmetry cell_info SOURCES print_info_test.cpp ../module_output/print_info.cpp ../../source_cell/klist.cpp ../../source_cell/parallel_kpoints.cpp ../../source_cell/k_vector_utils.cpp ) AddTest( TARGET MODULE_IO_single_R_test - LIBS parameter ${math_libs} + LIBS parameter SOURCES single_R_io_test.cpp ../module_hs/single_R_io.cpp ../../source_base/global_variable.cpp ../../source_base/parallel_reduce.cpp @@ -78,7 +78,7 @@ AddTest( AddTest( TARGET MODULE_IO_write_wfc_nao - LIBS parameter ${math_libs} base psi device + LIBS parameter base psi device SOURCES write_wfc_nao_test.cpp ../module_output/filename.cpp ../module_wf/write_wfc_nao.cpp ../../source_basis/module_ao/parallel_orbitals.cpp ../module_output/binstream.cpp ) @@ -91,62 +91,62 @@ add_test(NAME MODULE_IO_write_wfc_nao_para AddTest( TARGET MODULE_IO_write_orb_info - LIBS parameter ${math_libs} base device cell_info + LIBS parameter base device cell_info SOURCES write_orb_info_test.cpp ../module_output/write_orb_info.cpp ) AddTest( TARGET MODULE_IO_parse_args - LIBS parameter ${math_libs} base device io_input + LIBS parameter base device io_input SOURCES parse_args_test.cpp ../parse_args.cpp ../input_help.cpp ) AddTest( TARGET MODULE_IO_input_help_test - LIBS parameter ${math_libs} base device io_input + LIBS parameter base device io_input SOURCES input_help_test.cpp ../input_help.cpp ) AddTest( TARGET MODULE_IO_bessel_basis_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES bessel_basis_test.cpp ../module_bessel/bessel_basis.cpp ) AddTest( TARGET MODULE_IO_output_log_test - LIBS parameter base ${math_libs} device + LIBS parameter base device SOURCES ../module_output/output_log.cpp outputlog_test.cpp ../../source_basis/module_pw/test/test_tool.cpp ) AddTest( TARGET MODULE_IO_sparse_matrix_test - LIBS parameter base ${math_libs} device + LIBS parameter base device SOURCES sparse_matrix_test.cpp ../module_output/sparse_matrix.cpp ) AddTest( TARGET MODULE_IO_file_reader_test - LIBS parameter base ${math_libs} device + LIBS parameter base device SOURCES file_reader_test.cpp ../module_output/file_reader.cpp ) AddTest( TARGET MODULE_IO_csr_reader_test - LIBS parameter base ${math_libs} device + LIBS parameter base device SOURCES csr_reader_test.cpp ../module_output/csr_reader.cpp ../module_output/file_reader.cpp ../module_output/sparse_matrix.cpp ) AddTest( TARGET MODULE_IO_read_rhog_test - LIBS parameter ${math_libs} base device planewave + LIBS parameter base device planewave SOURCES read_rhog_test.cpp ../module_chgpot/rhog_io.cpp ../module_output/binstream.cpp ../../source_basis/module_pw/test/test_tool.cpp ) if(ENABLE_LCAO) AddTest( TARGET MODULE_IO_to_qo_test - LIBS parameter base ${math_libs} device numerical_atomic_orbitals container orb + LIBS parameter base device numerical_atomic_orbitals container orb SOURCES to_qo_test.cpp ../module_qo/to_qo_kernel.cpp @@ -162,7 +162,7 @@ endif() AddTest( TARGET MODULE_IO_read_wfc_pw_test - LIBS parameter base ${math_libs} device planewave + LIBS parameter base device planewave SOURCES read_wfc_pw_test.cpp ../module_wf/read_wfc_pw.cpp ../module_output/binstream.cpp ../../source_basis/module_pw/test/test_tool.cpp ) @@ -173,7 +173,7 @@ add_test(NAME MODULE_IO_read_wfc_pw_test_parallel AddTest( TARGET MODULE_IO_read_wf2rho_pw_test - LIBS parameter base ${math_libs} device planewave psi + LIBS parameter base device planewave psi SOURCES read_wf2rho_pw_test.cpp ../module_wf/read_wfc_pw.cpp ../module_wf/read_wf2rho_pw.cpp ../module_output/binstream.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_estate/module_charge/charge_mpi.cpp ../module_output/filename.cpp ../module_wf/write_wfc_pw.cpp ) @@ -185,7 +185,7 @@ add_test(NAME MODULE_IO_read_wf2rho_pw_parallel AddTest( TARGET MODULE_IO_numerical_basis_test - LIBS parameter base ${math_libs} device numerical_atomic_orbitals container orb + LIBS parameter base device numerical_atomic_orbitals container orb SOURCES numerical_basis_test.cpp ../module_bessel/numerical_basis_jyjy.cpp ../../source_lcao/center2_orb.cpp @@ -195,7 +195,7 @@ AddTest( AddTest( TARGET MODULE_IO_mulliken_test - LIBS parameter base ${math_libs} device + LIBS parameter base device SOURCES output_mulliken_test.cpp output_mulliken_mock.cpp ../module_mulliken/output_mulliken.cpp ../../source_cell/cell_index.cpp ../../source_basis/module_ao/parallel_orbitals.cpp @@ -205,7 +205,7 @@ AddTest( #if(ENABLE_LCAO) #AddTest( # TARGET MODULE_IO_read_wfc_lcao_test -# LIBS parameter base ${math_libs} device +# LIBS parameter base device # SOURCES read_wfc_lcao_test.cpp ../read_wfc_lcao.cpp #) @@ -218,7 +218,7 @@ AddTest( AddTest( TARGET MODULE_IO_cif_io_test - LIBS parameter base ${math_libs} device + LIBS parameter base device SOURCES cif_io_test.cpp ../module_output/cif_io.cpp ) @@ -229,7 +229,7 @@ add_test(NAME MODULE_IO_cif_io_test_parallel AddTest( TARGET MODULE_IO_orb_io_test - LIBS parameter base ${math_libs} device + LIBS parameter base device SOURCES orb_io_test.cpp ../module_output/orb_io.cpp ) @@ -240,7 +240,7 @@ add_test(NAME MODULE_IO_orb_io_test_parallel AddTest( TARGET MODULE_IO_write_dmk - LIBS parameter ${math_libs} base device cell_info + LIBS parameter base device cell_info SOURCES ../module_dm/test/write_dmk_test.cpp ../module_dm/write_dmk.cpp ../module_output/ucell_io.cpp ) @@ -252,7 +252,7 @@ add_test( AddTest( TARGET MODULE_IO_read_wfc_nao_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES read_wfc_nao_test.cpp ../module_wf/read_wfc_nao.cpp ../../source_psi/psi.cpp ../../source_basis/module_ao/parallel_orbitals.cpp ) @@ -265,7 +265,7 @@ add_test( if(ENABLE_LCAO) AddTest( TARGET MODULE_IO_cal_pLpR_test - LIBS parameter base ${math_libs} device neighbor + LIBS parameter base device neighbor SOURCES cal_pLpR_test.cpp ../module_hs/cal_pLpR.cpp @@ -286,7 +286,7 @@ AddTest( AddTest( TARGET MODULE_IO_write_hs_r_compat_test - LIBS parameter base ${math_libs} device hcontainer + LIBS parameter base device hcontainer SOURCES write_hs_r_compat_test.cpp ../module_hs/write_HS_R.cpp @@ -306,7 +306,7 @@ endif() if(ENABLE_LIBRI) AddTest( TARGET MODULE_IO_restart_exx_csr_test - LIBS parameter base ${math_libs} device + LIBS parameter base device SOURCES restart_exx_csr_test.cpp tmp_mocks.cpp diff --git a/source/source_io/test_serial/CMakeLists.txt b/source/source_io/test_serial/CMakeLists.txt index 0e3488320b3..a985cc7eef3 100644 --- a/source/source_io/test_serial/CMakeLists.txt +++ b/source/source_io/test_serial/CMakeLists.txt @@ -26,7 +26,7 @@ add_library( file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) AddTest( TARGET MODULE_IO_read_input_serial - LIBS parameter ${math_libs} io_input_serial + LIBS parameter io_input_serial SOURCES read_input_test.cpp ../../source_base/test/tool_quit_no_exit.cpp ../../source_base/module_device/device.cpp @@ -35,7 +35,7 @@ AddTest( AddTest( TARGET MODULE_IO_read_item_serial - LIBS parameter ${math_libs} base device io_input_serial + LIBS parameter base device io_input_serial SOURCES read_input_item_test.cpp ) @@ -46,18 +46,18 @@ AddTest( AddTest( TARGET MODULE_IO_rho_io - LIBS parameter ${math_libs} base device cell_info + LIBS parameter base device cell_info SOURCES rho_io_test.cpp ../module_output/read_cube.cpp ../module_output/write_cube.cpp ) AddTest( TARGET MODULE_IO_write_bands - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES write_bands_test.cpp ../module_energy/write_bands.cpp ) AddTest( TARGET MODULE_IO_system_variable_test - LIBS parameter ${math_libs} base device io_input_serial + LIBS parameter base device io_input_serial SOURCES io_system_variable_test.cpp ) diff --git a/source/source_lcao/module_deepks/test/CMakeLists.txt b/source/source_lcao/module_deepks/test/CMakeLists.txt index 1a382b9c745..deed5f16de2 100644 --- a/source/source_lcao/module_deepks/test/CMakeLists.txt +++ b/source/source_lcao/module_deepks/test/CMakeLists.txt @@ -67,6 +67,7 @@ set(DEEPKS_UNIT_COMMON_SOURCES ) add_library(deepks_unit_support OBJECT ${DEEPKS_UNIT_COMMON_SOURCES}) +target_link_libraries(deepks_unit_support PRIVATE GTest::gtest) if(ENABLE_COVERAGE) add_coverage(deepks_unit_support) @@ -86,7 +87,7 @@ set(DEEPKS_UNIT_LIBS gint numerical_atomic_orbitals symmetry - ${math_libs} + ${TORCH_LIBRARIES} ) set(DEEPKS_UNIT_PHIALPHA_SOURCES diff --git a/source/source_lcao/module_deltaspin/test/CMakeLists.txt b/source/source_lcao/module_deltaspin/test/CMakeLists.txt index 038990ad669..c47869123a5 100644 --- a/source/source_lcao/module_deltaspin/test/CMakeLists.txt +++ b/source/source_lcao/module_deltaspin/test/CMakeLists.txt @@ -4,14 +4,14 @@ if(ENABLE_LCAO) AddTest( TARGET MODULE_LCAO_deltaspin_basic_func_test - LIBS ${math_libs} base device parameter + LIBS base device parameter SOURCES basic_test.cpp ../basic_funcs.cpp ) AddTest( TARGET MODULE_LCAO_deltaspin_spin_constrain_test - LIBS ${math_libs} base device parameter + LIBS base device parameter SOURCES spin_constrain_test.cpp ../spin_constrain.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp @@ -19,7 +19,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_deltaspin_template_helpers - LIBS ${math_libs} base device parameter + LIBS base device parameter SOURCES template_helpers_test.cpp ../spin_constrain.cpp ../template_helpers.cpp @@ -27,13 +27,13 @@ AddTest( AddTest( TARGET deltaspin_pw_test - LIBS ${math_libs} base device parameter + LIBS base device parameter SOURCES deltaspin_pw_test.cpp ) AddTest( TARGET deltaspin_core_test - LIBS ${math_libs} base device + LIBS base device SOURCES deltaspin_core_test.cpp ) diff --git a/source/source_lcao/module_dftu/test/CMakeLists.txt b/source/source_lcao/module_dftu/test/CMakeLists.txt index 802b35537dd..de94b196903 100644 --- a/source/source_lcao/module_dftu/test/CMakeLists.txt +++ b/source/source_lcao/module_dftu/test/CMakeLists.txt @@ -2,18 +2,18 @@ abacus_disable_feature_definitions(__CUDA) AddTest( TARGET dftu_pw_test - LIBS ${math_libs} base device parameter + LIBS base device parameter SOURCES dftu_pw_test.cpp ) AddTest( TARGET dftu_core_test - LIBS ${math_libs} base device + LIBS base device SOURCES dftu_core_test.cpp ) AddTest( TARGET dftu_operator_test - LIBS ${math_libs} base device + LIBS base device SOURCES dftu_operator_test.cpp ) diff --git a/source/source_lcao/module_gint/test/CMakeLists.txt b/source/source_lcao/module_gint/test/CMakeLists.txt index 87a547d7b43..a72aef496db 100644 --- a/source/source_lcao/module_gint/test/CMakeLists.txt +++ b/source/source_lcao/module_gint/test/CMakeLists.txt @@ -8,7 +8,7 @@ if(ENABLE_LCAO) AddTest( TARGET MODULE_LCAO_gint_common_test - LIBS parameter ${math_libs} psi base device + LIBS parameter psi base device SOURCES test_gint_common.cpp tmp_mocks.cpp ../gint_common.cpp @@ -20,7 +20,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_gint_precision_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES test_gint_precision.cpp tmp_mocks.cpp ) diff --git a/source/source_lcao/module_hcontainer/test/CMakeLists.txt b/source/source_lcao/module_hcontainer/test/CMakeLists.txt index 35d7eb5a7d3..2b6d225fbbe 100644 --- a/source/source_lcao/module_hcontainer/test/CMakeLists.txt +++ b/source/source_lcao/module_hcontainer/test/CMakeLists.txt @@ -2,35 +2,35 @@ if(ENABLE_LCAO) AddTest( TARGET MODULE_LCAO_hcontainer_test - LIBS parameter ${math_libs} psi base device + LIBS parameter psi base device SOURCES test_hcontainer.cpp ../base_matrix.cpp ../hcontainer.cpp ../atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp tmp_mocks.cpp ) AddTest( TARGET MODULE_LCAO_hcontainer_complex_test - LIBS parameter ${math_libs} psi base device + LIBS parameter psi base device SOURCES test_hcontainer_complex.cpp ../base_matrix.cpp ../hcontainer.cpp ../atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp tmp_mocks.cpp ) AddTest( TARGET MODULE_LCAO_hcontainer_cost_test - LIBS parameter ${math_libs} psi base device + LIBS parameter psi base device SOURCES test_hcontainer_time.cpp ../base_matrix.cpp ../hcontainer.cpp ../atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp tmp_mocks.cpp ) AddTest( TARGET MODULE_LCAO_hcontainer_folding_test - LIBS parameter ${math_libs} psi base device + LIBS parameter psi base device SOURCES test_func_folding.cpp ../base_matrix.cpp ../hcontainer.cpp ../atom_pair.cpp ../func_folding.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp tmp_mocks.cpp ) AddTest( TARGET MODULE_LCAO_hcontainer_transfer_test - LIBS parameter ${math_libs} psi base device + LIBS parameter psi base device SOURCES test_transfer.cpp ../func_transfer.cpp ../base_matrix.cpp ../hcontainer.cpp ../atom_pair.cpp ../transfer.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp tmp_mocks.cpp ) @@ -44,7 +44,7 @@ add_test(NAME MODULE_LCAO_hcontainer_para_test AddTest( TARGET MODULE_LCAO_hcontainer_output_test - LIBS parameter base ${math_libs} device + LIBS parameter base device SOURCES test_hcontainer_output.cpp tmp_mocks.cpp ../output_hcontainer.cpp diff --git a/source/source_lcao/module_lr/ao_to_mo_transformer/test/CMakeLists.txt b/source/source_lcao/module_lr/ao_to_mo_transformer/test/CMakeLists.txt index ef1e405fdcb..fe0f12cc700 100644 --- a/source/source_lcao/module_lr/ao_to_mo_transformer/test/CMakeLists.txt +++ b/source/source_lcao/module_lr/ao_to_mo_transformer/test/CMakeLists.txt @@ -1,6 +1,6 @@ abacus_disable_feature_definitions(USE_LIBXC) AddTest( TARGET MODULE_LR_ao_to_mo_test - LIBS parameter base ${math_libs} container device psi + LIBS parameter base container device psi SOURCES ao_to_mo_test.cpp ../../utils/lr_util.cpp ../ao_to_mo_parallel.cpp ../ao_to_mo_serial.cpp ) \ No newline at end of file diff --git a/source/source_lcao/module_lr/dm_trans/test/CMakeLists.txt b/source/source_lcao/module_lr/dm_trans/test/CMakeLists.txt index 380fc48336b..d89d366b1c5 100644 --- a/source/source_lcao/module_lr/dm_trans/test/CMakeLists.txt +++ b/source/source_lcao/module_lr/dm_trans/test/CMakeLists.txt @@ -1,7 +1,7 @@ abacus_disable_feature_definitions(USE_LIBXC) AddTest( TARGET MODULE_LR_dm_trans_test - LIBS parameter psi base ${math_libs} device container + LIBS parameter psi base device container SOURCES dm_trans_test.cpp ../../utils/lr_util.cpp ../dm_trans_parallel.cpp ../dm_trans_serial.cpp # ../../../source_base/module_container/ATen/core/tensor.cpp # ../../../source_base/module_container/ATen/core/tensor_shape.cpp diff --git a/source/source_lcao/module_lr/ri_benchmark/test/CMakeLists.txt b/source/source_lcao/module_lr/ri_benchmark/test/CMakeLists.txt index 51ccc5b3976..d885e3ddea2 100644 --- a/source/source_lcao/module_lr/ri_benchmark/test/CMakeLists.txt +++ b/source/source_lcao/module_lr/ri_benchmark/test/CMakeLists.txt @@ -1,7 +1,7 @@ if (ENABLE_LIBRI) AddTest( TARGET MODULE_LR_ri_benchmark_test - LIBS psi base ${math_libs} device container parameter + LIBS psi base device container parameter SOURCES ri_benchmark_test.cpp ) endif() \ No newline at end of file diff --git a/source/source_lcao/module_lr/utils/test/CMakeLists.txt b/source/source_lcao/module_lr/utils/test/CMakeLists.txt index 2ce675b9c05..30beb2d88a5 100644 --- a/source/source_lcao/module_lr/utils/test/CMakeLists.txt +++ b/source/source_lcao/module_lr/utils/test/CMakeLists.txt @@ -1,13 +1,13 @@ abacus_disable_feature_definitions(USE_LIBXC) AddTest( TARGET MODULE_LR_lr_util_phys_test - LIBS parameter base ${math_libs} device container planewave #for FFT + LIBS parameter base device container planewave #for FFT SOURCES lr_util_physics_test.cpp ../lr_util.cpp ../../../../source_io/module_output/orb_io.cpp ) AddTest( TARGET MODULE_LR_lr_util_algo_test - LIBS parameter base ${math_libs} device psi container planewave #for FFT + LIBS parameter base device psi container planewave #for FFT SOURCES lr_util_algorithms_test.cpp ../lr_util.cpp ) \ No newline at end of file diff --git a/source/source_lcao/module_operator_lcao/test/CMakeLists.txt b/source/source_lcao/module_operator_lcao/test/CMakeLists.txt index b6ccf0632b7..86c67273598 100644 --- a/source/source_lcao/module_operator_lcao/test/CMakeLists.txt +++ b/source/source_lcao/module_operator_lcao/test/CMakeLists.txt @@ -3,7 +3,7 @@ abacus_disable_feature_definitions(USE_NEW_TWO_CENTER) AddTest( TARGET MODULE_LCAO_operator_overlap_test - LIBS parameter ${math_libs} psi base device container + LIBS parameter psi base device container SOURCES test_overlap.cpp ../overlap.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../module_hcontainer/func_transfer.cpp ../../module_hcontainer/output_hcontainer.cpp ../../module_hcontainer/transfer.cpp @@ -16,7 +16,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_operator_overlap_serial_test - LIBS parameter ${math_libs} psi base device container + LIBS parameter psi base device container SOURCES test_overlap_serial.cpp ../overlap.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../module_hcontainer/func_transfer.cpp ../../module_hcontainer/output_hcontainer.cpp ../../module_hcontainer/transfer.cpp @@ -29,7 +29,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_operator_overlap_cd_test - LIBS parameter ${math_libs} psi base device container + LIBS parameter psi base device container SOURCES test_overlap_cd.cpp ../overlap.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../module_hcontainer/func_transfer.cpp ../../module_hcontainer/output_hcontainer.cpp ../../module_hcontainer/transfer.cpp @@ -42,7 +42,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_operator_ekinetic_test - LIBS parameter ${math_libs} psi base device container + LIBS parameter psi base device container SOURCES test_ekinetic.cpp ../ekinetic.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp @@ -52,7 +52,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_operator_ekinetic_serial_test - LIBS parameter ${math_libs} psi base device container + LIBS parameter psi base device container SOURCES test_ekinetic_serial.cpp ../ekinetic.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp @@ -62,7 +62,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_operator_nonlocal_test - LIBS parameter ${math_libs} psi base device container + LIBS parameter psi base device container SOURCES test_nonlocal.cpp ../nonlocal.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp @@ -72,7 +72,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_operator_T_NL_cd_test - LIBS parameter ${math_libs} psi base device container + LIBS parameter psi base device container SOURCES test_T_NL_cd.cpp ../nonlocal.cpp ../ekinetic.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp @@ -82,7 +82,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_operator_dftu_test - LIBS parameter ${math_libs} psi base device container + LIBS parameter psi base device container SOURCES test_dftu.cpp ../dftu_lcao.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp diff --git a/source/source_lcao/module_ri/CMakeLists.txt b/source/source_lcao/module_ri/CMakeLists.txt index ec1344b1d58..ffd995c3d17 100644 --- a/source/source_lcao/module_ri/CMakeLists.txt +++ b/source/source_lcao/module_ri/CMakeLists.txt @@ -1,7 +1,7 @@ if (ENABLE_LIBRI) add_subdirectory(module_exx_symmetry) - + list(APPEND objects Matrix_Orbs11.cpp Matrix_Orbs21.cpp @@ -29,7 +29,7 @@ if (ENABLE_LIBRI) OBJECT ${objects} ) - + if(BUILD_TESTING) if(ENABLE_MPI) add_subdirectory(test) diff --git a/source/source_lcao/module_ri/module_exx_symmetry/CMakeLists.txt b/source/source_lcao/module_ri/module_exx_symmetry/CMakeLists.txt index b66e7f5c7ae..a7f4fde8ba8 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/CMakeLists.txt +++ b/source/source_lcao/module_ri/module_exx_symmetry/CMakeLists.txt @@ -14,7 +14,7 @@ if (ENABLE_LIBRI) if(BUILD_TESTING) add_subdirectory(test) endif() - + if(ENABLE_COVERAGE) add_coverage(module_exx_symmetry) endif() diff --git a/source/source_lcao/module_ri/module_exx_symmetry/test/CMakeLists.txt b/source/source_lcao/module_ri/module_exx_symmetry/test/CMakeLists.txt index 4a1c95167b1..767dcf6cb0a 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/test/CMakeLists.txt +++ b/source/source_lcao/module_ri/module_exx_symmetry/test/CMakeLists.txt @@ -3,7 +3,7 @@ abacus_disable_feature_definitions(__CUDA) abacus_disable_feature_definitions(__ROCM) AddTest( TARGET MODULE_RI_EXX_SYMMETRY_rotation - LIBS base ${math_libs} device symmetry neighbor parameter + LIBS base device symmetry neighbor parameter SOURCES symmetry_rotation_test.cpp ../symmetry_rotation.cpp ../symmetry_rotation_output.cpp ../irreducible_sector.cpp ../irreducible_sector_bvk.cpp ../../../../source_basis/module_ao/parallel_orbitals.cpp diff --git a/source/source_lcao/module_ri/test/CMakeLists.txt b/source/source_lcao/module_ri/test/CMakeLists.txt index d1ff566f461..23b2d816fca 100644 --- a/source/source_lcao/module_ri/test/CMakeLists.txt +++ b/source/source_lcao/module_ri/test/CMakeLists.txt @@ -3,12 +3,12 @@ abacus_disable_feature_definitions(__CUDA) abacus_disable_feature_definitions(__ROCM) AddTest( TARGET MODULE_RI_dm_mixing_test - LIBS parameter base ${math_libs} device + LIBS parameter base device SOURCES dm_mixing_test.cpp ../Mix_DMk_2D.cpp ) AddTest( TARGET MODULE_RI_ri_cv_io_test - LIBS base ${math_libs} device parameter + LIBS base device parameter SOURCES ri_cv_io_test.cpp ) AddTest( diff --git a/source/source_lcao/module_rt/test/CMakeLists.txt b/source/source_lcao/module_rt/test/CMakeLists.txt index 7a2fb16c08d..f624424e8c5 100644 --- a/source/source_lcao/module_rt/test/CMakeLists.txt +++ b/source/source_lcao/module_rt/test/CMakeLists.txt @@ -4,36 +4,36 @@ target_link_libraries(tddft_test_lib PRIVATE Threads::Threads GTest::gtest_main AddTest( TARGET MODULE_LCAO_tddft_middle_hamilt_test - LIBS parameter ${math_libs} base device tddft_test_lib + LIBS parameter base device tddft_test_lib SOURCES middle_hamilt_test.cpp ../middle_hamilt.cpp ) AddTest( TARGET MODULE_LCAO_tddft_band_energy_test - LIBS parameter ${math_libs} base device tddft_test_lib + LIBS parameter base device tddft_test_lib SOURCES band_energy_test.cpp ../band_energy.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp ) AddTest( TARGET MODULE_LCAO_tddft_norm_psi_test - LIBS parameter ${math_libs} base device tddft_test_lib + LIBS parameter base device tddft_test_lib SOURCES norm_psi_test.cpp ../norm_psi.cpp ) AddTest( TARGET MODULE_LCAO_tddft_upsi_test - LIBS parameter ${math_libs} base device tddft_test_lib + LIBS parameter base device tddft_test_lib SOURCES upsi_test1.cpp upsi_test2.cpp upsi_test3.cpp ../upsi.cpp ) AddTest( TARGET MODULE_LCAO_tddft_propagator_test - LIBS parameter ${math_libs} base device tddft_test_lib + LIBS parameter base device tddft_test_lib SOURCES propagator_test1.cpp propagator_test2.cpp propagator_test3.cpp ../propagator.cpp ../propagator_cn2.cpp ../propagator_taylor.cpp ../propagator_etrs.cpp ) AddTest( TARGET MODULE_LCAO_tddft_snap_psibeta_half_test - LIBS parameter ${math_libs} base device orb numerical_atomic_orbitals tddft_test_lib + LIBS parameter base device orb numerical_atomic_orbitals tddft_test_lib SOURCES snap_psibeta_half_tddft_test.cpp ../snap_projector_half_tddft.cpp ../snap_psibeta_half_tddft.cpp ) diff --git a/source/source_lcao/test/CMakeLists.txt b/source/source_lcao/test/CMakeLists.txt index 12fd83b912f..563ad619140 100644 --- a/source/source_lcao/test/CMakeLists.txt +++ b/source/source_lcao/test/CMakeLists.txt @@ -5,7 +5,7 @@ abacus_disable_feature_definitions(__ROCM) if(ENABLE_LCAO) AddTest( TARGET MODULE_LCAO_init_dm_from_file_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES test_init_dm_from_file.cpp tmp_mocks.cpp ${ABACUS_SOURCE_DIR}/source_estate/module_dm/density_matrix.cpp ${ABACUS_SOURCE_DIR}/source_estate/module_dm/density_matrix_io.cpp @@ -28,7 +28,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_output_hcontainer_consistency_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES test_output_hcontainer_consistency.cpp tmp_mocks.cpp ${ABACUS_SOURCE_DIR}/source_lcao/module_hcontainer/base_matrix.cpp ${ABACUS_SOURCE_DIR}/source_lcao/module_hcontainer/hcontainer.cpp @@ -47,7 +47,7 @@ AddTest( AddTest( TARGET MODULE_LCAO_init_chg_hr_error_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES test_init_chg_hr_error.cpp ) endif() diff --git a/source/source_md/test/CMakeLists.txt b/source/source_md/test/CMakeLists.txt index d01eb92d240..735e84f7973 100644 --- a/source/source_md/test/CMakeLists.txt +++ b/source/source_md/test/CMakeLists.txt @@ -67,21 +67,21 @@ list(APPEND depend_files AddTest( TARGET MODULE_MD_LJ_pot - LIBS parameter ${math_libs} psi device + LIBS parameter psi device SOURCES lj_pot_test.cpp ${depend_files} ) AddTest( TARGET MODULE_MD_func - LIBS parameter ${math_libs} psi device + LIBS parameter psi device SOURCES md_func_test.cpp ${depend_files} ) AddTest( TARGET MODULE_MD_fire - LIBS parameter ${math_libs} psi device + LIBS parameter psi device SOURCES fire_test.cpp ../md_base.cpp ../fire.cpp @@ -90,7 +90,7 @@ AddTest( AddTest( TARGET MODULE_MD_verlet - LIBS parameter ${math_libs} psi device + LIBS parameter psi device SOURCES verlet_test.cpp ../md_base.cpp ../verlet.cpp @@ -99,7 +99,7 @@ AddTest( AddTest( TARGET MODULE_MD_nhc - LIBS parameter ${math_libs} psi device + LIBS parameter psi device SOURCES nhchain_test.cpp ../md_base.cpp ../nhchain.cpp @@ -109,7 +109,7 @@ AddTest( AddTest( TARGET MODULE_MD_msst - LIBS parameter ${math_libs} psi device + LIBS parameter psi device SOURCES msst_test.cpp ../md_base.cpp ../msst.cpp @@ -120,7 +120,7 @@ AddTest( AddTest( TARGET MODULE_MD_lgv - LIBS parameter ${math_libs} psi device + LIBS parameter psi device SOURCES langevin_test.cpp ../md_base.cpp ../langevin.cpp diff --git a/source/source_psi/test/CMakeLists.txt b/source/source_psi/test/CMakeLists.txt index e0e292da261..63af5799e1a 100644 --- a/source/source_psi/test/CMakeLists.txt +++ b/source/source_psi/test/CMakeLists.txt @@ -1,6 +1,6 @@ AddTest( TARGET MODULE_PSI_Unittests - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES psi_test.cpp ../psi.cpp @@ -9,7 +9,7 @@ AddTest( if(ENABLE_LCAO) AddTest( TARGET MODULE_PSI_initializer_unit_test - LIBS parameter ${math_libs} base device psi psi_initializer planewave + LIBS parameter base device psi psi_initializer planewave SOURCES psi_initializer_unit_test.cpp ../../source_pw/module_pwdft/soc.cpp diff --git a/source/source_pw/module_pwdft/kernels/test/CMakeLists.txt b/source/source_pw/module_pwdft/kernels/test/CMakeLists.txt index 0a32a49c015..a864c632171 100644 --- a/source/source_pw/module_pwdft/kernels/test/CMakeLists.txt +++ b/source/source_pw/module_pwdft/kernels/test/CMakeLists.txt @@ -4,7 +4,7 @@ abacus_disable_feature_definitions(__CUDA) AddTest( TARGET MODULE_PW_Hamilt_Kernels_UTs - LIBS parameter ${math_libs} device base container + LIBS parameter device base container SOURCES ekinetic_op_test.cpp nonlocal_op_test.cpp veff_op_test.cpp meta_op_test.cpp force_op_test.cpp stress_op_test.cpp wf_op_test.cpp vnl_op_test.cpp stress_op_mgga_test.cpp @@ -12,6 +12,6 @@ AddTest( AddTest( TARGET onsite_op_test - LIBS parameter ${math_libs} device base container + LIBS parameter device base container SOURCES onsite_op_test.cpp ) diff --git a/source/source_pw/module_pwdft/test/CMakeLists.txt b/source/source_pw/module_pwdft/test/CMakeLists.txt index 2fd75206e13..7e4c64db0c3 100644 --- a/source/source_pw/module_pwdft/test/CMakeLists.txt +++ b/source/source_pw/module_pwdft/test/CMakeLists.txt @@ -5,7 +5,7 @@ abacus_disable_feature_definitions(__EXX) AddTest( TARGET MODULE_PW_pwdft_soc - LIBS parameter ${math_libs} + LIBS parameter SOURCES soc_test.cpp ../soc.cpp ../../../source_base/global_variable.cpp ../../../source_base/global_function.cpp @@ -24,13 +24,13 @@ AddTest( AddTest( TARGET MODULE_PW_radial_proj_test - LIBS parameter base device ${math_libs} + LIBS parameter base device SOURCES radial_proj_test.cpp ../radial_proj.cpp ) AddTest( TARGET MODULE_PW_structure_factor_test - LIBS parameter ${math_libs} base device planewave + LIBS parameter base device planewave SOURCES structure_factor_test.cpp ../structure_factor.cpp ../parallel_grid.cpp ../../../source_cell/unitcell.cpp diff --git a/source/source_pw/module_stodft/test/CMakeLists.txt b/source/source_pw/module_stodft/test/CMakeLists.txt index c5e07e626ed..a83352348c1 100644 --- a/source/source_pw/module_stodft/test/CMakeLists.txt +++ b/source/source_pw/module_stodft/test/CMakeLists.txt @@ -2,12 +2,12 @@ abacus_disable_feature_definitions(__MPI) AddTest( TARGET MODULE_PW_Sto_Tool_UTs - LIBS parameter ${math_libs} psi base device + LIBS parameter psi base device SOURCES ../sto_tool.cpp test_sto_tool.cpp ) AddTest( TARGET MODULE_PW_Sto_Hamilt_UTs - LIBS parameter ${math_libs} psi base device planewave_serial + LIBS parameter psi base device planewave_serial SOURCES ../hamilt_sdft_pw.cpp test_hamilt_sto.cpp ../../../source_hamilt/operator.cpp ) \ No newline at end of file diff --git a/source/source_relax/CMakeLists.txt b/source/source_relax/CMakeLists.txt index bce15417a9b..9e7ef96b0e2 100644 --- a/source/source_relax/CMakeLists.txt +++ b/source/source_relax/CMakeLists.txt @@ -29,5 +29,5 @@ if(BUILD_TESTING) if(ENABLE_MPI) add_subdirectory(test) endif() - + endif() diff --git a/source/source_relax/test/CMakeLists.txt b/source/source_relax/test/CMakeLists.txt index 7c56c67838c..2262fefb419 100644 --- a/source/source_relax/test/CMakeLists.txt +++ b/source/source_relax/test/CMakeLists.txt @@ -8,7 +8,7 @@ install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) AddTest( TARGET MODULE_RELAX_relax_new_line_search - LIBS parameter + LIBS parameter SOURCES line_search_test.cpp ../line_search.cpp ../../source_base/global_variable.cpp ../../source_base/global_file.cpp ../../source_base/global_function.cpp ../../source_base/memory_recorder.cpp ../../source_base/timer.cpp ../../source_base/tool_quit.cpp ) @@ -20,7 +20,7 @@ AddTest( ../../source_base/complexarray.cpp ../../source_base/tool_quit.cpp ../../source_base/realarray.cpp ../../source_base/module_external/blas_connector_base.cpp ../../source_base/module_external/blas_connector_vector.cpp ../../source_base/module_external/blas_connector_matrix.cpp ../../source_cell/update_cell.cpp ../../source_cell/print_cell.cpp ../../source_cell/bcast_cell.cpp ../../source_base/output.cpp - LIBS parameter ${math_libs} + LIBS parameter ) list(APPEND cell_source_files @@ -30,19 +30,19 @@ list(APPEND cell_source_files ) AddTest( TARGET MODULE_RELAX_lattice_change_methods_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES lattice_change_methods_test.cpp ../lattice_change_methods.cpp ../lattice_change_basic.cpp ../relax_data.cpp mock_remake_cell.cpp ) AddTest( TARGET MODULE_RELAX_lattice_change_basic_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES lattice_change_basic_test.cpp ../lattice_change_basic.cpp ../relax_data.cpp mock_remake_cell.cpp ) AddTest( TARGET MODULE_RELAX_lattice_change_cg_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES lattice_change_cg_test.cpp ../lattice_change_cg.cpp ../lattice_change_basic.cpp @@ -54,7 +54,7 @@ AddTest( AddTest( TARGET MODULE_RELAX_bfgs_basic_test - LIBS parameter ${math_libs} base device symmetry + LIBS parameter base device symmetry SOURCES bfgs_basic_test.cpp ../bfgs_basic.cpp ../relax_data.cpp ../ions_move_basic.cpp ../../source_io/module_output/orb_io.cpp ${cell_source_files} @@ -63,19 +63,19 @@ AddTest( AddTest( TARGET MODULE_RELAX_bfgs_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES bfgs_test.cpp ../ions_move_bfgs2.cpp ../ions_move_basic.cpp ../matrix_methods.cpp ../relax_data.cpp ${cell_source_files} ) AddTest( TARGET MODULE_RELAX_ions_move_basic_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES ions_move_basic_test.cpp ../ions_move_basic.cpp ../relax_data.cpp ${cell_source_files} ) AddTest( TARGET MODULE_RELAX_ions_move_bfgs_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES ions_move_bfgs_test.cpp ../ions_move_bfgs.cpp ../ions_move_basic.cpp @@ -87,7 +87,7 @@ AddTest( AddTest( TARGET MODULE_RELAX_ions_move_methods_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES ions_move_methods_test.cpp ../ions_move_methods.cpp ../ions_move_bfgs.cpp @@ -107,7 +107,7 @@ AddTest( AddTest( TARGET MODULE_RELAX_ions_move_cg_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES ions_move_cg_test.cpp ../ions_move_cg.cpp ../cg_base.cpp @@ -119,6 +119,6 @@ AddTest( AddTest( TARGET MODULE_RELAX_ions_move_sd_test - LIBS parameter ${math_libs} base device + LIBS parameter base device SOURCES ions_move_sd_test.cpp ../ions_move_sd.cpp ../ions_move_basic.cpp ../relax_data.cpp ${cell_source_files} )