diff --git a/docs/getting-started/build-from-source.md b/docs/getting-started/build-from-source.md index 5382199d39..ad395d7f3f 100644 --- a/docs/getting-started/build-from-source.md +++ b/docs/getting-started/build-from-source.md @@ -28,7 +28,7 @@ By default, [CMake] generates GNU Makefiles (on Linux). With [CMake], it is poss files for other build systems such as Ninja: ```bash -cmake -S . -B build -GNinja +cmake -S . -B build -GNinja ``` ### Release and Debug Builds @@ -36,7 +36,7 @@ cmake -S . -B build -GNinja [CMake] allows to specify a build type. `-DCMAKE_BUILD_TYPE=Release` turns on optimizations, while `-DCMAKE_BUILD_TYPE=Debug` turns on debug options. -## Requirements +## Dependencies The minimum requirements to use the [CMake] build system are the following: @@ -77,29 +77,50 @@ cmake -S . -B build -DCP2K_BLAS_VENDOR=SCI -DCP2K_SCALAPACK_VENDOR=SCI cmake --build build ``` -## Build Customization +### Others Build Options -### Default Dependencies +- `BUILD_SHARED_LIBS` +- `CMAKE_POSITION_INDEPENDENT_CODE` +- `CP2K_DBCSR_USE_CPU_ONLY` +- `CP2K_ENABLE_CONSISTENCY_CHECKS` +- `CP2K_ENABLE_DBM_GPU` +- `CP2K_ENABLE_ELPA_OPENMP_SUPPORT` +- `CP2K_ENABLE_FFTW3_OPENMP_SUPPORT` +- `CP2K_ENABLE_FFTW3_THREADS_SUPPORT` +- `CP2K_ENABLE_GRID_GPU` +- `CP2K_ENABLE_PW_GPU` +- `CP2K_USE_ACE` +- `CP2K_USE_CUSOLVER_MP` +- `CP2K_USE_DEEPMD` +- `CP2K_USE_DFTD4` +- `CP2K_USE_DLAF` +- `CP2K_USE_EVERYTHING` +- `CP2K_USE_FFTW3` +- `CP2K_USE_FFTW3_WITH_MKL` +- `CP2K_USE_GREENX` +- `CP2K_USE_GRPP` +- `CP2K_USE_HDF5` +- `CP2K_USE_LIBSMEAGOL` +- `CP2K_USE_LIBTORCH` +- `CP2K_USE_LIBVDWXC` +- `CP2K_USE_LIBVDWXC` +- `CP2K_USE_LIBXSMM` +- `CP2K_USE_MPI_F08` +- `CP2K_USE_PEXSI` +- `CP2K_USE_PEXSI` +- `CP2K_USE_PLUMED` +- `CP2K_USE_SIRIUS_DFTD4` +- `CP2K_USE_SIRIUS_NLCG` +- `CP2K_USE_SIRIUS_VCSQNM` +- `CP2K_USE_SPLA_GEMM_OFFLOADING` +- `CP2K_USE_STATIC_BLAS` +- `CP2K_USE_TBLITE` +- `CP2K_USE_TREXIO` +- `CP2K_USE_UNIFIED_MEMORY` +- `CP2K_USE_VORI` +- `CP2K_WITH_CUDA_PROFILING` -All optional dependencies are turned off by default, with the exception of MPI. - -For simplicity, `-DCP2K_BUILD_OPTIONS` is provided to turn on some of the optional dependencies. -`-DCP2K_BUILD_OPTIONS` can take the following values: - -- `CUSTOM` (default) -- `DEFAULT` -- `MINIMAL` -- `FULL` -- `SERIAL` - -By default, `-DCP2K_BUILD_OPTIONS=CUSTOM`, meaning that each dependency must be turned on explicitly -with `-DCP2K_USE_=ON`. `` is the name of the optional dependency (for example: -`-DCP2K_USE_COSMA=ON`, `-DCP2K_USE_LIBXC=ON`, ...). - -Please refer to the `CMakeLists.txt` file for an up-to-date list of the dependencies enabled by each -option. - -### GPUs +## GPUs CP2K is GPU-accelerated. In order to enable GPU acceleration with [CUDA] or [HIP], `-DCP2K_USE_ACCEL` can be used: diff --git a/tools/precommit/check_file_properties.py b/tools/precommit/check_file_properties.py index 1b002d9f4c..d1a07f03aa 100755 --- a/tools/precommit/check_file_properties.py +++ b/tools/precommit/check_file_properties.py @@ -109,6 +109,7 @@ NUM_RE = re.compile(r"[0-9]+[ulUL]*") CP2K_FLAGS_RE = re.compile( r"FUNCTION cp2k_flags\(\)(.*)END FUNCTION cp2k_flags", re.DOTALL ) +CMAKE_OPTION_RE = re.compile(r"option\(\s*(\w+)", re.DOTALL) STR_END_NOSPACE_RE = re.compile(r'[^ ]"\s*//\s*&') STR_BEGIN_NOSPACE_RE = re.compile(r'^\s*"[^ ]') STR_END_SPACE_RE = re.compile(r' "\s*//\s*&') @@ -156,17 +157,26 @@ BSD_PATHS = ( MIT_PATHS = ("src/grpp/",) +def read_text(filename: str) -> str: + return CP2K_DIR.joinpath(filename).read_text(encoding="utf8") + + @lru_cache(maxsize=None) def get_src_cmakelists_txt() -> str: - return sum( - CP2K_DIR.joinpath(fn).read_text(encoding="utf8") + return "\n".join( + read_text(fn) for fn in ["src/CMakeLists.txt", "cmake/CompilerConfiguration.cmake"] ) +@lru_cache(maxsize=None) +def get_build_from_source_md() -> str: + return read_text("docs/getting-started/build-from-source.md") + + @lru_cache(maxsize=None) def get_flags_src() -> str: - cp2k_info = CP2K_DIR.joinpath("src/cp2k_info.F").read_text(encoding="utf8") + cp2k_info = read_text("src/cp2k_info.F") match = CP2K_FLAGS_RE.search(cp2k_info) assert match return match.group(1) @@ -174,7 +184,7 @@ def get_flags_src() -> str: @lru_cache(maxsize=None) def get_bibliography_dois() -> List[str]: - bib = CP2K_DIR.joinpath("src/common/bibliography.F").read_text(encoding="utf8") + bib = read_text("src/common/bibliography.F") matches = re.findall(r'doi="([^"]+)"', bib, flags=re.IGNORECASE) assert len(matches) > 260 and "10.1016/j.cpc.2004.12.014" in matches return matches @@ -258,6 +268,7 @@ def check_file(path: pathlib.Path) -> List[str]: PY_SHEBANG = "#!/usr/bin/env python3" if fn_ext == ".py" and is_executable and not content.startswith(f"{PY_SHEBANG}\n"): warnings += [f"{path}: Wrong shebang, please use '{PY_SHEBANG}'"] + # find all flags flags = set() line_continuation = False @@ -298,6 +309,14 @@ def check_file(path: pathlib.Path) -> List[str]: if flag not in get_flags_src(): warnings += [f"{path}: Flag '{flag}' not mentioned in cp2k_flags()"] + if "cmake" in str(path).lower(): + options = CMAKE_OPTION_RE.findall(content) + for opt in options: + if opt not in get_build_from_source_md(): + warnings += [ + f"{path}: CMake option {opt} not mentioned in docs/getting-started/build-from-source.md" + ] + # Check for DOIs that could be a bibliography reference. if re.match(r"docs/[^/]+/.*\.md", str(path)) and "docs/CP2K_INPUT" not in str(path): for line in content.splitlines():