diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index d9c82678eb..71e3967186 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -160,9 +160,6 @@ else() enable_language(C) file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c) add_library(mpi_stubs STATIC ${MPI_SOURCES}) - if(NOT BUILD_SHARED_LIBS) - install(TARGETS mpi_stubs EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() set_target_properties(mpi_stubs PROPERTIES OUTPUT_NAME lammps_mpi_stubs${LAMMPS_MACHINE}) target_include_directories(mpi_stubs PUBLIC $ $) install(FILES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps/mpi) @@ -249,9 +246,6 @@ if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) enable_language(Fortran) file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.[fF]) add_library(linalg STATIC ${LAPACK_SOURCES}) - if(NOT BUILD_SHARED_LIBS) - install(TARGETS linalg EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() set_target_properties(linalg PROPERTIES OUTPUT_NAME lammps_linalg${LAMMPS_MACHINE}) set(BLAS_LIBRARIES "$") set(LAPACK_LIBRARIES "$") @@ -411,9 +405,6 @@ foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD) ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.cpp) add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) - if(NOT BUILD_SHARED_LIBS) - install(TARGETS ${PKG_LIB} EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() set_target_properties(${PKG_LIB} PROPERTIES OUTPUT_NAME lammps_${PKG_LIB}${LAMMPS_MACHINE}) target_link_libraries(lammps PRIVATE ${PKG_LIB}) if(PKG_LIB STREQUAL awpmd) @@ -520,14 +511,15 @@ endif() set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LAMMPS_MACHINE}) set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) -install(TARGETS lammps EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) target_include_directories(lammps PUBLIC $) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps) foreach(_HEADER ${LAMMPS_CXX_HEADERS}) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_SOURCE_DIR}/${_HEADER} ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} DEPENDS ${LAMMPS_SOURCE_DIR}/${_HEADER}) add_custom_target(${_HEADER} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER}) add_dependencies(lammps ${_HEADER}) - install(FILES ${LAMMPS_SOURCE_DIR}/${_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps) + if(BUILD_SHARED_LIBS) + install(FILES ${LAMMPS_SOURCE_DIR}/${_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps) + endif() endforeach() target_include_directories(lammps INTERFACE $) add_library(LAMMPS::lammps ALIAS lammps) @@ -536,15 +528,18 @@ set(LAMMPS_API_DEFINES) foreach(_DEF ${LAMMPS_DEFINES}) set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -D${_DEF}") endforeach() -configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -install(EXPORT LAMMPS_Targets FILE LAMMPS_Targets.cmake NAMESPACE LAMMPS:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS) -file(GLOB MODULE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Modules/Find*.cmake) -install(FILES ${MODULE_FILES} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS) -include(CMakePackageConfigHelpers) -configure_file(LAMMPSConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake @ONLY) -write_basic_package_version_file("LAMMPSConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS) +if(BUILD_SHARED_LIBS) + install(TARGETS lammps EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(EXPORT LAMMPS_Targets FILE LAMMPS_Targets.cmake NAMESPACE LAMMPS:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS) + file(GLOB MODULE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Modules/Find*.cmake) + install(FILES ${MODULE_FILES} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS) + include(CMakePackageConfigHelpers) + configure_file(LAMMPSConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake @ONLY) + write_basic_package_version_file("LAMMPSConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS) +endif() install(FILES ${LAMMPS_DOC_DIR}/lammps.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME ${LAMMPS_BINARY}.1) if(BUILD_TOOLS) diff --git a/cmake/LAMMPSConfig.cmake.in b/cmake/LAMMPSConfig.cmake.in index 7cd782b3b8..48c262c664 100644 --- a/cmake/LAMMPSConfig.cmake.in +++ b/cmake/LAMMPSConfig.cmake.in @@ -1,4 +1,4 @@ -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) include(CMakeFindDependencyMacro) if(@BUILD_MPI@) find_dependency(MPI REQUIRED CXX) @@ -8,80 +8,4 @@ if(@PKG_KSPACE@) find_dependency(@FFTW@ REQUIRED MODULE) endif() endif() -if(NOT @BUILD_SHARED_LIBS@) - if(@BUILD_OMP@) - find_dependency(OpenMP REQUIRED) - endif() - if(@WITH_JPEG@) - find_dependency(JPEG REQUIRED) - endif() - if(@WITH_PNG@) - find_dependency(PNG REQUIRED) - find_dependency(ZLIB REQUIRED) - endif() - if(@PKG_KIM@) - find_dependency(PkgConfig REQUIRED) - pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=@KIM-API_MIN_VERSION@) - if(@CURL_FOUND@) - find_dependency(CURL REQUIRED) - endif() - endif() - if(@PKG_USER-SMD@) - find_dependency(Eigen3 NO_MODULE REQUIRED) - endif() - if(@PKG_USER-SCAFACOS@) - find_dependency(PkgConfig REQUIRED) - find_ependency(GSL REQUIRED) - find_dependency(MPI REQUIRED C Fortran) - pkg_check_modules(SCAFACOS REQUIRED IMPORTED_TARGET scafacos) - endif() - if(@PKG_PYTHON@ AND NOT CMAKE_VERSION VERSION_LESS 3.12) - find_package(Python REQUIRED COMPONENTS Development) - endif() - if(@PKG_COMPRESS@) - find_dependency(ZLIB REQUIRED) - endif() - if(@PKG_KOKKOS@) - if(@EXTERNAL_KOKKOS@) - find_dependency(Kokkos 3 REQUIRED) - endif() - endif() - if(@PKG_VORONOI@) - find_dependency(VORO REQUIRED) - endif() - if(@PKG_USER-INTEL@) - if(@INTEL_LRT_MODE@ STREQUAL "THREADS") - find_dependency(Threads REQUIRED) - endif() - if(@TBB_MALLOC_FOUND@) - find_ependency(TBB_MALLOC REQUIRED) - endif() - endif() - if(@PKG_USER-ADIOS@) - find_ependency(ADIOS2 REQUIRED) - endif() - if(@PKG_LATTE@) - find_ependency(LATTE REQUIRED) - endif() - if(@PKG_MESSAGE@) - if(@MESSAGE_ZMQ@) - find_ependency(ZMQ REQUIRED) - endif() - endif() - if(@PKG_MSCG@) - find_ependency(GSL REQUIRED) - find_ependency(MSCG REQUIRED) - endif() - if(@USER-NETCDF@) - if(@NETCDF_FOUND@) - find_ependency(NetCDF REQUIRED) - endif() - if(@PNETCDF_FOUND@) - find_ependency(PNetCDF REQUIRED) - endif() - endif() - if(@PKG_QUIP@) - find_ependency(QUIP REQUIRED) - endif() -endif() include("${CMAKE_CURRENT_LIST_DIR}/LAMMPS_Targets.cmake") diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index 9299914b9b..5033c1f0f1 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -365,9 +365,6 @@ if(NOT BUILD_MPI) else() target_link_libraries(gpu PRIVATE MPI::MPI_CXX) endif() -if(NOT BUILD_SHARED_LIBS) - install(TARGETS gpu EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() target_compile_definitions(gpu PRIVATE -DLAMMPS_${LAMMPS_SIZES}) set_target_properties(gpu PROPERTIES OUTPUT_NAME lammps_gpu${LAMMPS_MACHINE}) target_sources(lammps PRIVATE ${GPU_SOURCES}) diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 278a6b5afc..d74b82b036 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -56,9 +56,6 @@ if(DOWNLOAD_KIM) INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include/kim-api") target_link_libraries(lammps PRIVATE LAMMPS::KIM) add_dependencies(LAMMPS::KIM kim_build) - if(NOT BUILD_SHARED_LIBS) - install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")") - endif() else() find_package(PkgConfig REQUIRED) pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=${KIM-API_MIN_VERSION}) diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index eb549519d1..df100f63f8 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -49,9 +49,6 @@ if(DOWNLOAD_KOKKOS) INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}) target_link_libraries(lammps PRIVATE LAMMPS::KOKKOS) add_dependencies(LAMMPS::KOKKOS kokkos_build) - if(NOT BUILD_SHARED_LIBS) - install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")") - endif() elseif(EXTERNAL_KOKKOS) find_package(Kokkos 3.1) if(NOT Kokkos_FOUND) diff --git a/cmake/Modules/Packages/LATTE.cmake b/cmake/Modules/Packages/LATTE.cmake index a2a94755ab..ce46569a3f 100644 --- a/cmake/Modules/Packages/LATTE.cmake +++ b/cmake/Modules/Packages/LATTE.cmake @@ -34,9 +34,6 @@ if(DOWNLOAD_LATTE) INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}") target_link_libraries(lammps PRIVATE LAMMPS::LATTE) add_dependencies(LAMMPS::LATTE latte_build) - if(NOT BUILD_SHARED_LIBS) - install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")") - endif() else() find_package(LATTE) if(NOT LATTE_FOUND) diff --git a/cmake/Modules/Packages/MESSAGE.cmake b/cmake/Modules/Packages/MESSAGE.cmake index e1dc4c1072..fb62763828 100644 --- a/cmake/Modules/Packages/MESSAGE.cmake +++ b/cmake/Modules/Packages/MESSAGE.cmake @@ -7,9 +7,6 @@ file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp) add_library(cslib STATIC ${cslib_SOURCES}) -if(NOT BUILD_SHARED_LIBS) - install(TARGETS cslib EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() target_compile_definitions(cslib PRIVATE -DLAMMPS_${LAMMPS_SIZES}) set_target_properties(cslib PROPERTIES OUTPUT_NAME lammps_cslib${LAMMPS_MACHINE}) if(BUILD_MPI) diff --git a/cmake/Modules/Packages/MSCG.cmake b/cmake/Modules/Packages/MSCG.cmake index 668d318d68..55f71588fe 100644 --- a/cmake/Modules/Packages/MSCG.cmake +++ b/cmake/Modules/Packages/MSCG.cmake @@ -35,9 +35,6 @@ if(DOWNLOAD_MSCG) INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}") target_link_libraries(lammps PRIVATE LAMMPS::MSCG) add_dependencies(LAMMPS::MSCG mscg_build) - if(NOT BUILD_SHARED_LIBS) - install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")") - endif() else() find_package(MSCG) if(NOT MSCG_FOUND) diff --git a/cmake/Modules/Packages/USER-COLVARS.cmake b/cmake/Modules/Packages/USER-COLVARS.cmake index 31e64e3790..92595a9c8a 100644 --- a/cmake/Modules/Packages/USER-COLVARS.cmake +++ b/cmake/Modules/Packages/USER-COLVARS.cmake @@ -9,9 +9,6 @@ if(COLVARS_LEPTON) set(LEPTON_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars/lepton) file(GLOB LEPTON_SOURCES ${LEPTON_DIR}/src/[^.]*.cpp) add_library(lepton STATIC ${LEPTON_SOURCES}) - if(NOT BUILD_SHARED_LIBS) - install(TARGETS lepton EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() # Change the define below to LEPTON_BUILDING_SHARED_LIBRARY when linking Lepton as a DLL with MSVC target_compile_definitions(lepton PRIVATE -DLEPTON_BUILDING_STATIC_LIBRARY) set_target_properties(lepton PROPERTIES OUTPUT_NAME lammps_lepton${LAMMPS_MACHINE}) @@ -19,9 +16,6 @@ if(COLVARS_LEPTON) endif() add_library(colvars STATIC ${COLVARS_SOURCES}) -if(NOT BUILD_SHARED_LIBS) - install(TARGETS colvars EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() target_compile_definitions(colvars PRIVATE -DLAMMPS_${LAMMPS_SIZES}) set_target_properties(colvars PROPERTIES OUTPUT_NAME lammps_colvars${LAMMPS_MACHINE}) target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars) diff --git a/cmake/Modules/Packages/USER-MOLFILE.cmake b/cmake/Modules/Packages/USER-MOLFILE.cmake index dd6435e56b..1a2df2202b 100644 --- a/cmake/Modules/Packages/USER-MOLFILE.cmake +++ b/cmake/Modules/Packages/USER-MOLFILE.cmake @@ -1,8 +1,5 @@ set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers") add_library(molfile INTERFACE) -if(NOT BUILD_SHARED_LIBS) - install(TARGETS molfile EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS}) # no need to link with -ldl on windows if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") diff --git a/cmake/Modules/Packages/USER-PLUMED.cmake b/cmake/Modules/Packages/USER-PLUMED.cmake index 102ce7a7ad..39148bdf3d 100644 --- a/cmake/Modules/Packages/USER-PLUMED.cmake +++ b/cmake/Modules/Packages/USER-PLUMED.cmake @@ -70,9 +70,6 @@ if(DOWNLOAD_PLUMED) ExternalProject_get_property(plumed_build INSTALL_DIR) add_library(LAMMPS::PLUMED UNKNOWN IMPORTED) add_dependencies(LAMMPS::PLUMED plumed_build) - if(NOT BUILD_SHARED_LIBS) - install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")") - endif() if(PLUMED_MODE STREQUAL "STATIC") set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumed.a INTERFACE_LINK_LIBRARIES "${PLUMED_LINK_LIBS};${CMAKE_DL_LIBS}") elseif(PLUMED_MODE STREQUAL "SHARED") diff --git a/cmake/Modules/Packages/USER-QMMM.cmake b/cmake/Modules/Packages/USER-QMMM.cmake index 76bb76fa5a..c613067349 100644 --- a/cmake/Modules/Packages/USER-QMMM.cmake +++ b/cmake/Modules/Packages/USER-QMMM.cmake @@ -1,12 +1,6 @@ enable_language(C) -if(NOT BUILD_SHARED_LIBS) - message(WARNING "It is recommended to use BUILD_SHARED_LIBS=yes with USER-QMMM") -endif() add_library(qmmm STATIC ${LAMMPS_LIB_SOURCE_DIR}/qmmm/libqmmm.c) -if(NOT BUILD_SHARED_LIBS) - install(TARGETS qmmm EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() set_target_properties(qmmm PROPERTIES OUTPUT_NAME lammps_qmmm${LAMMPS_MACHINE}) target_link_libraries(lammps PRIVATE qmmm) target_include_directories(qmmm PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/qmmm) diff --git a/cmake/Modules/Packages/USER-SCAFACOS.cmake b/cmake/Modules/Packages/USER-SCAFACOS.cmake index ee12e754e6..d92a83f7c1 100644 --- a/cmake/Modules/Packages/USER-SCAFACOS.cmake +++ b/cmake/Modules/Packages/USER-SCAFACOS.cmake @@ -52,9 +52,6 @@ if(DOWNLOAD_SCAFACOS) INTERFACE_LINK_LIBRARIES "${INSTALL_DIR}/lib/libfcs.a;${INSTALL_DIR}/lib/libfcs_direct.a;${INSTALL_DIR}/lib/libfcs_ewald.a;${INSTALL_DIR}/lib/libfcs_fmm.a;${INSTALL_DIR}/lib/libfcs_p2nfft.a;${INSTALL_DIR}/lib/libfcs_p3m.a;GSL::gsl;${INSTALL_DIR}/lib/libfcs_near.a;${INSTALL_DIR}/lib/libfcs_gridsort.a;${INSTALL_DIR}/lib/libfcs_resort.a;${INSTALL_DIR}/lib/libfcs_redist.a;${INSTALL_DIR}/lib/libfcs_common.a;${INSTALL_DIR}/lib/libfcs_pnfft.a;${INSTALL_DIR}/lib/libfcs_pfft.a;${INSTALL_DIR}/lib/libfcs_fftw3_mpi.a;${INSTALL_DIR}/lib/libfcs_fftw3.a;MPI::MPI_Fortran;MPI::MPI_C") target_link_libraries(lammps PRIVATE LAMMPS::SCAFACOS) add_dependencies(LAMMPS::SCAFACOS scafacos_build) - if(NOT BUILD_SHARED_LIBS) - install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")") - endif() else() find_package(PkgConfig REQUIRED) pkg_check_modules(SCAFACOS REQUIRED IMPORTED_TARGET scafacos) diff --git a/cmake/Modules/Packages/USER-SMD.cmake b/cmake/Modules/Packages/USER-SMD.cmake index 0a5165471c..6984b24d52 100644 --- a/cmake/Modules/Packages/USER-SMD.cmake +++ b/cmake/Modules/Packages/USER-SMD.cmake @@ -18,9 +18,6 @@ if(DOWNLOAD_EIGEN3) set_target_properties(LAMMPS::EIGEN3 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}") target_link_libraries(lammps PRIVATE LAMMPS::EIGEN3) add_dependencies(LAMMPS::EIGEN3 Eigen3_build) - if(NOT BUILD_SHARED_LIBS) - install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")") - endif() else() find_package(Eigen3 NO_MODULE) mark_as_advanced(Eigen3_DIR) diff --git a/cmake/Modules/Packages/VORONOI.cmake b/cmake/Modules/Packages/VORONOI.cmake index 4635466a50..39d494928b 100644 --- a/cmake/Modules/Packages/VORONOI.cmake +++ b/cmake/Modules/Packages/VORONOI.cmake @@ -35,9 +35,6 @@ if(DOWNLOAD_VORO) INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/src") target_link_libraries(lammps PRIVATE LAMMPS::VORO) add_dependencies(LAMMPS::VORO voro_build) - if(NOT BUILD_SHARED_LIBS) - install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")") - endif() else() find_package(VORO) if(NOT VORO_FOUND) diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 8230a88986..6a952fbd90 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -87,7 +87,7 @@ KOKKOS, o = USER-OMP, t = OPT. * :doc:`msd/chunk ` * :doc:`msd/nongauss ` * :doc:`omega/chunk ` - * :doc:`orientorder/atom ` + * :doc:`orientorder/atom (k) ` * :doc:`pair ` * :doc:`pair/local ` * :doc:`pe ` diff --git a/doc/src/Howto_cmake.rst b/doc/src/Howto_cmake.rst index db7b88dc3d..fa6038efb5 100644 --- a/doc/src/Howto_cmake.rst +++ b/doc/src/Howto_cmake.rst @@ -378,9 +378,9 @@ change some variables later with additional *-D* flags. A few examples: .. code-block:: bash - cmake -C ../cmake/preset/minimal.cmake -D PKG_MISC=on ../cmake - cmake -C ../cmake/preset/clang.cmake -C ../cmake/preset/most.cmake ../cmake - cmake -C ../cmake/preset/minimal.cmake -D BUILD_MPI=off ../cmake + cmake -C ../cmake/presets/minimal.cmake -D PKG_MISC=on ../cmake + cmake -C ../cmake/presets/clang.cmake -C ../cmake/presets/most.cmake ../cmake + cmake -C ../cmake/presets/minimal.cmake -D BUILD_MPI=off ../cmake The first command will install the packages ``KSPACE``, ``MANYBODY``, ``MOLECULE``, ``RIGID`` and ``MISC``; the first four from the preset @@ -396,7 +396,7 @@ It is also possible to do this incrementally. .. code-block:: bash - cmake -C ../cmake/preset/minimal.cmake ../cmake + cmake -C ../cmake/presets/minimal.cmake ../cmake cmake -D PKG_MISC=on . will achieve the same configuration like in the first example above. In diff --git a/doc/src/Install_linux.rst b/doc/src/Install_linux.rst index ec4f3fcc8e..ca3f794fc2 100644 --- a/doc/src/Install_linux.rst +++ b/doc/src/Install_linux.rst @@ -24,12 +24,13 @@ allows you to install LAMMPS with a single command, and stay up-to-date with the current version of LAMMPS by simply updating your operating system. -To install the appropriate personal-package archive (PPA), do the +To install the appropriate personal-package archives (PPAs), do the following once: .. code-block:: bash $ sudo add-apt-repository ppa:gladky-anton/lammps + $ sudo add-apt-repository ppa:openkim/latest $ sudo apt-get update To install LAMMPS do the following once: @@ -38,7 +39,7 @@ To install LAMMPS do the following once: $ sudo apt-get install lammps-daily -This downloads an executable named "lmp_daily" to your box, which +This downloads an executable named ``lmp_daily`` to your box, which can then be used in the usual way to run input scripts: .. code-block:: bash @@ -60,11 +61,29 @@ To get a copy of the current documentation and examples: $ sudo apt-get install lammps-daily-doc which will download the doc files in -/usr/share/doc/lammps-daily-doc/doc and example problems in -/usr/share/doc/lammps-doc/examples. +``/usr/share/doc/lammps-daily-doc/doc`` and example problems in +``/usr/share/doc/lammps-doc/examples``. -Note that you may still wish to download the tarball to get potential -files and auxiliary tools. +To get a copy of the current potentials files: + +.. code-block:: bash + + $ sudo apt-get install lammps-daily-data + +which will download the potentials files to +``/usr/share/lammps-daily/potentials``. The ``lmp_daily`` binary is +hard-coded to look for potential files in this directory (it does not +use the `LAMMPS_POTENTIALS` environment variable, as described +in :doc:`pair_coeff ` command). + +The ``lmp_daily`` binary is built with the :ref:`KIM package ` which +results in the above command also installing the `kim-api` binaries when LAMMPS +is installed. In order to use potentials from `openkim.org `_, you +can install the `openkim-models` package + +.. code-block:: bash + + $ sudo apt-get install openkim-models To un-install LAMMPS, do the following: @@ -72,17 +91,8 @@ To un-install LAMMPS, do the following: $ sudo apt-get remove lammps-daily -Note that the lammps-daily executable is built with the following -sequence of make commands, as if you had done the same with the -unpacked tarball files in the src directory: - -.. code-block:: bash - - $ make yes-all - $ make no-lib - $ make mpi - -Thus it builds with FFTW3 and OpenMPI. +Please use ``lmp_daily -help`` to see which compilation options, packages, +and styles are included in the binary. Thanks to Anton Gladky (gladky.anton at gmail.com) for setting up this Ubuntu package capability. @@ -103,14 +113,14 @@ linking to the C library interface (lammps-devel, lammps-mpich-devel, lammps-openmpi-devel), the header for compiling programs using the C library interface (lammps-headers), and the LAMMPS python module for Python 3. All packages can be installed at the same -time and the name of the LAMMPS executable is *lmp* and *lmp_openmpi* -or *lmp_mpich* respectively. By default, *lmp* will refer to the +time and the name of the LAMMPS executable is ``lmp`` and ``lmp_openmpi`` +or ``lmp_mpich`` respectively. By default, ``lmp`` will refer to the serial executable, unless one of the MPI environment modules is loaded -("module load mpi/mpich-x86_64" or "module load mpi/openmpi-x86_64"). +(``module load mpi/mpich-x86_64`` or ``module load mpi/openmpi-x86_64``). Then the corresponding parallel LAMMPS executable can be used. The same mechanism applies when loading the LAMMPS python module. -To install LAMMPS with OpenMPI and run an input in.lj with 2 CPUs do: +To install LAMMPS with OpenMPI and run an input ``in.lj`` with 2 CPUs do: .. code-block:: bash @@ -118,10 +128,10 @@ To install LAMMPS with OpenMPI and run an input in.lj with 2 CPUs do: $ module load mpi/openmpi-x86_64 $ mpirun -np 2 lmp -in in.lj -The "dnf install" command is needed only once. In case of a new LAMMPS -stable release, "dnf update" will automatically update to the newer +The ``dnf install`` command is needed only once. In case of a new LAMMPS +stable release, ``dnf update`` will automatically update to the newer version as soon at the RPM files are built and uploaded to the download -mirrors. The "module load" command is needed once per (shell) session +mirrors. The ``module load`` command is needed once per (shell) session or shell terminal instance, unless it is automatically loaded from the shell profile. @@ -134,7 +144,7 @@ can install the `openkim-models` package $ dnf install openkim-models -Please use "lmp -help" to see which compilation options, packages, +Please use ``lmp -help`` to see which compilation options, packages, and styles are included in the binary. Thanks to Christoph Junghans (LANL) for making LAMMPS available in Fedora. @@ -153,10 +163,10 @@ in the `Extra Packages for Enterprise Linux (EPEL) repository ` which diff --git a/doc/src/compute_orientorder_atom.rst b/doc/src/compute_orientorder_atom.rst index a967a6006c..34b12cb745 100644 --- a/doc/src/compute_orientorder_atom.rst +++ b/doc/src/compute_orientorder_atom.rst @@ -4,7 +4,7 @@ compute orientorder/atom command ================================ compute orientorder/atom/kk command -======================= +=================================== Syntax """""" diff --git a/src/KOKKOS/angle_charmm_kokkos.cpp b/src/KOKKOS/angle_charmm_kokkos.cpp index 245aead73e..8d7a4d23d6 100644 --- a/src/KOKKOS/angle_charmm_kokkos.cpp +++ b/src/KOKKOS/angle_charmm_kokkos.cpp @@ -72,21 +72,21 @@ void AngleCharmmKokkos::compute(int eflag_in, int vflag_in) //if(k_eatom.extent(0)destroy_kokkos(k_eatom,eatom); memoryKK->create_kokkos(k_eatom,eatom,maxeatom,"improper:eatom"); - d_eatom = k_eatom.template view(); + d_eatom = k_eatom.template view(); //} } if (vflag_atom) { //if(k_vatom.extent(0)destroy_kokkos(k_vatom,vatom); memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"improper:vatom"); - d_vatom = k_vatom.template view(); + d_vatom = k_vatom.template view(); //} } x = atomKK->k_x.view(); f = atomKK->k_f.view(); neighborKK->k_anglelist.template sync(); - anglelist = neighborKK->k_anglelist.view(); + anglelist = neighborKK->k_anglelist.view(); int nanglelist = neighborKK->nanglelist; nlocal = atom->nlocal; newton_bond = force->newton_bond; @@ -265,10 +265,10 @@ void AngleCharmmKokkos::coeff(int narg, char **arg) AngleCharmm::coeff(narg, arg); int n = atom->nangletypes; - Kokkos::DualView k_k("AngleCharmm::k",n+1); - Kokkos::DualView k_theta0("AngleCharmm::theta0",n+1); - Kokkos::DualView k_k_ub("AngleCharmm::k_ub",n+1); - Kokkos::DualView k_r_ub("AngleCharmm::r_ub",n+1); + typename AT::tdual_ffloat_1d k_k("AngleCharmm::k",n+1); + typename AT::tdual_ffloat_1d k_theta0("AngleCharmm::theta0",n+1); + typename AT::tdual_ffloat_1d k_k_ub("AngleCharmm::k_ub",n+1); + typename AT::tdual_ffloat_1d k_r_ub("AngleCharmm::r_ub",n+1); d_k = k_k.template view(); d_theta0 = k_theta0.template view(); @@ -303,10 +303,10 @@ void AngleCharmmKokkos::read_restart(FILE *fp) AngleCharmm::read_restart(fp); int n = atom->nangletypes; - Kokkos::DualView k_k("AngleCharmm::k",n+1); - Kokkos::DualView k_theta0("AngleCharmm::theta0",n+1); - Kokkos::DualView k_k_ub("AngleCharmm::k_ub",n+1); - Kokkos::DualView k_r_ub("AngleCharmm::r_ub",n+1); + typename AT::tdual_ffloat_1d k_k("AngleCharmm::k",n+1); + typename AT::tdual_ffloat_1d k_theta0("AngleCharmm::theta0",n+1); + typename AT::tdual_ffloat_1d k_k_ub("AngleCharmm::k_ub",n+1); + typename AT::tdual_ffloat_1d k_r_ub("AngleCharmm::r_ub",n+1); d_k = k_k.template view(); d_theta0 = k_theta0.template view(); diff --git a/src/KOKKOS/angle_charmm_kokkos.h b/src/KOKKOS/angle_charmm_kokkos.h index 865439b83a..c7f64d4c22 100644 --- a/src/KOKKOS/angle_charmm_kokkos.h +++ b/src/KOKKOS/angle_charmm_kokkos.h @@ -63,11 +63,13 @@ class AngleCharmmKokkos : public AngleCharmm { typedef ArrayTypes AT; typename AT::t_x_array_randomread x; - typename Kokkos::View::value,Kokkos::MemoryTraits > f; + + typedef typename KKDevice::value KKDeviceType; + typename Kokkos::View > f; typename AT::t_int_2d anglelist; - Kokkos::DualView k_eatom; - Kokkos::DualView k_vatom; + Kokkos::DualView k_eatom; + Kokkos::DualView k_vatom; Kokkos::View::value,Kokkos::MemoryTraits > d_eatom; Kokkos::View::value,Kokkos::MemoryTraits > d_vatom; diff --git a/src/KOKKOS/atom_vec_kokkos.h b/src/KOKKOS/atom_vec_kokkos.h index 0474a2380a..2111e73208 100644 --- a/src/KOKKOS/atom_vec_kokkos.h +++ b/src/KOKKOS/atom_vec_kokkos.h @@ -153,15 +153,7 @@ class AtomVecKokkos : public AtomVec { buffer = Kokkos::kokkos_realloc(buffer,src.span()); buffer_size = src.span(); } - return mirror_type( buffer , - src.extent(0) , - src.extent(1) , - src.extent(2) , - src.extent(3) , - src.extent(4) , - src.extent(5) , - src.extent(6) , - src.extent(7) ); + return mirror_type(buffer, src.d_view.layout()); } template @@ -179,15 +171,8 @@ class AtomVecKokkos : public AtomVec { buffer = Kokkos::kokkos_realloc(buffer,src.span()*sizeof(typename ViewType::value_type)); buffer_size = src.span(); } - mirror_type tmp_view( (typename ViewType::value_type*)buffer , - src.extent(0) , - src.extent(1) , - src.extent(2) , - src.extent(3) , - src.extent(4) , - src.extent(5) , - src.extent(6) , - src.extent(7) ); + mirror_type tmp_view((typename ViewType::value_type*)buffer, src.d_view.layout()); + if(space == Device) { Kokkos::deep_copy(LMPHostType(),tmp_view,src.h_view), Kokkos::deep_copy(LMPHostType(),src.d_view,tmp_view); diff --git a/src/KOKKOS/bond_harmonic_kokkos.cpp b/src/KOKKOS/bond_harmonic_kokkos.cpp index e0d75dcd9a..4e2a5aaa05 100644 --- a/src/KOKKOS/bond_harmonic_kokkos.cpp +++ b/src/KOKKOS/bond_harmonic_kokkos.cpp @@ -69,14 +69,14 @@ void BondHarmonicKokkos::compute(int eflag_in, int vflag_in) //if(k_eatom.extent(0)destroy_kokkos(k_eatom,eatom); memoryKK->create_kokkos(k_eatom,eatom,maxeatom,"improper:eatom"); - d_eatom = k_eatom.template view(); + d_eatom = k_eatom.template view(); //} } if (vflag_atom) { //if(k_vatom.extent(0)destroy_kokkos(k_vatom,vatom); memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"improper:vatom"); - d_vatom = k_vatom.template view(); + d_vatom = k_vatom.template view(); //} } @@ -204,8 +204,8 @@ void BondHarmonicKokkos::coeff(int narg, char **arg) BondHarmonic::coeff(narg, arg); int n = atom->nbondtypes; - Kokkos::DualView k_k("BondHarmonic::k",n+1); - Kokkos::DualView k_r0("BondHarmonic::r0",n+1); + typename AT::tdual_ffloat_1d k_k("BondHarmonic::k",n+1); + typename AT::tdual_ffloat_1d k_r0("BondHarmonic::r0",n+1); d_k = k_k.template view(); d_r0 = k_r0.template view(); @@ -231,8 +231,8 @@ void BondHarmonicKokkos::read_restart(FILE *fp) BondHarmonic::read_restart(fp); int n = atom->nbondtypes; - Kokkos::DualView k_k("BondHarmonic::k",n+1); - Kokkos::DualView k_r0("BondHarmonic::r0",n+1); + typename AT::tdual_ffloat_1d k_k("BondHarmonic::k",n+1); + typename AT::tdual_ffloat_1d k_r0("BondHarmonic::r0",n+1); d_k = k_k.template view(); d_r0 = k_r0.template view(); diff --git a/src/KOKKOS/bond_harmonic_kokkos.h b/src/KOKKOS/bond_harmonic_kokkos.h index b5bee7e909..cf716ec843 100644 --- a/src/KOKKOS/bond_harmonic_kokkos.h +++ b/src/KOKKOS/bond_harmonic_kokkos.h @@ -66,10 +66,11 @@ class BondHarmonicKokkos : public BondHarmonic { typename Kokkos::View::value,Kokkos::MemoryTraits > f; typename AT::t_int_2d bondlist; - Kokkos::DualView k_eatom; - Kokkos::DualView k_vatom; - Kokkos::View::value,Kokkos::MemoryTraits > d_eatom; - Kokkos::View::value,Kokkos::MemoryTraits > d_vatom; + typedef typename KKDevice::value KKDeviceType; + Kokkos::DualView k_eatom; + Kokkos::DualView k_vatom; + Kokkos::View > d_eatom; + Kokkos::View > d_vatom; int nlocal,newton_bond; int eflag,vflag; diff --git a/src/KOKKOS/dihedral_charmm_kokkos.cpp b/src/KOKKOS/dihedral_charmm_kokkos.cpp index 06f25ee0a2..64ab79c305 100644 --- a/src/KOKKOS/dihedral_charmm_kokkos.cpp +++ b/src/KOKKOS/dihedral_charmm_kokkos.cpp @@ -28,6 +28,7 @@ #include "memory_kokkos.h" #include "error.h" #include "atom_masks.h" +#include "kokkos.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -69,6 +70,9 @@ void DihedralCharmmKokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; + if (lmp->kokkos->neighflag == FULL) + error->all(FLERR,"Dihedral_style charmm/kk requires half neighbor list"); + ev_init(eflag,vflag,0); // insure pair->ev_tally() will use 1-4 virial contribution @@ -82,18 +86,18 @@ void DihedralCharmmKokkos::compute(int eflag_in, int vflag_in) //if(k_eatom.extent(0)destroy_kokkos(k_eatom,eatom); memoryKK->create_kokkos(k_eatom,eatom,maxeatom,"dihedral:eatom"); - d_eatom = k_eatom.template view(); - k_eatom_pair = Kokkos::DualView("dihedral:eatom_pair",maxeatom); - d_eatom_pair = k_eatom.template view(); + d_eatom = k_eatom.template view(); + k_eatom_pair = Kokkos::DualView("dihedral:eatom_pair",maxeatom); + d_eatom_pair = k_eatom_pair.template view(); //} } if (vflag_atom) { //if(k_vatom.extent(0)destroy_kokkos(k_vatom,vatom); memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"dihedral:vatom"); - d_vatom = k_vatom.template view(); - k_vatom_pair = Kokkos::DualView("dihedral:vatom_pair",maxvatom); - d_vatom_pair = k_vatom.template view(); + d_vatom = k_vatom.template view(); + k_vatom_pair = Kokkos::DualView("dihedral:vatom_pair",maxvatom); + d_vatom_pair = k_vatom_pair.template view(); //} } @@ -424,12 +428,12 @@ void DihedralCharmmKokkos::coeff(int narg, char **arg) DihedralCharmm::coeff(narg, arg); int nd = atom->ndihedraltypes; - Kokkos::DualView k_k("DihedralCharmm::k",nd+1); - Kokkos::DualView k_multiplicity("DihedralCharmm::multiplicity",nd+1); - Kokkos::DualView k_shift("DihedralCharmm::shift",nd+1); - Kokkos::DualView k_cos_shift("DihedralCharmm::cos_shift",nd+1); - Kokkos::DualView k_sin_shift("DihedralCharmm::sin_shift",nd+1); - Kokkos::DualView k_weight("DihedralCharmm::weight",nd+1); + typename AT::tdual_ffloat_1d k_k("DihedralCharmm::k",nd+1); + typename AT::tdual_ffloat_1d k_multiplicity("DihedralCharmm::multiplicity",nd+1); + typename AT::tdual_ffloat_1d k_shift("DihedralCharmm::shift",nd+1); + typename AT::tdual_ffloat_1d k_cos_shift("DihedralCharmm::cos_shift",nd+1); + typename AT::tdual_ffloat_1d k_sin_shift("DihedralCharmm::sin_shift",nd+1); + typename AT::tdual_ffloat_1d k_weight("DihedralCharmm::weight",nd+1); d_k = k_k.template view(); d_multiplicity = k_multiplicity.template view(); @@ -473,10 +477,10 @@ void DihedralCharmmKokkos::init_style() DihedralCharmm::init_style(); int n = atom->ntypes; - Kokkos::DualView k_lj14_1("DihedralCharmm:lj14_1",n+1,n+1); - Kokkos::DualView k_lj14_2("DihedralCharmm:lj14_2",n+1,n+1); - Kokkos::DualView k_lj14_3("DihedralCharmm:lj14_3",n+1,n+1); - Kokkos::DualView k_lj14_4("DihedralCharmm:lj14_4",n+1,n+1); + DAT::tdual_ffloat_2d k_lj14_1("DihedralCharmm:lj14_1",n+1,n+1); + DAT::tdual_ffloat_2d k_lj14_2("DihedralCharmm:lj14_2",n+1,n+1); + DAT::tdual_ffloat_2d k_lj14_3("DihedralCharmm:lj14_3",n+1,n+1); + DAT::tdual_ffloat_2d k_lj14_4("DihedralCharmm:lj14_4",n+1,n+1); d_lj14_1 = k_lj14_1.template view(); d_lj14_2 = k_lj14_2.template view(); @@ -517,12 +521,12 @@ void DihedralCharmmKokkos::read_restart(FILE *fp) DihedralCharmm::read_restart(fp); int nd = atom->ndihedraltypes; - Kokkos::DualView k_k("DihedralCharmm::k",nd+1); - Kokkos::DualView k_multiplicity("DihedralCharmm::multiplicity",nd+1); - Kokkos::DualView k_shift("DihedralCharmm::shift",nd+1); - Kokkos::DualView k_cos_shift("DihedralCharmm::cos_shift",nd+1); - Kokkos::DualView k_sin_shift("DihedralCharmm::sin_shift",nd+1); - Kokkos::DualView k_weight("DihedralCharmm::weight",nd+1); + typename AT::tdual_ffloat_1d k_k("DihedralCharmm::k",nd+1); + typename AT::tdual_ffloat_1d k_multiplicity("DihedralCharmm::multiplicity",nd+1); + typename AT::tdual_ffloat_1d k_shift("DihedralCharmm::shift",nd+1); + typename AT::tdual_ffloat_1d k_cos_shift("DihedralCharmm::cos_shift",nd+1); + typename AT::tdual_ffloat_1d k_sin_shift("DihedralCharmm::sin_shift",nd+1); + typename AT::tdual_ffloat_1d k_weight("DihedralCharmm::weight",nd+1); d_k = k_k.template view(); d_multiplicity = k_multiplicity.template view(); diff --git a/src/KOKKOS/dihedral_charmm_kokkos.h b/src/KOKKOS/dihedral_charmm_kokkos.h index 21bb6fd2e1..828abd2be7 100644 --- a/src/KOKKOS/dihedral_charmm_kokkos.h +++ b/src/KOKKOS/dihedral_charmm_kokkos.h @@ -132,15 +132,16 @@ class DihedralCharmmKokkos : public DihedralCharmm { typename AT::t_f_array f; typename AT::t_int_2d dihedrallist; - Kokkos::DualView k_eatom; - Kokkos::DualView k_vatom; - Kokkos::View::value,Kokkos::MemoryTraits > d_eatom; - Kokkos::View::value,Kokkos::MemoryTraits > d_vatom; + typedef typename KKDevice::value KKDeviceType; + Kokkos::DualView k_eatom; + Kokkos::DualView k_vatom; + Kokkos::View > d_eatom; + Kokkos::View > d_vatom; - Kokkos::DualView k_eatom_pair; - Kokkos::DualView k_vatom_pair; - Kokkos::View::value,Kokkos::MemoryTraits > d_eatom_pair; - Kokkos::View::value,Kokkos::MemoryTraits > d_vatom_pair; + Kokkos::DualView k_eatom_pair; + Kokkos::DualView k_vatom_pair; + Kokkos::View > d_eatom_pair; + Kokkos::View > d_vatom_pair; int nlocal,newton_bond; int eflag,vflag; diff --git a/src/KOKKOS/fix_qeq_reax_kokkos.cpp b/src/KOKKOS/fix_qeq_reax_kokkos.cpp index a0f4f3ec28..10d33ead45 100644 --- a/src/KOKKOS/fix_qeq_reax_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reax_kokkos.cpp @@ -39,8 +39,6 @@ using namespace FixConst; #define SMALL 0.0001 #define EV_TO_KCAL_PER_MOL 14.4 -#define TEAMSIZE 128 - /* ---------------------------------------------------------------------- */ template @@ -726,7 +724,9 @@ void FixQEqReaxKokkos::cg_solve1() const int inum = list->inum; F_FLOAT tmp, sig_old, b_norm; - const int teamsize = TEAMSIZE; + int teamsize; + if (execution_space == Host) teamsize = 1; + else teamsize = 128; // sparse_matvec( &H, x, q ); FixQEqReaxKokkosSparse12Functor sparse12_functor(this); @@ -861,7 +861,9 @@ void FixQEqReaxKokkos::cg_solve2() const int inum = list->inum; F_FLOAT tmp, sig_old, b_norm; - const int teamsize = TEAMSIZE; + int teamsize; + if (execution_space == Host) teamsize = 1; + else teamsize = 128; // sparse_matvec( &H, x, q ); FixQEqReaxKokkosSparse32Functor sparse32_functor(this); diff --git a/src/KOKKOS/improper_harmonic_kokkos.cpp b/src/KOKKOS/improper_harmonic_kokkos.cpp index 6a32e8af47..6f2969722a 100644 --- a/src/KOKKOS/improper_harmonic_kokkos.cpp +++ b/src/KOKKOS/improper_harmonic_kokkos.cpp @@ -73,14 +73,14 @@ void ImproperHarmonicKokkos::compute(int eflag_in, int vflag_in) //if(k_eatom.extent(0)destroy_kokkos(k_eatom,eatom); memoryKK->create_kokkos(k_eatom,eatom,maxeatom,"improper:eatom"); - d_eatom = k_eatom.template view(); + d_eatom = k_eatom.template view(); //} } if (vflag_atom) { //if(k_vatom.extent(0)destroy_kokkos(k_vatom,vatom); memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"improper:vatom"); - d_vatom = k_vatom.template view(); + d_vatom = k_vatom.template view(); //} } diff --git a/src/KOKKOS/improper_harmonic_kokkos.h b/src/KOKKOS/improper_harmonic_kokkos.h index fb44081928..e143e65adf 100644 --- a/src/KOKKOS/improper_harmonic_kokkos.h +++ b/src/KOKKOS/improper_harmonic_kokkos.h @@ -63,14 +63,15 @@ class ImproperHarmonicKokkos : public ImproperHarmonic { class NeighborKokkos *neighborKK; + typedef typename KKDevice::value KKDeviceType; typename AT::t_x_array_randomread x; - typename Kokkos::View::value,Kokkos::MemoryTraits > f; + typename Kokkos::View > f; typename AT::t_int_2d improperlist; - Kokkos::DualView k_eatom; - Kokkos::DualView k_vatom; - Kokkos::View::value,Kokkos::MemoryTraits > d_eatom; - Kokkos::View::value,Kokkos::MemoryTraits > d_vatom; + Kokkos::DualView k_eatom; + Kokkos::DualView k_vatom; + Kokkos::View > d_eatom; + Kokkos::View > d_vatom; int nlocal,newton_bond; int eflag,vflag; diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 8f60f3526d..f54df5cb76 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -306,7 +306,7 @@ void KokkosLMP::accelerator(int narg, char **arg) neighflag = HALFTHREAD; else neighflag = HALF; - } else if (strcmp(arg[iarg+1],"n2") == 0) neighflag = N2; + } else error->all(FLERR,"Illegal package kokkos command"); if (!neighflag_qeq_set) neighflag_qeq = neighflag; iarg += 2; @@ -318,7 +318,7 @@ void KokkosLMP::accelerator(int narg, char **arg) neighflag_qeq = HALFTHREAD; else neighflag_qeq = HALF; - } else if (strcmp(arg[iarg+1],"n2") == 0) neighflag_qeq = N2; + } else error->all(FLERR,"Illegal package kokkos command"); neighflag_qeq_set = 1; iarg += 2; diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index c8fccaf409..796f4612a4 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -22,7 +22,7 @@ #include #include -enum{FULL=1u,HALFTHREAD=2u,HALF=4u,N2=8u}; +enum{FULL=1u,HALFTHREAD=2u,HALF=4u}; #if defined(KOKKOS_ENABLE_CXX11) #undef ISFINITE diff --git a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp index b28bbebbeb..46c5ee82cb 100644 --- a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp @@ -307,9 +307,6 @@ void PairBuckCoulCutKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with buck/coul/cut/kk"); } diff --git a/src/KOKKOS/pair_buck_kokkos.cpp b/src/KOKKOS/pair_buck_kokkos.cpp index 990c9e94a6..04ebd6608b 100644 --- a/src/KOKKOS/pair_buck_kokkos.cpp +++ b/src/KOKKOS/pair_buck_kokkos.cpp @@ -229,9 +229,6 @@ void PairBuckKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with buck/kk"); } diff --git a/src/KOKKOS/pair_buck_kokkos.h b/src/KOKKOS/pair_buck_kokkos.h index 2691f10929..815b5b2dee 100644 --- a/src/KOKKOS/pair_buck_kokkos.h +++ b/src/KOKKOS/pair_buck_kokkos.h @@ -31,7 +31,7 @@ namespace LAMMPS_NS { template class PairBuckKokkos : public PairBuck { public: - enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF|N2}; + enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; enum {COUL_FLAG=0}; typedef DeviceType device_type; typedef ArrayTypes AT; @@ -98,15 +98,12 @@ class PairBuckKokkos : public PairBuck { friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend EV_FLOAT pair_compute_neighlist(PairBuckKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairBuckKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairBuckKokkos*,NeighListKokkos*); - friend EV_FLOAT pair_compute_neighlist(PairBuckKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute(PairBuckKokkos*,NeighListKokkos*); friend void pair_virial_fdotr_compute(PairBuckKokkos*); }; diff --git a/src/KOKKOS/pair_coul_debye_kokkos.cpp b/src/KOKKOS/pair_coul_debye_kokkos.cpp index b212bdc53a..a544a5fb8d 100644 --- a/src/KOKKOS/pair_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_coul_debye_kokkos.cpp @@ -276,9 +276,6 @@ void PairCoulDebyeKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with coul/debye/kk"); } diff --git a/src/KOKKOS/pair_kokkos.h b/src/KOKKOS/pair_kokkos.h index 54035c54eb..c28c858113 100644 --- a/src/KOKKOS/pair_kokkos.h +++ b/src/KOKKOS/pair_kokkos.h @@ -87,6 +87,8 @@ struct PairComputeFunctor { c(*c_ptr),list(*list_ptr) { // allocate duplicated memory f = c.f; + d_eatom = c.d_eatom; + d_vatom = c.d_vatom; dup_f = Kokkos::Experimental::create_scatter_view::value >(c.f); dup_eatom = Kokkos::Experimental::create_scatter_view::value >(c.d_eatom); dup_vatom = Kokkos::Experimental::create_scatter_view::value >(c.d_vatom); @@ -422,15 +424,15 @@ struct PairComputeFunctor { F_FLOAT evdwl = 0.0; if (c.eflag) { evdwl = factor_lj * c.template compute_evdwl(rsq,i,j,itype,jtype); - fev.evdwl += 0.5*evdwl; + fev_tmp.evdwl += 0.5*evdwl; } if (c.vflag_either) { - fev.v[0] += 0.5*delx*delx*fpair; - fev.v[1] += 0.5*dely*dely*fpair; - fev.v[2] += 0.5*delz*delz*fpair; - fev.v[3] += 0.5*delx*dely*fpair; - fev.v[4] += 0.5*delx*delz*fpair; - fev.v[5] += 0.5*dely*delz*fpair; + fev_tmp.v[0] += 0.5*delx*delx*fpair; + fev_tmp.v[1] += 0.5*dely*dely*fpair; + fev_tmp.v[2] += 0.5*delz*delz*fpair; + fev_tmp.v[3] += 0.5*delx*dely*fpair; + fev_tmp.v[4] += 0.5*delx*delz*fpair; + fev_tmp.v[5] += 0.5*dely*delz*fpair; } } },fev); @@ -479,8 +481,8 @@ struct PairComputeFunctor { const int inum = team.league_size(); const int atoms_per_team = team.team_size(); - int firstatom = team.league_rank()*atoms_per_team; - int lastatom = firstatom + atoms_per_team < inum ? firstatom + atoms_per_team : inum; + const int firstatom = team.league_rank()*atoms_per_team; + const int lastatom = firstatom + atoms_per_team < inum ? firstatom + atoms_per_team : inum; Kokkos::parallel_for(Kokkos::TeamThreadRange(team, firstatom, lastatom), [&] (const int &ii) { const int i = list.d_ilist[ii]; @@ -497,6 +499,7 @@ struct PairComputeFunctor { Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team,jnum), [&] (const int jj, FEV_FLOAT& fev_tmp) { + int j = neighbors_i(jj); const F_FLOAT factor_lj = c.special_lj[sbmask(j)]; const F_FLOAT factor_coul = c.special_coul[sbmask(j)]; @@ -516,29 +519,29 @@ struct PairComputeFunctor { if(rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) fpair+=c.template compute_fcoul(rsq,i,j,itype,jtype,factor_coul,qtmp); - fev.f[0] += delx*fpair; - fev.f[1] += dely*fpair; - fev.f[2] += delz*fpair; + fev_tmp.f[0] += delx*fpair; + fev_tmp.f[1] += dely*fpair; + fev_tmp.f[2] += delz*fpair; F_FLOAT evdwl = 0.0; F_FLOAT ecoul = 0.0; if (c.eflag) { if(rsq < (STACKPARAMS?c.m_cut_ljsq[itype][jtype]:c.d_cut_ljsq(itype,jtype))) { evdwl = factor_lj * c.template compute_evdwl(rsq,i,j,itype,jtype); - ev.evdwl += 0.5*evdwl; + fev_tmp.evdwl += 0.5*evdwl; } if(rsq < (STACKPARAMS?c.m_cut_coulsq[itype][jtype]:c.d_cut_coulsq(itype,jtype))) { ecoul = c.template compute_ecoul(rsq,i,j,itype,jtype,factor_coul,qtmp); - ev.ecoul += 0.5*ecoul; + fev_tmp.ecoul += 0.5*ecoul; } } - if (c.vflag) { - fev.v[0] += 0.5*delx*delx*fpair; - fev.v[1] += 0.5*dely*dely*fpair; - fev.v[2] += 0.5*delz*delz*fpair; - fev.v[3] += 0.5*delx*dely*fpair; - fev.v[4] += 0.5*delx*delz*fpair; - fev.v[5] += 0.5*dely*delz*fpair; + if (c.vflag_either) { + fev_tmp.v[0] += 0.5*delx*delx*fpair; + fev_tmp.v[1] += 0.5*dely*dely*fpair; + fev_tmp.v[2] += 0.5*delz*delz*fpair; + fev_tmp.v[3] += 0.5*delx*dely*fpair; + fev_tmp.v[4] += 0.5*delx*delz*fpair; + fev_tmp.v[5] += 0.5*dely*delz*fpair; } } },fev); @@ -690,148 +693,6 @@ struct PairComputeFunctor { } }; -template -struct PairComputeFunctor { - typedef typename PairStyle::device_type device_type ; - typedef EV_FLOAT value_type; - - PairStyle c; - NeighListKokkos list; - - PairComputeFunctor(PairStyle* c_ptr, - NeighListKokkos* list_ptr): - c(*c_ptr),list(*list_ptr) {}; - ~PairComputeFunctor() {c.cleanup_copy();list.copymode = 1;}; - - KOKKOS_INLINE_FUNCTION int sbmask(const int& j) const { - return j >> SBBITS & 3; - } - - - void contribute() {} - - template - KOKKOS_FUNCTION - EV_FLOAT compute_item(const int& ii, - const NeighListKokkos &list, const NoCoulTag&) const { - (void) list; - EV_FLOAT ev; - const int i = ii;//list.d_ilist[ii]; - const X_FLOAT xtmp = c.x(i,0); - const X_FLOAT ytmp = c.x(i,1); - const X_FLOAT ztmp = c.x(i,2); - const int itype = c.type(i); - - //const AtomNeighborsConst neighbors_i = list.get_neighbors_const(i); - const int jnum = c.nall; - - F_FLOAT fxtmp = 0.0; - F_FLOAT fytmp = 0.0; - F_FLOAT fztmp = 0.0; - - for (int jj = 0; jj < jnum; jj++) { - int j = jj;//neighbors_i(jj); - if(i==j) continue; - const F_FLOAT factor_lj = c.special_lj[sbmask(j)]; - j &= NEIGHMASK; - const X_FLOAT delx = xtmp - c.x(j,0); - const X_FLOAT dely = ytmp - c.x(j,1); - const X_FLOAT delz = ztmp - c.x(j,2); - const int jtype = c.type(j); - const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - - if(rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { - - const F_FLOAT fpair = factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); - fxtmp += delx*fpair; - fytmp += dely*fpair; - fztmp += delz*fpair; - - if (EVFLAG) { - F_FLOAT evdwl = 0.0; - if (c.eflag) { - evdwl = 0.5* - factor_lj * c.template compute_evdwl(rsq,i,j,itype,jtype); - ev.evdwl += evdwl; - } - - if (c.vflag_either || c.eflag_atom) ev_tally(ev,i,j,evdwl,fpair,delx,dely,delz); - } - } - } - - c.f(i,0) += fxtmp; - c.f(i,1) += fytmp; - c.f(i,2) += fztmp; - - return ev; - } - - KOKKOS_INLINE_FUNCTION - void ev_tally(EV_FLOAT &ev, const int &i, const int &j, - const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, - const F_FLOAT &dely, const F_FLOAT &delz) const - { - const int EFLAG = c.eflag; - const int VFLAG = c.vflag_either; - - if (EFLAG) { - if (c.eflag_atom) { - const E_FLOAT epairhalf = 0.5 * epair; - if (i < c.nlocal) c.d_eatom[i] += epairhalf; - if (j < c.nlocal) c.d_eatom[j] += epairhalf; - } - } - - if (VFLAG) { - const E_FLOAT v0 = delx*delx*fpair; - const E_FLOAT v1 = dely*dely*fpair; - const E_FLOAT v2 = delz*delz*fpair; - const E_FLOAT v3 = delx*dely*fpair; - const E_FLOAT v4 = delx*delz*fpair; - const E_FLOAT v5 = dely*delz*fpair; - - if (c.vflag_global) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; - } - - if (c.vflag_atom) { - if (i < c.nlocal) { - c.d_vatom(i,0) += 0.5*v0; - c.d_vatom(i,1) += 0.5*v1; - c.d_vatom(i,2) += 0.5*v2; - c.d_vatom(i,3) += 0.5*v3; - c.d_vatom(i,4) += 0.5*v4; - c.d_vatom(i,5) += 0.5*v5; - } - } - } - } - - KOKKOS_INLINE_FUNCTION - void operator()(const int i) const { - compute_item<0,0>(i,list,typename DoCoul::type()); - } - - KOKKOS_INLINE_FUNCTION - void operator()(const int i, value_type &energy_virial) const { - energy_virial += compute_item<1,0>(i,list,typename DoCoul::type()); - } - - KOKKOS_INLINE_FUNCTION - void operator()(const typename Kokkos::TeamPolicy<>::member_type& team) const - {} - - KOKKOS_INLINE_FUNCTION - void operator()(const typename Kokkos::TeamPolicy<>::member_type& team, value_type &energy_virial) const - {} - -}; // Filter out Neighflags which are not supported for PairStyle // The enable_if clause will invalidate the last parameter of the function, so that @@ -867,7 +728,7 @@ int GetTeamSize(FunctorStyle& functor, int inum, int reduce_flag, int team_size, return team_size; } -// Submit ParallelFor for NEIGHFLAG=HALF,HALFTHREAD,FULL,N2 +// Submit ParallelFor for NEIGHFLAG=HALF,HALFTHREAD,FULL template EV_FLOAT pair_compute_neighlist (PairStyle* fpair, typename std::enable_if<(NEIGHFLAG&PairStyle::EnabledNeighFlags) != 0, NeighListKokkos*>::type list) { EV_FLOAT ev; @@ -918,8 +779,6 @@ EV_FLOAT pair_compute (PairStyle* fpair, NeighListKokkos (fpair,list); } else if (fpair->neighflag == HALF) { ev = pair_compute_neighlist (fpair,list); - } else if (fpair->neighflag == N2) { - ev = pair_compute_neighlist (fpair,list); } return ev; } diff --git a/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp index 37485c77f0..b8c72d7b88 100644 --- a/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp @@ -309,9 +309,6 @@ void PairLJClass2CoulCutKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/class2/coul/cut/kk"); } diff --git a/src/KOKKOS/pair_lj_class2_kokkos.cpp b/src/KOKKOS/pair_lj_class2_kokkos.cpp index dd99ea9ab5..5bac4c8140 100644 --- a/src/KOKKOS/pair_lj_class2_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_kokkos.cpp @@ -247,9 +247,6 @@ void PairLJClass2Kokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/class2/kk"); } diff --git a/src/KOKKOS/pair_lj_class2_kokkos.h b/src/KOKKOS/pair_lj_class2_kokkos.h index ae0676c8a5..4bfc44ee6f 100644 --- a/src/KOKKOS/pair_lj_class2_kokkos.h +++ b/src/KOKKOS/pair_lj_class2_kokkos.h @@ -31,7 +31,7 @@ namespace LAMMPS_NS { template class PairLJClass2Kokkos : public PairLJClass2 { public: - enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF|N2}; + enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; enum {COUL_FLAG=0}; typedef DeviceType device_type; typedef ArrayTypes AT; @@ -104,15 +104,12 @@ class PairLJClass2Kokkos : public PairLJClass2 { friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend EV_FLOAT pair_compute_neighlist(PairLJClass2Kokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairLJClass2Kokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairLJClass2Kokkos*,NeighListKokkos*); - friend EV_FLOAT pair_compute_neighlist(PairLJClass2Kokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute(PairLJClass2Kokkos*,NeighListKokkos*); friend void pair_virial_fdotr_compute(PairLJClass2Kokkos*); }; diff --git a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp index 36fd960c98..e2b57e8df7 100644 --- a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp @@ -300,9 +300,6 @@ void PairLJCutCoulCutKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/cut/coul/cut/kk"); } diff --git a/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp index 3810a0140b..bc8369fd65 100644 --- a/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp @@ -329,9 +329,6 @@ void PairLJCutCoulDebyeKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/cut/coul/debye/kk"); } diff --git a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp index b8818b1098..feb6a58136 100644 --- a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp @@ -322,9 +322,6 @@ void PairLJCutCoulDSFKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/cut/coul/cut/kk"); } diff --git a/src/KOKKOS/pair_lj_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_kokkos.cpp index a4b2e90e07..5eb0a5b91a 100644 --- a/src/KOKKOS/pair_lj_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_kokkos.cpp @@ -241,9 +241,6 @@ void PairLJCutKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/cut/kk"); } diff --git a/src/KOKKOS/pair_lj_cut_kokkos.h b/src/KOKKOS/pair_lj_cut_kokkos.h index 7e2b8fd91a..122aef5a1e 100644 --- a/src/KOKKOS/pair_lj_cut_kokkos.h +++ b/src/KOKKOS/pair_lj_cut_kokkos.h @@ -31,7 +31,7 @@ namespace LAMMPS_NS { template class PairLJCutKokkos : public PairLJCut { public: - enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF|N2}; + enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; enum {COUL_FLAG=0}; typedef DeviceType device_type; typedef ArrayTypes AT; @@ -99,15 +99,12 @@ class PairLJCutKokkos : public PairLJCut { friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend EV_FLOAT pair_compute_neighlist(PairLJCutKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairLJCutKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairLJCutKokkos*,NeighListKokkos*); - friend EV_FLOAT pair_compute_neighlist(PairLJCutKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute(PairLJCutKokkos*,NeighListKokkos*); friend void pair_virial_fdotr_compute(PairLJCutKokkos*); }; diff --git a/src/KOKKOS/pair_lj_expand_kokkos.cpp b/src/KOKKOS/pair_lj_expand_kokkos.cpp index 496a7a76ac..0409eda401 100644 --- a/src/KOKKOS/pair_lj_expand_kokkos.cpp +++ b/src/KOKKOS/pair_lj_expand_kokkos.cpp @@ -249,9 +249,6 @@ void PairLJExpandKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/expand/kk"); } diff --git a/src/KOKKOS/pair_lj_expand_kokkos.h b/src/KOKKOS/pair_lj_expand_kokkos.h index 093031f7d7..bdd0bf5870 100644 --- a/src/KOKKOS/pair_lj_expand_kokkos.h +++ b/src/KOKKOS/pair_lj_expand_kokkos.h @@ -31,7 +31,7 @@ namespace LAMMPS_NS { template class PairLJExpandKokkos : public PairLJExpand { public: - enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF|N2}; + enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; enum {COUL_FLAG=0}; typedef DeviceType device_type; typedef ArrayTypes AT; @@ -105,15 +105,12 @@ class PairLJExpandKokkos : public PairLJExpand { friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend EV_FLOAT pair_compute_neighlist(PairLJExpandKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairLJExpandKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairLJExpandKokkos*,NeighListKokkos*); - friend EV_FLOAT pair_compute_neighlist(PairLJExpandKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute(PairLJExpandKokkos*,NeighListKokkos*); friend void pair_virial_fdotr_compute(PairLJExpandKokkos*); }; diff --git a/src/KOKKOS/pair_lj_sdk_kokkos.cpp b/src/KOKKOS/pair_lj_sdk_kokkos.cpp index 645f8a9159..70d04385d0 100644 --- a/src/KOKKOS/pair_lj_sdk_kokkos.cpp +++ b/src/KOKKOS/pair_lj_sdk_kokkos.cpp @@ -279,9 +279,6 @@ void PairLJSDKKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/sdk/kk"); } diff --git a/src/KOKKOS/pair_lj_sdk_kokkos.h b/src/KOKKOS/pair_lj_sdk_kokkos.h index f313c4342f..db71dc4677 100644 --- a/src/KOKKOS/pair_lj_sdk_kokkos.h +++ b/src/KOKKOS/pair_lj_sdk_kokkos.h @@ -31,7 +31,7 @@ namespace LAMMPS_NS { template class PairLJSDKKokkos : public PairLJSDK { public: - enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF|N2}; + enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; enum {COUL_FLAG=0}; typedef DeviceType device_type; typedef ArrayTypes AT; @@ -100,15 +100,12 @@ class PairLJSDKKokkos : public PairLJSDK { friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend EV_FLOAT pair_compute_neighlist(PairLJSDKKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairLJSDKKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairLJSDKKokkos*,NeighListKokkos*); - friend EV_FLOAT pair_compute_neighlist(PairLJSDKKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute(PairLJSDKKokkos*,NeighListKokkos*); friend void pair_virial_fdotr_compute(PairLJSDKKokkos*); }; diff --git a/src/KOKKOS/pair_morse_kokkos.cpp b/src/KOKKOS/pair_morse_kokkos.cpp index 4e88c72518..16d4d8a0a3 100644 --- a/src/KOKKOS/pair_morse_kokkos.cpp +++ b/src/KOKKOS/pair_morse_kokkos.cpp @@ -258,9 +258,6 @@ void PairMorseKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with morse/kk"); } diff --git a/src/KOKKOS/pair_morse_kokkos.h b/src/KOKKOS/pair_morse_kokkos.h index f9cce941a5..ff3c552437 100644 --- a/src/KOKKOS/pair_morse_kokkos.h +++ b/src/KOKKOS/pair_morse_kokkos.h @@ -31,7 +31,7 @@ namespace LAMMPS_NS { template class PairMorseKokkos : public PairMorse { public: - enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF|N2}; + enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; enum {COUL_FLAG=0}; typedef DeviceType device_type; PairMorseKokkos(class LAMMPS *); @@ -98,15 +98,12 @@ class PairMorseKokkos : public PairMorse { friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend EV_FLOAT pair_compute_neighlist(PairMorseKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairMorseKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist(PairMorseKokkos*,NeighListKokkos*); - friend EV_FLOAT pair_compute_neighlist(PairMorseKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute(PairMorseKokkos*,NeighListKokkos*); friend void pair_virial_fdotr_compute(PairMorseKokkos*); }; diff --git a/src/KOKKOS/pair_reaxc_kokkos.cpp b/src/KOKKOS/pair_reaxc_kokkos.cpp index bec3f2e655..5326e926e5 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.cpp +++ b/src/KOKKOS/pair_reaxc_kokkos.cpp @@ -152,16 +152,12 @@ void PairReaxCKokkos::init_style() neighbor->requests[irequest]-> kokkos_device = std::is_same::value; - if (neighflag == FULL) { - neighbor->requests[irequest]->full = 1; - neighbor->requests[irequest]->half = 0; - neighbor->requests[irequest]->ghost = 1; - } else if (neighflag == HALF || neighflag == HALFTHREAD) { + if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; neighbor->requests[irequest]->ghost = 1; } else { - error->all(FLERR,"Cannot use chosen neighbor list style with reax/c/kk"); + error->all(FLERR,"Must use half neighbor list with pair style reax/c/kk"); } allocate(); @@ -665,8 +661,6 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) eflag = eflag_in; vflag = vflag_in; - if (neighflag == FULL) no_virial_fdotr_compute = 1; - ev_init(eflag,vflag); atomKK->sync(execution_space,datamask_read); @@ -743,11 +737,6 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); - } else if (neighflag == FULL) { - if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); - else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); } } else { if (neighflag == HALF) { @@ -760,11 +749,6 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); else Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); - } else if (neighflag == FULL) { - if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,inum),*this,ev); - else - Kokkos::parallel_for(Kokkos::RangePolicy >(0,inum),*this); } } ev_all += ev; @@ -809,8 +793,6 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) Kokkos::parallel_for(Kokkos::RangePolicy >(0,ignum),*this); else if (neighflag == HALFTHREAD) Kokkos::parallel_for(Kokkos::RangePolicy >(0,ignum),*this); - else //(neighflag == FULL) - Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); k_resize_bo.modify(); k_resize_bo.sync(); @@ -853,11 +835,7 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) Kokkos::Experimental::contribute(d_total_bo, dup_total_bo); // needed in BondOrder1 // Bond order - if (neighflag == HALF) { - Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); - } else if (neighflag == HALFTHREAD) { - Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); - } + Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); @@ -1044,14 +1022,14 @@ void PairReaxCKokkos::compute(int eflag_in, int vflag_in) // free duplicated memory if (need_dup) { dup_f = decltype(dup_f)(); + dup_eatom = decltype(dup_eatom)(); + dup_vatom = decltype(dup_vatom)(); dup_dDeltap_self = decltype(dup_dDeltap_self)(); dup_total_bo = decltype(dup_total_bo)(); dup_CdDelta = decltype(dup_CdDelta)(); //dup_Cdbo = decltype(dup_Cdbo)(); //dup_Cdbopi = decltype(dup_Cdbopi)(); //dup_Cdbopi2 = decltype(dup_Cdbopi2)(); - dup_eatom = decltype(dup_eatom)(); - dup_vatom = decltype(dup_vatom)(); } } @@ -1119,18 +1097,16 @@ void PairReaxCKokkos::operator()(PairReaxComputeLJCoulomb= nlocal) { - if (itag > jtag) { - if ((itag+jtag) % 2 == 0) continue; - } else if (itag < jtag) { - if ((itag+jtag) % 2 == 1) continue; - } else { - if (x(j,2) < ztmp) continue; - if (x(j,2) == ztmp && x(j,1) < ytmp) continue; - if (x(j,2) == ztmp && x(j,1) == ytmp && x(j,0) < xtmp) continue; - } + // skip half of the interactions + if (j >= nlocal) { + if (itag > jtag) { + if ((itag+jtag) % 2 == 0) continue; + } else if (itag < jtag) { + if ((itag+jtag) % 2 == 1) continue; + } else { + if (x(j,2) < ztmp) continue; + if (x(j,2) == ztmp && x(j,1) < ytmp) continue; + if (x(j,2) == ztmp && x(j,1) == ytmp && x(j,0) < xtmp) continue; } } @@ -1215,19 +1191,12 @@ void PairReaxCKokkos::operator()(PairReaxComputeLJCoulombtemplate ev_tally(ev,i,j,evdwl+ecoul,-ftotal,delx,dely,delz); } @@ -1276,18 +1245,16 @@ void PairReaxCKokkos::operator()(PairReaxComputeTabulatedLJCoulomb= nlocal) { - if (itag > jtag) { - if ((itag+jtag) % 2 == 0) continue; - } else if (itag < jtag) { - if ((itag+jtag) % 2 == 1) continue; - } else { - if (x(j,2) < ztmp) continue; - if (x(j,2) == ztmp && x(j,1) < ytmp) continue; - if (x(j,2) == ztmp && x(j,1) == ytmp && x(j,0) < xtmp) continue; - } + // skip half of the interactions + if (j >= nlocal) { + if (itag > jtag) { + if ((itag+jtag) % 2 == 0) continue; + } else if (itag < jtag) { + if ((itag+jtag) % 2 == 1) continue; + } else { + if (x(j,2) < ztmp) continue; + if (x(j,2) == ztmp && x(j,1) < ytmp) continue; + if (x(j,2) == ztmp && x(j,1) == ytmp && x(j,0) < xtmp) continue; } } @@ -1331,19 +1298,12 @@ void PairReaxCKokkos::operator()(PairReaxComputeTabulatedLJCoulombtemplate ev_tally(ev,i,j,evdwl+ecoul,-ftotal,delx,dely,delz); } @@ -1436,10 +1396,8 @@ KOKKOS_INLINE_FUNCTION void PairReaxCKokkos::operator()(PairReaxZero, const int &n) const { d_total_bo(n) = 0.0; d_CdDelta(n) = 0.0; - if (neighflag != FULL) { - d_bo_num(n) = 0.0; - d_hb_num(n) = 0.0; - } + d_bo_num(n) = 0.0; + d_hb_num(n) = 0.0; for (int j = 0; j < 3; j++) d_dDeltap_self(n,j) = 0.0; } @@ -1850,261 +1808,6 @@ void PairReaxCKokkos::operator()(PairReaxBondOrder1, const int &ii) /* ---------------------------------------------------------------------- */ -template -template -KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxBuildListsHalf_LessAtomics, const int &ii) const { - - if (d_resize_bo() || d_resize_hb()) - return; - - const int i = d_ilist[ii]; - const X_FLOAT xtmp = x(i,0); - const X_FLOAT ytmp = x(i,1); - const X_FLOAT ztmp = x(i,2); - const int itype = type(i); - const tagint itag = tag(i); - const int jnum = d_numneigh[i]; - - F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[3]; - - int j_index,i_index; - d_bo_first[i] = i*maxbo; - const int bo_first_i = d_bo_first[i]; - - int ihb = -1; - int jhb = -1; - - int hb_first_i; - if (cut_hbsq > 0.0) { - ihb = paramssing(itype).p_hbond; - if (ihb == 1) { - d_hb_first[i] = i*maxhb; - hb_first_i = d_hb_first[i]; - } - } - - for (int jj = 0; jj < jnum; jj++) { - int j = d_neighbors(i,jj); - j &= NEIGHMASK; - const tagint jtag = tag(j); - - d_bo_first[j] = j*maxbo; - d_hb_first[j] = j*maxhb; - const int jtype = type(j); - - delij[0] = x(j,0) - xtmp; - delij[1] = x(j,1) - ytmp; - delij[2] = x(j,2) - ztmp; - const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; - - double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); - else cutoffsq = cut_bosq; - if (rsq > cutoffsq) continue; - - // hbond list - if (i < nlocal && cut_hbsq > 0.0 && (ihb == 1 || ihb == 2) && rsq <= cut_hbsq) { - jhb = paramssing(jtype).p_hbond; - if (ihb == 1 && jhb == 2) { - if (NEIGHFLAG == HALF) { - j_index = hb_first_i + d_hb_num[i]; - d_hb_num[i]++; - } else { - j_index = hb_first_i + Kokkos::atomic_fetch_add(&d_hb_num[i],1); - } - - const int jj_index = j_index - hb_first_i; - - if (jj_index >= maxhb) { - d_resize_hb() = 1; - return; - } - - d_hb_list[j_index] = j; - } else if ( j < nlocal && ihb == 2 && jhb == 1) { - if (NEIGHFLAG == HALF) { - i_index = d_hb_first[j] + d_hb_num[j]; - d_hb_num[j]++; - } else { - i_index = d_hb_first[j] + Kokkos::atomic_fetch_add(&d_hb_num[j],1); - } - - const int ii_index = i_index - d_hb_first[j]; - - if (ii_index >= maxhb) { - d_resize_hb() = 1; - return; - } - - d_hb_list[i_index] = i; - } - } - - if (rsq > cut_bosq) continue; - - // bond_list - const F_FLOAT rij = sqrt(rsq); - const F_FLOAT p_bo1 = paramstwbp(itype,jtype).p_bo1; - const F_FLOAT p_bo2 = paramstwbp(itype,jtype).p_bo2; - const F_FLOAT p_bo3 = paramstwbp(itype,jtype).p_bo3; - const F_FLOAT p_bo4 = paramstwbp(itype,jtype).p_bo4; - const F_FLOAT p_bo5 = paramstwbp(itype,jtype).p_bo5; - const F_FLOAT p_bo6 = paramstwbp(itype,jtype).p_bo6; - const F_FLOAT r_s = paramstwbp(itype,jtype).r_s; - const F_FLOAT r_pi = paramstwbp(itype,jtype).r_pi; - const F_FLOAT r_pi2 = paramstwbp(itype,jtype).r_pi2; - - if (paramssing(itype).r_s > 0.0 && paramssing(jtype).r_s > 0.0) { - C12 = p_bo1*pow(rij/r_s,p_bo2); - BO_s = (1.0+bo_cut)*exp(C12); - } - else BO_s = C12 = 0.0; - - if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { - C34 = p_bo3*pow(rij/r_pi,p_bo4); - BO_pi = exp(C34); - } - else BO_pi = C34 = 0.0; - - if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { - C56 = p_bo5*pow(rij/r_pi2,p_bo6); - BO_pi2 = exp(C56); - } - else BO_pi2 = C56 = 0.0; - - BO = BO_s + BO_pi + BO_pi2; - if (BO < bo_cut) continue; - - if (NEIGHFLAG == HALF) { - j_index = bo_first_i + d_bo_num[i]; - i_index = d_bo_first[j] + d_bo_num[j]; - d_bo_num[i]++; - d_bo_num[j]++; - } else { - j_index = bo_first_i + Kokkos::atomic_fetch_add(&d_bo_num[i],1); - i_index = d_bo_first[j] + Kokkos::atomic_fetch_add(&d_bo_num[j],1); - } - - const int jj_index = j_index - bo_first_i; - const int ii_index = i_index - d_bo_first[j]; - - if (jj_index >= maxbo || ii_index >= maxbo) { - d_resize_bo() = 1; - return; - } - - d_bo_list[j_index] = j; - d_bo_list[i_index] = i; - } - -} - -/* ---------------------------------------------------------------------- */ - -template -KOKKOS_INLINE_FUNCTION -void PairReaxCKokkos::operator()(PairReaxBondOrder1_LessAtomics, const int &ii) const { - - F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[3], dBOp_i[3], dln_BOp_pi_i[3], dln_BOp_pi2_i[3]; - - const int i = d_ilist[ii]; - const X_FLOAT xtmp = x(i,0); - const X_FLOAT ytmp = x(i,1); - const X_FLOAT ztmp = x(i,2); - const int itype = type(i); - - const int j_start = d_bo_first[i]; - const int j_end = j_start + d_bo_num[i]; - - F_FLOAT total_bo = 0.0; - - for (int jj = j_start; jj < j_end; jj++) { - int j = d_bo_list[jj]; - j &= NEIGHMASK; - delij[0] = x(j,0) - xtmp; - delij[1] = x(j,1) - ytmp; - delij[2] = x(j,2) - ztmp; - const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; - const F_FLOAT rij = sqrt(rsq); - const int jtype = type(j); - const int j_index = jj - j_start; - - // calculate uncorrected BO and total bond order - - const F_FLOAT p_bo1 = paramstwbp(itype,jtype).p_bo1; - const F_FLOAT p_bo2 = paramstwbp(itype,jtype).p_bo2; - const F_FLOAT p_bo3 = paramstwbp(itype,jtype).p_bo3; - const F_FLOAT p_bo4 = paramstwbp(itype,jtype).p_bo4; - const F_FLOAT p_bo5 = paramstwbp(itype,jtype).p_bo5; - const F_FLOAT p_bo6 = paramstwbp(itype,jtype).p_bo6; - const F_FLOAT r_s = paramstwbp(itype,jtype).r_s; - const F_FLOAT r_pi = paramstwbp(itype,jtype).r_pi; - const F_FLOAT r_pi2 = paramstwbp(itype,jtype).r_pi2; - - if (paramssing(itype).r_s > 0.0 && paramssing(jtype).r_s > 0.0) { - C12 = p_bo1*pow(rij/r_s,p_bo2); - BO_s = (1.0+bo_cut)*exp(C12); - } - else BO_s = C12 = 0.0; - - if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { - C34 = p_bo3*pow(rij/r_pi,p_bo4); - BO_pi = exp(C34); - } - else BO_pi = C34 = 0.0; - - if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { - C56 = p_bo5*pow(rij/r_pi2,p_bo6); - BO_pi2 = exp(C56); - } - else BO_pi2 = C56 = 0.0; - - BO = BO_s + BO_pi + BO_pi2; - if (BO < bo_cut) continue; - - d_BO(i,j_index) = BO; - d_BO_s(i,j_index) = BO; - d_BO_pi(i,j_index) = BO_pi; - d_BO_pi2(i,j_index) = BO_pi2; - - F_FLOAT Cln_BOp_s = p_bo2 * C12 / rij / rij; - F_FLOAT Cln_BOp_pi = p_bo4 * C34 / rij / rij; - F_FLOAT Cln_BOp_pi2 = p_bo6 * C56 / rij / rij; - - if (nlocal == 0) - Cln_BOp_s = Cln_BOp_pi = Cln_BOp_pi2 = 0.0; - - for (int d = 0; d < 3; d++) dln_BOp_pi_i[d] = -(BO_pi*Cln_BOp_pi)*delij[d]; - for (int d = 0; d < 3; d++) dln_BOp_pi2_i[d] = -(BO_pi2*Cln_BOp_pi2)*delij[d]; - for (int d = 0; d < 3; d++) dBOp_i[d] = -(BO_s*Cln_BOp_s+BO_pi*Cln_BOp_pi+BO_pi2*Cln_BOp_pi2)*delij[d]; - for (int d = 0; d < 3; d++) d_dDeltap_self(i,d) += dBOp_i[d]; - - d_dln_BOp_pix(i,j_index) = dln_BOp_pi_i[0]; - d_dln_BOp_piy(i,j_index) = dln_BOp_pi_i[1]; - d_dln_BOp_piz(i,j_index) = dln_BOp_pi_i[2]; - - d_dln_BOp_pi2x(i,j_index) = dln_BOp_pi2_i[0]; - d_dln_BOp_pi2y(i,j_index) = dln_BOp_pi2_i[1]; - d_dln_BOp_pi2z(i,j_index) = dln_BOp_pi2_i[2]; - - d_dBOpx(i,j_index) = dBOp_i[0]; - d_dBOpy(i,j_index) = dBOp_i[1]; - d_dBOpz(i,j_index) = dBOp_i[2]; - - d_BO(i,j_index) -= bo_cut; - d_BO_s(i,j_index) -= bo_cut; - total_bo += d_BO(i,j_index); - } - d_total_bo[i] += total_bo; - - const F_FLOAT val_i = paramssing(itype).valency; - d_Deltap[i] = d_total_bo[i] - val_i; - d_Deltap_boc[i] = d_total_bo[i] - paramssing(itype).valency_val; -} - -/* ---------------------------------------------------------------------- */ - template KOKKOS_INLINE_FUNCTION void PairReaxCKokkos::operator()(PairReaxBondOrder2, const int &ii) const { @@ -3728,7 +3431,7 @@ void PairReaxCKokkos::ev_tally(EV_FLOAT_REAX &ev, const int &i, cons if (eflag_atom) { const E_FLOAT epairhalf = 0.5 * epair; a_eatom[i] += epairhalf; - if (NEIGHFLAG != FULL) a_eatom[j] += epairhalf; + a_eatom[j] += epairhalf; } if (VFLAG) { @@ -3740,21 +3443,12 @@ void PairReaxCKokkos::ev_tally(EV_FLOAT_REAX &ev, const int &i, cons const E_FLOAT v5 = dely*delz*fpair; if (vflag_global) { - if (NEIGHFLAG != FULL) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; - } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; - } + ev.v[0] += v0; + ev.v[1] += v1; + ev.v[2] += v2; + ev.v[3] += v3; + ev.v[4] += v4; + ev.v[5] += v5; } if (vflag_atom) { @@ -3764,15 +3458,12 @@ void PairReaxCKokkos::ev_tally(EV_FLOAT_REAX &ev, const int &i, cons a_vatom(i,3) += 0.5*v3; a_vatom(i,4) += 0.5*v4; a_vatom(i,5) += 0.5*v5; - - if (NEIGHFLAG != FULL) { - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; - } + a_vatom(j,0) += 0.5*v0; + a_vatom(j,1) += 0.5*v1; + a_vatom(j,2) += 0.5*v2; + a_vatom(j,3) += 0.5*v3; + a_vatom(j,4) += 0.5*v4; + a_vatom(j,5) += 0.5*v5; } } } diff --git a/src/KOKKOS/pair_reaxc_kokkos.h b/src/KOKKOS/pair_reaxc_kokkos.h index 93ca4468ec..24a56b7076 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.h +++ b/src/KOKKOS/pair_reaxc_kokkos.h @@ -64,9 +64,6 @@ struct PairReaxBuildListsFull{}; template struct PairReaxBuildListsHalf{}; -template -struct PairReaxBuildListsHalf_LessAtomics{}; - struct PairReaxZero{}; struct PairReaxZeroEAtom{}; @@ -75,8 +72,6 @@ struct PairReaxZeroVAtom{}; struct PairReaxBondOrder1{}; -struct PairReaxBondOrder1_LessAtomics{}; - struct PairReaxBondOrder2{}; struct PairReaxBondOrder3{}; @@ -164,10 +159,6 @@ class PairReaxCKokkos : public PairReaxC { KOKKOS_INLINE_FUNCTION void operator()(PairReaxBuildListsHalf, const int&) const; - template - KOKKOS_INLINE_FUNCTION - void operator()(PairReaxBuildListsHalf_LessAtomics, const int&) const; - KOKKOS_INLINE_FUNCTION void operator()(PairReaxZero, const int&) const; @@ -180,9 +171,6 @@ class PairReaxCKokkos : public PairReaxC { KOKKOS_INLINE_FUNCTION void operator()(PairReaxBondOrder1, const int&) const; - KOKKOS_INLINE_FUNCTION - void operator()(PairReaxBondOrder1_LessAtomics, const int&) const; - KOKKOS_INLINE_FUNCTION void operator()(PairReaxBondOrder2, const int&) const; @@ -437,7 +425,7 @@ class PairReaxCKokkos : public PairReaxC { typename AT::t_ffloat_2d_dl d_sum_ovun; typename AT::t_ffloat_2d_dl d_dBOpx, d_dBOpy, d_dBOpz; - int neighflag,newton_pair, maxnumneigh, maxhb, maxbo; + int neighflag, newton_pair, maxnumneigh, maxhb, maxbo; int nlocal,nall,eflag,vflag; F_FLOAT cut_nbsq, cut_hbsq, cut_bosq, bo_cut, thb_cut, thb_cutsq; F_FLOAT bo_cut_bond; diff --git a/src/KOKKOS/pair_table_kokkos.cpp b/src/KOKKOS/pair_table_kokkos.cpp index a86db70d4d..b2aaaf1566 100644 --- a/src/KOKKOS/pair_table_kokkos.cpp +++ b/src/KOKKOS/pair_table_kokkos.cpp @@ -136,12 +136,6 @@ void PairTableKokkos::compute_style(int eflag_in, int vflag_in) if (eflag || vflag) Kokkos::parallel_reduce(list->inum,f,ev); else Kokkos::parallel_for(list->inum,f); f.contribute(); - } else if (neighflag == N2) { - PairComputeFunctor,N2,false,S_TableCompute > - f(this,(NeighListKokkos*) list); - if (eflag || vflag) Kokkos::parallel_reduce(list->inum,f,ev); - else Kokkos::parallel_for(list->inum,f); - f.contribute(); } } else { if (neighflag == FULL) { @@ -162,12 +156,6 @@ void PairTableKokkos::compute_style(int eflag_in, int vflag_in) if (eflag || vflag) Kokkos::parallel_reduce(list->inum,f,ev); else Kokkos::parallel_for(list->inum,f); f.contribute(); - } else if (neighflag == N2) { - PairComputeFunctor,N2,true,S_TableCompute > - f(this,(NeighListKokkos*) list); - if (eflag || vflag) Kokkos::parallel_reduce(list->inum,f,ev); - else Kokkos::parallel_for(list->inum,f); - f.contribute(); } } @@ -525,9 +513,6 @@ void PairTableKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/cut/kk"); } diff --git a/src/KOKKOS/pair_table_kokkos.h b/src/KOKKOS/pair_table_kokkos.h index eede023d7e..2f84e6a61e 100644 --- a/src/KOKKOS/pair_table_kokkos.h +++ b/src/KOKKOS/pair_table_kokkos.h @@ -41,7 +41,7 @@ template class PairTableKokkos : public PairTable { public: - enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF|N2}; + enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; enum {COUL_FLAG=0}; typedef DeviceType device_type; typedef ArrayTypes AT; @@ -139,38 +139,30 @@ class PairTableKokkos : public PairTable { friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; - friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; - friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; - friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; - friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; - friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; - friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; - friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; friend class PairComputeFunctor >; - friend class PairComputeFunctor >; friend void pair_virial_fdotr_compute(PairTableKokkos*); }; diff --git a/src/KOKKOS/pair_table_rx_kokkos.cpp b/src/KOKKOS/pair_table_rx_kokkos.cpp index d78a5ee646..2b066d7633 100644 --- a/src/KOKKOS/pair_table_rx_kokkos.cpp +++ b/src/KOKKOS/pair_table_rx_kokkos.cpp @@ -665,8 +665,6 @@ void PairTableRXKokkos::compute_style(int eflag_in, int vflag_in) nspecies, isite1, isite2, fractionalWeighting, mixWtSite1old, mixWtSite2old, mixWtSite1, mixWtSite2); - if (neighflag == N2) error->all(FLERR,"pair table/rx/kk can't handle N2 yet\n"); - NeighListKokkos* l = dynamic_cast*>(list); @@ -1282,9 +1280,6 @@ void PairTableRXKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/cut/kk"); } diff --git a/src/KOKKOS/pair_table_rx_kokkos.h b/src/KOKKOS/pair_table_rx_kokkos.h index 4230263dc9..7aba307476 100644 --- a/src/KOKKOS/pair_table_rx_kokkos.h +++ b/src/KOKKOS/pair_table_rx_kokkos.h @@ -30,7 +30,7 @@ namespace LAMMPS_NS { template class PairTableRXKokkos : public PairTable { public: - enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF|N2}; + enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; typedef DeviceType device_type; PairTableRXKokkos(class LAMMPS *); diff --git a/src/KOKKOS/pair_yukawa_kokkos.h b/src/KOKKOS/pair_yukawa_kokkos.h index 5f4e823657..f24298d415 100644 --- a/src/KOKKOS/pair_yukawa_kokkos.h +++ b/src/KOKKOS/pair_yukawa_kokkos.h @@ -103,19 +103,15 @@ class PairYukawaKokkos : public PairYukawa { friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; friend class PairComputeFunctor; - friend class PairComputeFunctor; friend EV_FLOAT pair_compute_neighlist( PairYukawaKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist( PairYukawaKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute_neighlist( PairYukawaKokkos*,NeighListKokkos*); - friend EV_FLOAT pair_compute_neighlist( - PairYukawaKokkos*,NeighListKokkos*); friend EV_FLOAT pair_compute( PairYukawaKokkos*,NeighListKokkos*); friend void pair_virial_fdotr_compute(PairYukawaKokkos*); diff --git a/src/KOKKOS/pair_zbl_kokkos.cpp b/src/KOKKOS/pair_zbl_kokkos.cpp index fe34f58fa6..5e4ec398d9 100644 --- a/src/KOKKOS/pair_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_zbl_kokkos.cpp @@ -103,9 +103,6 @@ void PairZBLKokkos::init_style() } else if (neighflag == HALF || neighflag == HALFTHREAD) { neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - } else if (neighflag == N2) { - neighbor->requests[irequest]->full = 0; - neighbor->requests[irequest]->half = 0; } else { error->all(FLERR,"Cannot use chosen neighbor list style with lj/cut/kk"); } diff --git a/src/KOKKOS/pppm_kokkos.cpp b/src/KOKKOS/pppm_kokkos.cpp index 62d7ccc3cd..0940bda7ac 100644 --- a/src/KOKKOS/pppm_kokkos.cpp +++ b/src/KOKKOS/pppm_kokkos.cpp @@ -106,7 +106,7 @@ PPPMKokkos::PPPMKokkos(LAMMPS *lmp) : PPPM(lmp) // see JCP 109, pg 7698 for derivation of coefficients // higher order coefficients may be computed if needed - acons = typename Kokkos::DualView::t_host("pppm:acons"); + acons = typename Kokkos::DualView::t_host("pppm:acons"); acons(1,0) = 2.0 / 3.0; acons(2,0) = 1.0 / 50.0; acons(2,1) = 5.0 / 294.0; @@ -2581,7 +2581,7 @@ void PPPMKokkos::operator()(TagPPPM_fieldforce_peratom, const int &i ------------------------------------------------------------------------- */ template -void PPPMKokkos::pack_forward_kspace_kokkos(int flag, Kokkos::DualView &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index) +void PPPMKokkos::pack_forward_kspace_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index) { typename AT::t_int_2d_um d_list = k_list.view(); d_list_index = Kokkos::subview(d_list,index,Kokkos::ALL()); @@ -2637,7 +2637,7 @@ void PPPMKokkos::operator()(TagPPPM_pack_forward2, const int &i) con ------------------------------------------------------------------------- */ template -void PPPMKokkos::unpack_forward_kspace_kokkos(int flag, Kokkos::DualView &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index) +void PPPMKokkos::unpack_forward_kspace_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index) { typename AT::t_int_2d_um d_list = k_list.view(); d_list_index = Kokkos::subview(d_list,index,Kokkos::ALL()); @@ -2694,7 +2694,7 @@ void PPPMKokkos::operator()(TagPPPM_unpack_forward2, const int &i) c ------------------------------------------------------------------------- */ template -void PPPMKokkos::pack_reverse_kspace_kokkos(int flag, Kokkos::DualView &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index) +void PPPMKokkos::pack_reverse_kspace_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index) { typename AT::t_int_2d_um d_list = k_list.view(); d_list_index = Kokkos::subview(d_list,index,Kokkos::ALL()); @@ -2724,7 +2724,7 @@ void PPPMKokkos::operator()(TagPPPM_pack_reverse, const int &i) cons ------------------------------------------------------------------------- */ template -void PPPMKokkos::unpack_reverse_kspace_kokkos(int flag, Kokkos::DualView &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index) +void PPPMKokkos::unpack_reverse_kspace_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index) { typename AT::t_int_2d_um d_list = k_list.view(); d_list_index = Kokkos::subview(d_list,index,Kokkos::ALL()); diff --git a/src/KOKKOS/pppm_kokkos.h b/src/KOKKOS/pppm_kokkos.h index a07ed7d7c4..847a2f807f 100644 --- a/src/KOKKOS/pppm_kokkos.h +++ b/src/KOKKOS/pppm_kokkos.h @@ -403,10 +403,10 @@ class PPPMKokkos : public PPPM, public KokkosBaseFFT { // grid communication - void pack_forward_kspace_kokkos(int, Kokkos::DualView &, int, DAT::tdual_int_2d &, int); - void unpack_forward_kspace_kokkos(int, Kokkos::DualView &, int, DAT::tdual_int_2d &, int); - void pack_reverse_kspace_kokkos(int, Kokkos::DualView &, int, DAT::tdual_int_2d &, int); - void unpack_reverse_kspace_kokkos(int, Kokkos::DualView &, int, DAT::tdual_int_2d &, int); + void pack_forward_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int); + void unpack_forward_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int); + void pack_reverse_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int); + void unpack_reverse_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int); // triclinic