Skip to content

Commit

Permalink
Merge branch 'develop' into warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuxuegang2022 authored Jan 27, 2024
2 parents 785e5e9 + 8239efb commit 91355ec
Show file tree
Hide file tree
Showing 67 changed files with 1,005 additions and 986 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Build
run: |
cmake -B build -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_PAW=ON
cmake -B build -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_PAW=ON -DENABLE_GOOGLEBENCH=ON
cmake --build build -j8
cmake --install build
Expand Down
41 changes: 32 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ option(DEBUG_INFO "Print message for developers to debug." OFF)
option(ENABLE_NATIVE_OPTIMIZATION "Enable compilation optimization for the native machine's CPU type" OFF)
option(COMMIT_INFO "Print commit information in log" ON)
option(ENABLE_FFT_TWO_CENTER "Enable FFT-based two-center integral method." ON)
option(ENABLE_GOOGLEBENCH "Enable GOOGLE-benchmark usage." OFF)
option(ENABLE_RAPIDJSON "Enable rapid-json usage." OFF)


Expand Down Expand Up @@ -428,8 +429,7 @@ endif()

if(ENABLE_DEEPKS)
# Torch uses outdated components to detech CUDA arch, causing failure on latest CUDA kits.
# See above for setting CMAKE_CUDA_ARCHITECTURES
set(TORCH_CUDA_ARCH_LIST CMAKE_CUDA_ARCHITECTURES)
# Set CMake variable TORCH_CUDA_ARCH_LIST in the form of "major.minor" if required.
find_package(Torch REQUIRED)
if(NOT Torch_VERSION VERSION_LESS "2.1.0")
set_if_higher(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -536,11 +536,8 @@ if(DEFINED Libxc_DIR)
set(ENABLE_LIBXC ON)
endif()
if(ENABLE_LIBXC)
find_package(Libxc REQUIRED HINTS
${Libxc_DIR}/share/cmake/Libxc
${Libxc_DIR}/lib/cmake/Libxc
${Libxc_DIR}/lib64/cmake/Libxc
)
# use `cmake/FindLibxc.cmake` to detect Libxc installation with `pkg-config`
find_package(Libxc REQUIRED)
message(STATUS "Found Libxc: version " ${Libxc_VERSION})
if(${Libxc_VERSION} VERSION_LESS 5.1.7)
message(FATAL_ERROR "LibXC >= 5.1.7 is required.")
Expand Down Expand Up @@ -594,6 +591,25 @@ if(INFO)
# modifications on blas_connector and lapack_connector
endif()

# Add performance test in abacus
IF (ENABLE_GOOGLEBENCH)
set(BUILD_TESTING ON)
find_package(benchmark HINTS ${BENCHMARK_DIR})
if(NOT ${benchmark_FOUND})
set(BENCHMARK_USE_BUNDLED_GTEST OFF)
include(FetchContent)
FetchContent_Declare(
benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG "origin/main"
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
set(BENCHMARK_ENABLE_TESTING OFF)
FetchContent_MakeAvailable(benchmark)
endif()
endif()

IF (BUILD_TESTING)
set_if_higher(CMAKE_CXX_STANDARD 14) # Required in orbital
include(CTest)
Expand Down Expand Up @@ -623,8 +639,14 @@ IF (BUILD_TESTING)
endif()

#dependencies & link library
target_link_libraries(${UT_TARGET} ${UT_LIBS}
Threads::Threads GTest::gtest_main GTest::gmock_main)
if(ENABLE_GOOGLEBENCH)
target_link_libraries(${UT_TARGET} ${UT_LIBS}
Threads::Threads GTest::gtest_main GTest::gmock_main benchmark::benchmark)
else()
target_link_libraries(${UT_TARGET} ${UT_LIBS}
Threads::Threads GTest::gtest_main GTest::gmock_main)
endif()

if(USE_OPENMP)
target_link_libraries(${UT_TARGET} OpenMP::OpenMP_CXX)
endif()
Expand All @@ -634,6 +656,7 @@ IF (BUILD_TESTING)
WORKING_DIRECTORY $<TARGET_FILE_DIR:${UT_TARGET}>
)
endfunction(AddTest)

endif()

add_subdirectory(source)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.cuda
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM nvidia/cuda:12.2.0-devel-ubuntu22.04

RUN apt update && apt install -y --no-install-recommends \
libopenblas-openmp-dev liblapack-dev libscalapack-mpi-dev libelpa-dev libfftw3-dev libcereal-dev \
libxc-dev libgtest-dev libgmock-dev python3-numpy \
libxc-dev libgtest-dev libgmock-dev libbenchmark-dev python3-numpy \
bc cmake git g++ make bc time sudo unzip vim wget

ENV GIT_SSL_NO_VERIFY=true TERM=xterm-256color \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.gnu
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:22.04
RUN apt update && apt install -y --no-install-recommends \
libopenblas-openmp-dev liblapack-dev libscalapack-mpi-dev libelpa-dev libfftw3-dev libcereal-dev \
libxc-dev libgtest-dev libgmock-dev python3-numpy \
libxc-dev libgtest-dev libgmock-dev libbenchmark-dev python3-numpy \
bc cmake git g++ make bc time sudo unzip vim wget gfortran

ENV GIT_SSL_NO_VERIFY=true TERM=xterm-256color \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.intel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:22.04

RUN apt-get update && apt-get install -y \
bc cmake git gnupg gcc g++ python3-numpy sudo wget vim unzip \
libcereal-dev libxc-dev libgtest-dev libgmock-dev
libcereal-dev libxc-dev libgtest-dev libgmock-dev libbenchmark-dev

# Following steps by https://software.intel.com/content/www/us/en/develop/documentation/installation-guide-for-intel-oneapi-toolkits-linux/top/installation/install-using-package-managers/apt.html .
RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
Expand Down
44 changes: 30 additions & 14 deletions cmake/FindELPA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,50 @@
# ELPA_INCLUDE_DIR - Where to find ELPA headers.
#

find_path(ELPA_INCLUDE_DIR
find_package(PkgConfig)

find_path(ELPA_INCLUDE_DIRS
elpa/elpa.h
HINTS ${ELPA_DIR}
PATH_SUFFIXES "include" "include/elpa"
)
if(USE_OPENMP)
find_library(ELPA_LIBRARY
NAMES elpa_openmp elpa
HINTS ${ELPA_DIR}
PATH_SUFFIXES "lib"
)
find_library(ELPA_LINK_LIBRARIES
NAMES elpa_openmp elpa
HINTS ${ELPA_DIR}
PATH_SUFFIXES "lib"
)
else()
find_library(ELPA_LIBRARY
NAMES elpa
HINTS ${ELPA_DIR}
PATH_SUFFIXES "lib"
)
find_library(ELPA_LINK_LIBRARIES
NAMES elpa
HINTS ${ELPA_DIR}
PATH_SUFFIXES "lib"
)
endif()

if(NOT ELPA_INCLUDE_DIRS AND PKG_CONFIG_FOUND)
if(DEFINED ELPA_DIR)
string(APPEND CMAKE_PREFIX_PATH ";${ELPA_DIR}")
endif()
if(USE_OPENMP)
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp)
else()
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa)
endif()
elseif(NOT PKG_CONFIG_FOUND)
message(
"ELPA : We need pkg-config to get all information about the elpa library")
endif()

