Skip to content

Commit 68280a4

Browse files
authored
CMake: Mark ELPA_DIR as deprecated (#7630)
* CMake: Find ELPA through pkg-config module * Adjust document and toolchain scripts accordingly * Adjust cmake/CollectBuildInfoVars.cmake * Include pkg-config in GH workflow * Keep ELPA_DIR but mark as deprecated
1 parent a2a45f8 commit 68280a4

14 files changed

Lines changed: 47 additions & 64 deletions

.github/workflows/ase_plugin_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
4040
- name: Install external tools from toolchain
4141
run: |
42-
sudo apt update && sudo apt install -y xz-utils ninja-build
42+
sudo apt update && sudo apt install -y xz-utils ninja-build pkg-config
4343
cd toolchain
4444
./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run -j8
4545
./scripts/stage4/install_stage4.sh

.github/workflows/build_test_cmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161

6262
- name: Install external tools from toolchain
6363
run: |
64-
sudo apt update && sudo apt install -y gfortran ninja-build xz-utils
64+
sudo apt update && sudo apt install -y gfortran ninja-build pkg-config xz-utils
6565
cd toolchain
6666
./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run ${{matrix.external_toolchain_args}}
6767
./scripts/stage4/install_stage4.sh

.github/workflows/coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
python3-pip \
3232
xz-utils \
3333
ninja-build \
34+
pkg-config \
3435
lcov \
3536
perl-modules \
3637
libcapture-tiny-perl \

.github/workflows/cuda.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
with:
3030
submodules: recursive
3131

32-
- name: Install Ccache
32+
- name: Install CI tools
3333
run: |
3434
sudo apt-get update
35-
sudo apt-get install -y ccache xz-utils ninja-build
35+
sudo apt-get install -y ccache xz-utils ninja-build pkg-config
3636
3737
- name: Install external tools from toolchain
3838
run: |

.github/workflows/dynamic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: actions/checkout@v7
2121
- name: Install external tools from toolchain
2222
run: |
23-
sudo apt update && sudo apt install -y xz-utils ninja-build
23+
sudo apt update && sudo apt install -y xz-utils ninja-build pkg-config
2424
cd toolchain
2525
./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run -j8
2626
./scripts/stage4/install_stage4.sh

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
gfortran \
4141
ccache \
4242
ca-certificates \
43+
pkg-config \
4344
python-is-python3 \
4445
python3-pip \
4546
ninja-build \

cmake/CollectBuildInfoVars.cmake

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,7 @@ endif()
146146

147147
# Core Math Libraries
148148
if(ENABLE_LCAO AND ENABLE_ELPA)
149-
set(ABACUS_ELPA_VERSION "yes (version unknown)")
150-
if(ELPA_VERSION)
151149
set(ABACUS_ELPA_VERSION "yes (v${ELPA_VERSION})")
152-
else()
153-
find_program(ELPA_VERSION_EXE elpa2_print_version PATHS ${ELPA_DIR}/bin NO_DEFAULT_PATH)
154-
if(ELPA_VERSION_EXE)
155-
execute_process(COMMAND ${ELPA_VERSION_EXE} OUTPUT_VARIABLE ELPA_VER_RAW OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
156-
if(ELPA_VER_RAW)
157-
set(ABACUS_ELPA_VERSION "yes (${ELPA_VER_RAW})")
158-
endif()
159-
endif()
160-
endif()
161-
if(ABACUS_ELPA_VERSION STREQUAL "yes (version unknown)" AND ELPA_DIR)
162-
set(ABACUS_ELPA_VERSION "yes (path: ${ELPA_DIR})")
163-
endif()
164150
else()
165151
set(ABACUS_ELPA_VERSION "no")
166152
endif()

cmake/modules/FindELPA.cmake

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
###############################################################################
22
# - Find ELPA
3-
# Find the native ELPA headers and libraries.
4-
#
5-
# ELPA_FOUND - True if libelpa is found.
6-
# ELPA_LIBRARIES - List of libraries when using libyaml
7-
# ELPA_INCLUDE_DIR - Where to find ELPA headers.
3+
# Find the native ELPA headers and libraries through pkg-config.
84
#
95

10-
find_package(PkgConfig)
6+
# ========================================================================
7+
# Deprecated (TODO: Remove this part)
8+
# ========================================================================
119

1210
# Compatible layer towards old manual routines
11+
if(DEFINED ELPA_DIR)
12+
message(WARNING "ELPA_DIR is deprecated and will be removed in the future release.")
13+
endif()
1314
if(DEFINED ELPA_INCLUDE_DIR)
1415
set(ELPA_INCLUDE_DIRS ${ELPA_INCLUDE_DIR})
1516
endif()
@@ -31,34 +32,35 @@ if(ELPA_INCLUDE_DIRS MATCHES "^/usr/include/elpa/.*")
3132
endif()
3233
endif()
3334
if(ENABLE_OPENMP)
34-
find_library(ELPA_LINK_LIBRARIES
35+
find_library(ELPA_LINK_LIBRARIES
3536
NAMES elpa_openmp elpa
3637
HINTS ${ELPA_DIR}
3738
PATH_SUFFIXES "lib"
38-
)
39+
)
3940
else()
40-
find_library(ELPA_LINK_LIBRARIES
41+
find_library(ELPA_LINK_LIBRARIES
4142
NAMES elpa
4243
HINTS ${ELPA_DIR}
4344
PATH_SUFFIXES "lib"
44-
)
45+
)
4546
endif()
4647

47-
# Incompatible with ELPA earlier than 2021.11.001
48-
# Before ELPA 2021.11.001, its pkg-config file
49-
# is named like "elpa-2021.05.002.pc".
50-
if(NOT ELPA_INCLUDE_DIRS AND PKG_CONFIG_FOUND)
51-
if(DEFINED ELPA_DIR)
52-
string(APPEND CMAKE_PREFIX_PATH ";${ELPA_DIR}")
48+
# ========================================================================
49+
50+
if(NOT ELPA_INCLUDE_DIRS)
51+
find_package(PkgConfig)
52+
if(NOT PKG_CONFIG_FOUND)
53+
message(FATAL_ERROR "Pkg-config is needed to get all information about the ELPA library")
5354
endif()
55+
# Find preferred library corresponding with ABACUS configuration first
5456
if(ENABLE_OPENMP)
55-
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp)
57+
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp elpa)
5658
else()
5759
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa)
5860
endif()
59-
elseif(NOT PKG_CONFIG_FOUND)
60-
message(STATUS
61-
"ELPA : We need pkg-config to get all information about the elpa library")
61+
if(${ELPA_VERSION} VERSION_LESS "2021.05.001")
62+
message(FATAL_ERROR "ELPA version >= 2021.05.001 is required.")
63+
endif()
6264
endif()
6365

