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..a65db7636b --- /dev/null +++ b/.github/workflows/unittest-macos.yml @@ -0,0 +1,34 @@ +# 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/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/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c29fba5957..f67699c54d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -107,13 +107,15 @@ 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) + 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) + +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 +156,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 $) @@ -650,7 +651,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}) @@ -660,10 +661,10 @@ if(BUILD_SHARED_LIBS) endif() if (Python_EXECUTABLE) add_custom_target( - install-python - ${Python_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h + 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${CMAKE_SHARED_LIBRARY_SUFFIX} + -l ${CMAKE_BINARY_DIR}/liblammps${LAMMPS_MACHINE}${CMAKE_SHARED_LIBRARY_SUFFIX} WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR} COMMENT "Installing LAMMPS Python module") else() @@ -776,9 +777,7 @@ if(PKG_GPU) message(STATUS "<<< GPU package settings >>> -- 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 "GPU default architecture: ${GPU_ARCH}") elseif(GPU_API STREQUAL "HIP") message(STATUS "HIP platform: ${HIP_PLATFORM}") message(STATUS "HIP architecture: ${HIP_ARCH}") diff --git a/cmake/Modules/Documentation.cmake b/cmake/Modules/Documentation.cmake index 189c32e301..5a42244b9e 100644 --- a/cmake/Modules/Documentation.cmake +++ b/cmake/Modules/Documentation.cmake @@ -50,9 +50,9 @@ 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 ) # download mathjax distribution and unpack to folder "mathjax" diff --git a/cmake/Modules/GTest.cmake b/cmake/Modules/GTest.cmake index 060a7e42f9..0c62291d5e 100644 --- a/cmake/Modules/GTest.cmake +++ b/cmake/Modules/GTest.cmake @@ -20,10 +20,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 +39,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/OpenCLLoader.cmake b/cmake/Modules/OpenCLLoader.cmake new file mode 100644 index 0000000000..5ab121f841 --- /dev/null +++ b/cmake/Modules/OpenCLLoader.cmake @@ -0,0 +1,48 @@ +message(STATUS "Downloading and building OpenCL loader library") + +include(ExternalProject) +set(OPENCL_LOADER_URL "https://download.lammps.org/thirdparty/opencl-loader-2020.12.18.tar.gz" CACHE STRING "URL for OpenCL loader tarball") +mark_as_advanced(OPENCL_LOADER_URL) +ExternalProject_Add(opencl_loader + URL ${OPENCL_LOADER_URL} + URL_MD5 011cdcbd41030be94f3fced6d763a52a + 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 bc66ef04d2..043d41e0ef 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -1,7 +1,9 @@ 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") @@ -36,6 +38,9 @@ if(GPU_API STREQUAL "CUDA") option(CUDPP_OPT "Enable CUDPP_OPT" ON) 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() @@ -98,6 +103,10 @@ 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() @@ -136,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) @@ -200,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) @@ -208,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}) @@ -390,13 +386,10 @@ elseif(GPU_API STREQUAL "HIP") 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 83a96d02b8..5482d3071c 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -69,14 +69,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/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 index d3f601a1e1..81bb10cb8f 100644 --- a/cmake/Modules/Packages/MLIAP.cmake +++ b/cmake/Modules/Packages/MLIAP.cmake @@ -1,7 +1,7 @@ # 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) + find_package(Cythonize QUIET) if(Cythonize_FOUND) set(MLIAP_ENABLE_PYTHON_DEFAULT ON) endif() @@ -14,6 +14,15 @@ if(MLIAP_ENABLE_PYTHON) 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) diff --git a/cmake/Modules/YAML.cmake b/cmake/Modules/YAML.cmake index a080b566be..f2ba34e1b6 100644 --- a/cmake/Modules/YAML.cmake +++ b/cmake/Modules/YAML.cmake @@ -12,7 +12,7 @@ ExternalProject_Add(libyaml 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 +23,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/doc/Makefile b/doc/Makefile index 041c7a372a..7deaaf2a2e 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 -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 --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/lammps.1 b/doc/lammps.1 index 299f8538b0..9351ba5636 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "24 December 2020" "2020-12-24" +.TH LAMMPS "10 February 2021" "2021-02-10" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. diff --git a/doc/src/Build_basics.rst b/doc/src/Build_basics.rst index cb6bd9f6aa..c7baa21e62 100644 --- a/doc/src/Build_basics.rst +++ b/doc/src/Build_basics.rst @@ -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 diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 0c048c53ff..9180933007 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -120,8 +120,6 @@ 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 @@ -131,10 +129,12 @@ CMake build -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 + # enables CUDA Performance Primitives Optimizations, must be "no" for CUDA_MPS_SUPPORT=yes # value = yes (default) or no -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: @@ -161,6 +161,12 @@ 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` @@ -219,11 +225,19 @@ 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 include CUDA performance primitives set the Makefile variable +``CUDPP_OPT = -DUSE_CUDPP -Icudpp_mini``. + +To support the CUDA multiprocessor server you can set the define +``-DCUDA_PROXY``. Please note that in this case you should **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 @@ -250,18 +264,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 @@ -301,7 +315,7 @@ minutes to hours) to build. Of course you only need to do that once.) 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. @@ -321,7 +335,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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -369,10 +383,11 @@ Enabling the extra unit tests have some requirements, Conda. More detailed information is available at: `kim-property installation `_. * It is also necessary to install - ``EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000``, and - ``EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005`` KIM models. + ``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-build binary of the OpenKIM Repository of + 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. 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/Commands_all.rst b/doc/src/Commands_all.rst index a38bd5f0db..132425948e 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