# Handle the QUIET and REQUIRED arguments and
# set ELPA_FOUND to TRUE if all variables are non-zero.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ELPA DEFAULT_MSG ELPA_LIBRARY ELPA_INCLUDE_DIR)
find_package_handle_standard_args(ELPA DEFAULT_MSG ELPA_LINK_LIBRARIES ELPA_INCLUDE_DIRS)

# Copy the results to the output variables and target.
if(ELPA_FOUND)
set(ELPA_LIBRARIES ${ELPA_LIBRARY})
set(ELPA_INCLUDE_DIR ${ELPA_INCLUDE_DIR})
list(GET ELPA_LINK_LIBRARIES 0 ELPA_LIBRARY)
set(ELPA_INCLUDE_DIR ${ELPA_INCLUDE_DIRS})

if(NOT TARGET ELPA::ELPA)
add_library(ELPA::ELPA UNKNOWN IMPORTED)
Expand Down
36 changes: 36 additions & 0 deletions cmake/FindLibxc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
include(FindPackageHandleStandardArgs)

if(DEFINED Libxc_DIR)
string(APPEND CMAKE_PREFIX_PATH ";${Libxc_DIR}")
endif()
# Using CMake interface as default.
# NO REQUIRED here, otherwhile it would throw error
# with no LibXC found.
find_package(Libxc HINTS
${Libxc_DIR}/share/cmake/Libxc
${Libxc_DIR}/lib/cmake/Libxc
${Libxc_DIR}/lib64/cmake/Libxc
)
if(NOT TARGET Libxc::xc)
find_package(PkgConfig REQUIRED)
pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc)
find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS)
endif()