6466
# Handle the QUIET and REQUIRED arguments and
@@ -68,20 +70,21 @@ find_package_handle_standard_args(ELPA DEFAULT_MSG ELPA_LINK_LIBRARIES ELPA_INCL
6870

6971
# Copy the results to the output variables and target.
7072
if(ELPA_FOUND)
71-
list(GET ELPA_LINK_LIBRARIES 0 ELPA_LIBRARY)
72-
set(ELPA_INCLUDE_DIR ${ELPA_INCLUDE_DIRS})
73-
74-
if(NOT TARGET ELPA::ELPA)
75-
add_library(ELPA::ELPA UNKNOWN IMPORTED)
76-
set_target_properties(ELPA::ELPA PROPERTIES
77-
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
78-
IMPORTED_LOCATION "${ELPA_LIBRARY}"
79-
INTERFACE_INCLUDE_DIRECTORIES "${ELPA_INCLUDE_DIR}")
80-
endif()
73+
list(GET ELPA_LINK_LIBRARIES 0 ELPA_LIBRARY)
74+
set(ELPA_INCLUDE_DIR ${ELPA_INCLUDE_DIRS})
75+
if(NOT TARGET ELPA::ELPA)
76+
add_library(ELPA::ELPA UNKNOWN IMPORTED)
77+
set_target_properties(ELPA::ELPA PROPERTIES
78+
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
79+
IMPORTED_LOCATION "${ELPA_LIBRARY}"
80+
INTERFACE_INCLUDE_DIRECTORIES "${ELPA_INCLUDE_DIR}")
81+
endif()
8182
endif()
8283

8384
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ELPA_INCLUDE_DIR})
8485

