Skip to content

Commit 75d2623

Browse files
committed
CMake: Introduce CMake dependent options
1 parent 31c899d commit 75d2623

1 file changed

Lines changed: 16 additions & 25 deletions

File tree

CMakeLists.txt

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cmake_minimum_required(VERSION 3.16)
2+
include(CMakeDependentOption)
23
if(POLICY CMP0135) # https://cmake.org/cmake/help/git-stage/policy/CMP0135.html
34
cmake_policy(SET CMP0135 NEW)
45
# Otherwise this policy generates a warning on CMake 3.24
@@ -16,8 +17,6 @@ project(
1617
option(ENABLE_MPI "Enable MPI" ON)
1718
option(ENABLE_OPENMP "Enable OpenMP" ON)
1819
option(USE_CUDA "Enable CUDA" OFF)
19-
option(USE_CUDA_MPI "Enable CUDA-aware MPI" OFF)
20-
option(USE_CUDA_ON_DCU "Enable CUDA on DCU" OFF)
2120
option(USE_ROCM "Enable ROCm" OFF)
2221
option(USE_DSP "Enable DSP" OFF)
2322
option(USE_KML "Enable Kunpeng Math Library" OFF)
@@ -27,13 +26,7 @@ option(ENABLE_ABACUS_LIBM "Build libmath from source to speed up" OFF)
2726
option(ENABLE_LIBXC "Enable using the LibXC package" OFF)
2827
option(ENABLE_FLOAT_FFTW "Enable using single-precision FFTW library." OFF)
2928

30-
option(ENABLE_MLALGO "Enable the machine learning algorithms" OFF)
31-
3229
option(ENABLE_LCAO "Enable LCAO algorithm" ON)
33-
option(ENABLE_ELPA "Enable ELPA for LCAO" ON)
34-
option(ENABLE_LIBRI "Enable LibRI for hybrid functional" OFF)
35-
option(EXX_DEV "Enable LibRI developing features" OFF)
36-
option(ENABLE_PEXSI "Enable PEXSI for LCAO" OFF)
3730
option(ENABLE_DFTD4 "Enable DFT-D4 dispersion correction" OFF)
3831

3932
option(BUILD_TESTING "Build unittests" OFF)
@@ -52,8 +45,21 @@ option(ENABLE_FFT_TWO_CENTER "Enable FFT-based two-center integral method" ON)
5245
option(ENABLE_GOOGLEBENCH "Enable GOOGLE-benchmark usage" OFF)
5346
option(ENABLE_RAPIDJSON "Enable rapid-json usage" OFF)
5447
option(ENABLE_CNPY "Enable cnpy usage" OFF)
55-
option(ENABLE_CUSOLVERMP "Enable cusolvermp" OFF)
56-
option(ENABLE_NCCL_PARALLEL_DEVICE "Enable NCCL-backed collectives in parallel_device" OFF)
48+
49+
cmake_dependent_option(ENABLE_ELPA "Enable ELPA for LCAO" ON "ENABLE_LCAO;ENABLE_MPI" OFF)
50+
cmake_dependent_option(ENABLE_LIBRI "Enable LibRI for hybrid functional" OFF "ENABLE_LCAO;ENABLE_MPI" OFF)
51+
cmake_dependent_option(EXX_DEV "Enable LibRI developing features" OFF "ENABLE_LIBRI" OFF)
52+
cmake_dependent_option(ENABLE_PEXSI "Enable PEXSI for LCAO" OFF "ENABLE_LCAO;ENABLE_MPI" OFF)
53+
cmake_dependent_option(ENABLE_MLALGO "Enable the machine learning algorithms"
54+
OFF "ENABLE_LCAO;ENABLE_MPI" OFF)
55+
56+
cmake_dependent_option(USE_CUDA_MPI "Enable CUDA-aware MPI" OFF "USE_CUDA" OFF)
57+
cmake_dependent_option(USE_CUDA_ON_DCU "Enable CUDA on DCU" OFF "USE_CUDA" OFF)
58+
cmake_dependent_option(ENABLE_CUBLASMP "Enable cublasmp" OFF "USE_CUDA" OFF)
59+
cmake_dependent_option(ENABLE_CUSOLVERMP "Enable cusolvermp" OFF "USE_CUDA" OFF)
60+
cmake_dependent_option(ENABLE_NCCL_PARALLEL_DEVICE
61+
"Enable NCCL-backed collectives in parallel_device"
62+
OFF "USE_CUDA;ENABLE_MPI" OFF)
5763

5864
# ==============================================================================
5965
# Deprecated options (TODO: Remove this section in the future release)
@@ -170,12 +176,6 @@ You can install Git first and reinstall abacus.")
170176
endif()
171177
endif()
172178

173-
# Serial version of ABACUS will not use ELPA
174-
if(NOT ENABLE_MPI)
175-
set(ENABLE_ELPA OFF)
176-
set(ENABLE_MLALGO OFF)
177-
endif()
178-
179179
# Different exe files of ABACUS
180180
unset(ABACUS_BIN_NAME CACHE)
181181

@@ -349,11 +349,9 @@ if(ENABLE_LCAO)
349349
find_package(ELPA REQUIRED)
350350
abacus_add_feature_definitions(__ELPA)
351351
endif()
352-
353352
if(ENABLE_FFT_TWO_CENTER)
354353
abacus_add_feature_definitions(USE_NEW_TWO_CENTER)
355354
endif()
356-
357355
if(ENABLE_PEXSI)
358356
find_package(PEXSI REQUIRED CONFIG)
359357
if(PEXSI_VERSION VERSION_LESS "2.0.0")
@@ -362,9 +360,6 @@ if(ENABLE_LCAO)
362360
abacus_add_feature_definitions(__PEXSI)
363361
set(CMAKE_CXX_STANDARD 14)
364362
endif()
365-
else()
366-
set(ENABLE_MLALGO OFF)
367-
set(ENABLE_LIBRI OFF)
368363
endif()
369364

370365
if(DEBUG_INFO)
@@ -520,10 +515,6 @@ if(USE_CUDA)
520515
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=${OpenMP_CXX_FLAGS}" CACHE STRING "CUDA flags" FORCE)
521516
endif()
522517
if (ENABLE_NCCL_PARALLEL_DEVICE)
523-
if (NOT ENABLE_MPI)
524-
message(FATAL_ERROR
525-
"ENABLE_NCCL_PARALLEL_DEVICE requires ENABLE_MPI=ON.")
526-
endif()
527518
abacus_add_feature_definitions(__NCCL_PARALLEL_DEVICE)
528519
include(cmake/modules/SetupNccl.cmake)
529520
abacus_setup_nccl()

0 commit comments

Comments
 (0)