# Copy the results to the output variables and target.
# if find_package() above works, Libxc::xc would be present and
# below would be skipped.
if(Libxc_FOUND AND NOT TARGET Libxc::xc)
set(Libxc_LIBRARY ${Libxc_LINK_LIBRARIES})
set(Libxc_LIBRARIES ${Libxc_LIBRARY})
set(Libxc_INCLUDE_DIR ${Libxc_INCLUDE_DIRS})
add_library(Libxc::xc UNKNOWN IMPORTED)
set_target_properties(Libxc::xc PROPERTIES
IMPORTED_LOCATION "${Libxc_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${Libxc_INCLUDE_DIR}")
endif()

set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Libxc_INCLUDE_DIR})

mark_as_advanced(Libxc_INCLUDE_DIR Libxc_LIBRARY)
2 changes: 1 addition & 1 deletion deps/libpaw_interface
37 changes: 32 additions & 5 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
- [mixing\_beta](#mixing_beta)
- [mixing\_beta\_mag](#mixing_beta_mag)
- [mixing\_ndim](#mixing_ndim)
- [mixing\_restart](#mixing_restart)
- [mixing\_gg0](#mixing_gg0)
- [mixing\_gg0\_mag](#mixing_gg0_mag)
- [mixing\_gg0\_min](#mixing_gg0_min)
Expand Down Expand Up @@ -145,6 +146,8 @@
- [out\_app\_flag](#out_app_flag)
- [out\_ndigits](#out_ndigits)
- [out\_interval](#out_interval)
- [band\_print\_num](#band_print_num)
- [bands\_to\_print](#bands_to_print)
- [out\_element\_info](#out_element_info)
- [restart\_save](#restart_save)
- [restart\_load](#restart_load)
Expand Down Expand Up @@ -945,6 +948,8 @@ calculations.
- **fixed**: fixed occupations (available for non-coductors only)
- **gauss** or **gaussian**: Gaussian smearing method.
- **mp**: methfessel-paxton smearing method; recommended for metals.
- **mp2**: 2-nd methfessel-paxton smearing method; recommended for metals.
- **mv** or **cold**: marzari-vanderbilt smearing method.
- **fd**: Fermi-Dirac smearing method: $f=1/\{1+\exp[(E-\mu)/kT]\}$ and smearing_sigma below is the temperature $T$ (in Ry).
- **Default**: gauss

Expand Down Expand Up @@ -1001,6 +1006,13 @@ We recommend the following options:
For systems that are difficult to converge, one could try increasing the value of 'mixing_ndim' to enhance the stability of the self-consistent field (SCF) calculation.
- **Default**: 8

### mixing_restart

- **Type**: Integer
- **Description**: At `mixing_restart`-th iteration, SCF will restart by using output charge density from perivos iteration as input charge density directly, and start a new mixing. `mixing_restart=0|1` means SCF starts from scratch.

- **Default**: 0

### mixing_gg0

- **Type**: Real
Expand Down Expand Up @@ -1494,8 +1506,8 @@ These variables are used to control the output of properties.

### out_band

- **Type**: Boolean
- **Description**: Whether to output the band structure (in eV). For more information, refer to the [band.md](../elec_properties/band.md)
- **Type**: Boolean Integer(optional)
- **Description**: Whether to output the band structure (in eV), optionally output precision can be set by a second parameter, default is 8. For more information, refer to the [band.md](../elec_properties/band.md)
- **Default**: False

### out_proj_band
Expand Down Expand Up @@ -1599,6 +1611,20 @@ These variables are used to control the output of properties.
- **Description**: Control the interval for printing Mulliken population analysis, $r(R)$, $H(R)$, $S(R)$, $T(R)$, $dH(R)$, $H(k)$, $S(k)$ and $wfc(k)$ matrices during molecular dynamics calculations. Check input parameters [out_mul](#out_mul), [out_mat_r](#out_mat_r), [out_mat_hs2](#out_mat_hs2), [out_mat_t](#out_mat_t), [out_mat_dh](#out_mat_dh), [out_mat_hs](#out_mat_hs) and [out_wfc_lcao](#out_wfc_lcao) for more information, respectively.
- **Default**: 1

### band_print_num

- **Type**: Integer
- **Availability**: PW basis
- **Description**: If you want to plot a partial charge density contributed from some chosen bands. `band_print_num` define the number of band list. The result can be found in "band*.cube".
- **Default**: 0

### bands_to_print

- **Type**: vector
- **Availability**: band_print_num > 0
- **Description**: define which band you want to choose for partial charge density.
- **Default**: []

### out_element_info

- **Type**: Boolean
Expand Down Expand Up @@ -2776,9 +2802,9 @@ These variables are used to control berry phase and wannier90 interface paramete

- **Type**: String
- **Description**: the spin direction for the Wannier function calculation when nspin is set to 2
- "up": Calculate spin up for the Wannier function.
- "down": Calculate spin down for the Wannier function.
- **Default**: "up"
- `up`: Calculate spin up for the Wannier function.
- `down`: Calculate spin down for the Wannier function.
- **Default**: `up`

### out_wannier_mmn

Expand Down Expand Up @@ -2818,6 +2844,7 @@ These variables are used to control berry phase and wannier90 interface paramete
- **Description**: write the "UNK.*" file in ASCII format or binary format.
- 0: write the "UNK.*" file in binary format.
- 1: write the "UNK.*" file in ASCII format (text file format).
- **Default**: 1

[back to top](#full-list-of-input-keywords)

Expand Down
10 changes: 10 additions & 0 deletions docs/advanced/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ After building and installing, unit tests can be performed with `ctest`.

To run a subset of unit test, use `ctest -R <test-match-pattern>` to perform tests with name matched by given pattern.

## Build Performance Tests

To build performance tests for ABACUS, define `ENABLE_GOOGLEBENCH` flag. You can also specify the path to a local installation of [Google Benchmark](https://github.com/google/benchmark.git) by setting `BENCHMARK_DIR` flags. If not found locally, the configuration process will try to download it automatically.

```bash
cmake -B build -DENABLE_GOOGLEBENCH=1
```

Google Benchmark requires Google Test to build and run the tests. When setting `ENABLE_GOOGLEBENCH` to ON, `BUILD_TESTING` is automatically enabled. After building and installing, performance tests can be executed with `ctest`.

## Build with CUDA support

### Extra prerequisites
Expand Down
7 changes: 4 additions & 3 deletions docs/quick_start/easy_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ These requirements support the calculation of plane-wave basis in ABACUS. For LC
Some of these packages can be installed with popular package management system, such as `apt` and `yum`:

```bash
sudo apt update && sudo apt install -y libopenblas-openmp-dev liblapack-dev libscalapack-mpi-dev libelpa-dev libfftw3-dev libcereal-dev libxc-dev g++ make cmake bc git
sudo apt update && sudo apt install -y libopenblas-openmp-dev liblapack-dev libscalapack-mpi-dev libelpa-dev libfftw3-dev libcereal-dev libxc-dev g++ make cmake bc git pkgconf
```

> Installing ELPA by apt only matches requirements on Ubuntu 22.04. For earlier linux distributions, you should build ELPA from source.
Expand Down Expand Up @@ -111,12 +111,12 @@ Here, 'build' is the path for building ABACUS; and '-D' is used for setting up s
- `LAPACK_DIR`: Path to OpenBLAS library `libopenblas.so`(including BLAS and LAPACK)
- `SCALAPACK_DIR`: Path to ScaLAPACK library `libscalapack.so`
- `ELPA_DIR`: Path to ELPA install directory; should be the folder containing 'include' and 'lib'.
> Note: If you install ELPA from source, please add a symlink to avoid the additional include file folder with version name: `ln -s elpa/include/elpa-2021.05.002/elpa elpa/include/elpa`. This is a known behavior of ELPA.
> Note: In ABACUS v3.5.1 or earlier, if you install ELPA from source , please add a symlink to avoid the additional include file folder with version name: `ln -s elpa/include/elpa-2021.05.002/elpa elpa/include/elpa` to help the build system find ELPA headers.
- `FFTW3_DIR`: Path to FFTW3.
- `CEREAL_INCLUDE_DIR`: Path to the parent folder of `cereal/cereal.hpp`. Will download from GitHub if absent.
- `Libxc_DIR`: (Optional) Path to Libxc.
> Note: Building Libxc from source with Makefile does NOT support using it in CMake here. Please compile Libxc with CMake instead.
> Note: In ABACUS v3.5.1 or earlier, Libxc built from source with Makefile is NOT supported; please compile Libxc with CMake instead.
- `LIBRI_DIR`: (Optional) Path to LibRI.
- `LIBCOMM_DIR`: (Optional) Path to LibComm.

Expand All @@ -126,6 +126,7 @@ Here, 'build' is the path for building ABACUS; and '-D' is used for setting up s
- `ENABLE_LIBRI=OFF`: [Enable LibRI](../advanced/install.md#add-libri-support) to suppport variety of functionals. If `LIBRI_DIR` and `LIBCOMM_DIR` is defined, `ENABLE_LIBRI` will set to 'ON'.
- `USE_OPENMP=ON`: Enable OpenMP support. Building ABACUS without OpenMP is not fully tested yet.
- `BUILD_TESTING=OFF`: [Build unit tests](../advanced/install.md#build-unit-tests).
- `ENABLE_GOOGLEBENCH=OFF`: [Build performance tests](../advanced/install.md#build-performance-tests)
- `ENABLE_MPI=ON`: Enable MPI parallel compilation. If set to `OFF`, a serial version of ABACUS with PW basis only will be compiled. Currently serial version of ABACUS with LCAO basis is not supported yet, so `ENABLE_LCAO` will be automatically set to `OFF`.
- `ENABLE_COVERAGE=OFF`: Build ABACUS executable supporting [coverage analysis](../CONTRIBUTING.md#generating-code-coverage-report). This feature has a drastic impact on performance.
- `ENABLE_ASAN=OFF`: Build with Address Sanitizer. This feature would help detecting memory problems.
Expand Down
11 changes: 8 additions & 3 deletions python/pyabacus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ set(BASE_PATH "${PROJECT_SOURCE_DIR}/../../source/module_base")
set(ABACUS_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../source")
include_directories(${BASE_PATH} ${ABACUS_SOURCE_DIR})
list(APPEND _sources
${ABACUS_SOURCE_DIR}/module_basis/module_nao/numerical_radial.h
${ABACUS_SOURCE_DIR}/module_basis/module_nao/numerical_radial.cpp
${PROJECT_SOURCE_DIR}/src/py_numerical_radial.cpp)
#${ABACUS_SOURCE_DIR}/module_basis/module_nao/numerical_radial.h
#${ABACUS_SOURCE_DIR}/module_basis/module_nao/numerical_radial.cpp
${ABACUS_SOURCE_DIR}/module_base/constants.h
${ABACUS_SOURCE_DIR}/module_base/math_sphbes.h
${ABACUS_SOURCE_DIR}/module_base/math_sphbes.cpp
${PROJECT_SOURCE_DIR}/src/py_abacus.cpp
#${PROJECT_SOURCE_DIR}/src/py_numerical_radial.cpp
${PROJECT_SOURCE_DIR}/src/py_math_base.cpp)
python_add_library(_core MODULE ${_sources} WITH_SOABI)
target_link_libraries(_core PRIVATE pybind11::headers)
target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION})
Expand Down
13 changes: 13 additions & 0 deletions python/pyabacus/src/py_abacus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>

namespace py = pybind11;

void bind_numerical_radial(py::module& m);
void bind_math_base(py::module& m);

PYBIND11_MODULE(_core, m)
{
// bind_numerical_radial(m);
bind_math_base(m);
}
Loading

0 comments on commit 91355ec

Please sign in to comment.