86+
# Compability workaround for ELPA_DIR
87+
# TODO: Remove this check
8588
include(CheckCXXSourceCompiles)
8689
check_cxx_source_compiles("
8790
#include <elpa/elpa_version.h>
@@ -93,7 +96,7 @@ int main(){}
9396
ELPA_VERSION_SATISFIES
9497
)
9598
if(NOT ELPA_VERSION_SATISFIES)
96-
message(FATAL_ERROR "ELPA version is too old. We support version 2021 or higher.")
99+
message(FATAL_ERROR "ELPA version is too old. We support version 2021 or higher.")
97100
endif()
98101

99102
mark_as_advanced(ELPA_INCLUDE_DIR ELPA_LIBRARY)

docs/quick_start/easy_install.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ Here, 'build' is the path for building ABACUS; and '-D' is used for setting up s
158158
- `MKLROOT`: If environment variable `MKLROOT` exists, `cmake` will take MKL as a preference, i.e. not using `LAPACK`, `ScaLAPACK` and `FFTW`. To disable MKL, unset environment variable `MKLROOT`, or pass `-DMKLROOT=OFF` to `cmake`.
159159
- `LAPACK_DIR`: Path to OpenBLAS library `libopenblas.so`(including BLAS and LAPACK)
160160
- `SCALAPACK_DIR`: Path to ScaLAPACK library `libscalapack.so`
161-
- `ELPA_DIR`: Path to ELPA install directory; should be the folder containing 'include' and 'lib'.
162-
> 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.
163-
164161
- `FFTW3_DIR`: Path to FFTW3.
165162
- `LIBRI_DIR`: (Optional) Path to LibRI.
166163
- `LIBCOMM_DIR`: (Optional) Path to LibComm when `ENABLE_LIBRI=ON`.
@@ -184,7 +181,12 @@ For some dependencies built with CMake, such as Libxc, dftd4, cereal, and RapidJ
184181
Here is an example:
185182

186183
```bash
187-
CXX=mpiicpx cmake -B build -DCMAKE_INSTALL_PREFIX=~/abacus -DELPA_DIR=~/elpa-2025.01.001/build
184+
CXX=mpiicpx cmake -B build \
185+
-DCMAKE_INSTALL_PREFIX=~/abacus \
186+
-DENABLE_MPI=ON \
187+
-DENABLE_LCAO=ON \
188+
-DENABLE_ELPA=ON \
189+
-DENABLE_LIBXC=ON
188190
```
189191

190192
### Build and Install

toolchain/build_abacus_aocc-aocl.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ BUILD_DIR=build_abacus_aocc_aocl
2222
rm -rf $BUILD_DIR
2323

2424
PREFIX=$ABACUS_DIR
25-
ELPA=${ELPA_ROOT}
2625
CEREAL=${CEREAL_ROOT}/include
2726
LAPACK=$AOCLhome/lib
2827
SCALAPACK=$AOCLhome/lib
@@ -67,7 +66,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
6766
-DLAPACK_DIR=$LAPACK \
6867
-DSCALAPACK_DIR=$SCALAPACK \
6968
-DFFTW3_DIR=$FFTW3 \
70-
-DELPA_DIR=$ELPA \
7169
-DCEREAL_INCLUDE_DIR=$CEREAL \
7270
-DENABLE_LCAO=ON \
7371
-DENABLE_LIBXC=ON \

0 commit comments

Comments
 (0)