diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 62e7186360..31b9becc0c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -26,11 +26,11 @@ __ ## I don't want to read this whole thing I just have a question! -> **Note:** Please do not file an issue to ask a general question about LAMMPS, its features, how to use specific commands, or how perform simulations or analysis in LAMMPS. Instead post your question to the ['lammps-users' mailing list](https://lammps.sandia.gov/mail.html). You do not need to be subscribed to post to the list (but a mailing list subscription avoids having your post delayed until it is approved by a mailing list moderator). Most posts to the mailing list receive a response within less than 24 hours. Before posting to the mailing list, please read the [mailing list guidelines](https://lammps.sandia.gov/guidelines.html). Following those guidelines will help greatly to get a helpful response. Always mention which LAMMPS version you are using. +> **Note:** Please do not file an issue to ask a general question about LAMMPS, its features, how to use specific commands, or how perform simulations or analysis in LAMMPS. Instead post your question to either the ['lammps-users' mailing list](https://lammps.sandia.gov/mail.html) or the [LAMMPS Material Science Discourse forum](https://matsci.org/lammps). You do not need to be subscribed to post to the list (but a mailing list subscription avoids having your post delayed until it is approved by a mailing list moderator). Most posts to the mailing list receive a response within less than 24 hours. Before posting to the mailing list, please read the [mailing list guidelines](https://lammps.sandia.gov/guidelines.html). Following those guidelines will help greatly to get a helpful response. Always mention which LAMMPS version you are using. The LAMMPS forum was recently created as part of a larger effort to build a materials science community and have discussions not just about using LAMMPS. Thus the forum may be also used for discussions that would be off-topic for the mailing list. Those will just have to be moved to a more general category. ## How Can I Contribute? -There are several ways how you can actively contribute to the LAMMPS project: you can discuss compiling and using LAMMPS, and solving LAMMPS related problems with other LAMMPS users on the lammps-users mailing list, you can report bugs or suggest enhancements by creating issues on GitHub (or posting them to the lammps-users mailing list), and you can contribute by submitting pull requests on GitHub or e-mail your code +There are several ways how you can actively contribute to the LAMMPS project: you can discuss compiling and using LAMMPS, and solving LAMMPS related problems with other LAMMPS users on the lammps-users mailing list, you can report bugs or suggest enhancements by creating issues on GitHub (or posting them to the lammps-users mailing list or posting in the LAMMPS Materials Science Discourse forum), and you can contribute by submitting pull requests on GitHub or e-mail your code to one of the [LAMMPS core developers](https://lammps.sandia.gov/authors.html). As you may see from the aforementioned developer page, the LAMMPS software package includes the efforts of a very large number of contributors beyond the principal authors and maintainers. ### Discussing How To Use LAMMPS @@ -42,6 +42,8 @@ Anyone can browse/search previous questions/answers in the archives. You do not If you post a message and you are a subscriber, your message will appear immediately. If you are not a subscriber, your message will be moderated, which typically takes one business day. Either way, when someone replies the reply will usually be sent to both, your personal email address and the mailing list. When replying to people, that responded to your post to the list, please always included the mailing list in your replies (i.e. use "Reply All" and **not** "Reply"). Responses will appear on the list in a few minutes, but it can take a few hours for postings and replies to show up in the SourceForge archive. Sending replies also to the mailing list is important, so that responses are archived and people with a similar issue can search for possible solutions in the mailing list archive. +The LAMMPS Materials Science Discourse forum was created recently to facilitate discussion not just about LAMMPS and as part of a larger effort towards building a materials science community. The forum contains a read-only sub-category with the continually updated mailing list archive, so you won't miss anything by joining only the forum and not the mailing list. + ### Reporting Bugs While developers writing code for LAMMPS are careful to test their code, LAMMPS is such a large and complex software, that it is impossible to test for all combinations of features under all normal and not so normal circumstances. Thus bugs do happen, and if you suspect, that you have encountered one, please try to document it and report it as an [Issue](https://github.com/lammps/lammps/issues) on the LAMMPS GitHub project web page. However, before reporting a bug, you need to check whether this is something that may have already been corrected. The [Latest Features and Bug Fixes in LAMMPS](https://lammps.sandia.gov/bug.html) web page lists all significant changes to LAMMPS over the years. It also tells you what the current latest development version of LAMMPS is, and you should test whether your issue still applies to that version. diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000000..827306c9aa --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,47 @@ +# GitHub action to run static code analysis on C++ and Python code +name: "CodeQL Code Analysis" + +on: + push: + branches: [master] + +jobs: + analyze: + name: Analyze + if: ${{ github.repository == 'lammps/lammps' }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: ['cpp', 'python'] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + - name: Create Build Environment + run: cmake -E make_directory ${{github.workspace}}/build + + - name: Building LAMMPS via CMake + if: ${{ matrix.language == 'cpp' }} + shell: bash + working-directory: ${{github.workspace}}/build + run: | + cmake -C $GITHUB_WORKSPACE/cmake/presets/most.cmake $GITHUB_WORKSPACE/cmake + cmake --build . --parallel 2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/unittest-macos.yml b/.github/workflows/unittest-macos.yml new file mode 100644 index 0000000000..f62b3046c9 --- /dev/null +++ b/.github/workflows/unittest-macos.yml @@ -0,0 +1,36 @@ +# GitHub action to build LAMMPS on MacOS and run unit tests +name: "Unittest for MacOS" + +on: + push: + branches: [master] + +jobs: + build: + name: MacOS Unit Test + if: ${{ github.repository == 'lammps/lammps' }} + runs-on: macos-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Create Build Environment + run: cmake -E make_directory ${{github.workspace}}/build + + - name: Building LAMMPS via CMake + shell: bash + working-directory: ${{github.workspace}}/build + run: | + cmake -C $GITHUB_WORKSPACE/cmake/presets/clang.cmake \ + -C $GITHUB_WORKSPACE/cmake/presets/most.cmake \ + $GITHUB_WORKSPACE/cmake \ + -DENABLE_TESTING=ON -DBUILD_SHARED_LIBS=ON -DLAMMPS_EXCEPTIONS=ON + cmake --build . --parallel 2 + + - name: Run Tests + working-directory: ${{github.workspace}}/build + shell: bash + run: ctest -V diff --git a/LICENSE b/LICENSE index f9489c8cf8..202b8cd796 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ GNU GENERAL PUBLIC LICENSE -Version 2, June 1991 +Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -301,9 +301,8 @@ one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or (at -your option) any later version. +it under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 42e6d12ffb..dd4c3bcaba 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -22,18 +22,30 @@ set(LAMMPS_TOOLS_DIR ${LAMMPS_DIR}/tools) set(LAMMPS_PYTHON_DIR ${LAMMPS_DIR}/python) set(LAMMPS_POTENTIALS_DIR ${LAMMPS_DIR}/potentials) +set(LAMMPS_DOWNLOADS_URL "https://download.lammps.org" CACHE STRING "Base URL for LAMMPS downloads") +set(LAMMPS_POTENTIALS_URL "${LAMMPS_DOWNLOADS_URL}/potentials") +set(LAMMPS_THIRDPARTY_URL "${LAMMPS_DOWNLOADS_URL}/thirdparty") +mark_as_advanced(LAMMPS_DOWNLOADS_URL) + find_package(Git) # by default, install into $HOME/.local (not /usr/local), so that no root access (and sudo!!) is needed -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "default install path" FORCE ) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "Default install path" FORCE) +endif() + +# If enabled, no need to use LD_LIBRARY_PATH / DYLD_LIBRARY_PATH when installed +option(LAMMPS_INSTALL_RPATH "Set runtime path for shared libraries linked to LAMMPS binaries" OFF) +if(LAMMPS_INSTALL_RPATH) + set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) endif() # Cmake modules/macros are in a subdirectory to keep this file cleaner set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules) # make sure LIBRARY_PATH is set if environment variable is set -if (DEFINED ENV{LIBRARY_PATH}) +if(DEFINED ENV{LIBRARY_PATH}) list(APPEND CMAKE_LIBRARY_PATH "$ENV{LIBRARY_PATH}") message(STATUS "Appending $ENV{LIBRARY_PATH} to CMAKE_LIBRARY_PATH: ${CMAKE_LIBRARY_PATH}") endif() @@ -106,14 +118,16 @@ option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF) set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MOLECULE PERI POEMS - QEQ REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI - USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESODPD USER-CGSDK USER-COLVARS - USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB - USER-MANIFOLD USER-MEAMC USER-MESONT USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE - USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REACTION - USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY - USER-UEF USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-ADIOS) -set(SUFFIX_PACKAGES CORESHELL USER-OMP KOKKOS OPT USER-INTEL GPU) + PLUGIN QEQ REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI + USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESODPD USER-CGSDK + USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD + USER-LB USER-MANIFOLD USER-MEAMC USER-MESONT USER-MGPT USER-MISC USER-MOFFF + USER-MOLFILE USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB + USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH + USER-TALLY USER-UEF USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-PACE) + +set(SUFFIX_PACKAGES CORESHELL GPU KOKKOS OPT USER-INTEL USER-OMP) + foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES}) option(PKG_${PKG} "Build ${PKG} Package" OFF) endforeach() @@ -154,8 +168,7 @@ if(BUILD_MPI) endif() endif() else() - enable_language(C) - file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c) + file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.cpp) add_library(mpi_stubs STATIC ${MPI_SOURCES}) set_target_properties(mpi_stubs PROPERTIES OUTPUT_NAME lammps_mpi_stubs${LAMMPS_MACHINE}) target_include_directories(mpi_stubs PUBLIC $) @@ -220,6 +233,7 @@ if(BUILD_OMP) endif() if (((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)) OR ((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0))) # GCC 9.x and later plus Clang 10.x and later implement strict OpenMP 4.0 semantics for consts. @@ -231,68 +245,6 @@ if(BUILD_OMP) target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX) endif() -# Compiler specific features for testing -if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) - mark_as_advanced(ENABLE_COVERAGE) - if(ENABLE_COVERAGE) - if(CMAKE_VERSION VERSION_LESS 3.13) - if(CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") - endif() - else() - target_compile_options(lammps PUBLIC --coverage) - target_link_options(lammps PUBLIC --coverage) - endif() - endif() -endif() - -####################################### -# add custom target for IWYU analysis -####################################### -set(ENABLE_IWYU OFF CACHE BOOL "Add 'iwyu' build target to call the include-what-you-use tool") -mark_as_advanced(ENABLE_IWYU) -if(ENABLE_IWYU) - find_program(IWYU_EXE NAMES include-what-you-use iwyu) - find_program(IWYU_TOOL NAMES iwyu_tool iwyu-tool iwyu_tool.py) - if (IWYU_EXE AND IWYU_TOOL) - add_custom_target( - iwyu - ${IWYU_TOOL} -o clang -p ${CMAKE_CURRENT_BINARY_DIR} -- -Xiwyu --mapping_file=${CMAKE_CURRENT_SOURCE_DIR}/iwyu/iwyu-extra-map.imp - COMMENT "Running IWYU") - add_dependencies(iwyu lammps) - else() - message(FATAL_ERROR "To use IWYU you need the include-what-you-use/iwyu executable" - "and the iwyu-tool/iwyu_tool script installed in your PATH") - endif() -endif() - -set(ENABLE_SANITIZER "none" CACHE STRING "Select a code sanitizer option (none (default), address, leak, thread, undefined)") -mark_as_advanced(ENABLE_SANITIZER) -set(ENABLE_SANITIZER_VALUES none address leak thread undefined) -set_property(CACHE ENABLE_SANITIZER PROPERTY STRINGS ${ENABLE_SANITIZER_VALUES}) -validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) -string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) -if(NOT ENABLE_SANITIZER STREQUAL "none") - if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) - if(CMAKE_VERSION VERSION_LESS 3.13) - if(CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} -fsanitize=${ENABLE_SANITIZER}") - endif() - else() - target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - endif() - else() - message(WARNING "ENABLE_SANITIZER option not supported by ${CMAKE_CXX_COMPILER_ID} compilers. Ignoring.") - set(ENABLE_SANITIZER "none") - endif() -endif() - if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) enable_language(C) find_package(LAPACK) @@ -372,10 +324,10 @@ else() set(CUDA_REQUEST_PIC) endif() -foreach(PKG_WITH_INCL KSPACE PYTHON VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM - USER-QUIP USER-SCAFACOS USER-SMD USER-VTK KIM LATTE MESSAGE MSCG COMPRESS) +foreach(PKG_WITH_INCL KSPACE PYTHON MLIAP VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM + USER-QUIP USER-SCAFACOS USER-SMD USER-VTK KIM LATTE MESSAGE MSCG COMPRESS USER-PACE) if(PKG_${PKG_WITH_INCL}) - include(Packages/${PKG_WITH_INCL}) + include(Packages/${PKG_WITH_INCL}) endif() endforeach() @@ -524,6 +476,18 @@ foreach(PKG_WITH_INCL CORESHELL QEQ USER-OMP USER-SDPD KOKKOS OPT USER-INTEL GPU endif() endforeach() +if(PKG_PLUGIN) + if(BUILD_SHARED_LIBS) + target_compile_definitions(lammps PRIVATE -DLMP_PLUGIN) + else() + message(WARNING "Plugin loading will not work unless BUILD_SHARED_LIBS is enabled") + endif() + # link with -ldl or equivalent for plugin loading; except on Windows + if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + target_link_libraries(lammps PRIVATE ${CMAKE_DL_LIBS}) + endif() +endif() + ###################################################################### # the windows version of LAMMPS requires a couple extra libraries # and the MPI library - if use - has to be linked right before those @@ -579,7 +543,7 @@ add_dependencies(lammps gitversion) ############################################ get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) list (FIND LANGUAGES "Fortran" _index) -if (${_index} GREATER -1) +if(${_index} GREATER -1) target_link_libraries(lammps PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) endif() set(LAMMPS_CXX_HEADERS angle.h atom.h bond.h citeme.h comm.h compute.h dihedral.h domain.h error.h fix.h force.h group.h improper.h @@ -649,7 +613,7 @@ install( if(BUILD_SHARED_LIBS) if(CMAKE_VERSION VERSION_LESS 3.12) # adjust so we find Python 3 versions before Python 2 on old systems with old CMake - set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6 3.5) + set(Python_ADDITIONAL_VERSIONS 3.9 3.8 3.7 3.6 3.5) find_package(PythonInterp) # Deprecated since version 3.12 if(PYTHONINTERP_FOUND) set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) @@ -659,10 +623,10 @@ if(BUILD_SHARED_LIBS) endif() if (Python_EXECUTABLE) add_custom_target( - install-python - ${Python_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h - -m ${LAMMPS_PYTHON_DIR}/lammps.py - -l ${CMAKE_BINARY_DIR}/liblammps${CMAKE_SHARED_LIBRARY_SUFFIX} + install-python ${CMAKE_COMMAND} -E remove_directory build + COMMAND ${Python_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h + -p ${LAMMPS_PYTHON_DIR}/lammps + -l ${CMAKE_BINARY_DIR}/liblammps${LAMMPS_MACHINE}${CMAKE_SHARED_LIBRARY_SUFFIX} WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR} COMMENT "Installing LAMMPS Python module") else() @@ -691,11 +655,8 @@ if(BUILD_SHARED_LIBS OR PKG_PYTHON) find_package(Python COMPONENTS Interpreter) endif() if (Python_EXECUTABLE) - execute_process(COMMAND ${Python_EXECUTABLE} - -c "import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))" - OUTPUT_VARIABLE PYTHON_DEFAULT_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE) - set(PYTHON_INSTDIR ${PYTHON_DEFAULT_INSTDIR} CACHE PATH "Installation folder for LAMMPS Python module") - install(FILES ${LAMMPS_PYTHON_DIR}/lammps.py DESTINATION ${PYTHON_INSTDIR}) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python) + install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} setup.py build -b ${CMAKE_BINARY_DIR}/python install --prefix=${CMAKE_INSTALL_PREFIX} --root=\$ENV{DESTDIR}/ WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR})") endif() endif() @@ -707,7 +668,7 @@ get_target_property(DEFINES lammps COMPILE_DEFINITIONS) include(FeatureSummary) feature_summary(DESCRIPTION "The following tools and libraries have been found and configured:" WHAT PACKAGES_FOUND) message(STATUS "<<< Build configuration >>> - Operating System: ${CMAKE_SYSTEM_NAME} + Operating System: ${CMAKE_SYSTEM_NAME} ${CMAKE_LINUX_DISTRO} ${CMAKE_DISTRO_VERSION} Build type: ${CMAKE_BUILD_TYPE} Install path: ${CMAKE_INSTALL_PREFIX} Generator: ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}") @@ -739,14 +700,14 @@ if(OPTIONS) endif() get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) list (FIND LANGUAGES "Fortran" _index) -if (${_index} GREATER -1) +if(${_index} GREATER -1) message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER} Type: ${CMAKE_Fortran_COMPILER_ID} Version: ${CMAKE_Fortran_COMPILER_VERSION} Fortran Flags:${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}") endif() list (FIND LANGUAGES "C" _index) -if (${_index} GREATER -1) +if(${_index} GREATER -1) message(STATUS "C compiler: ${CMAKE_C_COMPILER} Type: ${CMAKE_C_COMPILER_ID} Version: ${CMAKE_C_COMPILER_VERSION} @@ -776,11 +737,12 @@ if(BUILD_MPI) endif() if(PKG_GPU) message(STATUS "<<< GPU package settings >>> --- GPU API: ${GPU_API}") +-- GPU API: ${GPU_API}") if(GPU_API STREQUAL "CUDA") - message(STATUS "GPU architecture: ${GPU_ARCH}") - elseif(GPU_API STREQUAL "OPENCL") - message(STATUS "OpenCL tuning: ${OCL_TUNE}") + message(STATUS "CUDA Compiler: ${CUDA_NVCC_EXECUTABLE}") + message(STATUS "GPU default architecture: ${GPU_ARCH}") + message(STATUS "GPU binning with CUDPP: ${CUDPP_OPT}") + message(STATUS "CUDA MPS support: ${CUDA_MPS_SUPPORT}") elseif(GPU_API STREQUAL "HIP") message(STATUS "HIP platform: ${HIP_PLATFORM}") message(STATUS "HIP architecture: ${HIP_ARCH}") @@ -790,7 +752,7 @@ if(PKG_GPU) message(STATUS "HIP GPU sorting: off") endif() endif() - message(STATUS "GPU precision: ${GPU_PREC}") + message(STATUS "GPU precision: ${GPU_PREC}") endif() if(PKG_KOKKOS) message(STATUS "Kokkos Arch: ${KOKKOS_ARCH}") diff --git a/cmake/Modules/CodingStandard.cmake b/cmake/Modules/CodingStandard.cmake index 72b064af66..646bdcdd4a 100644 --- a/cmake/Modules/CodingStandard.cmake +++ b/cmake/Modules/CodingStandard.cmake @@ -8,7 +8,7 @@ else() find_package(Python3 COMPONENTS Interpreter QUIET) endif() -if (Python3_EXECUTABLE) +if(Python3_EXECUTABLE) if(Python3_VERSION VERSION_GREATER_EQUAL 3.5) add_custom_target( check-whitespace diff --git a/cmake/Modules/Documentation.cmake b/cmake/Modules/Documentation.cmake index 189c32e301..16dd5dd4fa 100644 --- a/cmake/Modules/Documentation.cmake +++ b/cmake/Modules/Documentation.cmake @@ -50,16 +50,20 @@ if(BUILD_DOC) OUTPUT ${DOC_BUILD_DIR}/requirements.txt DEPENDS docenv ${DOCENV_REQUIREMENTS_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${DOCENV_REQUIREMENTS_FILE} ${DOC_BUILD_DIR}/requirements.txt - COMMAND ${DOCENV_BINARY_DIR}/pip install --upgrade pip - COMMAND ${DOCENV_BINARY_DIR}/pip install --upgrade ${LAMMPS_DOC_DIR}/utils/converters - COMMAND ${DOCENV_BINARY_DIR}/pip install --use-feature=2020-resolver -r ${DOC_BUILD_DIR}/requirements.txt --upgrade + COMMAND ${DOCENV_BINARY_DIR}/pip $ENV{PIP_OPTIONS} install --upgrade pip + COMMAND ${DOCENV_BINARY_DIR}/pip $ENV{PIP_OPTIONS} install --upgrade ${LAMMPS_DOC_DIR}/utils/converters + COMMAND ${DOCENV_BINARY_DIR}/pip $ENV{PIP_OPTIONS} install -r ${DOC_BUILD_DIR}/requirements.txt --upgrade ) + set(MATHJAX_URL "https://github.com/mathjax/MathJax/archive/3.1.3.tar.gz" CACHE STRING "URL for MathJax tarball") + set(MATHJAX_MD5 "d1c98c746888bfd52ca8ebc10704f92f" CACHE STRING "MD5 checksum of MathJax tarball") + mark_as_advanced(MATHJAX_URL) + # download mathjax distribution and unpack to folder "mathjax" if(NOT EXISTS ${DOC_BUILD_STATIC_DIR}/mathjax/es5) - file(DOWNLOAD "https://github.com/mathjax/MathJax/archive/3.1.2.tar.gz" + file(DOWNLOAD ${MATHJAX_URL} "${CMAKE_CURRENT_BINARY_DIR}/mathjax.tar.gz" - EXPECTED_MD5 a4a6a093a89bc2ccab1452d766b98e53) + EXPECTED_MD5 ${MATHJAX_MD5}) execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf mathjax.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) file(GLOB MATHJAX_VERSION_DIR ${CMAKE_CURRENT_BINARY_DIR}/MathJax-*) execute_process(COMMAND ${CMAKE_COMMAND} -E rename ${MATHJAX_VERSION_DIR} ${DOC_BUILD_STATIC_DIR}/mathjax) diff --git a/cmake/Modules/FindCythonize.cmake b/cmake/Modules/FindCythonize.cmake new file mode 100644 index 0000000000..9a37904ea7 --- /dev/null +++ b/cmake/Modules/FindCythonize.cmake @@ -0,0 +1,30 @@ +# Find the Cythonize tool. +# +# This code sets the following variables: +# +# Cythonize_EXECUTABLE +# +# adapted from https://github.com/cmarshall108/cython-cmake-example/blob/master/cmake/FindCython.cmake +#============================================================================= + +if(CMAKE_VERSION VERSION_LESS 3.12) + find_package(PythonInterp 3.6 QUIET) # Deprecated since version 3.12 + if(PYTHONINTERP_FOUND) + set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) + endif() +else() + find_package(Python3 3.6 COMPONENTS Interpreter QUIET) +endif() + +# Use the Cython executable that lives next to the Python executable +# if it is a local installation. +if(Python3_EXECUTABLE) + get_filename_component(_python_path ${Python3_EXECUTABLE} PATH) + find_program(Cythonize_EXECUTABLE + NAMES cythonize3 cythonize cythonize.bat + HINTS ${_python_path}) +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cythonize REQUIRED_VARS Cythonize_EXECUTABLE) +mark_as_advanced(Cythonize_EXECUTABLE) diff --git a/cmake/Modules/GTest.cmake b/cmake/Modules/GTest.cmake index 060a7e42f9..677ed5f4af 100644 --- a/cmake/Modules/GTest.cmake +++ b/cmake/Modules/GTest.cmake @@ -8,10 +8,12 @@ endif() include(ExternalProject) set(GTEST_URL "https://github.com/google/googletest/archive/release-1.10.0.tar.gz" CACHE STRING "URL for GTest tarball") +set(GTEST_MD5 "ecd1fa65e7de707cd5c00bdac56022cd" CACHE STRING "MD5 checksum of GTest tarball") mark_as_advanced(GTEST_URL) +mark_as_advanced(GTEST_MD5) ExternalProject_Add(googletest - URL ${GTEST_URL} - URL_MD5 ecd1fa65e7de707cd5c00bdac56022cd + URL ${GTEST_URL} + URL_MD5 ${GTEST_MD5} SOURCE_DIR "${CMAKE_BINARY_DIR}/gtest-src" BINARY_DIR "${CMAKE_BINARY_DIR}/gtest-build" CMAKE_ARGS ${CMAKE_REQUEST_PIC} ${CMAKE_EXTRA_GTEST_OPTS} @@ -20,10 +22,10 @@ ExternalProject_Add(googletest -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - BUILD_BYPRODUCTS /lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${GTEST_LIB_POSTFIX}.a - /lib/${CMAKE_FIND_LIBRARY_PREFIXES}gmock${GTEST_LIB_POSTFIX}.a - /lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${GTEST_LIB_POSTFIX}.a - /lib/${CMAKE_FIND_LIBRARY_PREFIXES}gmock_main${GTEST_LIB_POSTFIX}.a + BUILD_BYPRODUCTS /lib/libgtest${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} + /lib/libgmock${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} + /lib/libgtest_main${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} + /lib/libgmock_main${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} LOG_DOWNLOAD ON LOG_CONFIGURE ON LOG_BUILD ON @@ -39,10 +41,10 @@ file(MAKE_DIRECTORY ${GTEST_INCLUDE_DIR}) file(MAKE_DIRECTORY ${GMOCK_INCLUDE_DIR}) ExternalProject_Get_Property(googletest BINARY_DIR) -set(GTEST_LIBRARY_PATH ${BINARY_DIR}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${GTEST_LIB_POSTFIX}.a) -set(GMOCK_LIBRARY_PATH ${BINARY_DIR}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gmock${GTEST_LIB_POSTFIX}.a) -set(GTEST_MAIN_LIBRARY_PATH ${BINARY_DIR}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${GTEST_LIB_POSTFIX}.a) -set(GMOCK_MAIN_LIBRARY_PATH ${BINARY_DIR}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gmock_main${GTEST_LIB_POSTFIX}.a) +set(GTEST_LIBRARY_PATH ${BINARY_DIR}/lib/libgtest${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) +set(GMOCK_LIBRARY_PATH ${BINARY_DIR}/lib/libgmock${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) +set(GTEST_MAIN_LIBRARY_PATH ${BINARY_DIR}/lib/libgtest_main${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) +set(GMOCK_MAIN_LIBRARY_PATH ${BINARY_DIR}/lib/libgmock_main${GTEST_LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) # Prevent GoogleTest from overriding our compiler/linker options # when building with Visual Studio diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index 339ba867bd..41dcfc5b2f 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -50,6 +50,7 @@ function(check_for_autogen_files source_dir) file(GLOB SRC_AUTOGEN_FILES ${source_dir}/style_*.h) file(GLOB SRC_AUTOGEN_PACKAGES ${source_dir}/packages_*.h) list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/lmpinstalledpkgs.h ${source_dir}/lmpgitversion.h) + list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/mliap_model_python_couple.h ${source_dir}/mliap_model_python_couple.cpp) foreach(_SRC ${SRC_AUTOGEN_FILES}) get_filename_component(FILENAME "${_SRC}" NAME) if(EXISTS ${source_dir}/${FILENAME}) @@ -85,7 +86,6 @@ endfunction(GenerateBinaryHeader) # fetch missing potential files function(FetchPotentials pkgfolder potfolder) if (EXISTS "${pkgfolder}/potentials.txt") - set(LAMMPS_POTENTIALS_URL "https://download.lammps.org/potentials") file(STRINGS "${pkgfolder}/potentials.txt" linelist REGEX "^[^#].") foreach(line ${linelist}) string(FIND ${line} " " blank) @@ -104,3 +104,13 @@ function(FetchPotentials pkgfolder potfolder) endforeach() endif() endfunction(FetchPotentials) + +# set CMAKE_LINUX_DISTRO and CMAKE_DISTRO_VERSION on Linux +if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (EXISTS /etc/os-release)) + file(STRINGS /etc/os-release distro REGEX "^NAME=") + string(REGEX REPLACE "NAME=\"?([^\"]*)\"?" "\\1" distro "${distro}") + file(STRINGS /etc/os-release disversion REGEX "^VERSION_ID=") + string(REGEX REPLACE "VERSION_ID=\"?([^\"]*)\"?" "\\1" disversion "${disversion}") + set(CMAKE_LINUX_DISTRO ${distro}) + set(CMAKE_DISTRO_VERSION ${disversion}) +endif() diff --git a/cmake/Modules/MPI4WIN.cmake b/cmake/Modules/MPI4WIN.cmake index 035c6a22f3..aa0c9e1833 100644 --- a/cmake/Modules/MPI4WIN.cmake +++ b/cmake/Modules/MPI4WIN.cmake @@ -1,16 +1,25 @@ # Download and configure custom MPICH files for Windows message(STATUS "Downloading and configuring MPICH-1.4.1 for Windows") +set(MPICH2_WIN64_DEVEL_URL "${LAMMPS_THIRDPARTY_URL}/mpich2-win64-devel.tar.gz" CACHE STRING "URL for MPICH2 (win64) tarball") +set(MPICH2_WIN32_DEVEL_URL "${LAMMPS_THIRDPARTY_URL}/mpich2-win32-devel.tar.gz" CACHE STRING "URL for MPICH2 (win32) tarball") +set(MPICH2_WIN64_DEVEL_MD5 "4939fdb59d13182fd5dd65211e469f14" CACHE STRING "MD5 checksum of MPICH2 (win64) tarball") +set(MPICH2_WIN32_DEVEL_MD5 "a61d153500dce44e21b755ee7257e031" CACHE STRING "MD5 checksum of MPICH2 (win32) tarball") +mark_as_advanced(MPICH2_WIN64_DEVEL_URL) +mark_as_advanced(MPICH2_WIN32_DEVEL_URL) +mark_as_advanced(MPICH2_WIN64_DEVEL_MD5) +mark_as_advanced(MPICH2_WIN32_DEVEL_MD5) + include(ExternalProject) -if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") ExternalProject_Add(mpi4win_build - URL https://download.lammps.org/thirdparty/mpich2-win64-devel.tar.gz - URL_MD5 4939fdb59d13182fd5dd65211e469f14 + URL ${MPICH2_WIN64_DEVEL_URL} + URL_MD5 ${MPICH2_WIN64_DEVEL_MD5} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" BUILD_BYPRODUCTS /lib/libmpi.a) else() ExternalProject_Add(mpi4win_build - URL https://download.lammps.org/thirdparty/mpich2-win32-devel.tar.gz - URL_MD5 a61d153500dce44e21b755ee7257e031 + URL ${MPICH2_WIN32_DEVEL_URL} + URL_MD5 ${MPICH2_WIN32_DEVEL_MD5} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" BUILD_BYPRODUCTS /lib/libmpi.a) endif() diff --git a/cmake/Modules/OpenCLLoader.cmake b/cmake/Modules/OpenCLLoader.cmake new file mode 100644 index 0000000000..54eaab4795 --- /dev/null +++ b/cmake/Modules/OpenCLLoader.cmake @@ -0,0 +1,50 @@ +message(STATUS "Downloading and building OpenCL loader library") +set(OPENCL_LOADER_URL "${LAMMPS_THIRDPARTY_URL}/opencl-loader-2020.12.18.tar.gz" CACHE STRING "URL for OpenCL loader tarball") +set(OPENCL_LOADER_MD5 "011cdcbd41030be94f3fced6d763a52a" CACHE STRING "MD5 checksum of OpenCL loader tarball") +mark_as_advanced(OPENCL_LOADER_URL) +mark_as_advanced(OPENCL_LOADER_MD5) + +include(ExternalProject) +ExternalProject_Add(opencl_loader + URL ${OPENCL_LOADER_URL} + URL_MD5 ${OPENCL_LOADER_MD5} + SOURCE_DIR "${CMAKE_BINARY_DIR}/opencl_loader-src" + BINARY_DIR "${CMAKE_BINARY_DIR}/opencl_loader-build" + CMAKE_ARGS ${CMAKE_REQUEST_PIC} ${CMAKE_EXTRA_OPENCL_LOADER_OPTS} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_INSTALL_PREFIX= + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + BUILD_BYPRODUCTS /libOpenCL${CMAKE_STATIC_LIBRARY_SUFFIX} + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + INSTALL_COMMAND "" + TEST_COMMAND "") + +ExternalProject_Get_Property(opencl_loader SOURCE_DIR) +set(OPENCL_LOADER_INCLUDE_DIR ${SOURCE_DIR}/inc) + +# workaround for CMake 3.10 on ubuntu 18.04 +file(MAKE_DIRECTORY ${OPENCL_LOADER_INCLUDE_DIR}) + +ExternalProject_Get_Property(opencl_loader BINARY_DIR) +set(OPENCL_LOADER_LIBRARY_PATH "${BINARY_DIR}/libOpenCL${CMAKE_STATIC_LIBRARY_SUFFIX}") + +find_package(Threads QUIET) +if(NOT WIN32) + set(OPENCL_LOADER_DEP_LIBS "Threads::Threads;${CMAKE_DL_LIBS}") +else() + set(OPENCL_LOADER_DEP_LIBS "cfgmgr32;runtimeobject") +endif() + +add_library(OpenCL::OpenCL UNKNOWN IMPORTED) +add_dependencies(OpenCL::OpenCL opencl_loader) + +set_target_properties(OpenCL::OpenCL PROPERTIES + IMPORTED_LOCATION ${OPENCL_LOADER_LIBRARY_PATH} + INTERFACE_INCLUDE_DIRECTORIES ${OPENCL_LOADER_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES "${OPENCL_LOADER_DEP_LIBS}") + + diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index cad6e2bf9a..fa1a493330 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -1,7 +1,10 @@ set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU) set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h ${GPU_SOURCES_DIR}/fix_gpu.h - ${GPU_SOURCES_DIR}/fix_gpu.cpp) + ${GPU_SOURCES_DIR}/fix_gpu.cpp + ${GPU_SOURCES_DIR}/fix_nh_gpu.h + ${GPU_SOURCES_DIR}/fix_nh_gpu.cpp) +target_compile_definitions(lammps PRIVATE -DLMP_GPU) set(GPU_API "opencl" CACHE STRING "API used by GPU package") set(GPU_API_VALUES opencl cuda hip) @@ -32,9 +35,12 @@ if(GPU_API STREQUAL "CUDA") if(NOT BIN2C) message(FATAL_ERROR "Could not find bin2c, use -DBIN2C=/path/to/bin2c to help cmake finding it.") endif() - option(CUDPP_OPT "Enable CUDPP_OPT" ON) + option(CUDPP_OPT "Enable GPU binning via CUDAPP (should be off for modern GPUs)" OFF) option(CUDA_MPS_SUPPORT "Enable tweaks to support CUDA Multi-process service (MPS)" OFF) if(CUDA_MPS_SUPPORT) + if(CUDPP_OPT) + message(FATAL_ERROR "Must use -DCUDPP_OPT=OFF with -DGPU_CUDA_MPS_SUPPORT=ON") + endif() set(GPU_CUDA_MPS_FLAGS "-DCUDA_PROXY") endif() @@ -97,15 +103,19 @@ if(GPU_API STREQUAL "CUDA") if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_80,code=[sm_80,compute_80]") endif() + # Ampere (GPU Arch 8.6) is supported by CUDA 11.1 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_86,code=[sm_86,compute_86]") + endif() if(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") message(WARNING "Unsupported CUDA version. Use at your own risk.") endif() cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS ${CUDA_REQUEST_PIC} - -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING}) + -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES}) cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS ${CUDA_REQUEST_PIC} - -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING}) + -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES}) foreach(CU_OBJ ${GPU_GEN_OBJS}) get_filename_component(CU_NAME ${CU_OBJ} NAME_WE) @@ -121,7 +131,7 @@ if(GPU_API STREQUAL "CUDA") add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS}) target_link_libraries(gpu PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS}) - target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT ${GPU_CUDA_MPS_FLAGS}) + target_compile_definitions(gpu PRIVATE -DUSE_CUDA -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT ${GPU_CUDA_MPS_FLAGS}) if(CUDPP_OPT) target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) target_compile_definitions(gpu PRIVATE -DUSE_CUDPP) @@ -135,27 +145,13 @@ if(GPU_API STREQUAL "CUDA") target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS}) elseif(GPU_API STREQUAL "OPENCL") - if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - # download and unpack support binaries for compilation of windows binaries. - set(LAMMPS_THIRDPARTY_URL "https://download.lammps.org/thirdparty") - file(DOWNLOAD "${LAMMPS_THIRDPARTY_URL}/opencl-win-devel.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/opencl-win-devel.tar.gz" - EXPECTED_MD5 2c00364888d5671195598b44c2e0d44d) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf opencl-win-devel.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - add_library(OpenCL::OpenCL UNKNOWN IMPORTED) - if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") - set_target_properties(OpenCL::OpenCL PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win32/libOpenCL.dll") - elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") - set_target_properties(OpenCL::OpenCL PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win64/libOpenCL.dll") - endif() - set_target_properties(OpenCL::OpenCL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/include") + option(USE_STATIC_OPENCL_LOADER "Download and include a static OpenCL ICD loader" ON) + mark_as_advanced(USE_STATIC_OPENCL_LOADER) + if (USE_STATIC_OPENCL_LOADER) + include(OpenCLLoader) else() find_package(OpenCL REQUIRED) endif() - set(OCL_TUNE "generic" CACHE STRING "OpenCL Device Tuning") - set(OCL_TUNE_VALUES intel fermi kepler cypress generic) - set_property(CACHE OCL_TUNE PROPERTY STRINGS ${OCL_TUNE_VALUES}) - validate_option(OCL_TUNE OCL_TUNE_VALUES) - string(TOUPPER ${OCL_TUNE} OCL_TUNE) include(OpenCLUtils) set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h) @@ -199,7 +195,7 @@ elseif(GPU_API STREQUAL "OPENCL") add_library(gpu STATIC ${GPU_LIB_SOURCES}) target_link_libraries(gpu PRIVATE OpenCL::OpenCL) target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu) - target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -D${OCL_TUNE}_OCL -DMPI_GERYON -DUCL_NO_EXIT) + target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DGERYON_NUMA_FISSION -DUCL_NO_EXIT) target_compile_definitions(gpu PRIVATE -DUSE_OPENCL) target_link_libraries(lammps PRIVATE gpu) @@ -207,6 +203,7 @@ elseif(GPU_API STREQUAL "OPENCL") add_executable(ocl_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp) target_compile_definitions(ocl_get_devices PRIVATE -DUCL_OPENCL) target_link_libraries(ocl_get_devices PRIVATE OpenCL::OpenCL) + add_dependencies(ocl_get_devices OpenCL::OpenCL) elseif(GPU_API STREQUAL "HIP") if(NOT DEFINED HIP_PATH) if(NOT DEFINED ENV{HIP_PATH}) @@ -221,7 +218,7 @@ elseif(GPU_API STREQUAL "HIP") if(NOT DEFINED HIP_PLATFORM) if(NOT DEFINED ENV{HIP_PLATFORM}) - set(HIP_PLATFORM "hcc" CACHE PATH "HIP Platform to be used during compilation") + set(HIP_PLATFORM "amd" CACHE PATH "HIP Platform to be used during compilation") else() set(HIP_PLATFORM $ENV{HIP_PLATFORM} CACHE PATH "HIP Platform used during compilation") endif() @@ -229,7 +226,7 @@ elseif(GPU_API STREQUAL "HIP") set(ENV{HIP_PLATFORM} ${HIP_PLATFORM}) - if(HIP_PLATFORM STREQUAL "hcc") + if(HIP_PLATFORM STREQUAL "hcc" OR HIP_PLATFORM STREQUAL "amd") set(HIP_ARCH "gfx906" CACHE STRING "HIP target architecture") elseif(HIP_PLATFORM STREQUAL "nvcc") find_package(CUDA REQUIRED) @@ -287,23 +284,23 @@ elseif(GPU_API STREQUAL "HIP") set(CUBIN_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}.cubin") set(CUBIN_H_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h") - if(HIP_PLATFORM STREQUAL "hcc") + if(HIP_PLATFORM STREQUAL "hcc" OR HIP_PLATFORM STREQUAL "amd") configure_file(${CU_FILE} ${CU_CPP_FILE} COPYONLY) if(HIP_COMPILER STREQUAL "clang") add_custom_command(OUTPUT ${CUBIN_FILE} - VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --genco --offload-arch=${HIP_ARCH} -O3 -ffast-math -DUSE_HIP -D_${GPU_PREC_SETTING} -I${LAMMPS_LIB_SOURCE_DIR}/gpu -o ${CUBIN_FILE} ${CU_CPP_FILE} + VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --genco --offload-arch=${HIP_ARCH} -O3 -ffast-math -DUSE_HIP -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES} -I${LAMMPS_LIB_SOURCE_DIR}/gpu -o ${CUBIN_FILE} ${CU_CPP_FILE} DEPENDS ${CU_CPP_FILE} COMMENT "Generating ${CU_NAME}.cubin") else() add_custom_command(OUTPUT ${CUBIN_FILE} - VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --genco -t="${HIP_ARCH}" -f=\"-O3 -ffast-math -DUSE_HIP -D_${GPU_PREC_SETTING} -I${LAMMPS_LIB_SOURCE_DIR}/gpu\" -o ${CUBIN_FILE} ${CU_CPP_FILE} + VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --genco -t="${HIP_ARCH}" -f=\"-O3 -ffast-math -DUSE_HIP -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES} -I${LAMMPS_LIB_SOURCE_DIR}/gpu\" -o ${CUBIN_FILE} ${CU_CPP_FILE} DEPENDS ${CU_CPP_FILE} COMMENT "Generating ${CU_NAME}.cubin") endif() elseif(HIP_PLATFORM STREQUAL "nvcc") add_custom_command(OUTPUT ${CUBIN_FILE} - VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --fatbin --use_fast_math -DUSE_HIP -D_${GPU_PREC_SETTING} ${HIP_CUDA_GENCODE} -I${LAMMPS_LIB_SOURCE_DIR}/gpu -o ${CUBIN_FILE} ${CU_FILE} + VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --fatbin --use_fast_math -DUSE_HIP -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES} ${HIP_CUDA_GENCODE} -I${LAMMPS_LIB_SOURCE_DIR}/gpu -o ${CUBIN_FILE} ${CU_FILE} DEPENDS ${CU_FILE} COMMENT "Generating ${CU_NAME}.cubin") endif() @@ -341,11 +338,16 @@ elseif(GPU_API STREQUAL "HIP") if(DOWNLOAD_CUB) message(STATUS "CUB download requested") + set(CUB_URL "https://github.com/NVlabs/cub/archive/1.12.0.tar.gz" CACHE STRING "URL for CUB tarball") + set(CUB_MD5 "1cf595beacafff104700921bac8519f3" CACHE STRING "MD5 checksum of CUB tarball") + mark_as_advanced(CUB_URL) + mark_as_advanced(CUB_MD5) + include(ExternalProject) ExternalProject_Add(CUB - GIT_REPOSITORY https://github.com/NVlabs/cub - TIMEOUT 5 + URL ${CUB_URL} + URL_MD5 ${CUB_MD5} PREFIX "${CMAKE_CURRENT_BINARY_DIR}" CONFIGURE_COMMAND "" BUILD_COMMAND "" @@ -357,7 +359,7 @@ elseif(GPU_API STREQUAL "HIP") else() find_package(CUB) if(NOT CUB_FOUND) - message(FATAL_ERROR "CUB library not found. Help CMake to find it by setting CUB_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it") + message(FATAL_ERROR "CUB library not found. Help CMake to find it by setting CUB_INCLUDE_DIR, or set DOWNLOAD_CUB=ON to download it") endif() endif() @@ -384,18 +386,21 @@ elseif(GPU_API STREQUAL "HIP") target_compile_definitions(hip_get_devices PRIVATE -D__HIP_PLATFORM_HCC__) target_include_directories(hip_get_devices PRIVATE ${HIP_ROOT_DIR}/../include) + elseif(HIP_PLATFORM STREQUAL "amd") + target_compile_definitions(gpu PRIVATE -D__HIP_PLATFORM_AMD__) + target_include_directories(gpu PRIVATE ${HIP_ROOT_DIR}/../include) + + target_compile_definitions(hip_get_devices PRIVATE -D__HIP_PLATFORM_AMD__) + target_include_directories(hip_get_devices PRIVATE ${HIP_ROOT_DIR}/../include) endif() target_link_libraries(lammps PRIVATE gpu) endif() -# GPU package -FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX) - set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}") - -# detects styles which have GPU version +# detect styles which have a GPU version RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES) +RegisterFixStyle(${GPU_SOURCES_DIR}/fix_gpu.h) get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES) diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 91a48eb3a7..2a2a1cde78 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -19,6 +19,8 @@ if(CURL_FOUND) target_compile_definitions(lammps PRIVATE -DLMP_NO_SSL_CHECK) endif() endif() +set(KIM_EXTRA_UNITTESTS OFF CACHE STRING "Set extra unit tests verbose mode on/off. If on, extra tests are included.") +mark_as_advanced(KIM_EXTRA_UNITTESTS) find_package(PkgConfig QUIET) set(DOWNLOAD_KIM_DEFAULT ON) if(PKG_CONFIG_FOUND) @@ -33,9 +35,13 @@ if(DOWNLOAD_KIM) include(ExternalProject) enable_language(C) enable_language(Fortran) + set(KIM_URL "https://s3.openkim.org/kim-api/kim-api-2.2.1.txz" CACHE STRING "URL for KIM tarball") + set(KIM_MD5 "ae1ddda2ef7017ea07934e519d023dca" CACHE STRING "MD5 checksum of KIM tarball") + mark_as_advanced(KIM_URL) + mark_as_advanced(KIM_MD5) ExternalProject_Add(kim_build - URL https://s3.openkim.org/kim-api/kim-api-2.2.1.txz - URL_MD5 ae1ddda2ef7017ea07934e519d023dca + URL ${KIM_URL} + URL_MD5 ${KIM_MD5} BINARY_DIR build CMAKE_ARGS ${CMAKE_REQUEST_PIC} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} @@ -67,14 +73,14 @@ if(DOWNLOAD_KIM) BUILD_RPATH "${_rpath_prefix}/kim_build-prefix/lib" ) else() - if(KIM-API_FOUND AND KIM_API_VERSION VERSION_GREATER_EQUAL 2.2.0) + if(KIM-API_FOUND AND KIM-API_VERSION VERSION_GREATER_EQUAL 2.2.0) # For kim-api >= 2.2.0 - find_package(KIM-API ${KIM-API_MIN_VERSION} CONFIG REQUIRED) + find_package(KIM-API 2.2.0 CONFIG REQUIRED) target_link_libraries(lammps PRIVATE KIM-API::kim-api) else() # For kim-api 2.1.3 (consistent with previous version of this file) find_package(PkgConfig REQUIRED) - pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=KIM-API_MIN_VERSION) + pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=${KIM-API_MIN_VERSION}) target_link_libraries(lammps PRIVATE PkgConfig::KIM-API) endif() endif() diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index 19cc401c3d..1f00516e08 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -1,4 +1,7 @@ ######################################################################## +# As of version 3.3.0 Kokkos requires C++14 +set(CMAKE_CXX_STANDARD 14) +######################################################################## # consistency checks and Kokkos options/settings required by LAMMPS if(Kokkos_ENABLE_CUDA) message(STATUS "KOKKOS: Enabling CUDA LAMBDA function support") @@ -34,9 +37,13 @@ if(DOWNLOAD_KOKKOS) list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}") list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") include(ExternalProject) + set(KOKKOS_URL "https://github.com/kokkos/kokkos/archive/3.3.01.tar.gz" CACHE STRING "URL for KOKKOS tarball") + set(KOKKOS_MD5 "08201d1c7cf5bc458ce0f5b44a629d5a" CACHE STRING "MD5 checksum of KOKKOS tarball") + mark_as_advanced(KOKKOS_URL) + mark_as_advanced(KOKKOS_MD5) ExternalProject_Add(kokkos_build - URL https://github.com/kokkos/kokkos/archive/3.2.01.tar.gz - URL_MD5 ba72440e285ccde05b403694ea0c92e5 + URL ${KOKKOS_URL} + URL_MD5 ${KOKKOS_MD5} CMAKE_ARGS ${KOKKOS_LIB_BUILD_ARGS} BUILD_BYPRODUCTS /lib/libkokkoscore.a ) @@ -48,10 +55,12 @@ if(DOWNLOAD_KOKKOS) INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include" INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}) target_link_libraries(lammps PRIVATE LAMMPS::KOKKOS) + target_link_libraries(lmp PRIVATE LAMMPS::KOKKOS) add_dependencies(LAMMPS::KOKKOS kokkos_build) elseif(EXTERNAL_KOKKOS) - find_package(Kokkos 3.2.01 REQUIRED CONFIG) + find_package(Kokkos 3.3.01 REQUIRED CONFIG) target_link_libraries(lammps PRIVATE Kokkos::kokkos) + target_link_libraries(lmp PRIVATE Kokkos::kokkos) else() set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos) set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos) @@ -63,6 +72,7 @@ else() ${LAMMPS_LIB_KOKKOS_BIN_DIR}) target_include_directories(lammps PRIVATE ${Kokkos_INCLUDE_DIRS}) target_link_libraries(lammps PRIVATE kokkos) + target_link_libraries(lmp PRIVATE kokkos) endif() target_compile_definitions(lammps PRIVATE -DLMP_KOKKOS) diff --git a/cmake/Modules/Packages/LATTE.cmake b/cmake/Modules/Packages/LATTE.cmake index e66f83fa43..ddf31a68ed 100644 --- a/cmake/Modules/Packages/LATTE.cmake +++ b/cmake/Modules/Packages/LATTE.cmake @@ -15,10 +15,14 @@ endif() option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT}) if(DOWNLOAD_LATTE) message(STATUS "LATTE download requested - we will build our own") + set(LATTE_URL "https://github.com/lanl/LATTE/archive/v1.2.2.tar.gz" CACHE STRING "URL for LATTE tarball") + set(LATTE_MD5 "820e73a457ced178c08c71389a385de7" CACHE STRING "MD5 checksum of LATTE tarball") + mark_as_advanced(LATTE_URL) + mark_as_advanced(LATTE_MD5) include(ExternalProject) ExternalProject_Add(latte_build - URL https://github.com/lanl/LATTE/archive/v1.2.2.tar.gz - URL_MD5 820e73a457ced178c08c71389a385de7 + URL ${LATTE_URL} + URL_MD5 ${LATTE_MD5} SOURCE_SUBDIR cmake CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= ${CMAKE_REQUEST_PIC} -DCMAKE_INSTALL_LIBDIR=lib -DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES} diff --git a/cmake/Modules/Packages/MESSAGE.cmake b/cmake/Modules/Packages/MESSAGE.cmake index fb62763828..6ff4e322aa 100644 --- a/cmake/Modules/Packages/MESSAGE.cmake +++ b/cmake/Modules/Packages/MESSAGE.cmake @@ -2,9 +2,8 @@ if(LAMMPS_SIZES STREQUAL BIGBIG) message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG") endif() option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF) -file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F - ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c - ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp) +file(GLOB_RECURSE cslib_SOURCES + ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp) add_library(cslib STATIC ${cslib_SOURCES}) target_compile_definitions(cslib PRIVATE -DLAMMPS_${LAMMPS_SIZES}) diff --git a/cmake/Modules/Packages/MLIAP.cmake b/cmake/Modules/Packages/MLIAP.cmake new file mode 100644 index 0000000000..81bb10cb8f --- /dev/null +++ b/cmake/Modules/Packages/MLIAP.cmake @@ -0,0 +1,40 @@ +# if PYTHON package is included we may also include Python support in MLIAP +set(MLIAP_ENABLE_PYTHON_DEFAULT OFF) +if(PKG_PYTHON) + find_package(Cythonize QUIET) + if(Cythonize_FOUND) + set(MLIAP_ENABLE_PYTHON_DEFAULT ON) + endif() +endif() + +option(MLIAP_ENABLE_PYTHON "Build MLIAP package with Python support" ${MLIAP_ENABLE_PYTHON_DEFAULT}) + +if(MLIAP_ENABLE_PYTHON) + find_package(Cythonize REQUIRED) + if(NOT PKG_PYTHON) + message(FATAL_ERROR "Must enable PYTHON package for including Python support in MLIAP") + endif() + if(CMAKE_VERSION VERSION_LESS 3.12) + if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3.6) + message(FATAL_ERROR "Python support in MLIAP requires Python 3.6 or later") + endif() + else() + if(Python_VERSION VERSION_LESS 3.6) + message(FATAL_ERROR "Python support in MLIAP requires Python 3.6 or later") + endif() + endif() + + set(MLIAP_BINARY_DIR ${CMAKE_BINARY_DIR}/cython) + set(MLIAP_CYTHON_SRC ${LAMMPS_SOURCE_DIR}/MLIAP/mliap_model_python_couple.pyx) + get_filename_component(MLIAP_CYTHON_BASE ${MLIAP_CYTHON_SRC} NAME_WE) + file(MAKE_DIRECTORY ${MLIAP_BINARY_DIR}) + add_custom_command(OUTPUT ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.cpp ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MLIAP_CYTHON_SRC} ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.pyx + COMMAND ${Cythonize_EXECUTABLE} -3 ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.pyx + WORKING_DIRECTORY ${MLIAP_BINARY_DIR} + MAIN_DEPENDENCY ${MLIAP_CYTHON_SRC} + COMMENT "Generating C++ sources with cythonize...") + target_compile_definitions(lammps PRIVATE -DMLIAP_PYTHON) + target_sources(lammps PRIVATE ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.cpp) + target_include_directories(lammps PRIVATE ${MLIAP_BINARY_DIR}) +endif() diff --git a/cmake/Modules/Packages/MSCG.cmake b/cmake/Modules/Packages/MSCG.cmake index 6cb389fb13..6ac62cb012 100644 --- a/cmake/Modules/Packages/MSCG.cmake +++ b/cmake/Modules/Packages/MSCG.cmake @@ -7,10 +7,15 @@ else() endif() option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT}) if(DOWNLOAD_MSCG) + set(MSCG_URL "https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz" CACHE STRING "URL for MSCG tarball") + set(MSCG_MD5 "8c45e269ee13f60b303edd7823866a91" CACHE STRING "MD5 checksum of MSCG tarball") + mark_as_advanced(MSCG_URL) + mark_as_advanced(MSCG_MD5) + include(ExternalProject) ExternalProject_Add(mscg_build - URL https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz - URL_MD5 8c45e269ee13f60b303edd7823866a91 + URL ${MSCG_URL} + URL_MD5 ${MSCG_MD5} SOURCE_SUBDIR src/CMake CMAKE_ARGS ${CMAKE_REQUEST_PIC} ${EXTRA_MSCG_OPTS} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} diff --git a/cmake/Modules/Packages/USER-INTEL.cmake b/cmake/Modules/Packages/USER-INTEL.cmake index ff0858f0ff..90ab6167a3 100644 --- a/cmake/Modules/Packages/USER-INTEL.cmake +++ b/cmake/Modules/Packages/USER-INTEL.cmake @@ -30,7 +30,12 @@ if(INTEL_LRT_MODE STREQUAL "THREADS") endif() endif() if(INTEL_LRT_MODE STREQUAL "C++11") - target_compile_definitions(lammps PRIVATE -DLMP_INTEL_USELRT -DLMP_INTEL_LRT11) + if(Threads_FOUND) + target_compile_definitions(lammps PRIVATE -DLMP_INTEL_USELRT -DLMP_INTEL_LRT11) + target_link_libraries(lammps PRIVATE Threads::Threads) + else() + message(FATAL_ERROR "Must have working threads library for Long-range thread support") + endif() endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") diff --git a/cmake/Modules/Packages/USER-MOLFILE.cmake b/cmake/Modules/Packages/USER-MOLFILE.cmake index 4d414acead..427f0ed6fa 100644 --- a/cmake/Modules/Packages/USER-MOLFILE.cmake +++ b/cmake/Modules/Packages/USER-MOLFILE.cmake @@ -2,8 +2,4 @@ set(MOLFILE_INCLUDE_DIR "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to set(MOLFILE_INCLUDE_DIRS "${MOLFILE_INCLUDE_DIR}") add_library(molfile INTERFACE) target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS}) -# no need to link with -ldl on windows -if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS}) -endif() target_link_libraries(lammps PRIVATE molfile) diff --git a/cmake/Modules/Packages/USER-PACE.cmake b/cmake/Modules/Packages/USER-PACE.cmake new file mode 100644 index 0000000000..2d88d3a313 --- /dev/null +++ b/cmake/Modules/Packages/USER-PACE.cmake @@ -0,0 +1,26 @@ + +set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2021.4.9.tar.gz" CACHE STRING "URL for PACE evaluator library sources") +set(PACELIB_MD5 "4db54962fbd6adcf8c18d46e1798ceb5" CACHE STRING "MD5 checksum of PACE evaluator library tarball") +mark_as_advanced(PACELIB_URL) +mark_as_advanced(PACELIB_MD5) + +# download library sources to build folder +file(DOWNLOAD ${PACELIB_URL} ${CMAKE_BINARY_DIR}/libpace.tar.gz SHOW_PROGRESS EXPECTED_HASH MD5=${PACELIB_MD5}) + +# uncompress downloaded sources +execute_process( + COMMAND ${CMAKE_COMMAND} -E remove_directory lammps-user-pace* + COMMAND ${CMAKE_COMMAND} -E tar xzf libpace.tar.gz + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +) + + +file(GLOB PACE_EVALUATOR_INCLUDE_DIR ${CMAKE_BINARY_DIR}/lammps-user-pace-*/USER-PACE) +file(GLOB PACE_EVALUATOR_SOURCES ${CMAKE_BINARY_DIR}/lammps-user-pace-*/USER-PACE/*.cpp) +list(FILTER PACE_EVALUATOR_SOURCES EXCLUDE REGEX pair_pace.cpp) + +add_library(pace STATIC ${PACE_EVALUATOR_SOURCES}) +set_target_properties(pace PROPERTIES OUTPUT_NAME lammps_pace${LAMMPS_MACHINE}) +target_include_directories(pace PUBLIC ${PACE_EVALUATOR_INCLUDE_DIR}) +target_link_libraries(lammps PRIVATE pace) + diff --git a/cmake/Modules/Packages/USER-PLUMED.cmake b/cmake/Modules/Packages/USER-PLUMED.cmake index 74add65cdc..e71542cfc5 100644 --- a/cmake/Modules/Packages/USER-PLUMED.cmake +++ b/cmake/Modules/Packages/USER-PLUMED.cmake @@ -53,10 +53,17 @@ if(DOWNLOAD_PLUMED) elseif(PLUMED_MODE STREQUAL "RUNTIME") set(PLUMED_BUILD_BYPRODUCTS "/lib/libplumedWrapper.a") endif() + + set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.7.1/plumed-src-2.7.1.tgz" CACHE STRING "URL for PLUMED tarball") + set(PLUMED_MD5 "4eac6a462ec84dfe0cec96c82421b8e8" CACHE STRING "MD5 checksum of PLUMED tarball") + + mark_as_advanced(PLUMED_URL) + mark_as_advanced(PLUMED_MD5) + include(ExternalProject) ExternalProject_Add(plumed_build - URL https://github.com/plumed/plumed2/releases/download/v2.6.1/plumed-src-2.6.1.tgz - URL_MD5 89a9a450fc6025299fe16af235957163 + URL ${PLUMED_URL} + URL_MD5 ${PLUMED_MD5} BUILD_IN_SOURCE 1 CONFIGURE_COMMAND /configure --prefix= ${CONFIGURE_REQUEST_PIC} diff --git a/cmake/Modules/Packages/USER-SCAFACOS.cmake b/cmake/Modules/Packages/USER-SCAFACOS.cmake index dc5c400c36..fd355420c3 100644 --- a/cmake/Modules/Packages/USER-SCAFACOS.cmake +++ b/cmake/Modules/Packages/USER-SCAFACOS.cmake @@ -14,15 +14,19 @@ endif() option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT}) if(DOWNLOAD_SCAFACOS) message(STATUS "ScaFaCoS download requested - we will build our own") + set(SCAFACOS_URL "https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz" CACHE STRING "URL for SCAFACOS tarball") + set(SCAFACOS_MD5 "bd46d74e3296bd8a444d731bb10c1738" CACHE STRING "MD5 checksum of SCAFACOS tarball") + mark_as_advanced(SCAFACOS_URL) + mark_as_advanced(SCAFACOS_MD5) # version 1.0.1 needs a patch to compile and linke cleanly with GCC 10 and later. - file(DOWNLOAD https://download.lammps.org/thirdparty/scafacos-1.0.1-fix.diff ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff + file(DOWNLOAD ${LAMMPS_THIRDPARTY_URL}/scafacos-1.0.1-fix.diff ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff EXPECTED_HASH MD5=4baa1333bb28fcce102d505e1992d032) include(ExternalProject) ExternalProject_Add(scafacos_build - URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz - URL_MD5 bd46d74e3296bd8a444d731bb10c1738 + URL ${SCAFACOS_URL} + URL_MD5 ${SCAFACOS_MD5} PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff CONFIGURE_COMMAND /configure --prefix= --disable-doc --enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m diff --git a/cmake/Modules/Packages/USER-SMD.cmake b/cmake/Modules/Packages/USER-SMD.cmake index 67f4aae99d..6d941f9798 100644 --- a/cmake/Modules/Packages/USER-SMD.cmake +++ b/cmake/Modules/Packages/USER-SMD.cmake @@ -7,10 +7,14 @@ endif() option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT}) if(DOWNLOAD_EIGEN3) message(STATUS "Eigen3 download requested - we will build our own") + set(EIGEN3_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz" CACHE STRING "URL for Eigen3 tarball") + set(EIGEN3_MD5 "9e30f67e8531477de4117506fe44669b" CACHE STRING "MD5 checksum of Eigen3 tarball") + mark_as_advanced(EIGEN3_URL) + mark_as_advanced(EIGEN3_MD5) include(ExternalProject) ExternalProject_Add(Eigen3_build - URL https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz - URL_MD5 9e30f67e8531477de4117506fe44669b + URL ${EIGEN3_URL} + URL_MD5 ${EIGEN3_MD5} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" ) ExternalProject_get_property(Eigen3_build SOURCE_DIR) diff --git a/cmake/Modules/Packages/VORONOI.cmake b/cmake/Modules/Packages/VORONOI.cmake index 1d6893a978..7feea4c52e 100644 --- a/cmake/Modules/Packages/VORONOI.cmake +++ b/cmake/Modules/Packages/VORONOI.cmake @@ -7,6 +7,11 @@ endif() option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" ${DOWNLOAD_VORO_DEFAULT}) if(DOWNLOAD_VORO) message(STATUS "Voro++ download requested - we will build our own") + set(VORO_URL "${LAMMPS_THIRDPARTY_URL}/voro++-0.4.6.tar.gz" CACHE STRING "URL for Voro++ tarball") + set(VORO_MD5 "2338b824c3b7b25590e18e8df5d68af9" CACHE STRING "MD5 checksum for Voro++ tarball") + mark_as_advanced(VORO_URL) + mark_as_advanced(VORO_MD5) + include(ExternalProject) if(BUILD_SHARED_LIBS) @@ -22,8 +27,8 @@ if(DOWNLOAD_VORO) endif() ExternalProject_Add(voro_build - URL https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz - URL_MD5 2338b824c3b7b25590e18e8df5d68af9 + URL ${VORO_URL} + URL_MD5 ${VORO_MD5} PATCH_COMMAND patch -b -p0 < ${LAMMPS_LIB_SOURCE_DIR}/voronoi/voro-make.patch CONFIGURE_COMMAND "" BUILD_COMMAND make ${VORO_BUILD_OPTIONS} diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake index 6d2f39b0f3..d1fa97a7a8 100644 --- a/cmake/Modules/Testing.cmake +++ b/cmake/Modules/Testing.cmake @@ -16,11 +16,14 @@ if(ENABLE_TESTING) set(MEMORYCHECK_COMMAND "${VALGRIND_BINARY}" CACHE FILEPATH "Memory Check Command") set(MEMORYCHECK_COMMAND_OPTIONS "${VALGRIND_DEFAULT_OPTIONS}" CACHE STRING "Memory Check Command Options") - # check if a faster linker is available. - # only verified with GNU and Clang compilers and new CMake - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) + # we need to build and link a LOT of tester executables, so it is worth checking if + # a faster linker is available. requires GNU or Clang compiler, newer CMake. + # also only verified with Fedora Linux > 30 and Ubuntu <= 18.04 (Ubuntu 20.04 fails) + if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + AND ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))) + if (((CMAKE_LINUX_DISTRO STREQUAL Ubuntu) AND (CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04)) + OR ((CMAKE_LINUX_DISTRO STREQUAL Fedora) AND (CMAKE_DISTRO_VERSION VERSION_GREATER 30))) include(CheckCXXCompilerFlag) set(CMAKE_CUSTOM_LINKER_DEFAULT default) check_cxx_compiler_flag(-fuse-ld=lld HAVE_LLD_LINKER_FLAG) @@ -53,3 +56,76 @@ if(ENABLE_TESTING) get_filename_component(LAMMPS_UNITTEST_BIN ${CMAKE_BINARY_DIR}/unittest ABSOLUTE) add_subdirectory(${LAMMPS_UNITTEST_DIR} ${LAMMPS_UNITTEST_BIN}) endif() + +# Compiler specific features for testing +if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) + mark_as_advanced(ENABLE_COVERAGE) + if(ENABLE_COVERAGE) + if(CMAKE_VERSION VERSION_LESS 3.13) + if(CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") + endif() + else() + target_compile_options(lammps PUBLIC --coverage) + target_link_options(lammps PUBLIC --coverage) + endif() + endif() +endif() + +####################################### +# add custom target for IWYU analysis +####################################### +set(ENABLE_IWYU OFF CACHE BOOL "Add 'iwyu' build target to call the include-what-you-use tool") +mark_as_advanced(ENABLE_IWYU) +if(ENABLE_IWYU) + # enforce these settings + set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable reporting compilation commands to compile_commands.json" FORCE) + if (NOT ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))) + message(FATAL_ERROR "IWYU is only supported with Clang or GNU compilers") + endif() + # detect the "native" header folder so we can include them first + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-search-dirs OUTPUT_VARIABLE IWYU_SEARCH_PATHS) + string(REGEX REPLACE ".*libraries: *=([^:]+):.*" "\\1/include" IWYU_EXTRA_INCLUDE_DIR ${IWYU_SEARCH_PATHS}) + find_program(IWYU_EXE NAMES include-what-you-use iwyu) + find_program(IWYU_TOOL NAMES iwyu_tool iwyu-tool iwyu_tool.py) + if (IWYU_EXE AND IWYU_TOOL) + add_custom_target( + iwyu + ${IWYU_TOOL} -o clang -p ${CMAKE_CURRENT_BINARY_DIR} -- -I${IWYU_EXTRA_INCLUDE_DIR} -Xiwyu --mapping_file=${CMAKE_CURRENT_SOURCE_DIR}/iwyu/iwyu-extra-map.imp + COMMENT "Running IWYU") + add_dependencies(iwyu lammps) + else() + message(FATAL_ERROR "To use IWYU you need the include-what-you-use/iwyu executable" + "and the iwyu-tool/iwyu_tool script installed in your PATH") + endif() +endif() + +####################################### +# select code sanitizer options +####################################### +set(ENABLE_SANITIZER "none" CACHE STRING "Select a code sanitizer option (none (default), address, leak, thread, undefined)") +mark_as_advanced(ENABLE_SANITIZER) +set(ENABLE_SANITIZER_VALUES none address leak thread undefined) +set_property(CACHE ENABLE_SANITIZER PROPERTY STRINGS ${ENABLE_SANITIZER_VALUES}) +validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) +string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) +if(NOT ENABLE_SANITIZER STREQUAL "none") + if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) + if(CMAKE_VERSION VERSION_LESS 3.13) + if(CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} -fsanitize=${ENABLE_SANITIZER}") + endif() + else() + target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + endif() + else() + message(WARNING "ENABLE_SANITIZER option not supported by ${CMAKE_CXX_COMPILER_ID} compilers. Ignoring.") + set(ENABLE_SANITIZER "none") + endif() +endif() diff --git a/cmake/Modules/YAML.cmake b/cmake/Modules/YAML.cmake index a080b566be..c50773568c 100644 --- a/cmake/Modules/YAML.cmake +++ b/cmake/Modules/YAML.cmake @@ -2,17 +2,20 @@ message(STATUS "Downloading and building YAML library") include(ExternalProject) set(YAML_URL "https://pyyaml.org/download/libyaml/yaml-0.2.5.tar.gz" CACHE STRING "URL for libyaml tarball") +set(YAML_MD5 "bb15429d8fb787e7d3f1c83ae129a999" CACHE STRING "MD5 checksum of libyaml tarball") mark_as_advanced(YAML_URL) +mark_as_advanced(YAML_MD5) + ExternalProject_Add(libyaml URL ${YAML_URL} - URL_MD5 bb15429d8fb787e7d3f1c83ae129a999 + URL_MD5 ${YAML_MD5} SOURCE_DIR "${CMAKE_BINARY_DIR}/yaml-src" BINARY_DIR "${CMAKE_BINARY_DIR}/yaml-build" CONFIGURE_COMMAND /configure ${CONFIGURE_REQUEST_PIC} CXX=${CMAKE_CXX_COMPILER} CC=${CMAKE_C_COMPILER} --prefix= --disable-shared - BUILD_BYPRODUCTS /lib/${CMAKE_FIND_LIBRARY_PREFIXES}yaml.a + BUILD_BYPRODUCTS /lib/libyaml${CMAKE_STATIC_LIBRARY_SUFFIX} TEST_COMMAND "") ExternalProject_Get_Property(libyaml INSTALL_DIR) @@ -23,7 +26,7 @@ set(YAML_LIBRARY_DIR ${INSTALL_DIR}/lib) file(MAKE_DIRECTORY ${YAML_INCLUDE_DIR}) file(MAKE_DIRECTORY ${YAML_LIBRARY_DIR}) -set(YAML_LIBRARY_PATH ${INSTALL_DIR}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}yaml.a) +set(YAML_LIBRARY_PATH ${INSTALL_DIR}/lib/libyaml${CMAKE_STATIC_LIBRARY_SUFFIX}) add_library(Yaml::Yaml UNKNOWN IMPORTED) set_target_properties(Yaml::Yaml PROPERTIES diff --git a/cmake/Modules/generate_lmpgitversion.cmake b/cmake/Modules/generate_lmpgitversion.cmake index 4ff01c7501..b19716d74b 100644 --- a/cmake/Modules/generate_lmpgitversion.cmake +++ b/cmake/Modules/generate_lmpgitversion.cmake @@ -17,7 +17,7 @@ if(GIT_FOUND AND EXISTS ${LAMMPS_DIR}/.git) ERROR_QUIET WORKING_DIRECTORY ${LAMMPS_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty=-modified + execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty=-modified --always OUTPUT_VARIABLE temp_git_describe ERROR_QUIET WORKING_DIRECTORY ${LAMMPS_DIR} diff --git a/cmake/presets/all_off.cmake b/cmake/presets/all_off.cmake index bd94b9dbe5..9be6cfe54b 100644 --- a/cmake/presets/all_off.cmake +++ b/cmake/presets/all_off.cmake @@ -2,16 +2,16 @@ # an existing package selection without losing any other settings set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MISC MESSAGE MLIAP - MOLECULE MPIIO MSCG OPT PERI POEMS PYTHON QEQ REPLICA RIGID SHOCK - SNAP SPIN SRD VORONOI - USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK - USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP - USER-H5MD USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESODPD - USER-MESONT USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP - USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP - USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ - USER-SPH USER-TALLY USER-UEF USER-VTK USER-YAFF) + GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MOLECULE + MPIIO MSCG OPT PERI PLUGIN POEMS PYTHON QEQ REPLICA RIGID SHOCK SNAP SPIN + SRD VORONOI + USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS + USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-INTEL + USER-LB USER-MANIFOLD USER-MEAMC USER-MESODPD USER-MESONT USER-MGPT + USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP USER-PACE USER-PHONON + USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP USER-REACTION USER-REAXC + USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF + USER-VTK USER-YAFF) foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} OFF CACHE BOOL "" FORCE) diff --git a/cmake/presets/all_on.cmake b/cmake/presets/all_on.cmake index 438c119c4c..411fb09d6b 100644 --- a/cmake/presets/all_on.cmake +++ b/cmake/presets/all_on.cmake @@ -4,16 +4,16 @@ # with just a working C++ compiler and an MPI library. set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU - GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MISC MESSAGE MLIAP - MOLECULE MPIIO MSCG OPT PERI POEMS PYTHON QEQ REPLICA RIGID SHOCK - SNAP SPIN SRD VORONOI - USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK - USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP - USER-H5MD USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESODPD - USER-MESONT USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP - USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP - USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ - USER-SPH USER-TALLY USER-UEF USER-VTK USER-YAFF) + GRANULAR KIM KOKKOS KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MOLECULE + MPIIO MSCG OPT PERI PLUGIN POEMS PYTHON QEQ REPLICA RIGID SHOCK SNAP SPIN + SRD VORONOI + USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS + USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-INTEL + USER-LB USER-MANIFOLD USER-MEAMC USER-MESODPD USER-MESONT USER-MGPT + USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP USER-PACE USER-PHONON + USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP USER-REACTION USER-REAXC + USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF + USER-VTK USER-YAFF) foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} ON CACHE BOOL "" FORCE) diff --git a/cmake/presets/most.cmake b/cmake/presets/most.cmake index bddefc077b..5dc58b735b 100644 --- a/cmake/presets/most.cmake +++ b/cmake/presets/most.cmake @@ -4,7 +4,7 @@ set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GRANULAR KSPACE MANYBODY MC MISC MLIAP MOLECULE OPT PERI - POEMS PYTHON QEQ REPLICA RIGID SHOCK SNAP SPIN SRD VORONOI + PLUGIN POEMS PYTHON QEQ REPLICA RIGID SHOCK SNAP SPIN SRD VORONOI USER-BOCS USER-CGDNA USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-MEAMC USER-MESODPD USER-MISC USER-MOFFF USER-OMP USER-PHONON USER-REACTION diff --git a/cmake/presets/nolib.cmake b/cmake/presets/nolib.cmake index 0245b58cc7..c9abb00a15 100644 --- a/cmake/presets/nolib.cmake +++ b/cmake/presets/nolib.cmake @@ -1,10 +1,11 @@ # preset that turns off all packages that require some form of external # library or special compiler (fortran or cuda) or equivalent. -set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MPIIO MSCG PYTHON - VORONOI USER-ADIOS USER-ATC USER-AWPMD USER-H5MD USER-LB - USER-MOLFILE USER-MESONT USER-NETCDF USER-PLUMED USER-QMMM USER-QUIP - USER-SCAFACOS USER-SMD USER-VTK) +set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MESSAGE MPIIO MSCG + PYTHON VORONOI + USER-ADIOS USER-ATC USER-AWPMD USER-H5MD USER-LB USER-MOLFILE USER-MESONT + USER-NETCDF USER-PACE USER-PLUMED USER-QMMM USER-QUIP USER-SCAFACOS + USER-SMD USER-VTK) foreach(PKG ${PACKAGES_WITH_LIB}) set(PKG_${PKG} OFF CACHE BOOL "" FORCE) diff --git a/cmake/presets/oneapi.cmake b/cmake/presets/oneapi.cmake new file mode 100644 index 0000000000..ef04167305 --- /dev/null +++ b/cmake/presets/oneapi.cmake @@ -0,0 +1,18 @@ +# preset that will enable the LLVM based Intel compilers with support for MPI and OpenMP (on Linux boxes) + +set(CMAKE_CXX_COMPILER "icpx" CACHE STRING "" FORCE) +set(CMAKE_C_COMPILER "icx" CACHE STRING "" FORCE) +set(CMAKE_Fortran_COMPILER "ifx" CACHE STRING "" FORCE) +set(MPI_CXX "icpx" CACHE STRING "" FORCE) +set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) +unset(HAVE_OMP_H_INCLUDE CACHE) + +set(OpenMP_C "icx" CACHE STRING "" FORCE) +set(OpenMP_C_FLAGS "-qopenmp" CACHE STRING "" FORCE) +set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) +set(OpenMP_CXX "icpx" CACHE STRING "" FORCE) +set(OpenMP_CXX_FLAGS "-qopenmp" CACHE STRING "" FORCE) +set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE) +set(OpenMP_Fortran_FLAGS "-qopenmp" CACHE STRING "" FORCE) +set(OpenMP_omp_LIBRARY "libiomp5.so" CACHE PATH "" FORCE) + diff --git a/cmake/presets/pgi.cmake b/cmake/presets/pgi.cmake new file mode 100644 index 0000000000..b34cb05331 --- /dev/null +++ b/cmake/presets/pgi.cmake @@ -0,0 +1,16 @@ +# preset that will enable clang/clang++ with support for MPI and OpenMP (on Linux boxes) + +set(CMAKE_CXX_COMPILER "pgc++" CACHE STRING "" FORCE) +set(CMAKE_C_COMPILER "pgcc" CACHE STRING "" FORCE) +set(CMAKE_Fortran_COMPILER "pgfortran" CACHE STRING "" FORCE) +set(MPI_CXX "pgc++" CACHE STRING "" FORCE) +set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE) +unset(HAVE_OMP_H_INCLUDE CACHE) + +set(OpenMP_C "pgcc" CACHE STRING "" FORCE) +set(OpenMP_C_FLAGS "-mp" CACHE STRING "" FORCE) +set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE) +set(OpenMP_CXX "pgc++" CACHE STRING "" FORCE) +set(OpenMP_CXX_FLAGS "-mp" CACHE STRING "" FORCE) +set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE) +set(OpenMP_omp_LIBRARY "libomp.so" CACHE PATH "" FORCE) diff --git a/doc/Makefile b/doc/Makefile index 59700f03aa..e49d42ca77 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -47,6 +47,8 @@ HAS_PDFLATEX = YES endif endif +# override settings for PIP commands +# PIP_OPTIONS = --cert /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt --proxy http://proxy.mydomain.org #SPHINXEXTRA = -j $(shell $(PYTHON) -c 'import multiprocessing;print(multiprocessing.cpu_count())') $(shell test -f $(BUILDDIR)/doxygen/xml/run.stamp && printf -- "-E") @@ -94,7 +96,7 @@ $(SPHINXCONFIG)/conf.py: $(SPHINXCONFIG)/conf.py.in -e 's,@LAMMPS_PYTHON_DIR@,$(BUILDDIR)/../python,g' \ -e 's,@LAMMPS_DOC_DIR@,$(BUILDDIR),g' $< > $@ -html: xmlgen $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX) +html: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX) @if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi @$(MAKE) $(MFLAGS) -C graphviz all @(\ @@ -118,7 +120,7 @@ html: xmlgen $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX) @rm -rf html/PDF/.[sg]* @echo "Build finished. The HTML pages are in doc/html." -spelling: xmlgen $(VENV) $(SPHINXCONFIG)/false_positives.txt +spelling: xmlgen $(SPHINXCONFIG)/conf.py $(VENV) $(SPHINXCONFIG)/false_positives.txt @if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi @(\ . $(VENV)/bin/activate ; env PYTHONWARNINGS= \ @@ -228,13 +230,13 @@ $(VENV): @( \ $(VIRTUALENV) -p $(PYTHON) $(VENV); \ . $(VENV)/bin/activate; \ - pip install --upgrade pip; \ - pip install --use-feature=2020-resolver -r $(BUILDDIR)/utils/requirements.txt; \ + pip $(PIP_OPTIONS) install --upgrade pip; \ + pip $(PIP_OPTIONS) install -r $(BUILDDIR)/utils/requirements.txt; \ deactivate;\ ) $(MATHJAX): - @git clone --depth 1 https://github.com/mathjax/MathJax.git $@ + @git clone -b 3.1.4 -c advice.detachedHead=0 --depth 1 git://github.com/mathjax/MathJax.git $@ $(TXT2RST) $(ANCHORCHECK): $(VENV) @( \ diff --git a/doc/doxygen/Doxyfile.in b/doc/doxygen/Doxyfile.in index f8a5bc6cdb..49a271355f 100644 --- a/doc/doxygen/Doxyfile.in +++ b/doc/doxygen/Doxyfile.in @@ -424,6 +424,8 @@ INPUT = @LAMMPS_SOURCE_DIR@/utils.cpp \ @LAMMPS_SOURCE_DIR@/input.h \ @LAMMPS_SOURCE_DIR@/tokenizer.cpp \ @LAMMPS_SOURCE_DIR@/tokenizer.h \ + @LAMMPS_SOURCE_DIR@/arg_info.cpp \ + @LAMMPS_SOURCE_DIR@/arg_info.h \ @LAMMPS_SOURCE_DIR@/text_file_reader.cpp \ @LAMMPS_SOURCE_DIR@/text_file_reader.h \ @LAMMPS_SOURCE_DIR@/potential_file_reader.cpp \ diff --git a/doc/graphviz/lammps-classes.dot b/doc/graphviz/lammps-classes.dot index 3c2d2f418d..390dd2cc4b 100644 --- a/doc/graphviz/lammps-classes.dot +++ b/doc/graphviz/lammps-classes.dot @@ -18,8 +18,8 @@ digraph lammps { Up [shape=box label="Update" color=blue] Un [shape=box label="Universe" color=blue] Ti [shape=box label="Timer" color=blue] - Lt [label="Lattice"] Rg [label="Region" color=red] + Lt [label="Lattice"] Rb [shape=box label="RegionBlock"] Rs [shape=box label="RegionSphere"] Av [label="AtomVec" color=red] @@ -34,6 +34,7 @@ digraph lammps { Du [label="Dump" color=red] Fi [label="Fix" color=red] Cp [label="Compute" color=red] + Cm [label="Command" color=red] Th [label="Thermo"] Va [label="Variable"] Ew [shape=box label="Ewald"] @@ -71,16 +72,19 @@ digraph lammps { Dg [shape=box label="DumpCFG"] Ve [shape=box label="Verlet"] Rr [shape=box label="Respa"] + Ru [shape=box label="Run"] + Se [shape=box label="Set"] Pt [shape=box label="PPPMTIP4P"] Vs [shape=box label="VerletSplit"] Ro [shape=box label="RespaOMP"] Mc [shape=box label="MinCG"] Mf [shape=box label="MinFire"] La -> {At Ci Co Do Er Fo Gr In Me Mo Ne Ou Ti Up Un} [penwidth=2] - Do -> {Lt Rg} [penwidth=2] + Do -> {Rg Lt} [penwidth=2] Rg -> {Rb Rs} [style=dashed penwidth=2] Co -> {Cb Ct} [style=dashed penwidth=2] - In -> Va [penwidth=2] + In -> {Va Cm} [penwidth=2] + Cm -> {Ru Se} [style=dashed penwidth=2] Mo -> {Fi Cp} [penwidth=2] Fo -> {Pa Bo An Di Im Ks} [penwidth=2] Ks -> {Ew Pp} [style=dashed penwidth=2] diff --git a/doc/lammps.1 b/doc/lammps.1 index 5fc4795ba7..c10950643d 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "30 November 2020" "2020-10-29" +.TH LAMMPS "8 April 2021" "2021-04-08" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. diff --git a/doc/src/Build_basics.rst b/doc/src/Build_basics.rst index 8f40d3e5ba..30e668a283 100644 --- a/doc/src/Build_basics.rst +++ b/doc/src/Build_basics.rst @@ -1,7 +1,7 @@ Basic build options =================== -The following topics are covered on this page, for building both with +The following topics are covered on this page, for building with both CMake and make: * :ref:`Serial vs parallel build ` @@ -95,7 +95,7 @@ standard. A more detailed discussion of that is below. .. note:: - The file ``src/STUBS/mpi.c`` provides a CPU timer function + The file ``src/STUBS/mpi.cpp`` provides a CPU timer function called ``MPI_Wtime()`` that calls ``gettimeofday()``. If your operating system does not support ``gettimeofday()``, you will need to insert code to call another timer. Note that the @@ -234,14 +234,21 @@ LAMMPS. cmake ../cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_Fortran_COMPILER=gfortran # Building with Intel Compilers: cmake ../cmake -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DCMAKE_Fortran_COMPILER=ifort + # Building with Intel oneAPI Compilers: + cmake ../cmake -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DCMAKE_Fortran_COMPILER=ifx # Building with LLVM/Clang Compilers: cmake ../cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_Fortran_COMPILER=flang + # Building with PGI/Nvidia Compilers: + cmake ../cmake -DCMAKE_C_COMPILER=pgcc -DCMAKE_CXX_COMPILER=pgc++ -DCMAKE_Fortran_COMPILER=pgfortran For compiling with the Clang/LLVM compilers a CMake preset is provided that can be loaded with `-C ../cmake/presets/clang.cmake`. Similarly, `-C ../cmake/presets/intel.cmake` should switch the compiler - toolchain to the Intel compilers. + toolchain to the legacy Intel compilers, `-C ../cmake/presets/oneapi.cmake` + will switch to the LLVM based oneAPI Intel compilers, + and `-C ../cmake/presets/pgi.cmake` + will switch the compiler to the PGI compilers. In addition you can set ``CMAKE_TUNE_FLAGS`` to specifically add compiler flags to tune for optimal performance on given hosts. By @@ -523,6 +530,20 @@ you want to copy files to is protected. make # perform make after CMake command make install # perform the installation into prefix + During the installation process CMake will by default remove any runtime + path settings for loading shared libraries. Because of this you may + have to set or modify the ``LD_LIBRARY_PATH`` (or ``DYLD_LIBRARY_PATH``) + environment variable, if you are installing LAMMPS into a non-system + location and/or are linking to libraries in a non-system location that + depend on such runtime path settings. + As an alternative you may set the CMake variable ``LAMMPS_INSTALL_RPATH`` + to ``on`` and then the runtime paths for any linked shared libraries + and the library installation folder for the LAMMPS library will be + embedded and thus the requirement to set environment variables is avoided. + The ``off`` setting is usually preferred for packaged binaries or when + setting up environment modules, the ``on`` setting is more convenient + for installing software into a non-system or personal folder. + .. tab:: Traditional make There is no "install" option in the ``src/Makefile`` for LAMMPS. diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 5ef29fbca1..d375d33e56 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -37,6 +37,7 @@ This is the list of packages that may require additional steps. * :ref:`KOKKOS ` * :ref:`LATTE ` * :ref:`MESSAGE ` + * :ref:`MLIAP ` * :ref:`MSCG ` * :ref:`OPT ` * :ref:`POEMS ` @@ -51,6 +52,7 @@ This is the list of packages that may require additional steps. * :ref:`USER-MESONT ` * :ref:`USER-MOLFILE ` * :ref:`USER-NETCDF ` + * :ref:`USER-PACE ` * :ref:`USER-PLUMED ` * :ref:`USER-OMP ` * :ref:`USER-QMMM ` @@ -119,21 +121,21 @@ CMake build -D GPU_API=value # value = opencl (default) or cuda or hip -D GPU_PREC=value # precision setting # value = double or mixed (default) or single - -D OCL_TUNE=value # hardware choice for GPU_API=opencl - # generic (default) or intel (Intel CPU) or fermi, kepler, cypress (NVIDIA) -D GPU_ARCH=value # primary GPU hardware choice for GPU_API=cuda # value = sm_XX, see below # default is sm_50 -D HIP_ARCH=value # primary GPU hardware choice for GPU_API=hip # value depends on selected HIP_PLATFORM - # default is 'gfx906' for HIP_PLATFORM=hcc and 'sm_50' for HIP_PLATFORM=nvcc + # default is 'gfx906' for HIP_PLATFORM=amd and 'sm_50' for HIP_PLATFORM=nvcc -D HIP_USE_DEVICE_SORT=value # enables GPU sorting # value = yes (default) or no - -D CUDPP_OPT=value # optimization setting for GPU_API=cuda - # enables CUDA Performance Primitives Optimizations - # value = yes (default) or no + -D CUDPP_OPT=value # use GPU binning on with CUDA (should be off for modern GPUs) + # enables CUDA Performance Primitives, must be "no" for CUDA_MPS_SUPPORT=yes + # value = yes or no (default) -D CUDA_MPS_SUPPORT=value # enables some tweaks required to run with active nvidia-cuda-mps daemon # value = yes or no (default) + -D USE_STATIC_OPENCL_LOADER=value # downloads/includes OpenCL ICD loader library, no local OpenCL headers/libs needed + # value = yes (default) or no :code:`GPU_ARCH` settings for different GPU hardware is as follows: @@ -160,19 +162,32 @@ When building with CMake, you **must NOT** build the GPU library in ``lib/gpu`` using the traditional build procedure. CMake will detect files generated by that process and will terminate with an error and a suggestion for how to remove them. +If you are compiling for OpenCL, the default setting is to download, build, and +link with a static OpenCL ICD loader library and standard OpenCL headers. This +way no local OpenCL development headers or library needs to be present and only +OpenCL compatible drivers need to be installed to use OpenCL. If this is not +desired, you can set :code:`USE_STATIC_OPENCL_LOADER` to :code:`no`. + If you are compiling with HIP, note that before running CMake you will have to set appropriate environment variables. Some variables such as -:code:`HCC_AMDGPU_TARGET` or :code:`CUDA_PATH` are necessary for :code:`hipcc` +:code:`HCC_AMDGPU_TARGET` (for ROCm <= 4.0) or :code:`CUDA_PATH` are necessary for :code:`hipcc` and the linker to work correctly. .. code:: bash - # AMDGPU target + # AMDGPU target (ROCm <= 4.0) export HIP_PLATFORM=hcc export HCC_AMDGPU_TARGET=gfx906 cmake -D PKG_GPU=on -D GPU_API=HIP -D HIP_ARCH=gfx906 -D CMAKE_CXX_COMPILER=hipcc .. make -j 4 +.. code:: bash + + # AMDGPU target (ROCm >= 4.1) + export HIP_PLATFORM=amd + cmake -D PKG_GPU=on -D GPU_API=HIP -D HIP_ARCH=gfx906 -D CMAKE_CXX_COMPILER=hipcc .. + make -j 4 + .. code:: bash # CUDA target (not recommended, use GPU_ARCH=cuda) @@ -218,11 +233,20 @@ Makefile if desired: * ``CUDA_PRECISION`` = precision (double, mixed, single) * ``EXTRAMAKE`` = which Makefile.lammps.\* file to copy to Makefile.lammps -The file Makefile.linux_multi is set up to include support for multiple +The file Makefile.cuda is set up to include support for multiple GPU architectures as supported by the CUDA toolkit in use. This is done through using the "--gencode " flag, which can be used multiple times and thus support all GPU architectures supported by your CUDA compiler. +To enable GPU binning via CUDA performance primitives set the Makefile variable +``CUDPP_OPT = -DUSE_CUDPP -Icudpp_mini``. This should **not** be used with +most modern GPUs. + +To support the CUDA multiprocessor server you can set the define +``-DCUDA_PROXY``. Please note that in this case you must **not** use +the CUDA performance primitives and thus set the variable ``CUDPP_OPT`` +to empty. + If the library build is successful, 3 files should be created: ``lib/gpu/libgpu.a``\ , ``lib/gpu/nvc_get_devices``\ , and ``lib/gpu/Makefile.lammps``\ . The latter has settings that enable LAMMPS @@ -249,18 +273,18 @@ To build with this package, the KIM library with API v2 must be downloaded and built on your system. It must include the KIM models that you want to use with LAMMPS. -If you would like to use the :doc:`kim_query ` +If you would like to use the :doc:`kim query ` command, you also need to have libcurl installed with the matching development headers and the curl-config tool. -If you would like to use the :doc:`kim_property ` +If you would like to use the :doc:`kim property ` command, you need to build LAMMPS with the PYTHON package installed and linked to Python 3.6 or later. See the :ref:`PYTHON package build info ` for more details on this. After successfully building LAMMPS with Python, you -also need to install the kim-property Python package, which can be easily done using -*pip* as ``pip install kim-property``, or from the *conda-forge* channel as -``conda install kim-property`` if LAMMPS is built in Conda. More detailed -information is available at: +also need to install the ``kim-property`` Python package, which can be easily +done using *pip* as ``pip install kim-property``, or from the *conda-forge* +channel as ``conda install kim-property`` if LAMMPS is built in Conda. More +detailed information is available at: `kim-property installation `_. In addition to installing the KIM API, it is also necessary to install the @@ -282,6 +306,7 @@ minutes to hours) to build. Of course you only need to do that once.) -D DOWNLOAD_KIM=value # download OpenKIM API v2 for build, value = no (default) or yes -D LMP_DEBUG_CURL=value # set libcurl verbose mode on/off, value = off (default) or on -D LMP_NO_SSL_CHECK=value # tell libcurl to not verify the peer, value = no (default) or yes + -D KIM_EXTRA_UNITTESTS=value # enables extra unit tests, value = no (default) or yes If ``DOWNLOAD_KIM`` is set to *yes* (or *on*), the KIM API library will be downloaded and built inside the CMake build directory. If @@ -290,11 +315,16 @@ minutes to hours) to build. Of course you only need to do that once.) ``PKG_CONFIG_PATH`` environment variable so that libkim-api can be found, or run the command ``source kim-api-activate``. + Extra unit tests can only be available if they are explicitly requested + (``KIM_EXTRA_UNITTESTS`` is set to *yes* (or *on*)) and the prerequisites + are met. See :ref:`KIM Extra unit tests ` for + more details on this. + .. tab:: Traditional make You can download and build the KIM library manually if you prefer; follow the instructions in ``lib/kim/README``. You can also do - this in one step from the lammps/src dir, using a command like + this in one step from the lammps/src directory, using a command like these, which simply invoke the ``lib/kim/Install.py`` script with the specified args. @@ -314,7 +344,7 @@ minutes to hours) to build. Of course you only need to do that once.) .. code-block:: make - LMP_INC = -DLMP_NO_SSL_CHECK + LMP_INC = -DLMP_NO_SSL_CHECK Debugging OpenKIM web queries in LAMMPS ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -338,6 +368,39 @@ specify your own CA cert path by setting the environment variable ``CURL_CA_BUNDLE`` to the path of your choice. A call to the KIM web query would get this value from the environment variable. +.. _kim_extra_unittests: + +KIM Extra unit tests (CMake only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +During development, testing, or debugging, if +:doc:`unit testing ` is enabled in LAMMPS, one can also +enable extra tests on :doc:`KIM commands ` by setting the +``KIM_EXTRA_UNITTESTS`` to *yes* (or *on*). + +Enabling the extra unit tests have some requirements, + +* It requires to have internet access. +* It requires to have libcurl installed with the matching development headers + and the curl-config tool. +* It requires to build LAMMPS with the PYTHON package installed and linked to + Python 3.6 or later. See the :ref:`PYTHON package build info ` for + more details on this. +* It requires to have ``kim-property`` Python package installed, which can be + easily done using *pip* as ``pip install kim-property``, or from the + *conda-forge* channel as ``conda install kim-property`` if LAMMPS is built in + Conda. More detailed information is available at: + `kim-property installation `_. +* It is also necessary to install + ``EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000``, + ``EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005``, and + ``LennardJones612_UniversalShifted__MO_959249795837_003`` KIM models. + See `Obtaining KIM Models `_ + to learn how to install a pre-built binary of the OpenKIM Repository of + Models or see + `Installing KIM Models `_ + to learn how to install the specific KIM models. + ---------- .. _kokkos: @@ -482,11 +545,14 @@ They must be specified in uppercase. * - VEGA906 - GPU - AMD GPU MI50/MI60 GFX906 + * - VEGA908 + - GPU + - AMD GPU GFX908 * - INTEL_GEN - GPU - Intel GPUs Gen9+ -This list was last updated for version 3.2 of the Kokkos library. +This list was last updated for version 3.3 of the Kokkos library. .. tabs:: @@ -732,6 +798,54 @@ be installed on your system. ---------- +.. _mliap: + +MLIAP package +--------------------------- + +Building the MLIAP package requires including the :ref:`SNAP ` +package. There will be an error message if this requirement is not satisfied. +Using the *mliappy* model also requires enabling Python support, which +in turn requires the :ref:`PYTHON ` +package **and** requires you have the `cython `_ software +installed and with it a working ``cythonize`` command. This feature requires +compiling LAMMPS with Python version 3.6 or later. + +.. tabs:: + + .. tab:: CMake build + + .. code-block:: bash + + -D MLIAP_ENABLE_PYTHON=value # enable mliappy model (default is autodetect) + + Without this setting, CMake will check whether it can find a + suitable Python version and the ``cythonize`` command and choose + the default accordingly. During the build procedure the provided + .pyx file(s) will be automatically translated to C++ code and compiled. + Please do **not** run ``cythonize`` manually in the ``src/MLIAP`` folder, + as that can lead to compilation errors if Python support is not enabled. + If you did by accident, please remove the generated .cpp and .h files. + + .. tab:: Traditional make + + The build uses the ``lib/python/Makefile.mliap_python`` file in the + compile/link process to add a rule to update the files generated by + the ``cythonize`` command in case the corresponding .pyx file(s) were + modified. You may need to modify ``lib/python/Makefile.lammps`` + if the LAMMPS build fails. + To manually enforce building MLIAP with Python support enabled, + you can add + ``-DMLIAP_PYTHON`` to the ``LMP_INC`` variable in your machine makefile. + You may have to manually run the ``cythonize`` command on .pyx file(s) + in the ``src`` folder, if this is not automatically done during + installing the MLIAP package. Please do **not** run ``cythonize`` + in the ``src/MLIAP`` folder, as that can lead to compilation errors + if Python support is not enabled. + If you did by accident, please remove the generated .cpp and .h files. + +---------- + .. _mscg: MSCG package @@ -1134,6 +1248,46 @@ be built for the most part with all major versions of the C++ language. ---------- +.. _user-pace: + +USER-PACE package +----------------------------- + +This package requires a library that can be downloaded and built +in lib/pace or somewhere else, which must be done before building +LAMMPS with this package. The code for the library can be found +at: `https://github.com/ICAMS/lammps-user-pace/ `_ + +.. tabs:: + + .. tab:: CMake build + + By default the library will be downloaded from the git repository + and built automatically when the USER-PACE package is enabled with + ``-D PKG_USER-PACE=yes``. The location for the sources may be + customized by setting the variable ``PACELIB_URL`` when + configuring with CMake (e.g. to use a local archive on machines + without internet access). Since CMake checks the validity of the + archive with ``md5sum`` you may also need to set ``PACELIB_MD5`` + if you provide a different library version than what is downloaded + automatically. + + + .. tab:: Traditional make + + You can download and build the USER-PACE library + in one step from the ``lammps/src`` dir, using these commands, + which invoke the ``lib/pace/Install.py`` script. + + .. code-block:: bash + + $ make lib-pace # print help message + $ make lib-pace args="-b" # download and build the default version in lib/pace + + You should not need to edit the ``lib/pace/Makefile.lammps`` file. + +---------- + .. _user-plumed: USER-PLUMED package diff --git a/doc/src/Build_link.rst b/doc/src/Build_link.rst index 3d66371304..5255620231 100644 --- a/doc/src/Build_link.rst +++ b/doc/src/Build_link.rst @@ -20,16 +20,8 @@ the suffix ``.so.0`` (or some other number). .. note:: Care should be taken to use the same MPI library for the calling code - and the LAMMPS library. The ``library.h`` file includes ``mpi.h`` - and uses definitions from it so those need to be available and - consistent. When LAMMPS is compiled with the included STUBS MPI - library, then its ``mpi.h`` file needs to be included. While it is - technically possible to use a full MPI library in the calling code - and link to a serial LAMMPS library compiled with MPI STUBS, it is - recommended to use the *same* MPI library for both, and then use - ``MPI_Comm_split()`` in the calling code to pass a suitable - communicator with a subset of MPI ranks to the function creating the - LAMMPS instance. + and the LAMMPS library unless LAMMPS is to be compiled without (real) + MPI support using the include STUBS MPI library. Link with LAMMPS as a static library ------------------------------------ @@ -110,7 +102,7 @@ executable, that are also required to link the LAMMPS executable. .. code-block:: bash - gcc -c -O -I${HOME}/lammps/src/STUBS -I${HOME}/lammps/src -caller.c + gcc -c -O -I${HOME}/lammps/src -caller.c g++ -o caller caller.o -L${HOME}/lammps/lib/poems \ -L${HOME}/lammps/src/STUBS -L${HOME}/lammps/src \ -llammps_serial -lpoems -lmpi_stubs @@ -174,7 +166,7 @@ the POEMS package installed becomes: .. code-block:: bash - gcc -c -O -I${HOME}/lammps/src/STUBS -I${HOME}/lammps/src -caller.c + gcc -c -O -I${HOME}/lammps/src -caller.c g++ -o caller caller.o -L${HOME}/lammps/src -llammps_serial Locating liblammps.so at runtime diff --git a/doc/src/Build_manual.rst b/doc/src/Build_manual.rst index 59e4e3235b..3bf0337b31 100644 --- a/doc/src/Build_manual.rst +++ b/doc/src/Build_manual.rst @@ -74,7 +74,11 @@ For the documentation build a python virtual environment is set up in the folder ``doc/docenv`` and various python packages are installed into that virtual environment via the ``pip`` tool. For rendering embedded LaTeX code also the `MathJax `_ JavaScript -engine needs to be downloaded. +engine needs to be downloaded. If you need to pass additional options +to the pip commands to work (e.g. to use a web proxy or to point to +additional SSL certificates) you can set them via the ``PIP_OPTIONS`` +environment variable or uncomment and edit the ``PIP_OPTIONS`` setting +at beginning of the makefile. The actual translation is then done via ``make`` commands in the doc folder. The following ``make`` commands are available: @@ -108,7 +112,10 @@ installation of the HTML manual pages into the "install" step when installing LAMMPS after the CMake build via ``cmake --build . --target install``. The documentation build is included in the default build target, but can also be requested independently with -``cmake --build . --target doc``. +``cmake --build . --target doc``. If you need to pass additional options +to the pip commands to work (e.g. to use a web proxy or to point to +additional SSL certificates) you can set them via the ``PIP_OPTIONS`` +environment variable. .. code-block:: bash diff --git a/doc/src/Build_package.rst b/doc/src/Build_package.rst index 18d9ab5f19..91531f51ec 100644 --- a/doc/src/Build_package.rst +++ b/doc/src/Build_package.rst @@ -30,17 +30,17 @@ steps, as explained on the :doc:`Build extras ` page. These links take you to the extra instructions for those select packages: -+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ -| :ref:`COMPRESS ` | :ref:`GPU ` | :ref:`KIM ` | :ref:`KOKKOS ` | :ref:`LATTE ` | :ref:`MESSAGE ` | -+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ -| :ref:`MSCG ` | :ref:`OPT ` | :ref:`POEMS ` | :ref:`PYTHON ` | :ref:`VORONOI ` | :ref:`USER-ADIOS ` | -+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ -| :ref:`USER-ATC ` | :ref:`USER-AWPMD ` | :ref:`USER-COLVARS ` | :ref:`USER-H5MD ` | :ref:`USER-INTEL ` | :ref:`USER-MOLFILE ` | -+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ -| :ref:`USER-NETCDF ` | :ref:`USER-PLUMED ` | :ref:`USER-OMP ` | :ref:`USER-QMMM ` | :ref:`USER-QUIP ` | :ref:`USER-SCAFACOS ` | -+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ -| :ref:`USER-SMD ` | :ref:`USER-VTK ` | | | | | -+----------------------------------+----------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ ++--------------------------------------+--------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ +| :ref:`COMPRESS ` | :ref:`GPU ` | :ref:`KIM ` | :ref:`KOKKOS ` | :ref:`LATTE ` | :ref:`MESSAGE ` | ++--------------------------------------+--------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ +| :ref:`MSCG ` | :ref:`OPT ` | :ref:`POEMS ` | :ref:`PYTHON ` | :ref:`VORONOI ` | :ref:`USER-ADIOS ` | ++--------------------------------------+--------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ +| :ref:`USER-ATC ` | :ref:`USER-AWPMD ` | :ref:`USER-COLVARS ` | :ref:`USER-H5MD ` | :ref:`USER-INTEL ` | :ref:`USER-MOLFILE ` | ++--------------------------------------+--------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ +| :ref:`USER-NETCDF ` | :ref:`USER-PACE ` | :ref:`USER-PLUMED ` | :ref:`USER-OMP ` | :ref:`USER-QMMM ` | :ref:`USER-QUIP ` | ++--------------------------------------+--------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ +| :ref:`USER-SCAFACOS ` | :ref:`USER-SMD ` | :ref:`USER-VTK ` | | | | ++--------------------------------------+--------------------------------+------------------------------------+------------------------------+--------------------------------+--------------------------------------+ The mechanism for including packages is simple but different for CMake versus make. @@ -160,6 +160,7 @@ one of them as a starting point and customize it to your needs. cmake -C ../cmake/presets/clang.cmake [OPTIONS] ../cmake # change settings to use the Clang compilers by default cmake -C ../cmake/presets/gcc.cmake [OPTIONS] ../cmake # change settings to use the GNU compilers by default cmake -C ../cmake/presets/intel.cmake [OPTIONS] ../cmake # change settings to use the Intel compilers by default + cmake -C ../cmake/presets/pgi.cmake [OPTIONS] ../cmake # change settings to use the PGI compilers by default cmake -C ../cmake/presets/all_on.cmake [OPTIONS] ../cmake # enable all packages cmake -C ../cmake/presets/all_off.cmake [OPTIONS] ../cmake # disable all packages mingw64-cmake -C ../cmake/presets/mingw-cross.cmake [OPTIONS] ../cmake # compile with MinGW cross compilers diff --git a/doc/src/Commands_all.rst b/doc/src/Commands_all.rst index a38bd5f0db..b43fd0ed56 100644 --- a/doc/src/Commands_all.rst +++ b/doc/src/Commands_all.rst @@ -60,11 +60,7 @@ An alphabetic list of all general LAMMPS commands. * :doc:`include ` * :doc:`info ` * :doc:`jump ` - * :doc:`kim_init ` - * :doc:`kim_interactions ` - * :doc:`kim_param ` - * :doc:`kim_property ` - * :doc:`kim_query ` + * :doc:`kim ` * :doc:`kspace_modify ` * :doc:`kspace_style ` * :doc:`label