From 1a80d4bc13464c04d959da996639ca7447175dbd Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sat, 19 Aug 2017 05:29:16 -0400 Subject: [PATCH 01/55] Remove style files in src dir while running cmake --- cmake/CMakeLists.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 76c28fcb72..72719cb0ed 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -23,13 +23,11 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS) set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS) -foreach(STYLE_FILE style_angle.h style_atom.h style_body.h style_bond.h style_command.h style_compute.h style_dihedral.h style_dump.h - style_fix.h style_improper.h style_integrate.h style_kspace.h style_minimize.h style_nbin.h style_npair.h style_nstencil.h - style_ntopo.h style_pair.h style_reader.h style_region.h) - if(EXISTS ${LAMMPS_SOURCE_DIR}/${STYLE_FILE}) - message(FATAL_ERROR "There is a ${STYLE_FILE} in ${LAMMPS_SOURCE_DIR}, please clean up the source directory first") - endif() -endforeach() +# remove any style headers in the src dir +file(GLOB SRC_STYLE_FILES ${LAMMPS_SOURCE_DIR}/style_*.h) +if(SRC_STYLE_FILES) + file(REMOVE ${SRC_STYLE_FILES}) +endif() enable_language(CXX) From c9d41dbb47e4ae4cf2f5eb9cc019d2a09bf53e9f Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sat, 19 Aug 2017 06:33:27 -0400 Subject: [PATCH 02/55] Ignore installed package files when using cmake --- cmake/CMakeLists.txt | 25 +++++++++++++++++--- cmake/Modules/StyleHeaderUtils.cmake | 34 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 72719cb0ed..2f11f8fab2 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -328,13 +328,32 @@ RegisterStyles(${LAMMPS_SOURCE_DIR}) # add sources of enabled packages ############################################ foreach(PKG ${DEFAULT_PACKAGES} ${OTHER_PACKAGES}) - if(ENABLE_${PKG}) - set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) + set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) + # ignore PKG files which were manually installed in src folder + # headers are ignored during RegisterStyles + file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/*.cpp) + file(GLOB ${PKG}_HEADERS ${${PKG}_SOURCES_DIR}/*.h) + + foreach(PKG_FILE in ${${PKG}_SOURCES}) + get_filename_component(FNAME ${PKG_FILE} NAME) + list(FIND LIB_SOURCES ${LAMMPS_SOURCE_DIR}/${FNAME} IDX) + + if(NOT (IDX LESS 0)) + #message("Ignoring ${PKG_FILE}...") + list(REMOVE_AT LIB_SOURCES ${IDX}) + endif() + endforeach() + + foreach(PKG_FILE in ${${PKG}_HEADERS}) + get_filename_component(FNAME ${PKG_FILE} NAME) + DetectAndRemovePackageHeader(${LAMMPS_SOURCE_DIR}/${FNAME}) + endforeach() + + if(ENABLE_${PKG}) # detects styles in package and adds them to global list RegisterStyles(${${PKG}_SOURCES_DIR}) - file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/*.cpp) list(APPEND LIB_SOURCES ${${PKG}_SOURCES}) include_directories(${${PKG}_SOURCES_DIR}) endif() diff --git a/cmake/Modules/StyleHeaderUtils.cmake b/cmake/Modules/StyleHeaderUtils.cmake index 9939a7505a..c3433c42ce 100644 --- a/cmake/Modules/StyleHeaderUtils.cmake +++ b/cmake/Modules/StyleHeaderUtils.cmake @@ -85,6 +85,40 @@ function(RegisterStyles search_path) FindStyleHeaders(${search_path} REGION_CLASS region_ REGION ) # region ) # domain endfunction(RegisterStyles) +function(RemovePackageHeader headers pkg_header) + get_property(hlist GLOBAL PROPERTY ${headers}) + + list(FIND hlist ${pkg_header} idx) + if(NOT (idx LESS 0)) + list(REMOVE_AT hlist ${idx}) + #message("Ignoring ${pkg_header}...") + set_property(GLOBAL PROPERTY ${headers} "${hlist}") + endif() +endfunction(RemovePackageHeader) + +function(DetectAndRemovePackageHeader fname) + RemovePackageHeader(ANGLE ${fname}) + RemovePackageHeader(ATOM_VEC ${fname}) + RemovePackageHeader(BODY ${fname}) + RemovePackageHeader(BOND ${fname}) + RemovePackageHeader(COMMAND ${fname}) + RemovePackageHeader(COMPUTE ${fname}) + RemovePackageHeader(DIHEDRAL ${fname}) + RemovePackageHeader(DUMP ${fname}) + RemovePackageHeader(FIX ${fname}) + RemovePackageHeader(IMPROPER ${fname}) + RemovePackageHeader(INTEGRATE ${fname}) + RemovePackageHeader(KSPACE ${fname}) + RemovePackageHeader(MINIMIZE ${fname}) + RemovePackageHeader(NBIN ${fname}) + RemovePackageHeader(NPAIR ${fname}) + RemovePackageHeader(NSTENCIL ${fname}) + RemovePackageHeader(NTOPO ${fname}) + RemovePackageHeader(PAIR ${fname}) + RemovePackageHeader(READER ${fname}) + RemovePackageHeader(REGION ${fname}) +endfunction(DetectAndRemovePackageHeader) + function(RegisterStylesExt search_path extension sources) FindStyleHeadersExt(${search_path} ANGLE_CLASS ${extension} ANGLE ${sources}) FindStyleHeadersExt(${search_path} ATOM_CLASS ${extension} ATOM_VEC ${sources}) From 00a78cfa1a98b7eaf916ce70704c7e83786f3ef9 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 20 Aug 2017 08:30:09 -0600 Subject: [PATCH 03/55] cmake: add LAMMPS_SUFFIX --- cmake/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 76c28fcb72..66f0dd62ce 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -520,9 +520,12 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR}) ########################################### # Actually add executable and lib to build ############################################ +set(LAMMPS_SUFFIX "" CACHE STRING "Suffix to append to lmp binary and liblammps") +mark_as_advanced(LAMMPS_SUFFIX) + add_library(lammps ${LIB_SOURCES}) target_link_libraries(lammps ${LAMMPS_LINK_LIBS}) -set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) +set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION} OUTPUT_NAME lammps${LAMMPS_SUFFIX}) if(INSTALL_LIB) install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${LAMMPS_SOURCE_DIR}/lammps.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) @@ -532,9 +535,10 @@ endif() add_executable(lmp ${LMP_SOURCES}) target_link_libraries(lmp lammps) +set_target_properties(lmp PROPERTIES OUTPUT_NAME lmp${LAMMPS_SUFFIX}) install(TARGETS lmp DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ENABLE_TESTING) - add_test(ShowHelp ${CMAKE_CURRENT_BINARY_DIR}/lmp -help) + add_test(ShowHelp lmp${LAMMPS_SUFFIX} -help) endif() ################################## From aef2416ece3fb7cc616bae0ea6a0f8432630de7a Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sun, 20 Aug 2017 10:49:30 -0400 Subject: [PATCH 04/55] Simplify CMake script --- cmake/CMakeLists.txt | 7 +------ cmake/Modules/StyleHeaderUtils.cmake | 9 ++------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2f11f8fab2..6573427db5 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -337,12 +337,7 @@ foreach(PKG ${DEFAULT_PACKAGES} ${OTHER_PACKAGES}) foreach(PKG_FILE in ${${PKG}_SOURCES}) get_filename_component(FNAME ${PKG_FILE} NAME) - list(FIND LIB_SOURCES ${LAMMPS_SOURCE_DIR}/${FNAME} IDX) - - if(NOT (IDX LESS 0)) - #message("Ignoring ${PKG_FILE}...") - list(REMOVE_AT LIB_SOURCES ${IDX}) - endif() + list(REMOVE_ITEM LIB_SOURCES ${LAMMPS_SOURCE_DIR}/${FNAME}) endforeach() foreach(PKG_FILE in ${${PKG}_HEADERS}) diff --git a/cmake/Modules/StyleHeaderUtils.cmake b/cmake/Modules/StyleHeaderUtils.cmake index c3433c42ce..32054c53ba 100644 --- a/cmake/Modules/StyleHeaderUtils.cmake +++ b/cmake/Modules/StyleHeaderUtils.cmake @@ -87,13 +87,8 @@ endfunction(RegisterStyles) function(RemovePackageHeader headers pkg_header) get_property(hlist GLOBAL PROPERTY ${headers}) - - list(FIND hlist ${pkg_header} idx) - if(NOT (idx LESS 0)) - list(REMOVE_AT hlist ${idx}) - #message("Ignoring ${pkg_header}...") - set_property(GLOBAL PROPERTY ${headers} "${hlist}") - endif() + list(REMOVE_ITEM hlist ${pkg_header}) + set_property(GLOBAL PROPERTY ${headers} "${hlist}") endfunction(RemovePackageHeader) function(DetectAndRemovePackageHeader fname) From b1615d183959afd762672d146bd1f5b2e63b3d31 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 20 Aug 2017 09:17:49 -0600 Subject: [PATCH 05/55] cmake: print flag summary --- cmake/CMakeLists.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 76c28fcb72..9a2bc47f9e 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -545,3 +545,28 @@ foreach(PKG ${DEFAULT_PACKAGES} ${OTHER_PACKAGES} ${ACCEL_PACKAGES}) message(STATUS "Building package: ${PKG}") endif() endforeach() + +string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE) +message(STATUS "<<< Build configuration >>> + Build type ${CMAKE_BUILD_TYPE} + Install path ${CMAKE_INSTALL_PREFIX} + Compilers and Flags: + C++ Compiler ${CMAKE_CXX_COMPILER} + Type ${CMAKE_CXX_COMPILER_ID} + C++ Flags ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}") +get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +list(FIND LANGUAGES "Fortran" FORTRAN_ENABLED) +if(LANGUAGES MATCHES ".*Fortran.*") + message(STATUS "Fortran Compiler ${CMAKE_Fortran_COMPILER} + Type ${CMAKE_Fortran_COMPILER_ID} + Fortran Flags ${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}") +endif() +message(STATUS "Linker flags: + Executable ${CMAKE_EXE_LINKER_FLAGS}") +if(BUILD_SHARED_LIBS) + message(STATUS "Shared ${CMAKE_SHARED_LINKER_FLAGS}") +else() + message(STATUS "Static ${CMAKE_STATIC_LINKER_FLAGS}") +endif() +message(STATUS "Link libraries: ${LAMMPS_LINK_LIBS}") + From de5883b7bb8176ac53a76c123fe4f17c29a290fe Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 20 Aug 2017 09:27:12 -0600 Subject: [PATCH 06/55] cmake: LAMMPS_SUFFIX -> LAMMPS_MACHINE --- cmake/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 66f0dd62ce..3582fe96aa 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -520,12 +520,12 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR}) ########################################### # Actually add executable and lib to build ############################################ -set(LAMMPS_SUFFIX "" CACHE STRING "Suffix to append to lmp binary and liblammps") -mark_as_advanced(LAMMPS_SUFFIX) +set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary and liblammps") +mark_as_advanced(LAMMPS_MACHINE) add_library(lammps ${LIB_SOURCES}) target_link_libraries(lammps ${LAMMPS_LINK_LIBS}) -set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION} OUTPUT_NAME lammps${LAMMPS_SUFFIX}) +set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION} OUTPUT_NAME lammps${LAMMPS_MACHINE}) if(INSTALL_LIB) install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${LAMMPS_SOURCE_DIR}/lammps.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) @@ -535,10 +535,10 @@ endif() add_executable(lmp ${LMP_SOURCES}) target_link_libraries(lmp lammps) -set_target_properties(lmp PROPERTIES OUTPUT_NAME lmp${LAMMPS_SUFFIX}) +set_target_properties(lmp PROPERTIES OUTPUT_NAME lmp${LAMMPS_MACHINE}) install(TARGETS lmp DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ENABLE_TESTING) - add_test(ShowHelp lmp${LAMMPS_SUFFIX} -help) + add_test(ShowHelp lmp${LAMMPS_MACHINE} -help) endif() ################################## From 892a3f860922f5aa9b7879d1ca2ea0b021f2361c Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 20 Aug 2017 09:39:51 -0600 Subject: [PATCH 07/55] cmake: make _ in LAMMPS_MACHINE implicit --- cmake/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 3582fe96aa..650308dc93 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -525,7 +525,7 @@ mark_as_advanced(LAMMPS_MACHINE) add_library(lammps ${LIB_SOURCES}) target_link_libraries(lammps ${LAMMPS_LINK_LIBS}) -set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION} OUTPUT_NAME lammps${LAMMPS_MACHINE}) +set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION} OUTPUT_NAME lammps$<$:_>${LAMMPS_MACHINE}) if(INSTALL_LIB) install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${LAMMPS_SOURCE_DIR}/lammps.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) @@ -535,7 +535,7 @@ endif() add_executable(lmp ${LMP_SOURCES}) target_link_libraries(lmp lammps) -set_target_properties(lmp PROPERTIES OUTPUT_NAME lmp${LAMMPS_MACHINE}) +set_target_properties(lmp PROPERTIES OUTPUT_NAME lmp$<$:_>${LAMMPS_MACHINE}) install(TARGETS lmp DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ENABLE_TESTING) add_test(ShowHelp lmp${LAMMPS_MACHINE} -help) From 6d86697b3ff3a47936a8904959e71da15549da48 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 21 Aug 2017 10:18:20 -0600 Subject: [PATCH 08/55] cmake: move option in user options block --- cmake/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 650308dc93..611f8f1682 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -74,6 +74,9 @@ if(LAMMPS_EXCEPTIONS) add_definitions(-DLAMMPS_EXCEPTIONS) endif() +set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary and liblammps") +mark_as_advanced(LAMMPS_MACHINE) + option(CMAKE_VERBOSE_MAKEFILE "Verbose makefile" OFF) option(ENABLE_TESTING "Enable testing" OFF) @@ -520,9 +523,6 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR}) ########################################### # Actually add executable and lib to build ############################################ -set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary and liblammps") -mark_as_advanced(LAMMPS_MACHINE) - add_library(lammps ${LIB_SOURCES}) target_link_libraries(lammps ${LAMMPS_LINK_LIBS}) set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION} OUTPUT_NAME lammps$<$:_>${LAMMPS_MACHINE}) From bdccdbf2c20fb6c0bc66cab4024011a2b60a8a6e Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 21 Aug 2017 10:20:56 -0600 Subject: [PATCH 09/55] cmake: make linker flags more clear --- cmake/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9a2bc47f9e..d5040ee4b9 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -555,7 +555,6 @@ message(STATUS "<<< Build configuration >>> Type ${CMAKE_CXX_COMPILER_ID} C++ Flags ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}") get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) -list(FIND LANGUAGES "Fortran" FORTRAN_ENABLED) if(LANGUAGES MATCHES ".*Fortran.*") message(STATUS "Fortran Compiler ${CMAKE_Fortran_COMPILER} Type ${CMAKE_Fortran_COMPILER_ID} @@ -564,9 +563,9 @@ endif() message(STATUS "Linker flags: Executable ${CMAKE_EXE_LINKER_FLAGS}") if(BUILD_SHARED_LIBS) - message(STATUS "Shared ${CMAKE_SHARED_LINKER_FLAGS}") + message(STATUS "Shared libries ${CMAKE_SHARED_LINKER_FLAGS}") else() - message(STATUS "Static ${CMAKE_STATIC_LINKER_FLAGS}") + message(STATUS "Static libries ${CMAKE_STATIC_LINKER_FLAGS}") endif() message(STATUS "Link libraries: ${LAMMPS_LINK_LIBS}") From c8aa06b959e96814b8da9031a707a0f5868268b3 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 21 Aug 2017 11:12:36 -0600 Subject: [PATCH 10/55] cmake: build libs separate --- cmake/CMakeLists.txt | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 76c28fcb72..d917fef714 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -348,12 +348,26 @@ endforeach() foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD USER-MOLFILE USER-QMMM) if(ENABLE_${SIMPLE_LIB}) - string(REGEX REPLACE "^USER-" "" SIMPLE_LIB "${SIMPLE_LIB}") - string(TOLOWER "${SIMPLE_LIB}" INC_DIR) - file(GLOB_RECURSE ${SIMPLE_LIB}_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/${INC_DIR}/*.F - ${LAMMPS_LIB_SOURCE_DIR}/${INC_DIR}/*.c ${LAMMPS_LIB_SOURCE_DIR}/${INC_DIR}/*.cpp) - list(APPEND LIB_SOURCES ${${SIMPLE_LIB}_SOURCES}) - include_directories(${LAMMPS_LIB_SOURCE_DIR}/${INC_DIR}) + string(REGEX REPLACE "^USER-" "" PKG_LIB "${SIMPLE_LIB}") + string(TOLOWER "${PKG_LIB}" PKG_LIB) + file(GLOB_RECURSE ${PKG_LIB}_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.F + ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.cpp) + option(BUILD_SHARED_PKG_LIBS "Build package libs shared" OFF) + if(BUILD_SHARED_PKG_LIBS) + add_library(${PKG_LIB} SHARED ${${PKG_LIB}_SOURCES}) + set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) + if(INSTALL_LIB) + install(TARGETS ${PKG_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + else() + message(FATAL_ERROR "Shared library has to be installed, use -DINSTALL_LIB=ON to install lammps with a library") + endif() + else() + add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) + endif() + list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) + foreach(PKG_SRC ${${SIMPLE_LIB}_SOURCES}) + set_property(SOURCE ${PKG_SRC} APPEND PROPERTY COMPILE_FLAGS -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) + endforeach() endif() endforeach() From 1f4c550f9fab00198f687af9fd2312b0fb02b66c Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 21 Aug 2017 13:09:52 -0600 Subject: [PATCH 11/55] cmake: make awpmd includes local --- cmake/CMakeLists.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index d917fef714..22b1759ddc 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -248,11 +248,6 @@ if(ENABLE_USER-QMMM) list(APPEND LAMMPS_LINK_LIBS ${QE_LIBRARIES} ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) endif() -if(ENABLE_USER-AWPMD) - include_directories(${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact - ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) -endif() - if(ENABLE_USER-H5MD) find_package(HDF5 REQUIRED) list(APPEND LAMMPS_LINK_LIBS ${HDF5_LIBRARIES}) @@ -366,11 +361,21 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD endif() list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) foreach(PKG_SRC ${${SIMPLE_LIB}_SOURCES}) - set_property(SOURCE ${PKG_SRC} APPEND PROPERTY COMPILE_FLAGS -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) + if(PKG_LIB STREQUAL awpmd) + set_property(SOURCE ${PKG_SRC} APPEND PROPERTY COMPILE_FLAGS -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/systems/interact) + set_property(SOURCE ${PKG_SRC} APPEND APPEND_STRING PROPERTY COMPILE_FLAGS " -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/ivutils/include") + else() + set_property(SOURCE ${PKG_SRC} APPEND PROPERTY COMPILE_FLAGS -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) + endif() endforeach() endif() endforeach() +if(ENABLE_USER-AWPMD) + set_target_properties(awpmd PROPERTIES INCLUDE_DIRECTORIES + "${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact;${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include") +endif() + ###################################################################### # packages which selectively include variants based on enabled styles # e.g. accelerator packages From 5fcc19777c075e8749217ae27d0d0283eee8c903 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 21 Aug 2017 14:24:00 -0600 Subject: [PATCH 12/55] cmake: fix molfile compile --- cmake/CMakeLists.txt | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 22b1759ddc..1f8a0322f5 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -347,19 +347,21 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD string(TOLOWER "${PKG_LIB}" PKG_LIB) file(GLOB_RECURSE ${PKG_LIB}_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.F ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.cpp) - option(BUILD_SHARED_PKG_LIBS "Build package libs shared" OFF) - if(BUILD_SHARED_PKG_LIBS) - add_library(${PKG_LIB} SHARED ${${PKG_LIB}_SOURCES}) - set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) - if(INSTALL_LIB) - install(TARGETS ${PKG_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + if(${PKG_LIB}_SOURCES) #some libs (e.g. molfile have headers only) + if(BUILD_SHARED_PKG_LIBS) + option(BUILD_SHARED_PKG_LIBS "Build package libs shared" OFF) + add_library(${PKG_LIB} SHARED ${${PKG_LIB}_SOURCES}) + set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) + if(INSTALL_LIB) + install(TARGETS ${PKG_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + else() + message(FATAL_ERROR "Shared library has to be installed, use -DINSTALL_LIB=ON to install lammps with a library") + endif() else() - message(FATAL_ERROR "Shared library has to be installed, use -DINSTALL_LIB=ON to install lammps with a library") + add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) endif() - else() - add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) + list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) endif() - list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) foreach(PKG_SRC ${${SIMPLE_LIB}_SOURCES}) if(PKG_LIB STREQUAL awpmd) set_property(SOURCE ${PKG_SRC} APPEND PROPERTY COMPILE_FLAGS -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/systems/interact) From cf3f15b0a5b3b0f68add1b65c5655e132ec2d0fe Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 21 Aug 2017 15:04:03 -0600 Subject: [PATCH 13/55] cmake: make h5md includes local --- cmake/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 1f8a0322f5..7ac0294f09 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -248,12 +248,6 @@ if(ENABLE_USER-QMMM) list(APPEND LAMMPS_LINK_LIBS ${QE_LIBRARIES} ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) endif() -if(ENABLE_USER-H5MD) - find_package(HDF5 REQUIRED) - list(APPEND LAMMPS_LINK_LIBS ${HDF5_LIBRARIES}) - include_directories(${HDF5_INCLUDE_DIRS} ${LAMMPS_LIB_SOURCE_DIR}/h5md/include) -endif() - if(ENABLE_USER-VTK) find_package(VTK REQUIRED NO_MODULE) include(${VTK_USE_FILE}) @@ -366,6 +360,8 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD if(PKG_LIB STREQUAL awpmd) set_property(SOURCE ${PKG_SRC} APPEND PROPERTY COMPILE_FLAGS -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/systems/interact) set_property(SOURCE ${PKG_SRC} APPEND APPEND_STRING PROPERTY COMPILE_FLAGS " -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/ivutils/include") + elseif(PKG_LIB STREQUAL h5md) + include_directories(${LAMMPS_LIB_SOURCE_DIR}/h5md/include) #ch5md.h is included indirectly in style.h else() set_property(SOURCE ${PKG_SRC} APPEND PROPERTY COMPILE_FLAGS -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) endif() @@ -378,6 +374,13 @@ if(ENABLE_USER-AWPMD) "${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact;${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include") endif() +if(ENABLE_USER-H5MD) + find_package(HDF5 REQUIRED) + target_link_libraries(h5md ${HDF5_LIBRARIES}) + set_target_properties(h5md PROPERTIES INCLUDE_DIRECTORIES + "${HDF5_INCLUDE_DIRS};${LAMMPS_LIB_SOURCE_DIR}/h5md/include") +endif() + ###################################################################### # packages which selectively include variants based on enabled styles # e.g. accelerator packages From c5ccbbeea756f34180dd5d574faa9fa0123fb7c6 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Tue, 22 Aug 2017 07:13:04 -0600 Subject: [PATCH 14/55] cmake: fix 'make test' --- cmake/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 37bd19392b..4aeec84d18 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -72,7 +72,7 @@ if(LAMMPS_EXCEPTIONS) add_definitions(-DLAMMPS_EXCEPTIONS) endif() -set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary and liblammps") +set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary and liblammps (WON'T enable any features automatically") mark_as_advanced(LAMMPS_MACHINE) option(CMAKE_VERBOSE_MAKEFILE "Verbose makefile" OFF) @@ -550,7 +550,7 @@ target_link_libraries(lmp lammps) set_target_properties(lmp PROPERTIES OUTPUT_NAME lmp$<$:_>${LAMMPS_MACHINE}) install(TARGETS lmp DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ENABLE_TESTING) - add_test(ShowHelp lmp${LAMMPS_MACHINE} -help) + add_test(ShowHelp lmp$<$:_>${LAMMPS_MACHINE} -help) endif() ################################## From 67ae2719a877a0cfd2605abeafbbe396c67d6b08 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sun, 27 Aug 2017 03:04:32 -0400 Subject: [PATCH 15/55] Simplify lib build by using target_include_directories --- cmake/CMakeLists.txt | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 7ac0294f09..53984cbf17 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -355,30 +355,23 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) endif() list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) - endif() - foreach(PKG_SRC ${${SIMPLE_LIB}_SOURCES}) if(PKG_LIB STREQUAL awpmd) - set_property(SOURCE ${PKG_SRC} APPEND PROPERTY COMPILE_FLAGS -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/systems/interact) - set_property(SOURCE ${PKG_SRC} APPEND APPEND_STRING PROPERTY COMPILE_FLAGS " -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/ivutils/include") + target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) elseif(PKG_LIB STREQUAL h5md) - include_directories(${LAMMPS_LIB_SOURCE_DIR}/h5md/include) #ch5md.h is included indirectly in style.h + target_include_directories(h5md PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/h5md/include) else() - set_property(SOURCE ${PKG_SRC} APPEND PROPERTY COMPILE_FLAGS -I${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) + target_include_directories(${PKG_LIB} PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) endif() - endforeach() + else() + include_directories(${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) + endif() endif() endforeach() -if(ENABLE_USER-AWPMD) - set_target_properties(awpmd PROPERTIES INCLUDE_DIRECTORIES - "${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact;${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include") -endif() - if(ENABLE_USER-H5MD) find_package(HDF5 REQUIRED) target_link_libraries(h5md ${HDF5_LIBRARIES}) - set_target_properties(h5md PROPERTIES INCLUDE_DIRECTORIES - "${HDF5_INCLUDE_DIRS};${LAMMPS_LIB_SOURCE_DIR}/h5md/include") + target_include_directories(h5md PRIVATE ${HDF5_INCLUDE_DIRS}) endif() ###################################################################### From 76926b7fcf9828b774d2cf6fbfd4da3be4898b01 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sun, 27 Aug 2017 03:54:40 -0400 Subject: [PATCH 16/55] Compile linalg as library and track link dependencies for correct link order --- cmake/CMakeLists.txt | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 53984cbf17..6abf445f3d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -162,12 +162,23 @@ endif() if(ENABLE_MSCG OR ENABLE_USER-ATC OR ENABLE_USER-AWPMD OR ENABLE_USER-QUIP) find_package(LAPACK) - if(LAPACK_FOUND) - list(APPEND LAMMPS_LINK_LIBS ${LAPACK_LIBRARIES}) - else() + if(NOT LAPACK_FOUND) enable_language(Fortran) file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/*.f) - list(APPEND LIB_SOURCES ${LAPACK_SOURCES}) + + if(BUILD_SHARED_PKG_LIBS) + add_library(linalg SHARED ${LAPACK_SOURCES}) + set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) + if(INSTALL_LIB) + install(TARGETS linalg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + else() + message(FATAL_ERROR "Shared library has to be installed, use -DINSTALL_LIB=ON to install lammps with a library") + endif() + else() + add_library(linalg STATIC ${LAPACK_SOURCES}) + endif() + target_compile_options(linalg PRIVATE -fno-second-underscore) + set(LAPACK_LIBRARIES linalg) endif() endif() @@ -368,6 +379,14 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD endif() endforeach() +if(ENABLE_USER-AWPMD) + target_link_libraries(awpmd ${LAPACK_LIBRARIES}) +endif() + +if(ENABLE_USER-ATC) + target_link_libraries(atc ${LAPACK_LIBRARIES}) +endif() + if(ENABLE_USER-H5MD) find_package(HDF5 REQUIRED) target_link_libraries(h5md ${HDF5_LIBRARIES}) From 47f16c0d70b349198aba02bfc94805062339ed57 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 07:06:08 -0600 Subject: [PATCH 17/55] cmake: move shared libs install warning in one place --- cmake/CMakeLists.txt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 6abf445f3d..c130b9d090 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -43,7 +43,11 @@ include(CheckCCompilerFlag) # User input options # ######################################################################## option(BUILD_SHARED_LIBS "Build shared libs" OFF) +option(BUILD_SHARED_PKG_LIBS "Build package libs shared" OFF) option(INSTALL_LIB "Install lammps library and header" ON) +if(NOT INSTALL_LIB AND ( BUILD_SHARED_LIBS OR BUILD_SHARED_PKG_LIBS ) ) + message(FATAL_ERROR "Shared libs need to be installed, enable install with -DINSTALL_LIB=ON") +endif() include(GNUInstallDirs) set(LAMMPS_LINK_LIBS) @@ -171,8 +175,6 @@ if(ENABLE_MSCG OR ENABLE_USER-ATC OR ENABLE_USER-AWPMD OR ENABLE_USER-QUIP) set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) if(INSTALL_LIB) install(TARGETS linalg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - else() - message(FATAL_ERROR "Shared library has to be installed, use -DINSTALL_LIB=ON to install lammps with a library") endif() else() add_library(linalg STATIC ${LAPACK_SOURCES}) @@ -354,13 +356,10 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.cpp) if(${PKG_LIB}_SOURCES) #some libs (e.g. molfile have headers only) if(BUILD_SHARED_PKG_LIBS) - option(BUILD_SHARED_PKG_LIBS "Build package libs shared" OFF) add_library(${PKG_LIB} SHARED ${${PKG_LIB}_SOURCES}) set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) if(INSTALL_LIB) install(TARGETS ${PKG_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - else() - message(FATAL_ERROR "Shared library has to be installed, use -DINSTALL_LIB=ON to install lammps with a library") endif() else() add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) @@ -562,8 +561,6 @@ set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) if(INSTALL_LIB) install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${LAMMPS_SOURCE_DIR}/lammps.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -elseif(BUILD_SHARED_LIBS) - message(FATAL_ERROR "Shared library has to be installed, use -DINSTALL_LIB=ON to install lammps with a library") endif() add_executable(lmp ${LMP_SOURCES}) From b7ec720f91fcda0513fa5757ff0d95f6755a6c39 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 07:13:55 -0600 Subject: [PATCH 18/55] link QUIP against LAPACK_LIB too --- cmake/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c130b9d090..b15e7183e7 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -252,7 +252,7 @@ endif() if(ENABLE_USER-QUIP) find_package(QUIP REQUIRED) - list(APPEND LAMMPS_LINK_LIBS ${QUIP_LIBRARIES} ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) + list(APPEND LAMMPS_LINK_LIBS ${QUIP_LIBRARIES} ${LAPACK_LIBRARIES} ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) endif() if(ENABLE_USER-QMMM) From bdc117bf1089ea63dd18226cb9b495e7d6332463 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 07:15:00 -0600 Subject: [PATCH 19/55] cmake: convert mscg into a lib --- cmake/CMakeLists.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b15e7183e7..aec40ca852 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -291,13 +291,11 @@ if(ENABLE_MSCG) WORKING_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/mscg) endif() file(GLOB MSCG_SOURCES ${LAMMPS_LIB_MSCG_BIN_DIR}/*.cpp) - list(APPEND LIB_SOURCES ${MSCG_SOURCES}) - foreach(MSCG_SOURCE ${MSCG_SOURCES}) - set_property(SOURCE ${MSCG_SOURCE} APPEND PROPERTY COMPILE_DEFINITIONS - DIMENSION=3 _exclude_gromacs=1) - endforeach() - include_directories(${LAMMPS_LIB_MSCG_BIN_DIR} ${GSL_INCLUDE_DIRS}) - list(APPEND LAMMPS_LINK_LIBS ${GSL_LIBRARIES}) + add_library(mscg ${MSCG_SOURCES}) + list(APPEND LAMMPS_LINK_LIBS mscg) + target_compile_options(mscg PRIVATE -DDIMENSION=3 -D_exclude_gromacs=1) + target_include_directories(mscg PUBLIC ${LAMMPS_LIB_MSCG_BIN_DIR}) + target_link_libraries(mscg ${GSL_LIBRARIES} ${LAPACK_LIBRARIES}) endif() ######################################################################## From 98f27162ba6aea6bbb554b6a544756dac5a9cba1 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 08:58:47 -0600 Subject: [PATCH 20/55] make libmpi_stubs --- cmake/CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index aec40ca852..ea06528daa 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -62,8 +62,17 @@ if(ENABLE_MPI) endif() else() file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c) - list(APPEND LIB_SOURCES ${MPI_SOURCES}) + if(BUILD_SHARED_PKG_LIBS) + add_library(mpi_stubs SHARED ${MPI_SOURCES}) + set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) + if(INSTALL_LIB) + install(TARGETS mpi_stubs LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() + else() + add_library(mpi_stubs STATIC ${MPI_SOURCES}) + endif() include_directories(${LAMMPS_SOURCE_DIR}/STUBS) + list(APPEND LAMMPS_LINK_LIBS mpi_stubs) endif() set(LAMMPS_SIZE_LIMIT "LAMMPS_SMALLBIG" CACHE STRING "Lammps size limit") @@ -160,7 +169,8 @@ endif() if(ENABLE_MISC) option(LAMMPS_XDR "include XDR compatibility files for doing particle dumps in XTC format" OFF) if(LAMMPS_XDR) - add_definitions(-DLAMMPS_XDR) + target_compile_options(pkg_MISC PRIVATE -DLAMMPS_XDR) + add_definitions(-DLAMMPS_XDR) # for liblammps endif() endif() From e4415735f2e53a7486bf2f68fd6326789041d68c Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 12:10:46 -0600 Subject: [PATCH 21/55] check for '-fno-second-underscore' --- cmake/CMakeLists.txt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index ea06528daa..ecffc0484d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -135,6 +135,8 @@ endif() ###################################################### if(ENABLE_REAX OR ENABLE_MEAM OR ENABLE_USER-QUIP OR ENABLE_USER-QMMM) enable_language(Fortran) + include(CheckFortranCompilerFlag) + check_Fortran_compiler_flag("-fno-second-underscore" FC_HAS_NO_SECOND_UNDERSCORE) endif() if(ENABLE_KOKKOS OR ENABLE_MSCG) @@ -189,7 +191,11 @@ if(ENABLE_MSCG OR ENABLE_USER-ATC OR ENABLE_USER-AWPMD OR ENABLE_USER-QUIP) else() add_library(linalg STATIC ${LAPACK_SOURCES}) endif() - target_compile_options(linalg PRIVATE -fno-second-underscore) + include(CheckFortranCompilerFlag) + check_Fortran_compiler_flag("-fno-second-underscore" FC_HAS_NO_SECOND_UNDERSCORE) + if(FC_HAS_NO_SECOND_UNDERSCORE) + target_compile_options(linalg PRIVATE -fno-second-underscore) + endif() set(LAPACK_LIBRARIES linalg) endif() endif() @@ -399,6 +405,19 @@ if(ENABLE_USER-H5MD) target_link_libraries(h5md ${HDF5_LIBRARIES}) target_include_directories(h5md PRIVATE ${HDF5_INCLUDE_DIRS}) endif() + +if(ENABLE_MEAM AND FC_HAS_NO_SECOND_UNDERSCORE) + foreach(FSRC ${meam_SOURCES}) + if(FSRC MATCHES "\.F$") + set_property(SOURCE ${MSCG_SOURCE} APPEND PROPERTY COMPILE_FLAGS "-fno-second-underscore") + endif() + endforeach() +endif() + +if(ENABLE_REAX AND FC_HAS_NO_SECOND_UNDERSCORE) + target_compile_options(reax PRIVATE -fno-second-underscore) +endif() + ###################################################################### # packages which selectively include variants based on enabled styles From bc1186898697aa0bf28f79c0c4e74f26002153e5 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 12:13:35 -0600 Subject: [PATCH 22/55] cmake: fixed a typo --- cmake/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index ecffc0484d..96a4082c31 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -171,7 +171,6 @@ endif() if(ENABLE_MISC) option(LAMMPS_XDR "include XDR compatibility files for doing particle dumps in XTC format" OFF) if(LAMMPS_XDR) - target_compile_options(pkg_MISC PRIVATE -DLAMMPS_XDR) add_definitions(-DLAMMPS_XDR) # for liblammps endif() endif() From c196025ea958d4809c35f6775eda32995ef88e34 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 12:23:30 -0600 Subject: [PATCH 23/55] make molfile less special --- cmake/CMakeLists.txt | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 96a4082c31..503adeb3e8 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -250,7 +250,10 @@ if(ENABLE_VORONOI) endif() if(ENABLE_USER-MOLFILE) - list(APPEND LAMMPS_LINK_LIBS ${CMAKE_DL_LIBS}) + add_library(molfile INTERFACE) + target_include_directories(molfile INTERFACE ${LAMMPS_LIB_SOURCE_DIR}/molfile) + target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS}) + list(APPEND LAMMPS_LINK_LIBS molfile) endif() if(ENABLE_USER-NETCDF) @@ -361,32 +364,28 @@ endforeach() # add lib sources of (simple) enabled packages ############################################ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD - USER-MOLFILE USER-QMMM) + USER-QMMM) if(ENABLE_${SIMPLE_LIB}) string(REGEX REPLACE "^USER-" "" PKG_LIB "${SIMPLE_LIB}") string(TOLOWER "${PKG_LIB}" PKG_LIB) file(GLOB_RECURSE ${PKG_LIB}_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.F ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.cpp) - if(${PKG_LIB}_SOURCES) #some libs (e.g. molfile have headers only) - if(BUILD_SHARED_PKG_LIBS) - add_library(${PKG_LIB} SHARED ${${PKG_LIB}_SOURCES}) - set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) - if(INSTALL_LIB) - install(TARGETS ${PKG_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - else() - add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) - endif() - list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) - if(PKG_LIB STREQUAL awpmd) - target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) - elseif(PKG_LIB STREQUAL h5md) - target_include_directories(h5md PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/h5md/include) - else() - target_include_directories(${PKG_LIB} PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) + if(BUILD_SHARED_PKG_LIBS) + add_library(${PKG_LIB} SHARED ${${PKG_LIB}_SOURCES}) + set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) + if(INSTALL_LIB) + install(TARGETS ${PKG_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() else() - include_directories(${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) + add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) + endif() + list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) + if(PKG_LIB STREQUAL awpmd) + target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) + elseif(PKG_LIB STREQUAL h5md) + target_include_directories(h5md PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/h5md/include) + else() + target_include_directories(${PKG_LIB} PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) endif() endif() endforeach() From 5308ee67fa378e65fcb8f066520c19a894bc0fbe Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 13:45:48 -0600 Subject: [PATCH 24/55] fix shared build and mscg install --- cmake/CMakeLists.txt | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 503adeb3e8..9fec9bc306 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -64,7 +64,7 @@ else() file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c) if(BUILD_SHARED_PKG_LIBS) add_library(mpi_stubs SHARED ${MPI_SOURCES}) - set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) + set_target_properties(mpi_stubs PROPERTIES SOVERSION ${SOVERSION}) if(INSTALL_LIB) install(TARGETS mpi_stubs LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() @@ -190,6 +190,9 @@ if(ENABLE_MSCG OR ENABLE_USER-ATC OR ENABLE_USER-AWPMD OR ENABLE_USER-QUIP) else() add_library(linalg STATIC ${LAPACK_SOURCES}) endif() + if(BUILD_SHARED_LIBS) + set_target_properties(linalg PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif() include(CheckFortranCompilerFlag) check_Fortran_compiler_flag("-fno-second-underscore" FC_HAS_NO_SECOND_UNDERSCORE) if(FC_HAS_NO_SECOND_UNDERSCORE) @@ -309,7 +312,18 @@ if(ENABLE_MSCG) WORKING_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/mscg) endif() file(GLOB MSCG_SOURCES ${LAMMPS_LIB_MSCG_BIN_DIR}/*.cpp) - add_library(mscg ${MSCG_SOURCES}) + if(BUILD_SHARED_PKG_LIBS) + add_library(mscg SHARED ${MSCG_SOURCES}) + set_target_properties(mscg PROPERTIES SOVERSION ${SOVERSION}) + if(INSTALL_LIB) + install(TARGETS mscg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() + else() + add_library(mscg STATIC ${MSCG_SOURCES}) + endif() + if(BUILD_SHARED_LIBS) + set_target_properties(mscg PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif() list(APPEND LAMMPS_LINK_LIBS mscg) target_compile_options(mscg PRIVATE -DDIMENSION=3 -D_exclude_gromacs=1) target_include_directories(mscg PUBLIC ${LAMMPS_LIB_MSCG_BIN_DIR}) @@ -379,6 +393,9 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD else() add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) endif() + if(BUILD_SHARED_LIBS) + set_target_properties(${PKG_LIB} PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif() list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) if(PKG_LIB STREQUAL awpmd) target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) From 313b8bc2fad06dabf96469b7bb25740295eada08 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sun, 27 Aug 2017 16:58:19 -0400 Subject: [PATCH 25/55] build lib/gpu as a library --- cmake/CMakeLists.txt | 58 +++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9fec9bc306..03f9b2f7f3 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -535,36 +535,31 @@ if(ENABLE_GPU) if(NOT BIN2C) message(FATAL_ERROR "Couldn't find bin2c, use -DBIN2C helping cmake to find it.") endif() - include_directories(${CUDA_INCLUDE_DIRS}) - list(APPEND LAMMPS_LINK_LIBS ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) set(GPU_PREC "SINGLE_DOUBLE" CACHE STRING "Lammps gpu precision size") set_property(CACHE GPU_PREC PROPERTY STRINGS SINGLE_DOUBLE SINGLE_SINGLE DOUBLE_DOUBLE) - add_definitions(-D_${GPU_PREC}) - add_definitions(-DNV_KERNEL -DUCL_CUDADR) option(CUDPP_OPT "Enable CUDPP_OPT" ON) - - set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU) - set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h) - - set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}") - - # detects styles which have GPU version - RegisterStylesExt(${GPU_SOURCES_DIR} opt GPU_SOURCES) - - get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES) file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cpp) file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cu ${CMAKE_SOURCE_DIR}/gpu/*.cu) file(GLOB_RECURSE GPU_NOT_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu) list(REMOVE_ITEM GPU_LIB_CU ${GPU_NOT_LIB_CU}) - include_directories(${GPU_SOURCES_DIR} ${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu) + + # still missing a way to limit defines to GPU build only + # something like cuda_compile_definitions() + # one way is this, the other adding it to OPTIONS + add_definitions(-D_${GPU_PREC}) + add_definitions(-DNV_KERNEL -DUCL_CUDADR) + + cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu) + if(CUDPP_OPT) - include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) - add_definitions(-DCUDPP_OPT) + cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) file(GLOB GPU_LIB_CUDPP_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/*.cpp) file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/*.cu) endif() + cuda_compile(GPU_OBJS ${GPU_LIB_CU} ${GPU_LIB_CUDPP_CU} OPTIONS $<$:-Xcompiler=-fPIC>) + file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu) foreach(CU_OBJ ${GPU_OBJS}) get_filename_component(CU_NAME ${CU_OBJ} NAME_WE) @@ -573,14 +568,39 @@ if(ENABLE_GPU) COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h DEPENDS ${CU_OBJ} COMMENT "Generating ${CU_NAME}_cubin.h") - list(APPEND LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h) + list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h) if(${CU_NAME} STREQUAL "pppm_d") #pppm_d doesn't get linked into the lib set(CU_FORBIDDEN_OBJ "${CU_OBJ}") endif() endforeach() list(REMOVE_ITEM GPU_OBJS "${CU_FORBIDDEN_OBJ}") - list(APPEND LIB_SOURCES ${GPU_SOURCES} ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS}) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h") + + + cuda_add_library(gpu ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS} STATIC) + target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu) + if(CUDPP_OPT) + target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) + target_compile_definitions(gpu PRIVATE -DUSE_CUDPP) + endif() + + list(APPEND LAMMPS_LINK_LIBS gpu) + + + # GPU package + + set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU) + set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h) + include_directories(${GPU_SOURCES_DIR}) + + set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}") + + # detects styles which have GPU version + RegisterStylesExt(${GPU_SOURCES_DIR} opt GPU_SOURCES) + + get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES) + + list(APPEND LIB_SOURCES ${GPU_SOURCES}) endif() ###################################################### From 153c771a6ddc58df97b2ef860208a25a7437a4e4 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sun, 27 Aug 2017 17:27:43 -0400 Subject: [PATCH 26/55] Use PIC in mpi_stubs when BUILD_SHARED_LIBS=on --- cmake/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 03f9b2f7f3..877f8d3e44 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -71,6 +71,9 @@ else() else() add_library(mpi_stubs STATIC ${MPI_SOURCES}) endif() + if(BUILD_SHARED_LIBS) + set_target_properties(mpi_stubs PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif() include_directories(${LAMMPS_SOURCE_DIR}/STUBS) list(APPEND LAMMPS_LINK_LIBS mpi_stubs) endif() From 4bff0087779d9819cd74080fbedb8568f26ff1a1 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 18:40:55 -0600 Subject: [PATCH 27/55] enable PIC globally --- cmake/CMakeLists.txt | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 877f8d3e44..e038f4d619 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -48,6 +48,9 @@ option(INSTALL_LIB "Install lammps library and header" ON) if(NOT INSTALL_LIB AND ( BUILD_SHARED_LIBS OR BUILD_SHARED_PKG_LIBS ) ) message(FATAL_ERROR "Shared libs need to be installed, enable install with -DINSTALL_LIB=ON") endif() +if(BUILD_SHARED_LIBS OR BUILD_SHARED_PKG_LIBS) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif() include(GNUInstallDirs) set(LAMMPS_LINK_LIBS) @@ -71,9 +74,6 @@ else() else() add_library(mpi_stubs STATIC ${MPI_SOURCES}) endif() - if(BUILD_SHARED_LIBS) - set_target_properties(mpi_stubs PROPERTIES POSITION_INDEPENDENT_CODE ON) - endif() include_directories(${LAMMPS_SOURCE_DIR}/STUBS) list(APPEND LAMMPS_LINK_LIBS mpi_stubs) endif() @@ -193,9 +193,6 @@ if(ENABLE_MSCG OR ENABLE_USER-ATC OR ENABLE_USER-AWPMD OR ENABLE_USER-QUIP) else() add_library(linalg STATIC ${LAPACK_SOURCES}) endif() - if(BUILD_SHARED_LIBS) - set_target_properties(linalg PROPERTIES POSITION_INDEPENDENT_CODE ON) - endif() include(CheckFortranCompilerFlag) check_Fortran_compiler_flag("-fno-second-underscore" FC_HAS_NO_SECOND_UNDERSCORE) if(FC_HAS_NO_SECOND_UNDERSCORE) @@ -324,9 +321,6 @@ if(ENABLE_MSCG) else() add_library(mscg STATIC ${MSCG_SOURCES}) endif() - if(BUILD_SHARED_LIBS) - set_target_properties(mscg PROPERTIES POSITION_INDEPENDENT_CODE ON) - endif() list(APPEND LAMMPS_LINK_LIBS mscg) target_compile_options(mscg PRIVATE -DDIMENSION=3 -D_exclude_gromacs=1) target_include_directories(mscg PUBLIC ${LAMMPS_LIB_MSCG_BIN_DIR}) @@ -396,9 +390,6 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD else() add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) endif() - if(BUILD_SHARED_LIBS) - set_target_properties(${PKG_LIB} PROPERTIES POSITION_INDEPENDENT_CODE ON) - endif() list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) if(PKG_LIB STREQUAL awpmd) target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) From 57872c8b60be02590788c23f32d5d4e2541e2fd6 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 18:42:32 -0600 Subject: [PATCH 28/55] drop INSTALL_LIB option --- cmake/CMakeLists.txt | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e038f4d619..a63a67e6cc 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -44,10 +44,6 @@ include(CheckCCompilerFlag) ######################################################################## option(BUILD_SHARED_LIBS "Build shared libs" OFF) option(BUILD_SHARED_PKG_LIBS "Build package libs shared" OFF) -option(INSTALL_LIB "Install lammps library and header" ON) -if(NOT INSTALL_LIB AND ( BUILD_SHARED_LIBS OR BUILD_SHARED_PKG_LIBS ) ) - message(FATAL_ERROR "Shared libs need to be installed, enable install with -DINSTALL_LIB=ON") -endif() if(BUILD_SHARED_LIBS OR BUILD_SHARED_PKG_LIBS) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() @@ -68,12 +64,10 @@ else() if(BUILD_SHARED_PKG_LIBS) add_library(mpi_stubs SHARED ${MPI_SOURCES}) set_target_properties(mpi_stubs PROPERTIES SOVERSION ${SOVERSION}) - if(INSTALL_LIB) - install(TARGETS mpi_stubs LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() else() add_library(mpi_stubs STATIC ${MPI_SOURCES}) endif() + install(TARGETS mpi_stubs LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) include_directories(${LAMMPS_SOURCE_DIR}/STUBS) list(APPEND LAMMPS_LINK_LIBS mpi_stubs) endif() @@ -187,12 +181,10 @@ if(ENABLE_MSCG OR ENABLE_USER-ATC OR ENABLE_USER-AWPMD OR ENABLE_USER-QUIP) if(BUILD_SHARED_PKG_LIBS) add_library(linalg SHARED ${LAPACK_SOURCES}) set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) - if(INSTALL_LIB) - install(TARGETS linalg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() else() add_library(linalg STATIC ${LAPACK_SOURCES}) endif() + install(TARGETS linalg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) include(CheckFortranCompilerFlag) check_Fortran_compiler_flag("-fno-second-underscore" FC_HAS_NO_SECOND_UNDERSCORE) if(FC_HAS_NO_SECOND_UNDERSCORE) @@ -315,12 +307,10 @@ if(ENABLE_MSCG) if(BUILD_SHARED_PKG_LIBS) add_library(mscg SHARED ${MSCG_SOURCES}) set_target_properties(mscg PROPERTIES SOVERSION ${SOVERSION}) - if(INSTALL_LIB) - install(TARGETS mscg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() else() add_library(mscg STATIC ${MSCG_SOURCES}) endif() + install(TARGETS mscg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) list(APPEND LAMMPS_LINK_LIBS mscg) target_compile_options(mscg PRIVATE -DDIMENSION=3 -D_exclude_gromacs=1) target_include_directories(mscg PUBLIC ${LAMMPS_LIB_MSCG_BIN_DIR}) @@ -384,12 +374,10 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD if(BUILD_SHARED_PKG_LIBS) add_library(${PKG_LIB} SHARED ${${PKG_LIB}_SOURCES}) set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) - if(INSTALL_LIB) - install(TARGETS ${PKG_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() else() add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) endif() + install(TARGETS ${PKG_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) if(PKG_LIB STREQUAL awpmd) target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) @@ -614,10 +602,8 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR}) add_library(lammps ${LIB_SOURCES}) target_link_libraries(lammps ${LAMMPS_LINK_LIBS}) set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) -if(INSTALL_LIB) - install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(FILES ${LAMMPS_SOURCE_DIR}/lammps.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -endif() +install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(FILES ${LAMMPS_SOURCE_DIR}/lammps.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) add_executable(lmp ${LMP_SOURCES}) target_link_libraries(lmp lammps) From f47cc0aab5515bb0790c65a73e8982c79f81551e Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sun, 27 Aug 2017 18:55:28 -0600 Subject: [PATCH 29/55] simpilfy pkg lib build --- cmake/CMakeLists.txt | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index a63a67e6cc..a0fc2a9801 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -47,6 +47,11 @@ option(BUILD_SHARED_PKG_LIBS "Build package libs shared" OFF) if(BUILD_SHARED_LIBS OR BUILD_SHARED_PKG_LIBS) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +if(BUILD_SHARED_PKG_LIBS) + set(PKG_LIBS_BUILD_TYPE "SHARED") +else() + set(PKG_LIBS_BUILD_TYPE "STATIC") +endif() include(GNUInstallDirs) set(LAMMPS_LINK_LIBS) @@ -61,12 +66,8 @@ if(ENABLE_MPI) endif() else() file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c) - if(BUILD_SHARED_PKG_LIBS) - add_library(mpi_stubs SHARED ${MPI_SOURCES}) - set_target_properties(mpi_stubs PROPERTIES SOVERSION ${SOVERSION}) - else() - add_library(mpi_stubs STATIC ${MPI_SOURCES}) - endif() + add_library(mpi_stubs ${PKG_LIBS_BUILD_TYPE} ${MPI_SOURCES}) + set_target_properties(mpi_stubs PROPERTIES SOVERSION ${SOVERSION}) install(TARGETS mpi_stubs LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) include_directories(${LAMMPS_SOURCE_DIR}/STUBS) list(APPEND LAMMPS_LINK_LIBS mpi_stubs) @@ -177,13 +178,8 @@ if(ENABLE_MSCG OR ENABLE_USER-ATC OR ENABLE_USER-AWPMD OR ENABLE_USER-QUIP) if(NOT LAPACK_FOUND) enable_language(Fortran) file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/*.f) - - if(BUILD_SHARED_PKG_LIBS) - add_library(linalg SHARED ${LAPACK_SOURCES}) - set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) - else() - add_library(linalg STATIC ${LAPACK_SOURCES}) - endif() + add_library(linalg ${PKG_LIBS_BUILD_TYPE} ${LAPACK_SOURCES}) + set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) install(TARGETS linalg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) include(CheckFortranCompilerFlag) check_Fortran_compiler_flag("-fno-second-underscore" FC_HAS_NO_SECOND_UNDERSCORE) @@ -304,12 +300,8 @@ if(ENABLE_MSCG) WORKING_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/mscg) endif() file(GLOB MSCG_SOURCES ${LAMMPS_LIB_MSCG_BIN_DIR}/*.cpp) - if(BUILD_SHARED_PKG_LIBS) - add_library(mscg SHARED ${MSCG_SOURCES}) - set_target_properties(mscg PROPERTIES SOVERSION ${SOVERSION}) - else() - add_library(mscg STATIC ${MSCG_SOURCES}) - endif() + add_library(mscg ${PKG_LIBS_BUILD_TYPE} ${MSCG_SOURCES}) + set_target_properties(mscg PROPERTIES SOVERSION ${SOVERSION}) install(TARGETS mscg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) list(APPEND LAMMPS_LINK_LIBS mscg) target_compile_options(mscg PRIVATE -DDIMENSION=3 -D_exclude_gromacs=1) @@ -371,12 +363,8 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD string(TOLOWER "${PKG_LIB}" PKG_LIB) file(GLOB_RECURSE ${PKG_LIB}_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.F ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.cpp) - if(BUILD_SHARED_PKG_LIBS) - add_library(${PKG_LIB} SHARED ${${PKG_LIB}_SOURCES}) - set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) - else() - add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) - endif() + add_library(${PKG_LIB} ${PKG_LIBS_BUILD_TYPE} ${${PKG_LIB}_SOURCES}) + set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) install(TARGETS ${PKG_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) if(PKG_LIB STREQUAL awpmd) From c8dfe0c3de6f70c1dc65326ca33b1c97f2168e70 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 28 Aug 2017 13:17:27 -0600 Subject: [PATCH 30/55] drop BUILD_SHARED_PKG_LIBS and make all pkglibs static --- cmake/CMakeLists.txt | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index a0fc2a9801..638a79e891 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -43,15 +43,9 @@ include(CheckCCompilerFlag) # User input options # ######################################################################## option(BUILD_SHARED_LIBS "Build shared libs" OFF) -option(BUILD_SHARED_PKG_LIBS "Build package libs shared" OFF) -if(BUILD_SHARED_LIBS OR BUILD_SHARED_PKG_LIBS) +if(BUILD_SHARED_LIBS) # for all pkg libs, mpi_stubs and linalg set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() -if(BUILD_SHARED_PKG_LIBS) - set(PKG_LIBS_BUILD_TYPE "SHARED") -else() - set(PKG_LIBS_BUILD_TYPE "STATIC") -endif() include(GNUInstallDirs) set(LAMMPS_LINK_LIBS) @@ -66,9 +60,8 @@ if(ENABLE_MPI) endif() else() file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c) - add_library(mpi_stubs ${PKG_LIBS_BUILD_TYPE} ${MPI_SOURCES}) + add_library(mpi_stubs STATIC ${MPI_SOURCES}) set_target_properties(mpi_stubs PROPERTIES SOVERSION ${SOVERSION}) - install(TARGETS mpi_stubs LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) include_directories(${LAMMPS_SOURCE_DIR}/STUBS) list(APPEND LAMMPS_LINK_LIBS mpi_stubs) endif() @@ -178,9 +171,8 @@ if(ENABLE_MSCG OR ENABLE_USER-ATC OR ENABLE_USER-AWPMD OR ENABLE_USER-QUIP) if(NOT LAPACK_FOUND) enable_language(Fortran) file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/*.f) - add_library(linalg ${PKG_LIBS_BUILD_TYPE} ${LAPACK_SOURCES}) + add_library(linalg STATIC ${LAPACK_SOURCES}) set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) - install(TARGETS linalg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) include(CheckFortranCompilerFlag) check_Fortran_compiler_flag("-fno-second-underscore" FC_HAS_NO_SECOND_UNDERSCORE) if(FC_HAS_NO_SECOND_UNDERSCORE) @@ -300,9 +292,8 @@ if(ENABLE_MSCG) WORKING_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/mscg) endif() file(GLOB MSCG_SOURCES ${LAMMPS_LIB_MSCG_BIN_DIR}/*.cpp) - add_library(mscg ${PKG_LIBS_BUILD_TYPE} ${MSCG_SOURCES}) + add_library(mscg STATIC ${MSCG_SOURCES}) set_target_properties(mscg PROPERTIES SOVERSION ${SOVERSION}) - install(TARGETS mscg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) list(APPEND LAMMPS_LINK_LIBS mscg) target_compile_options(mscg PRIVATE -DDIMENSION=3 -D_exclude_gromacs=1) target_include_directories(mscg PUBLIC ${LAMMPS_LIB_MSCG_BIN_DIR}) @@ -363,9 +354,8 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD string(TOLOWER "${PKG_LIB}" PKG_LIB) file(GLOB_RECURSE ${PKG_LIB}_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.F ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.cpp) - add_library(${PKG_LIB} ${PKG_LIBS_BUILD_TYPE} ${${PKG_LIB}_SOURCES}) + add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) - install(TARGETS ${PKG_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) if(PKG_LIB STREQUAL awpmd) target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) @@ -590,8 +580,10 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR}) add_library(lammps ${LIB_SOURCES}) target_link_libraries(lammps ${LAMMPS_LINK_LIBS}) set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) -install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(FILES ${LAMMPS_SOURCE_DIR}/lammps.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +if(BUILD_SHARED_LIBS) + install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(FILES ${LAMMPS_SOURCE_DIR}/lammps.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +endif() add_executable(lmp ${LMP_SOURCES}) target_link_libraries(lmp lammps) From 62928a16377bc449449f2597093af66b2da91596 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 28 Aug 2017 13:24:41 -0600 Subject: [PATCH 31/55] make GPU flags local to libgpu --- cmake/CMakeLists.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 638a79e891..4296a040c8 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -504,12 +504,6 @@ if(ENABLE_GPU) file(GLOB_RECURSE GPU_NOT_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu) list(REMOVE_ITEM GPU_LIB_CU ${GPU_NOT_LIB_CU}) - # still missing a way to limit defines to GPU build only - # something like cuda_compile_definitions() - # one way is this, the other adding it to OPTIONS - add_definitions(-D_${GPU_PREC}) - add_definitions(-DNV_KERNEL -DUCL_CUDADR) - cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu) if(CUDPP_OPT) @@ -518,7 +512,9 @@ if(ENABLE_GPU) file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/*.cu) endif() - cuda_compile(GPU_OBJS ${GPU_LIB_CU} ${GPU_LIB_CUDPP_CU} OPTIONS $<$:-Xcompiler=-fPIC>) + cuda_compile(GPU_OBJS ${GPU_LIB_CU} ${GPU_LIB_CUDPP_CU} OPTIONS + $<$:-Xcompiler=-fPIC> + -DNV_KERNEL -DUCL_CUDADR -D_${GPU_PREC}) file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu) foreach(CU_OBJ ${GPU_OBJS}) From 9207f6540e848212d6fe2512edc3a52880cbcbc3 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 28 Aug 2017 14:11:21 -0600 Subject: [PATCH 32/55] fix liblammps install --- cmake/CMakeLists.txt | 7 ++++++- cmake/pkgconfig/liblammps.pc.in | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 cmake/pkgconfig/liblammps.pc.in diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 4296a040c8..d143f5bc2f 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -49,6 +49,7 @@ endif() include(GNUInstallDirs) set(LAMMPS_LINK_LIBS) +set(LAMMPS_API_DEFINES) option(ENABLE_MPI "Build MPI version" OFF) if(ENABLE_MPI) find_package(MPI REQUIRED) @@ -69,6 +70,7 @@ endif() set(LAMMPS_SIZE_LIMIT "LAMMPS_SMALLBIG" CACHE STRING "Lammps size limit") set_property(CACHE LAMMPS_SIZE_LIMIT PROPERTY STRINGS LAMMPS_SMALLBIG LAMMPS_BIGBIG LAMMPS_SMALLSMALL) add_definitions(-D${LAMMPS_SIZE_LIMIT}) +set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -D${LAMMPS_SIZE_LIMIT}") set(LAMMPS_MEMALIGN "64" CACHE STRING "enables the use of the posix_memalign() call instead of malloc() when large chunks or memory are allocated by LAMMPS") add_definitions(-DLAMMPS_MEMALIGN=${LAMMPS_MEMALIGN}) @@ -76,6 +78,7 @@ add_definitions(-DLAMMPS_MEMALIGN=${LAMMPS_MEMALIGN}) option(LAMMPS_EXCEPTIONS "enable the use of C++ exceptions for error messages (useful for library interface)" OFF) if(LAMMPS_EXCEPTIONS) add_definitions(-DLAMMPS_EXCEPTIONS) + set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES -DLAMMPS_EXCEPTIONS") endif() option(CMAKE_VERBOSE_MAKEFILE "Verbose makefile" OFF) @@ -578,7 +581,9 @@ target_link_libraries(lammps ${LAMMPS_LINK_LIBS}) set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) if(BUILD_SHARED_LIBS) install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(FILES ${LAMMPS_SOURCE_DIR}/lammps.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(FILES ${LAMMPS_SOURCE_DIR}/library.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps) + configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() add_executable(lmp ${LMP_SOURCES}) diff --git a/cmake/pkgconfig/liblammps.pc.in b/cmake/pkgconfig/liblammps.pc.in new file mode 100644 index 0000000000..643b4ba501 --- /dev/null +++ b/cmake/pkgconfig/liblammps.pc.in @@ -0,0 +1,18 @@ +# pkg-config file for lammps +# https://people.freedesktop.org/~dbn/pkg-config-guide.html +# Usage: cc `pkg-config --cflags --libs liblammps` -o myapp myapp.c +# after you added @CMAKE_INSTALL_FULL_LIBDIR@/pkg-config to PKG_CONFIG_PATH, +# e.g. export PKG_CONFIG_PATH=@CMAKE_INSTALL_FULL_LIBDIR@/pkgconfig + +prefix=@CMAKE_INSTALL_FULL_PREFIX@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: liblammps +Description: Large-scale Atomic/Molecular Massively Parallel Simulator Library +URL: http://lammps.sandia.gov +Version: +Requires: +Libs: -L${libdir} -llammps +Libs.private: -lm +Cflags: -I${includedir} @LAMMPS_API_DEFINES@ From bd9dc4886d89228677f1a07fea7a2ff0d3bf371d Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 28 Aug 2017 14:27:12 -0600 Subject: [PATCH 33/55] cmake: README is markdown --- cmake/{README => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cmake/{README => README.md} (100%) diff --git a/cmake/README b/cmake/README.md similarity index 100% rename from cmake/README rename to cmake/README.md From 19b77857dc3efbe51a949b82d3251fa20ba3abe7 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 28 Aug 2017 14:59:01 -0600 Subject: [PATCH 34/55] fix Fortran flags for MEAM --- cmake/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index d143f5bc2f..f49dfb977e 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -386,8 +386,10 @@ endif() if(ENABLE_MEAM AND FC_HAS_NO_SECOND_UNDERSCORE) foreach(FSRC ${meam_SOURCES}) - if(FSRC MATCHES "\.F$") - set_property(SOURCE ${MSCG_SOURCE} APPEND PROPERTY COMPILE_FLAGS "-fno-second-underscore") + string(REGEX REPLACE "^.*\\." "" FEXT "${FSRC}") + list(FIND CMAKE_Fortran_SOURCE_FILE_EXTENSIONS "${FEXT}" FINDEX) + if(FINDEX GREATER -1) + set_property(SOURCE ${FSRC} APPEND PROPERTY COMPILE_FLAGS "-fno-second-underscore") endif() endforeach() endif() From 098861375bf08d5a64b8353b7f69e18bca7c5922 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Mon, 28 Aug 2017 16:18:58 -0600 Subject: [PATCH 35/55] SOVERSION not needed for STATIC libs --- cmake/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f49dfb977e..aee928ed9a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -62,7 +62,6 @@ if(ENABLE_MPI) else() file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c) add_library(mpi_stubs STATIC ${MPI_SOURCES}) - set_target_properties(mpi_stubs PROPERTIES SOVERSION ${SOVERSION}) include_directories(${LAMMPS_SOURCE_DIR}/STUBS) list(APPEND LAMMPS_LINK_LIBS mpi_stubs) endif() @@ -175,7 +174,6 @@ if(ENABLE_MSCG OR ENABLE_USER-ATC OR ENABLE_USER-AWPMD OR ENABLE_USER-QUIP) enable_language(Fortran) file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/*.f) add_library(linalg STATIC ${LAPACK_SOURCES}) - set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) include(CheckFortranCompilerFlag) check_Fortran_compiler_flag("-fno-second-underscore" FC_HAS_NO_SECOND_UNDERSCORE) if(FC_HAS_NO_SECOND_UNDERSCORE) @@ -296,7 +294,6 @@ if(ENABLE_MSCG) endif() file(GLOB MSCG_SOURCES ${LAMMPS_LIB_MSCG_BIN_DIR}/*.cpp) add_library(mscg STATIC ${MSCG_SOURCES}) - set_target_properties(mscg PROPERTIES SOVERSION ${SOVERSION}) list(APPEND LAMMPS_LINK_LIBS mscg) target_compile_options(mscg PRIVATE -DDIMENSION=3 -D_exclude_gromacs=1) target_include_directories(mscg PUBLIC ${LAMMPS_LIB_MSCG_BIN_DIR}) @@ -358,7 +355,6 @@ foreach(SIMPLE_LIB REAX MEAM POEMS USER-ATC USER-AWPMD USER-COLVARS USER-H5MD file(GLOB_RECURSE ${PKG_LIB}_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.F ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/*.cpp) add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) - set_target_properties(${PKG_LIB} PROPERTIES SOVERSION ${SOVERSION}) list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB}) if(PKG_LIB STREQUAL awpmd) target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) @@ -580,8 +576,8 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR}) ############################################ add_library(lammps ${LIB_SOURCES}) target_link_libraries(lammps ${LAMMPS_LINK_LIBS}) -set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) if(BUILD_SHARED_LIBS) + set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${LAMMPS_SOURCE_DIR}/library.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps) configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps.pc @ONLY) From 34b3fc21572c02b0f0128dc4dfe7b902ece53bb1 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 29 Aug 2017 01:04:39 -0400 Subject: [PATCH 36/55] Fix GPU CMake compilation --- cmake/CMakeLists.txt | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index aee928ed9a..6b29c80e61 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -499,11 +499,13 @@ if(ENABLE_GPU) set(GPU_PREC "SINGLE_DOUBLE" CACHE STRING "Lammps gpu precision size") set_property(CACHE GPU_PREC PROPERTY STRINGS SINGLE_DOUBLE SINGLE_SINGLE DOUBLE_DOUBLE) option(CUDPP_OPT "Enable CUDPP_OPT" ON) + + set(GPU_ARCH "sm_30" CACHE STRING "LAMMPS GPU CUDA SM architecture") + set_property(CACHE GPU_ARCH PROPERTY STRINGS sm_10 sm_20 sm_30 sm_60) file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cpp) file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cu ${CMAKE_SOURCE_DIR}/gpu/*.cu) - file(GLOB_RECURSE GPU_NOT_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu) - list(REMOVE_ITEM GPU_LIB_CU ${GPU_NOT_LIB_CU}) + list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu) cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu) @@ -513,12 +515,14 @@ if(ENABLE_GPU) file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/*.cu) endif() - cuda_compile(GPU_OBJS ${GPU_LIB_CU} ${GPU_LIB_CUDPP_CU} OPTIONS - $<$:-Xcompiler=-fPIC> - -DNV_KERNEL -DUCL_CUDADR -D_${GPU_PREC}) + cuda_compile_cubin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS + -DUNIX -O3 -Xptxas -v --use_fast_math -DNV_KERNEL -DUCL_CUDADR -arch=${GPU_ARCH} -D_${GPU_PREC}) + + cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS $<$:-Xcompiler=-fPIC> + -DUNIX -O3 -Xptxas -v --use_fast_math -DUCL_CUDADR -arch=${GPU_ARCH} -D_${GPU_PREC}) file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu) - foreach(CU_OBJ ${GPU_OBJS}) + foreach(CU_OBJ ${GPU_GEN_OBJS}) get_filename_component(CU_NAME ${CU_OBJ} NAME_WE) string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}") add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h @@ -526,16 +530,13 @@ if(ENABLE_GPU) DEPENDS ${CU_OBJ} COMMENT "Generating ${CU_NAME}_cubin.h") list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h) - if(${CU_NAME} STREQUAL "pppm_d") #pppm_d doesn't get linked into the lib - set(CU_FORBIDDEN_OBJ "${CU_OBJ}") - endif() endforeach() - list(REMOVE_ITEM GPU_OBJS "${CU_FORBIDDEN_OBJ}") set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h") - cuda_add_library(gpu ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS} STATIC) - target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu) + add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS}) + target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS}) + target_compile_definitions(gpu PRIVATE -D_${GPU_PREC} -DMPI_GERYON -DUCL_NO_EXIT) if(CUDPP_OPT) target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) target_compile_definitions(gpu PRIVATE -DUSE_CUDPP) @@ -543,21 +544,31 @@ if(ENABLE_GPU) list(APPEND LAMMPS_LINK_LIBS gpu) + add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp) + target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR) + target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) + target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS}) + # GPU package + list(APPEND LAMMPS_LINK_LIBS ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU) - set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h) + set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h + ${GPU_SOURCES_DIR}/fix_gpu.h + ${GPU_SOURCES_DIR}/fix_gpu.cpp) + FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX) include_directories(${GPU_SOURCES_DIR}) set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}") # detects styles which have GPU version - RegisterStylesExt(${GPU_SOURCES_DIR} opt GPU_SOURCES) + RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES) get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES) list(APPEND LIB_SOURCES ${GPU_SOURCES}) + include_directories(${GPU_SOURCES_DIR}) endif() ###################################################### From 27c962dc3b81a5714fd890b117f4b8c238a02483 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Wed, 30 Aug 2017 09:45:01 -0600 Subject: [PATCH 37/55] link cuda in gpu only, remove duplicated incl. dir --- cmake/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 6b29c80e61..af51708cad 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -551,14 +551,13 @@ if(ENABLE_GPU) # GPU package - list(APPEND LAMMPS_LINK_LIBS ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) + target_link_libraries(gpu ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) 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) FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX) - include_directories(${GPU_SOURCES_DIR}) set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}") From dbc60d949f566fe9828989d981e43a7b23f88ee7 Mon Sep 17 00:00:00 2001 From: Anders Hafreager Date: Wed, 6 Sep 2017 15:08:02 +0200 Subject: [PATCH 38/55] Fixed OpenCL compilation issues with __global keywords --- lib/gpu/lal_sw.cu | 8 ++++---- lib/gpu/lal_tersoff.cu | 10 +++++----- lib/gpu/lal_vashishta.cu | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/gpu/lal_sw.cu b/lib/gpu/lal_sw.cu index a5c9f49d08..517de70691 100644 --- a/lib/gpu/lal_sw.cu +++ b/lib/gpu/lal_sw.cu @@ -217,7 +217,7 @@ __kernel void k_sw(const __global numtyp4 *restrict x_, if (ii Date: Wed, 6 Sep 2017 11:35:52 -0400 Subject: [PATCH 39/55] fix typo in commands table --- doc/src/Section_commands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/Section_commands.txt b/doc/src/Section_commands.txt index 32b714e1de..010454b870 100644 --- a/doc/src/Section_commands.txt +++ b/doc/src/Section_commands.txt @@ -532,7 +532,7 @@ package"_Section_start.html#start_3. "dump vtk"_dump_vtk.html, "group2ndx"_group2ndx.html, "ndx2group"_group2ndx.html, -"temper/grem"_temper_grem.html +"temper/grem"_temper_grem.html, "temper/npt"_temper_npt.html :tb(c=3,ea=c) :line From de8297ea194b877a97e1c6d104c13f0a7372e676 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 6 Sep 2017 12:02:14 -0400 Subject: [PATCH 40/55] recover ability to compile USER-INTEL without OpenMP enabled --- src/USER-INTEL/intel_preprocess.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/USER-INTEL/intel_preprocess.h b/src/USER-INTEL/intel_preprocess.h index 24cb92a0f3..a7663d54a6 100644 --- a/src/USER-INTEL/intel_preprocess.h +++ b/src/USER-INTEL/intel_preprocess.h @@ -255,11 +255,10 @@ enum {TIME_PACK, TIME_HOST_NEIGHBOR, TIME_HOST_PAIR, TIME_OFFLOAD_NEIGHBOR, ito = inum; \ } -#define IP_PRE_omp_range(ifrom, ip, ito, tid, inum, nthreads) \ +#define IP_PRE_omp_range(ifrom, ito, tid, inum, nthreads) \ { \ ifrom = 0; \ ito = inum; \ - ip = 1; \ } #define IP_PRE_omp_stride_id(ifrom, ip, ito, tid, inum, nthr) \ From 8a06a7bc6bfec056477653d9e5dc2c09668e0512 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 8 Sep 2017 22:20:47 -0400 Subject: [PATCH 41/55] Add OpenCL support to CMake build --- cmake/CMakeLists.txt | 176 ++++++++++++++++++++------------ cmake/Modules/OpenCLUtils.cmake | 18 ++++ 2 files changed, 128 insertions(+), 66 deletions(-) create mode 100644 cmake/Modules/OpenCLUtils.cmake diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index af51708cad..79445c4b1e 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -95,7 +95,7 @@ set(OTHER_PACKAGES KIM PYTHON MSCG MPIIO VORONOI POEMS USER-ATC USER-AWPMD USER-CGDNA USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB USER-MANIFOLD USER-MEAMC USER-MGPT USER-MISC - USER-MOLFILE USER-NETCDF USER-PHONON USER-QTB USER-REAXC USER-SMD + USER-MOLFILE USER-NETCDF USER-PHONON USER-QTB USER-REAXC USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-VTK USER-QUIP USER-QMMM) set(ACCEL_PACKAGES USER-OMP KOKKOS OPT USER-INTEL GPU) foreach(PKG ${DEFAULT_PACKAGES}) @@ -323,7 +323,7 @@ endforeach(FUNC) list(APPEND LAMMPS_LINK_LIBS ${MATH_LIBRARIES}) ###################################### -# Generate Basic Style files +# Generate Basic Style files ###################################### include(StyleHeaderUtils) RegisterStyles(${LAMMPS_SOURCE_DIR}) @@ -379,7 +379,7 @@ if(ENABLE_USER-H5MD) target_link_libraries(h5md ${HDF5_LIBRARIES}) target_include_directories(h5md PRIVATE ${HDF5_INCLUDE_DIRS}) endif() - + if(ENABLE_MEAM AND FC_HAS_NO_SECOND_UNDERSCORE) foreach(FSRC ${meam_SOURCES}) string(REGEX REPLACE "^.*\\." "" FEXT "${FSRC}") @@ -491,72 +491,116 @@ if(ENABLE_USER-INTEL) endif() if(ENABLE_GPU) - find_package(CUDA REQUIRED) - find_program(BIN2C bin2c) - if(NOT BIN2C) - message(FATAL_ERROR "Couldn't find bin2c, use -DBIN2C helping cmake to find it.") - endif() - set(GPU_PREC "SINGLE_DOUBLE" CACHE STRING "Lammps gpu precision size") - set_property(CACHE GPU_PREC PROPERTY STRINGS SINGLE_DOUBLE SINGLE_SINGLE DOUBLE_DOUBLE) - option(CUDPP_OPT "Enable CUDPP_OPT" ON) - - set(GPU_ARCH "sm_30" CACHE STRING "LAMMPS GPU CUDA SM architecture") - set_property(CACHE GPU_ARCH PROPERTY STRINGS sm_10 sm_20 sm_30 sm_60) - - file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cpp) - file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cu ${CMAKE_SOURCE_DIR}/gpu/*.cu) - list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu) - - cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu) - - if(CUDPP_OPT) - cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) - file(GLOB GPU_LIB_CUDPP_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/*.cpp) - file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/*.cu) - endif() - - cuda_compile_cubin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS - -DUNIX -O3 -Xptxas -v --use_fast_math -DNV_KERNEL -DUCL_CUDADR -arch=${GPU_ARCH} -D_${GPU_PREC}) - - cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS $<$:-Xcompiler=-fPIC> - -DUNIX -O3 -Xptxas -v --use_fast_math -DUCL_CUDADR -arch=${GPU_ARCH} -D_${GPU_PREC}) - - file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu) - foreach(CU_OBJ ${GPU_GEN_OBJS}) - get_filename_component(CU_NAME ${CU_OBJ} NAME_WE) - string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}") - add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h - COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h - DEPENDS ${CU_OBJ} - COMMENT "Generating ${CU_NAME}_cubin.h") - list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h) - endforeach() - set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h") - - - add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS}) - target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS}) - target_compile_definitions(gpu PRIVATE -D_${GPU_PREC} -DMPI_GERYON -DUCL_NO_EXIT) - if(CUDPP_OPT) - target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) - target_compile_definitions(gpu PRIVATE -DUSE_CUDPP) - endif() - - list(APPEND LAMMPS_LINK_LIBS gpu) - - add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp) - target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR) - target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) - target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS}) - - - # GPU package - target_link_libraries(gpu ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) - 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) + + set(GPU_API "OpenCL" CACHE STRING "API used by GPU package") + set_property(CACHE GPU_API PROPERTY STRINGS OpenCL CUDA) + + set(GPU_PREC "SINGLE_DOUBLE" CACHE STRING "LAMMPS GPU precision size") + set_property(CACHE GPU_PREC PROPERTY STRINGS SINGLE_DOUBLE SINGLE_SINGLE DOUBLE_DOUBLE) + + file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cpp) + file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu) + + if(GPU_API STREQUAL "CUDA") + find_package(CUDA REQUIRED) + find_program(BIN2C bin2c) + if(NOT BIN2C) + message(FATAL_ERROR "Couldn't find bin2c, use -DBIN2C helping cmake to find it.") + endif() + option(CUDPP_OPT "Enable CUDPP_OPT" ON) + + set(GPU_ARCH "sm_30" CACHE STRING "LAMMPS GPU CUDA SM architecture") + set_property(CACHE GPU_ARCH PROPERTY STRINGS sm_10 sm_20 sm_30 sm_60) + + file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cu ${CMAKE_SOURCE_DIR}/gpu/*.cu) + list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu) + + cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu) + + if(CUDPP_OPT) + cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) + file(GLOB GPU_LIB_CUDPP_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/*.cpp) + file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/*.cu) + endif() + + cuda_compile_cubin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS + -DUNIX -O3 -Xptxas -v --use_fast_math -DNV_KERNEL -DUCL_CUDADR -arch=${GPU_ARCH} -D_${GPU_PREC}) + + cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS $<$:-Xcompiler=-fPIC> + -DUNIX -O3 -Xptxas -v --use_fast_math -DUCL_CUDADR -arch=${GPU_ARCH} -D_${GPU_PREC}) + + foreach(CU_OBJ ${GPU_GEN_OBJS}) + get_filename_component(CU_NAME ${CU_OBJ} NAME_WE) + string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}") + add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h + COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h + DEPENDS ${CU_OBJ} + COMMENT "Generating ${CU_NAME}_cubin.h") + list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h) + endforeach() + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h") + + + add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS}) + target_link_libraries(gpu ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) + target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS}) + target_compile_definitions(gpu PRIVATE -D_${GPU_PREC} -DMPI_GERYON -DUCL_NO_EXIT) + if(CUDPP_OPT) + target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini) + target_compile_definitions(gpu PRIVATE -DUSE_CUDPP) + endif() + + list(APPEND LAMMPS_LINK_LIBS gpu) + + add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp) + target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR) + target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) + target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS}) + + + elseif(GPU_API STREQUAL "OpenCL") + find_package(OpenCL REQUIRED) + if(OpenCL_FOUND) + set(OCL_TUNE "GENERIC" CACHE STRING "OpenCL Device Tuning") + set_property(CACHE OCL_TUNE PROPERTY STRINGS INTEL FERMI KEPLER CYPRESS GENERIC) + + include(OpenCLUtils) + set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h) + + file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cu) + list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu) + + foreach(GPU_KERNEL ${GPU_LIB_CU}) + get_filename_component(basename ${GPU_KERNEL} NAME_WE) + string(SUBSTRING ${basename} 4 -1 KERNEL_NAME) + GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL}) + list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h) + endforeach() + + GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu) + GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu) + list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h) + + add_library(gpu STATIC ${GPU_LIB_SOURCES}) + target_link_libraries(gpu ${OpenCL_LIBRARIES}) + target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu ${OpenCL_INCLUDE_DIRS}) + target_compile_definitions(gpu PRIVATE -D_${GPU_PREC} -DMPI_GERYON -DUCL_NO_EXIT) + target_compile_definitions(gpu PRIVATE -DUSE_OPENCL) + + list(APPEND LAMMPS_LINK_LIBS gpu) + + 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_LIBRARIES}) + target_include_directories(ocl_get_devices PRIVATE ${OpenCL_INCLUDE_DIRS}) + endif() + endif() + + # GPU package FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX) set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}") @@ -572,7 +616,7 @@ endif() ###################################################### # Generate style headers based on global list of -# styles registered during package selection +# styles registered during package selection ###################################################### set(LAMMPS_STYLE_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/styles) diff --git a/cmake/Modules/OpenCLUtils.cmake b/cmake/Modules/OpenCLUtils.cmake new file mode 100644 index 0000000000..5c147a685c --- /dev/null +++ b/cmake/Modules/OpenCLUtils.cmake @@ -0,0 +1,18 @@ +function(GenerateOpenCLHeader varname outfile files) + message("Creating ${outfile}...") + file(WRITE ${outfile} "const char * ${varname} = \n") + math(EXPR ARG_END "${ARGC}-1") + + foreach(IDX RANGE 2 ${ARG_END}) + list(GET ARGV ${IDX} filename) + file(READ ${filename} content) + string(REGEX REPLACE "\\s*//[^\n]*\n" "" content "${content}") + string(REGEX REPLACE "\\\\" "\\\\\\\\" content "${content}") + string(REGEX REPLACE "\"" "\\\\\"" content "${content}") + string(REGEX REPLACE "([^\n]+)\n" "\"\\1\\\\n\"\n" content "${content}") + string(REGEX REPLACE "\n+" "\n" content "${content}") + file(APPEND ${outfile} "${content}") + endforeach() + + file(APPEND ${outfile} ";\n") +endfunction(GenerateOpenCLHeader) From 3fdb6f10fac8cae64be7febfa22ae41a001ac2b0 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sat, 9 Sep 2017 06:51:24 -0600 Subject: [PATCH 42/55] cmake: OpenCL is always found if required --- cmake/CMakeLists.txt | 52 +++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 436dd6856d..190e825de8 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -579,40 +579,38 @@ if(ENABLE_GPU) elseif(GPU_API STREQUAL "OpenCL") find_package(OpenCL REQUIRED) - if(OpenCL_FOUND) - set(OCL_TUNE "GENERIC" CACHE STRING "OpenCL Device Tuning") - set_property(CACHE OCL_TUNE PROPERTY STRINGS INTEL FERMI KEPLER CYPRESS GENERIC) + set(OCL_TUNE "GENERIC" CACHE STRING "OpenCL Device Tuning") + set_property(CACHE OCL_TUNE PROPERTY STRINGS INTEL FERMI KEPLER CYPRESS GENERIC) - include(OpenCLUtils) - set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h) + include(OpenCLUtils) + set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h) - file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cu) - list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu) + file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/*.cu) + list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu) - foreach(GPU_KERNEL ${GPU_LIB_CU}) - get_filename_component(basename ${GPU_KERNEL} NAME_WE) - string(SUBSTRING ${basename} 4 -1 KERNEL_NAME) - GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL}) - list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h) - endforeach() + foreach(GPU_KERNEL ${GPU_LIB_CU}) + get_filename_component(basename ${GPU_KERNEL} NAME_WE) + string(SUBSTRING ${basename} 4 -1 KERNEL_NAME) + GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL}) + list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h) + endforeach() - GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu) - GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu) - list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h) + GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu) + GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu) + list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h) - add_library(gpu STATIC ${GPU_LIB_SOURCES}) - target_link_libraries(gpu ${OpenCL_LIBRARIES}) - target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu ${OpenCL_INCLUDE_DIRS}) - target_compile_definitions(gpu PRIVATE -D_${GPU_PREC} -DMPI_GERYON -DUCL_NO_EXIT) - target_compile_definitions(gpu PRIVATE -DUSE_OPENCL) + add_library(gpu STATIC ${GPU_LIB_SOURCES}) + target_link_libraries(gpu ${OpenCL_LIBRARIES}) + target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu ${OpenCL_INCLUDE_DIRS}) + target_compile_definitions(gpu PRIVATE -D_${GPU_PREC} -DMPI_GERYON -DUCL_NO_EXIT) + target_compile_definitions(gpu PRIVATE -DUSE_OPENCL) - list(APPEND LAMMPS_LINK_LIBS gpu) + list(APPEND LAMMPS_LINK_LIBS gpu) - 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_LIBRARIES}) - target_include_directories(ocl_get_devices PRIVATE ${OpenCL_INCLUDE_DIRS}) - endif() + 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_LIBRARIES}) + target_include_directories(ocl_get_devices PRIVATE ${OpenCL_INCLUDE_DIRS}) endif() # GPU package From 1601433ca1e5256bc793312a88fe4ef2e7971649 Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sat, 9 Sep 2017 07:05:51 -0600 Subject: [PATCH 43/55] cmake: fix lib suffix --- cmake/CMakeLists.txt | 12 ++++++++---- cmake/pkgconfig/liblammps.pc.in | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 190e825de8..8f6449f684 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -80,6 +80,9 @@ endif() set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary and liblammps (WON'T enable any features automatically") mark_as_advanced(LAMMPS_MACHINE) +if(LAMMPS_MACHINE) + set(LAMMPS_MACHINE "_${LAMMPS_MACHINE}") +endif() option(CMAKE_VERBOSE_MAKEFILE "Verbose makefile" OFF) @@ -643,20 +646,21 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR}) ############################################ add_library(lammps ${LIB_SOURCES}) target_link_libraries(lammps ${LAMMPS_LINK_LIBS}) +set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LAMMPS_MACHINE}) if(BUILD_SHARED_LIBS) set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${LAMMPS_SOURCE_DIR}/library.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps) - configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + 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) endif() add_executable(lmp ${LMP_SOURCES}) target_link_libraries(lmp lammps) -set_target_properties(lmp PROPERTIES OUTPUT_NAME lmp$<$:_>${LAMMPS_MACHINE}) +set_target_properties(lmp PROPERTIES OUTPUT_NAME lmp${LAMMPS_MACHINE}) install(TARGETS lmp DESTINATION ${CMAKE_INSTALL_BINDIR}) if(ENABLE_TESTING) - add_test(ShowHelp lmp$<$:_>${LAMMPS_MACHINE} -help) + add_test(ShowHelp lmp${LAMMPS_MACHINE} -help) endif() ################################## diff --git a/cmake/pkgconfig/liblammps.pc.in b/cmake/pkgconfig/liblammps.pc.in index 643b4ba501..c5e1701782 100644 --- a/cmake/pkgconfig/liblammps.pc.in +++ b/cmake/pkgconfig/liblammps.pc.in @@ -8,11 +8,11 @@ prefix=@CMAKE_INSTALL_FULL_PREFIX@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ -Name: liblammps +Name: liblammps@LAMMPS_MACHINE@ Description: Large-scale Atomic/Molecular Massively Parallel Simulator Library URL: http://lammps.sandia.gov Version: Requires: -Libs: -L${libdir} -llammps +Libs: -L${libdir} -llammps@LAMMPS_MACHINE@ Libs.private: -lm Cflags: -I${includedir} @LAMMPS_API_DEFINES@ From 0be7f4675083ef9e00970f850d26c5c097c89e2c Mon Sep 17 00:00:00 2001 From: Christoph Junghans Date: Sat, 9 Sep 2017 08:25:57 -0600 Subject: [PATCH 44/55] cmake: added USER-MESO --- cmake/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 8f6449f684..e1e082005b 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -96,7 +96,7 @@ set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GRANU KSPACE MANYBODY MC MEAM MISC MOLECULE PERI QEQ REAX REPLICA RIGID SHOCK SNAP SRD) set(OTHER_PACKAGES KIM PYTHON MSCG MPIIO VORONOI POEMS - USER-ATC USER-AWPMD USER-CGDNA + USER-ATC USER-AWPMD USER-CGDNA USER-MESO USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB USER-MANIFOLD USER-MEAMC USER-MGPT USER-MISC USER-MOLFILE USER-NETCDF USER-PHONON USER-QTB USER-REAXC USER-SMD From 84b84c10db1b69ac28dad41f2cee0848b7abb2fb Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sat, 9 Sep 2017 19:53:56 -0400 Subject: [PATCH 45/55] Use OpenCL 2.x API in GPU package when supported --- lib/gpu/geryon/ocl_device.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/gpu/geryon/ocl_device.h b/lib/gpu/geryon/ocl_device.h index 20656c8489..138b03c091 100644 --- a/lib/gpu/geryon/ocl_device.h +++ b/lib/gpu/geryon/ocl_device.h @@ -140,8 +140,13 @@ class UCL_Device { inline void push_command_queue() { cl_int errorv; _cq.push_back(cl_command_queue()); - _cq.back()=clCreateCommandQueue(_context,_cl_device, - CL_QUEUE_PROFILING_ENABLE,&errorv); + +#ifdef CL_VERSION_2_0 + cl_queue_properties props[] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; + _cq.back()=clCreateCommandQueueWithProperties(_context, _cl_device, props, &errorv); +#else + _cq.back()=clCreateCommandQueue(_context, _cl_device, CL_QUEUE_PROFILING_ENABLE, &errorv); +#endif if (errorv!=CL_SUCCESS) { std::cerr << "Could not create command queue on device: " << name() << std::endl; From b3547a9eca79b73c352bf3f7a8a3838908f87535 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 11 Sep 2017 11:09:59 -0400 Subject: [PATCH 46/55] add infrastructure for enabling fixes to contribute to the virial by aidan --- src/fix.cpp | 87 +++++++++++++++++++++++++++++++++++++++++++++++++---- src/fix.h | 3 ++ 2 files changed, 84 insertions(+), 6 deletions(-) diff --git a/src/fix.cpp b/src/fix.cpp index e6e8a292b9..80fa00f4b3 100644 --- a/src/fix.cpp +++ b/src/fix.cpp @@ -31,7 +31,7 @@ int Fix::instance_total = 0; /* ---------------------------------------------------------------------- */ -Fix::Fix(LAMMPS *lmp, int narg, char **arg) : +Fix::Fix(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp), id(NULL), style(NULL), extlist(NULL), vector_atom(NULL), array_atom(NULL), vector_local(NULL), array_local(NULL), eatom(NULL), vatom(NULL) @@ -61,6 +61,7 @@ Fix::Fix(LAMMPS *lmp, int narg, char **arg) : force_reneighbor = 0; box_change_size = box_change_shape = box_change_domain = 0; thermo_energy = 0; + thermo_virial = 0; rigid_flag = 0; peatom_flag = 0; virial_flag = 0; @@ -140,8 +141,20 @@ void Fix::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"energy") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix_modify command"); if (strcmp(arg[iarg+1],"no") == 0) thermo_energy = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) thermo_energy = 1; - else error->all(FLERR,"Illegal fix_modify command"); + else if (strcmp(arg[iarg+1],"yes") == 0) { + if (!(THERMO_ENERGY & setmask())) + error->all(FLERR,"Illegal fix_modify command"); + thermo_energy = 1; + } else error->all(FLERR,"Illegal fix_modify command"); + iarg += 2; + } else if (strcmp(arg[iarg],"virial") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix_modify command"); + if (strcmp(arg[iarg+1],"no") == 0) thermo_virial = 0; + else if (strcmp(arg[iarg+1],"yes") == 0) { + if (virial_flag == 0) + error->all(FLERR,"Illegal fix_modify command"); + thermo_virial = 1; + } else error->all(FLERR,"Illegal fix_modify command"); iarg += 2; } else if (strcmp(arg[iarg],"respa") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix_modify command"); @@ -214,15 +227,22 @@ void Fix::ev_setup(int eflag, int vflag) } /* ---------------------------------------------------------------------- - setup for virial computation - see integrate::ev_set() for values of vflag (0-6) - fixes call this if use v_tally() + if thermo_virial is on: + setup for virial computation + see integrate::ev_set() for values of vflag (0-6) + fixes call this if use v_tally() + else: set evflag=0 ------------------------------------------------------------------------- */ void Fix::v_setup(int vflag) { int i,n; + if (!thermo_virial) { + evflag = 0; + return; + } + evflag = 1; vflag_global = vflag % 4; @@ -316,3 +336,58 @@ void Fix::v_tally(int n, int *list, double total, double *v) } } } + +/* ---------------------------------------------------------------------- + tally virial into global and per-atom accumulators + i = local index of atom + v = total virial for the interaction + increment global virial by v + increment per-atom virial by v + this method can be used when fix computes forces in post_force() + and the force depends on a distance to some external object + e.g. fix wall/lj93: compute virial only on owned atoms +------------------------------------------------------------------------- */ + +void Fix::v_tally(int i, double *v) +{ + + if (vflag_global) { + virial[0] += v[0]; + virial[1] += v[1]; + virial[2] += v[2]; + virial[3] += v[3]; + virial[4] += v[4]; + virial[5] += v[5]; + } + + if (vflag_atom) { + vatom[i][0] += v[0]; + vatom[i][1] += v[1]; + vatom[i][2] += v[2]; + vatom[i][3] += v[3]; + vatom[i][4] += v[4]; + vatom[i][5] += v[5]; + } +} + +/* ---------------------------------------------------------------------- + tally virial component into global and per-atom accumulators + n = index of virial component (0-5) + i = local index of atom + vn = nth component of virial for the interaction + increment nth component of global virial by vn + increment nth component of per-atom virial by vn + this method can be used when fix computes forces in post_force() + and the force depends on a distance to some external object + e.g. fix wall/lj93: compute virial only on owned atoms +------------------------------------------------------------------------- */ + +void Fix::v_tally(int n, int i, double vn) +{ + + if (vflag_global) + virial[n] += vn; + + if (vflag_atom) + vatom[i][n] += vn; +} diff --git a/src/fix.h b/src/fix.h index d91937848a..3f32895309 100644 --- a/src/fix.h +++ b/src/fix.h @@ -36,6 +36,7 @@ class Fix : protected Pointers { bigint next_reneighbor; // next timestep to force a reneighboring int thermo_energy; // 1 if fix_modify enabled ThEng, 0 if not + int thermo_virial; // 1 if fix_modify enabled ThVir, 0 if not int nevery; // how often to call an end_of_step fix int rigid_flag; // 1 if Fix integrates rigid bodies, 0 if not int peatom_flag; // 1 if Fix contributes per-atom eng, 0 if not @@ -223,6 +224,8 @@ class Fix : protected Pointers { void ev_tally(int, int *, double, double, double *); void v_setup(int); void v_tally(int, int *, double, double *); + void v_tally(int, double *); + void v_tally(int, int, double); // union data struct for packing 32-bit and 64-bit ints into double bufs // see atom_vec.h for documentation From 95d849285345b82342499f38260da1f338e377f4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 11 Sep 2017 21:59:22 -0400 Subject: [PATCH 47/55] the original fix qeq went away over 7 years ago, we don't need to purge it --- src/Purge.list | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Purge.list b/src/Purge.list index 315e5e3424..9de26d2d64 100644 --- a/src/Purge.list +++ b/src/Purge.list @@ -423,9 +423,6 @@ atom_vec_granular.h # deleted on Fri Nov 19 12:53:07 2010 -0500 fix_pour_omp.cpp fix_pour_omp.h -# deleted on Thu Aug 19 23:20:14 2010 +0000 -fix_qeq.cpp -fix_qeq.h # deleted on Thu Jun 17 01:34:38 2010 +0000 compute_vsum.cpp compute_vsum.h From cb19ef547e0d0cb2e62cfe439fb14c92f87a4d4c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 11 Sep 2017 22:00:58 -0400 Subject: [PATCH 48/55] update src/.gitignore --- src/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/src/.gitignore b/src/.gitignore index a5d6773c5b..1571065b72 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -46,6 +46,7 @@ /colvarproxy_lammps.cpp /colvarproxy_lammps.h +/colvarproxy_lammps_version.h /fix_colvars.cpp /fix_colvars.h /dump_molfile.cpp From e196a2b9e54ad207a72b15e501e6fa1f9b4893f1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 11 Sep 2017 22:24:06 -0400 Subject: [PATCH 49/55] import changes to various fixes by aidan to include virial contributions --- doc/src/fix_cmap.txt | 5 +++ doc/src/fix_efield.txt | 5 +++ doc/src/fix_external.txt | 5 +++ doc/src/fix_modify.txt | 33 ++++++++++++--- doc/src/fix_rigid.txt | 5 +++ doc/src/fix_shake.txt | 5 +++ doc/src/fix_wall.txt | 5 +++ doc/src/fix_wall_region.txt | 56 ++++++------------------ src/COLLOID/fix_wall_colloid.cpp | 7 +++ src/KOKKOS/fix_wall_lj93_kokkos.cpp | 1 + src/MISC/fix_efield.cpp | 16 +++++++ src/MOLECULE/fix_cmap.cpp | 1 + src/RIGID/fix_rigid.cpp | 1 + src/RIGID/fix_rigid_small.cpp | 1 + src/RIGID/fix_shake.cpp | 1 + src/fix_external.cpp | 1 + src/fix_wall.cpp | 6 +++ src/fix_wall_harmonic.cpp | 7 +++ src/fix_wall_lj1043.cpp | 7 +++ src/fix_wall_lj126.cpp | 7 +++ src/fix_wall_lj93.cpp | 7 +++ src/fix_wall_region.cpp | 66 ++++++++++++++++++++++++++--- src/fix_wall_region.h | 2 + 23 files changed, 193 insertions(+), 57 deletions(-) diff --git a/doc/src/fix_cmap.txt b/doc/src/fix_cmap.txt index 2b14a20c1d..b126382b80 100644 --- a/doc/src/fix_cmap.txt +++ b/doc/src/fix_cmap.txt @@ -97,6 +97,11 @@ The "fix_modify"_fix_modify.html {energy} option is supported by this fix to add the potential "energy" of the CMAP interactions system's potential energy as part of "thermodynamic output"_thermo_style.html. +The "fix_modify"_fix_modify.html {virial} option is supported by this +fix to add the contribution due to the interaction between +atoms and each wall to the system's virial as part of "thermodynamic +output"_thermo_style.html. The default is {virial yes} + This fix computes a global scalar which can be accessed by various "output commands"_Section_howto.html#howto_15. The scalar is the potential energy discussed above. The scalar value calculated by this diff --git a/doc/src/fix_efield.txt b/doc/src/fix_efield.txt index 9e3d7797d8..6537898315 100644 --- a/doc/src/fix_efield.txt +++ b/doc/src/fix_efield.txt @@ -124,6 +124,11 @@ can include the forces added by this fix in a consistent manner. I.e. there is a decrease in potential energy when atoms move in the direction of the added force due to the electric field. +The "fix_modify"_fix_modify.html {virial} option is supported by this +fix to add the contribution due to the interaction between +atoms and each wall to the system's virial as part of "thermodynamic +output"_thermo_style.html. The default is {virial no} + The "fix_modify"_fix_modify.html {respa} option is supported by this fix. This allows to set at which level of the "r-RESPA"_run_style.html integrator the fix adding its forces. Default is the outermost level. diff --git a/doc/src/fix_external.txt b/doc/src/fix_external.txt index 25158be0db..c77a54d800 100644 --- a/doc/src/fix_external.txt +++ b/doc/src/fix_external.txt @@ -131,6 +131,11 @@ forces added by this fix in a consistent manner. I.e. there is a decrease in potential energy when atoms move in the direction of the added force. +The "fix_modify"_fix_modify.html {virial} option is supported by this +fix to add the contribution due to the interaction between +atoms and each wall to the system's virial as part of "thermodynamic +output"_thermo_style.html. The default is {virial yes} + This fix computes a global scalar which can be accessed by various "output commands"_Section_howto.html#howto_15. The scalar is the potential energy discussed above. The scalar stored by this fix diff --git a/doc/src/fix_modify.txt b/doc/src/fix_modify.txt index 4e31092888..1c7dcf77a5 100644 --- a/doc/src/fix_modify.txt +++ b/doc/src/fix_modify.txt @@ -14,10 +14,11 @@ fix_modify fix-ID keyword value ... :pre fix-ID = ID of the fix to modify :ulb,l one or more keyword/value pairs may be appended :l -keyword = {temp} or {press} or {energy} or {respa} or {dynamic/dof} :l +keyword = {temp} or {press} or {energy} or {virial} or {respa} or {dynamic/dof} :l {temp} value = compute ID that calculates a temperature {press} value = compute ID that calculates a pressure {energy} value = {yes} or {no} + {virial} value = {yes} or {no} {respa} value = {1} to {max respa level} or {0} (for outermost level) {dynamic/dof} value = {yes} or {no} yes/no = do or do not recompute the number of degrees of freedom (DOF) contributing to the temperature :pre @@ -52,11 +53,10 @@ define their own compute by default, as described in their documentation. Thus this option allows the user to override the default method for computing P. -For fixes that calculate a contribution to the potential energy of the -system, the {energy} keyword will include that contribution in -thermodynamic output of potential energy. This is because the {energy -yes} setting must be specified to include the fix's global or per-atom -energy in the calculation performed by the "compute +The {energy} keyword can be used with fixes that support it. +{energy yes} adds a contribution to the potential energy of the +system. The fix's global and per-atom +energy is included in the calculation performed by the "compute pe"_compute_pe.html or "compute pe/atom"_compute_pe_atom.html commands. See the "thermo_style"_thermo_style.html command for info on how potential energy is output. For fixes that tally a global @@ -69,6 +69,25 @@ are using it when performing an "energy minimization"_minimize.html and if you want the energy and forces it produces to be part of the optimization criteria. +The {virial} keyword can be used with fixes that support it. +{virial yes} adds a contribution to the virial of the +system. The fix's global and per-atom +virial is included in the calculation performed by the "compute +pressure"_compute_pressure.html or +"compute stress/atom"_compute_stress_atom.html +commands. See the "thermo_style"_thermo_style.html command for info +on how pressure is output. + +NOTE: You must specify the {virial yes} setting for a fix if you +are doing "box relaxation"_fix_box_relax.html and +if you want virial contribution of the fix to be part of the +relaxation criteria, although this seems unlikely. + +NOTE: This option is only supported by fixes that explicitly say +so. For some of these (e.g. the +"fix shake"_fix_shake.html command) the default setting is +{virial yes}, for others it is {virial no}. + For fixes that set or modify forces, it may be possible to select at which "r-RESPA"_run_style.html level the fix operates via the {respa} keyword. The RESPA level at which the fix is active can be selected. @@ -111,4 +130,4 @@ pressure"_compute_pressure.html, "thermo_style"_thermo_style.html [Default:] The option defaults are temp = ID defined by fix, press = ID defined -by fix, energy = no, respa = 0. +by fix, energy = no, virial = different for each fix style, respa = 0. diff --git a/doc/src/fix_rigid.txt b/doc/src/fix_rigid.txt index 62969112f7..af00882c5b 100644 --- a/doc/src/fix_rigid.txt +++ b/doc/src/fix_rigid.txt @@ -703,6 +703,11 @@ NVT, NPT, NPH rigid styles to add the energy change induced by the thermostatting to the system's potential energy as part of "thermodynamic output"_thermo_style.html. +The "fix_modify"_fix_modify.html {virial} option is supported by this +fix to add the contribution due to the interaction between +atoms and each wall to the system's virial as part of "thermodynamic +output"_thermo_style.html. The default is {virial yes} + The "fix_modify"_fix_modify.html {temp} and {press} options are supported by the 4 NPT and NPH rigid styles to change the computes used to calculate the instantaneous pressure tensor. Note that the 2 diff --git a/doc/src/fix_shake.txt b/doc/src/fix_shake.txt index c187b17c6c..c39ccdd07e 100644 --- a/doc/src/fix_shake.txt +++ b/doc/src/fix_shake.txt @@ -186,6 +186,11 @@ to 1 and recompiling LAMMPS. [Restart, fix_modify, output, run start/stop, minimize info:] +The "fix_modify"_fix_modify.html {virial} option is supported by this +fix to add the contribution due to the interaction between +atoms and each wall to the system's virial as part of "thermodynamic +output"_thermo_style.html. The default is {virial yes} + No information about these fixes is written to "binary restart files"_restart.html. None of the "fix_modify"_fix_modify.html options are relevant to these fixes. No global or per-atom quantities are diff --git a/doc/src/fix_wall.txt b/doc/src/fix_wall.txt index 6bbfccf9db..e814c89a07 100644 --- a/doc/src/fix_wall.txt +++ b/doc/src/fix_wall.txt @@ -252,6 +252,11 @@ fix to add the energy of interaction between atoms and each wall to the system's potential energy as part of "thermodynamic output"_thermo_style.html. +The "fix_modify"_fix_modify.html {virial} option is supported by this +fix to add the contribution due to the interaction between +atoms and each wall to the system's virial as part of "thermodynamic +output"_thermo_style.html. The default is {virial no} + The "fix_modify"_fix_modify.html {respa} option is supported by this fix. This allows to set at which level of the "r-RESPA"_run_style.html integrator the fix is adding its forces. Default is the outermost level. diff --git a/doc/src/fix_wall_region.txt b/doc/src/fix_wall_region.txt index ca5335e3fb..9700545dc9 100644 --- a/doc/src/fix_wall_region.txt +++ b/doc/src/fix_wall_region.txt @@ -15,7 +15,7 @@ fix ID group-ID wall/region region-ID style epsilon sigma cutoff :pre ID, group-ID are documented in "fix"_fix.html command wall/region = style name of this fix command region-ID = region whose boundary will act as wall -style = {lj93} or {lj126} or {colloid} or {harmonic} +style = {lj93} or {lj126} or {lj1043} or {colloid} or {harmonic} epsilon = strength factor for wall-particle interaction (energy or energy/distance^2 units) sigma = size factor for wall-particle interaction (distance units) cutoff = distance from wall at which wall-particle interaction is cut off (distance units) :ul @@ -112,6 +112,10 @@ For style {lj126}, the energy E is given by the 12/6 potential: :c,image(Eqs/pair_lj.jpg) +For style {wall/lj1043}, the energy E is given by the 10/4/3 potential: + +:c,image(Eqs/fix_wall_lj1043.jpg) + For style {colloid}, the energy E is given by an integrated form of the "pair_style colloid"_pair_colloid.html potential: @@ -128,49 +132,8 @@ surface no longer interact. The energy of the wall potential is shifted so that the wall-particle interaction energy is 0.0 at the cutoff distance. -For the {lj93} and {lj126} styles, {epsilon} and {sigma} are the usual -Lennard-Jones parameters, which determine the strength and size of the -particle as it interacts with the wall. Epsilon has energy units. -Note that this {epsilon} and {sigma} may be different than any -{epsilon} or {sigma} values defined for a pair style that computes -particle-particle interactions. - -The {lj93} interaction is derived by integrating over a 3d -half-lattice of Lennard-Jones 12/6 particles. The {lj126} interaction -is effectively a harder, more repulsive wall interaction. - -For the {colloid} style, {epsilon} is effectively a Hamaker constant -with energy units for the colloid-wall interaction, {R} is the radius -of the colloid particle, {D} is the distance from the surface of the -colloid particle to the wall (r-R), and {sigma} is the size of a -constituent LJ particle inside the colloid particle. Note that the -cutoff distance Rc in this case is the distance from the colloid -particle center to the wall. - -The {colloid} interaction is derived by integrating over constituent -LJ particles of size {sigma} within the colloid particle and a 3d -half-lattice of Lennard-Jones 12/6 particles of size {sigma} in the -wall. - -For the {wall/harmonic} style, {epsilon} is effectively the spring -constant K, and has units (energy/distance^2). The input parameter -{sigma} is ignored. The minimum energy position of the harmonic -spring is at the {cutoff}. This is a repulsive-only spring since the -interaction is truncated at the {cutoff} - -NOTE: For all of the styles, you must insure that r is always > 0 for -all particles in the group, or LAMMPS will generate an error. This -means you cannot start your simulation with particles on the region -surface (r = 0) or with particles on the wrong side of the region -surface (r < 0). For the {wall/lj93} and {wall/lj126} styles, the -energy of the wall/particle interaction (and hence the force on the -particle) blows up as r -> 0. The {wall/colloid} style is even more -restrictive, since the energy blows up as D = r-R -> 0. This means -the finite-size particles of radius R must be a distance larger than R -from the region surface. The {harmonic} style is a softer potential -and does not blow up as r -> 0, but you must use a large enough -{epsilon} that particles always reamin on the correct side of the -region surface (r > 0). +For a full description of these wall styles, see fix_style +"wall"_fix_wall.html [Restart, fix_modify, output, run start/stop, minimize info:] @@ -182,6 +145,11 @@ fix to add the energy of interaction between atoms and the wall to the system's potential energy as part of "thermodynamic output"_thermo_style.html. +The "fix_modify"_fix_modify.html {virial} option is supported by this +fix to add the contribution due to the interaction between +atoms and each wall to the system's virial as part of "thermodynamic +output"_thermo_style.html. The default is {virial no} + The "fix_modify"_fix_modify.html {respa} option is supported by this fix. This allows to set at which level of the "r-RESPA"_run_style.html integrator the fix is adding its forces. Default is the outermost level. diff --git a/src/COLLOID/fix_wall_colloid.cpp b/src/COLLOID/fix_wall_colloid.cpp index 7c0203ac5f..651e0da4f8 100644 --- a/src/COLLOID/fix_wall_colloid.cpp +++ b/src/COLLOID/fix_wall_colloid.cpp @@ -81,6 +81,7 @@ void FixWallColloid::wall_particle(int m, int which, double coord) double r3,rinv3,r2inv3,r4inv3; double rad,rad2,rad4,rad8,diam,new_coeff2; double eoffset; + double vn; double **x = atom->x; double **f = atom->f; @@ -151,6 +152,12 @@ void FixWallColloid::wall_particle(int m, int which, double coord) ewall[0] -= eoffset; ewall[m+1] += fwall; + + if (evflag) { + if (side < 0) vn = -fwall*delta; + else vn = fwall*delta; + v_tally(dim, i, vn); + } } if (onflag) error->one(FLERR,"Particle on or inside fix wall surface"); diff --git a/src/KOKKOS/fix_wall_lj93_kokkos.cpp b/src/KOKKOS/fix_wall_lj93_kokkos.cpp index b0f7e0bda4..720b844601 100644 --- a/src/KOKKOS/fix_wall_lj93_kokkos.cpp +++ b/src/KOKKOS/fix_wall_lj93_kokkos.cpp @@ -31,6 +31,7 @@ FixWallLJ93Kokkos::FixWallLJ93Kokkos(LAMMPS *lmp, int narg, char **a execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; datamask_modify = EMPTY_MASK; + virial_flag = 0 } /* ---------------------------------------------------------------------- diff --git a/src/MISC/fix_efield.cpp b/src/MISC/fix_efield.cpp index 8a6b7937b5..c0384adc41 100644 --- a/src/MISC/fix_efield.cpp +++ b/src/MISC/fix_efield.cpp @@ -55,6 +55,7 @@ FixEfield::FixEfield(LAMMPS *lmp, int narg, char **arg) : extscalar = 1; respa_level_support = 1; ilevel_respa = 0; + virial_flag = 1; qe2f = force->qe2f; xstr = ystr = zstr = NULL; @@ -257,6 +258,11 @@ void FixEfield::post_force(int vflag) imageint *image = atom->image; int nlocal = atom->nlocal; + // energy and virial setup + + if (vflag) v_setup(vflag); + else evflag = 0; + // reallocate efield array if necessary if (varflag == ATOM && atom->nmax > maxatom) { @@ -281,6 +287,7 @@ void FixEfield::post_force(int vflag) double **x = atom->x; double fx,fy,fz; + double v[6]; // constant efield @@ -306,6 +313,15 @@ void FixEfield::post_force(int vflag) fsum[1] += fx; fsum[2] += fy; fsum[3] += fz; + if (evflag) { + v[0] = fx*unwrap[0]; + v[1] = fy*unwrap[1]; + v[2] = fz*unwrap[2]; + v[3] = fx*unwrap[1]; + v[4] = fx*unwrap[2]; + v[5] = fy*unwrap[2]; + v_tally(i, v); + } } } diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp index 551e049238..56106cc3e0 100644 --- a/src/MOLECULE/fix_cmap.cpp +++ b/src/MOLECULE/fix_cmap.cpp @@ -76,6 +76,7 @@ FixCMAP::FixCMAP(LAMMPS *lmp, int narg, char **arg) : restart_peratom = 1; peatom_flag = 1; virial_flag = 1; + thermo_virial = 1; peratom_freq = 1; scalar_flag = 1; global_freq = 1; diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index 9d46968273..d2a770cc47 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -74,6 +74,7 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) : time_integrate = 1; rigid_flag = 1; virial_flag = 1; + thermo_virial = 1; create_attribute = 1; dof_flag = 1; enforce2d_flag = 1; diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 60afeecbf0..1404c3bf58 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -78,6 +78,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : time_integrate = 1; rigid_flag = 1; virial_flag = 1; + thermo_virial = 1; create_attribute = 1; dof_flag = 1; enforce2d_flag = 1; diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index f08228f3d3..c624fe2fe8 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -60,6 +60,7 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : MPI_Comm_size(world,&nprocs); virial_flag = 1; + thermo_virial = 1; create_attribute = 1; dof_flag = 1; diff --git a/src/fix_external.cpp b/src/fix_external.cpp index 85523b912c..ab942f874c 100644 --- a/src/fix_external.cpp +++ b/src/fix_external.cpp @@ -37,6 +37,7 @@ FixExternal::FixExternal(LAMMPS *lmp, int narg, char **arg) : scalar_flag = 1; global_freq = 1; virial_flag = 1; + thermo_virial = 1; extscalar = 1; if (strcmp(arg[3],"pf/callback") == 0) { diff --git a/src/fix_wall.cpp b/src/fix_wall.cpp index 8b569cafc6..2c3aa4afa0 100644 --- a/src/fix_wall.cpp +++ b/src/fix_wall.cpp @@ -45,6 +45,7 @@ FixWall::FixWall(LAMMPS *lmp, int narg, char **arg) : extvector = 1; respa_level_support = 1; ilevel_respa = 0; + virial_flag = 1; // parse args @@ -298,7 +299,12 @@ void FixWall::pre_force(int vflag) void FixWall::post_force(int vflag) { + + // energy and virial setup + eflag = 0; + if (vflag) v_setup(vflag); + else evflag = 0; for (int m = 0; m <= nwall; m++) ewall[m] = 0.0; // coord = current position of wall diff --git a/src/fix_wall_harmonic.cpp b/src/fix_wall_harmonic.cpp index 41d630b7fe..f91295d469 100644 --- a/src/fix_wall_harmonic.cpp +++ b/src/fix_wall_harmonic.cpp @@ -34,6 +34,7 @@ FixWallHarmonic::FixWallHarmonic(LAMMPS *lmp, int narg, char **arg) : void FixWallHarmonic::wall_particle(int m, int which, double coord) { double delta,dr,fwall; + double vn; double **x = atom->x; double **f = atom->f; @@ -60,6 +61,12 @@ void FixWallHarmonic::wall_particle(int m, int which, double coord) f[i][dim] -= fwall; ewall[0] += epsilon[m]*dr*dr; ewall[m+1] += fwall; + + if (evflag) { + if (side < 0) vn = -fwall*delta; + else vn = fwall*delta; + v_tally(dim, i, vn); + } } if (onflag) error->one(FLERR,"Particle on or inside fix wall surface"); diff --git a/src/fix_wall_lj1043.cpp b/src/fix_wall_lj1043.cpp index 72d71fbb3c..e8e706ed5e 100644 --- a/src/fix_wall_lj1043.cpp +++ b/src/fix_wall_lj1043.cpp @@ -52,6 +52,7 @@ void FixWallLJ1043::precompute(int m) void FixWallLJ1043::wall_particle(int m, int which, double coord) { double delta,rinv,r2inv,r4inv,r10inv,fwall; + double vn; double **x = atom->x; double **f = atom->f; @@ -79,5 +80,11 @@ void FixWallLJ1043::wall_particle(int m, int which, double coord) ewall[0] += coeff1[m]*r10inv - coeff2[m]*r4inv - coeff3[m]*pow(delta+coeff4[m],-3.0) - offset[m]; ewall[m+1] += fwall; + + if (evflag) { + if (side < 0) vn = -fwall*delta; + else vn = fwall*delta; + v_tally(dim, i, vn); + } } } diff --git a/src/fix_wall_lj126.cpp b/src/fix_wall_lj126.cpp index f6d8654eea..22199fed5b 100644 --- a/src/fix_wall_lj126.cpp +++ b/src/fix_wall_lj126.cpp @@ -48,6 +48,7 @@ void FixWallLJ126::precompute(int m) void FixWallLJ126::wall_particle(int m, int which, double coord) { double delta,rinv,r2inv,r6inv,fwall; + double vn; double **x = atom->x; double **f = atom->f; @@ -76,6 +77,12 @@ void FixWallLJ126::wall_particle(int m, int which, double coord) f[i][dim] -= fwall; ewall[0] += r6inv*(coeff3[m]*r6inv - coeff4[m]) - offset[m]; ewall[m+1] += fwall; + + if (evflag) { + if (side < 0) vn = -fwall*delta; + else vn = fwall*delta; + v_tally(dim, i, vn); + } } if (onflag) error->one(FLERR,"Particle on or inside fix wall surface"); diff --git a/src/fix_wall_lj93.cpp b/src/fix_wall_lj93.cpp index f7a3aaf14c..281a1fafc4 100644 --- a/src/fix_wall_lj93.cpp +++ b/src/fix_wall_lj93.cpp @@ -49,6 +49,7 @@ void FixWallLJ93::precompute(int m) void FixWallLJ93::wall_particle(int m, int which, double coord) { double delta,rinv,r2inv,r4inv,r10inv,fwall; + double vn; double **x = atom->x; double **f = atom->f; @@ -79,6 +80,12 @@ void FixWallLJ93::wall_particle(int m, int which, double coord) ewall[0] += coeff3[m]*r4inv*r4inv*rinv - coeff4[m]*r2inv*rinv - offset[m]; ewall[m+1] += fwall; + + if (evflag) { + if (side < 0) vn = -fwall*delta; + else vn = fwall*delta; + v_tally(dim, i, vn); + } } if (onflag) error->one(FLERR,"Particle on or inside fix wall surface"); diff --git a/src/fix_wall_region.cpp b/src/fix_wall_region.cpp index f543c12171..1d22e6141b 100644 --- a/src/fix_wall_region.cpp +++ b/src/fix_wall_region.cpp @@ -25,11 +25,13 @@ #include "output.h" #include "respa.h" #include "error.h" +#include "math_const.h" using namespace LAMMPS_NS; using namespace FixConst; +using namespace MathConst; -enum{LJ93,LJ126,COLLOID,HARMONIC}; +enum{LJ93,LJ126,LJ1043,COLLOID,HARMONIC}; /* ---------------------------------------------------------------------- */ @@ -47,6 +49,7 @@ FixWallRegion::FixWallRegion(LAMMPS *lmp, int narg, char **arg) : extvector = 1; respa_level_support = 1; ilevel_respa = 0; + virial_flag = 1; // parse args @@ -59,6 +62,7 @@ FixWallRegion::FixWallRegion(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[4],"lj93") == 0) style = LJ93; else if (strcmp(arg[4],"lj126") == 0) style = LJ126; + else if (strcmp(arg[4],"lj1043") == 0) style = LJ1043; else if (strcmp(arg[4],"colloid") == 0) style = COLLOID; else if (strcmp(arg[4],"harmonic") == 0) style = HARMONIC; else error->all(FLERR,"Illegal fix wall/region command"); @@ -143,6 +147,20 @@ void FixWallRegion::init() double r2inv = 1.0/(cutoff*cutoff); double r6inv = r2inv*r2inv*r2inv; offset = r6inv*(coeff3*r6inv - coeff4); + } else if (style == LJ1043) { + coeff1 = MY_2PI * 2.0/5.0 * epsilon * pow(sigma,10.0); + coeff2 = MY_2PI * epsilon * pow(sigma,4.0); + coeff3 = MY_2PI * pow(2.0,1/2.0) / 3 * epsilon * pow(sigma,3.0); + coeff4 = 0.61 / pow(2.0,1/2.0) * sigma; + coeff5 = coeff1 * 10.0; + coeff6 = coeff2 * 4.0; + coeff7 = coeff3 * 3.0; + + double rinv = 1.0/cutoff; + double r2inv = rinv*rinv; + double r4inv = r2inv*r2inv; + offset = coeff1*r4inv*r4inv*r2inv - coeff2*r4inv - + coeff3*pow(cutoff+coeff4,-3.0); } else if (style == COLLOID) { coeff1 = -4.0/315.0 * epsilon * pow(sigma,6.0); coeff2 = -2.0/3.0 * epsilon; @@ -186,6 +204,7 @@ void FixWallRegion::post_force(int vflag) { int i,m,n; double rinv,fx,fy,fz,tooclose; + double delx, dely, delz, v[6]; double **x = atom->x; double **f = atom->f; @@ -198,13 +217,18 @@ void FixWallRegion::post_force(int vflag) int onflag = 0; + // energy and virial setup + + eflag = 0; + if (vflag) v_setup(vflag); + else evflag = 0; + // region->match() insures particle is in region or on surface, else error // if returned contact dist r = 0, is on surface, also an error // in COLLOID case, r <= radius is an error // initilize ewall after region->prematch(), // so a dynamic region can access last timestep values - eflag = 0; ewall[0] = ewall[1] = ewall[2] = ewall[3] = 0.0; for (i = 0; i < nlocal; i++) @@ -226,19 +250,32 @@ void FixWallRegion::post_force(int vflag) if (style == LJ93) lj93(region->contact[m].r); else if (style == LJ126) lj126(region->contact[m].r); + else if (style == LJ1043) lj1043(region->contact[m].r); else if (style == COLLOID) colloid(region->contact[m].r,radius[i]); else harmonic(region->contact[m].r); - ewall[0] += eng; - fx = fwall * region->contact[m].delx * rinv; - fy = fwall * region->contact[m].dely * rinv; - fz = fwall * region->contact[m].delz * rinv; + delx = region->contact[m].delx; + dely = region->contact[m].dely; + delz = region->contact[m].delz; + fx = fwall * delx * rinv; + fy = fwall * dely * rinv; + fz = fwall * delz * rinv; f[i][0] += fx; f[i][1] += fy; f[i][2] += fz; ewall[1] -= fx; ewall[2] -= fy; ewall[3] -= fz; + ewall[0] += eng; + if (evflag) { + v[0] = fx*delx; + v[1] = fy*dely; + v[2] = fz*delz; + v[3] = fx*dely; + v[4] = fx*delz; + v[5] = fy*delz; + v_tally(i, v); + } } } @@ -319,6 +356,23 @@ void FixWallRegion::lj126(double r) eng = r6inv*(coeff3*r6inv - coeff4) - offset; } +/* ---------------------------------------------------------------------- + LJ 10/4/3 interaction for particle with wall + compute eng and fwall = magnitude of wall force +------------------------------------------------------------------------- */ + +void FixWallRegion::lj1043(double r) +{ + double rinv = 1.0/r; + double r2inv = rinv*rinv; + double r4inv = r2inv*r2inv; + double r10inv = r4inv*r4inv*r2inv; + fwall = coeff5*r10inv*rinv - coeff6*r4inv*rinv - + coeff7*pow(r+coeff4,-4.0); + eng = coeff1*r10inv - coeff2*r4inv - + coeff3*pow(r+coeff4,-3.0) - offset; +} + /* ---------------------------------------------------------------------- colloid interaction for finite-size particle of rad with wall compute eng and fwall = magnitude of wall force diff --git a/src/fix_wall_region.h b/src/fix_wall_region.h index cecd7faa33..e3688c99ee 100644 --- a/src/fix_wall_region.h +++ b/src/fix_wall_region.h @@ -47,10 +47,12 @@ class FixWallRegion : public Fix { char *idregion; double coeff1,coeff2,coeff3,coeff4,offset; + double coeff5,coeff6,coeff7; double eng,fwall; void lj93(double); void lj126(double); + void lj1043(double); void colloid(double, double); void harmonic(double); }; From da7776f818b85073b9fd8214882e687b263519f8 Mon Sep 17 00:00:00 2001 From: Julien Devemy Date: Thu, 14 Sep 2017 11:00:55 +0200 Subject: [PATCH 50/55] Bugfix for the limit keyword --- src/compute_chunk_atom.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index f1052bb85a..dcfd2ff131 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -218,10 +218,10 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : if (limit && !compress) limitfirst = 1; iarg += 2; if (limit) { - if (iarg+1 > narg) + if (iarg > narg) error->all(FLERR,"Illegal compute chunk/atom command"); - if (strcmp(arg[iarg+1],"max") == 0) limitstyle = LIMITMAX; - else if (strcmp(arg[iarg+1],"exact") == 0) limitstyle = LIMITEXACT; + if (strcmp(arg[iarg],"max") == 0) limitstyle = LIMITMAX; + else if (strcmp(arg[iarg],"exact") == 0) limitstyle = LIMITEXACT; else error->all(FLERR,"Illegal compute chunk/atom command"); iarg++; } From f1fce64ff9df81c91d4db98d94d75904b04a0908 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Thu, 14 Sep 2017 12:58:00 -0400 Subject: [PATCH 51/55] Fix small typo to calculation of accumulated work in Colvars --- lib/colvars/colvarbias_restraint.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/colvars/colvarbias_restraint.cpp b/lib/colvars/colvarbias_restraint.cpp index 6879190968..70beca29fa 100644 --- a/lib/colvars/colvarbias_restraint.cpp +++ b/lib/colvars/colvarbias_restraint.cpp @@ -308,7 +308,7 @@ int colvarbias_restraint_centers_moving::update_centers(cvm::real lambda) colvarvalue const c_new = colvarvalue::interpolate(initial_centers[i], target_centers[i], lambda); - centers_incr[i] = (c_new).dist2_grad(colvar_centers[i]); + centers_incr[i] = 0.5 * c_new.dist2_grad(colvar_centers[i]); colvar_centers[i] = c_new; variables(i)->wrap(colvar_centers[i]); } From 8776b8103337cb30f5e7e509697fe85fb7077a69 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 15 Sep 2017 00:46:18 -0400 Subject: [PATCH 52/55] add virial support to fix addforce --- src/fix_addforce.cpp | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/fix_addforce.cpp b/src/fix_addforce.cpp index 472d03f1f9..a05933e2fe 100644 --- a/src/fix_addforce.cpp +++ b/src/fix_addforce.cpp @@ -51,6 +51,7 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) : extvector = 1; respa_level_support = 1; ilevel_respa = 0; + virial_flag = 1; xstr = ystr = zstr = NULL; @@ -237,10 +238,16 @@ void FixAddForce::post_force(int vflag) double **f = atom->f; int *mask = atom->mask; imageint *image = atom->image; + double v[6]; int nlocal = atom->nlocal; if (update->ntimestep % nevery) return; + // energy and virial setup + + if (vflag) v_setup(vflag); + else evflag = 0; + if (lmp->kokkos) atom->sync_modify(Host, (unsigned int) (F_MASK | MASK_MASK), (unsigned int) F_MASK); @@ -283,6 +290,14 @@ void FixAddForce::post_force(int vflag) f[i][0] += xvalue; f[i][1] += yvalue; f[i][2] += zvalue; + if (evflag) { + v[0] = xvalue * unwrap[0]; + v[1] = yvalue * unwrap[1]; + v[2] = zvalue * unwrap[2]; + v[3] = xvalue * unwrap[1]; + v[4] = xvalue * unwrap[2]; + v[5] = yvalue * unwrap[2]; + v_tally(i,v); } // variable force, wrap with clear/add @@ -290,6 +305,7 @@ void FixAddForce::post_force(int vflag) // wrap with clear/add } else { + double unwrap[3]; modify->clearstep_compute(); @@ -310,16 +326,32 @@ void FixAddForce::post_force(int vflag) for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { if (region && !region->match(x[i][0],x[i][1],x[i][2])) continue; + domain->unmap(x[i],image[i],unwrap); + if (xstyle == ATOM) xvalue = sforce[i][0]; + if (ystyle == ATOM) yvalue = sforce[i][1]; + if (zstyle == ATOM) zvalue = sforce[i][2]; + if (estyle == ATOM) foriginal[0] += sforce[i][3]; + else { + if (xstyle) foriginal[0] -= xvalue*unwrap[0]; + if (ystyle) foriginal[0] -= yvalue*unwrap[1]; + if (zstyle) foriginal[0] -= zvalue*unwrap[2]; + } foriginal[1] += f[i][0]; foriginal[2] += f[i][1]; foriginal[3] += f[i][2]; - if (xstyle == ATOM) f[i][0] += sforce[i][0]; - else if (xstyle) f[i][0] += xvalue; - if (ystyle == ATOM) f[i][1] += sforce[i][1]; - else if (ystyle) f[i][1] += yvalue; - if (zstyle == ATOM) f[i][2] += sforce[i][2]; - else if (zstyle) f[i][2] += zvalue; + if (xstyle) f[i][0] += xvalue; + if (ystyle) f[i][1] += yvalue; + if (zstyle) f[i][2] += zvalue; + if (evflag) { + v[0] = xstyle ? fx*unwrap[0] : 0.0; + v[1] = ystyle ? fy*unwrap[1] : 0.0; + v[2] = zstyle ? fz*unwrap[2] : 0.0; + v[3] = xstyle ? fx*unwrap[1] : 0.0; + v[4] = xstyle ? fx*unwrap[2] : 0.0; + v[5] = ystyle ? fy*unwrap[2] : 0.0; + v_tally(i, v); + } } } } From 2cd7cbd964152d0afcdd18a1d898ca0a6633886f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 15 Sep 2017 00:51:16 -0400 Subject: [PATCH 53/55] correct cut-n-paste error, add docs --- doc/src/fix_addforce.txt | 5 +++++ src/fix_addforce.cpp | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/doc/src/fix_addforce.txt b/doc/src/fix_addforce.txt index 1cc0a15332..4d0bde2e5b 100644 --- a/doc/src/fix_addforce.txt +++ b/doc/src/fix_addforce.txt @@ -139,6 +139,11 @@ forces added by this fix in a consistent manner. I.e. there is a decrease in potential energy when atoms move in the direction of the added force. +The "fix_modify"_fix_modify.html {virial} option is supported by this +fix to add the contribution due to the interaction between +atoms and each wall to the system's virial as part of "thermodynamic +output"_thermo_style.html. The default is {virial no} + The "fix_modify"_fix_modify.html {respa} option is supported by this fix. This allows to set at which level of the "r-RESPA"_run_style.html integrator the fix is adding its forces. Default is the outermost diff --git a/src/fix_addforce.cpp b/src/fix_addforce.cpp index a05933e2fe..5c677a4338 100644 --- a/src/fix_addforce.cpp +++ b/src/fix_addforce.cpp @@ -298,6 +298,7 @@ void FixAddForce::post_force(int vflag) v[4] = xvalue * unwrap[2]; v[5] = yvalue * unwrap[2]; v_tally(i,v); + } } // variable force, wrap with clear/add @@ -323,7 +324,7 @@ void FixAddForce::post_force(int vflag) modify->addstep_compute(update->ntimestep + 1); - for (int i = 0; i < nlocal; i++) + for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (region && !region->match(x[i][0],x[i][1],x[i][2])) continue; domain->unmap(x[i],image[i],unwrap); @@ -331,8 +332,9 @@ void FixAddForce::post_force(int vflag) if (ystyle == ATOM) yvalue = sforce[i][1]; if (zstyle == ATOM) zvalue = sforce[i][2]; - if (estyle == ATOM) foriginal[0] += sforce[i][3]; - else { + if (estyle == ATOM) { + foriginal[0] += sforce[i][3]; + } else { if (xstyle) foriginal[0] -= xvalue*unwrap[0]; if (ystyle) foriginal[0] -= yvalue*unwrap[1]; if (zstyle) foriginal[0] -= zvalue*unwrap[2]; @@ -340,19 +342,21 @@ void FixAddForce::post_force(int vflag) foriginal[1] += f[i][0]; foriginal[2] += f[i][1]; foriginal[3] += f[i][2]; + if (xstyle) f[i][0] += xvalue; if (ystyle) f[i][1] += yvalue; if (zstyle) f[i][2] += zvalue; if (evflag) { - v[0] = xstyle ? fx*unwrap[0] : 0.0; - v[1] = ystyle ? fy*unwrap[1] : 0.0; - v[2] = zstyle ? fz*unwrap[2] : 0.0; - v[3] = xstyle ? fx*unwrap[1] : 0.0; - v[4] = xstyle ? fx*unwrap[2] : 0.0; - v[5] = ystyle ? fy*unwrap[2] : 0.0; + v[0] = xstyle ? xvalue*unwrap[0] : 0.0; + v[1] = ystyle ? yvalue*unwrap[1] : 0.0; + v[2] = zstyle ? zvalue*unwrap[2] : 0.0; + v[3] = xstyle ? xvalue*unwrap[1] : 0.0; + v[4] = xstyle ? xvalue*unwrap[2] : 0.0; + v[5] = ystyle ? yvalue*unwrap[2] : 0.0; v_tally(i, v); } } + } } } From ccb67d8dc51150155551ccc6254122283552c68d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 15 Sep 2017 01:20:56 -0400 Subject: [PATCH 54/55] correct cut-n-paste errors in the documentation of fix_modify virial --- doc/src/Section_packages.txt | 2 +- doc/src/fix_addforce.txt | 6 +++--- doc/src/fix_cmap.txt | 6 +++--- doc/src/fix_efield.txt | 6 +++--- doc/src/fix_external.txt | 4 ++-- doc/src/fix_rigid.txt | 6 +++--- doc/src/fix_shake.txt | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/src/Section_packages.txt b/doc/src/Section_packages.txt index 6122dfac78..c6f976fe23 100644 --- a/doc/src/Section_packages.txt +++ b/doc/src/Section_packages.txt @@ -2191,7 +2191,7 @@ src/USER-MESO/README "pair_style edpd"_pair_meso.html "pair_style mdpd"_pair_meso.html "pair_style tdpd"_pair_meso.html -"fix mvv/dpd"_fix_mvv.html +"fix mvv/dpd"_fix_mvv_dpd.html examples/USER/meso http://lammps.sandia.gov/movies.html#mesodpd :ul diff --git a/doc/src/fix_addforce.txt b/doc/src/fix_addforce.txt index 4d0bde2e5b..b2ac95eabb 100644 --- a/doc/src/fix_addforce.txt +++ b/doc/src/fix_addforce.txt @@ -140,9 +140,9 @@ decrease in potential energy when atoms move in the direction of the added force. The "fix_modify"_fix_modify.html {virial} option is supported by this -fix to add the contribution due to the interaction between -atoms and each wall to the system's virial as part of "thermodynamic -output"_thermo_style.html. The default is {virial no} +fix to add the contribution due to the added forces on atoms to the +system's virial as part of "thermodynamic output"_thermo_style.html. +The default is {virial no} The "fix_modify"_fix_modify.html {respa} option is supported by this fix. This allows to set at which level of the "r-RESPA"_run_style.html diff --git a/doc/src/fix_cmap.txt b/doc/src/fix_cmap.txt index b126382b80..e80154bccf 100644 --- a/doc/src/fix_cmap.txt +++ b/doc/src/fix_cmap.txt @@ -98,9 +98,9 @@ fix to add the potential "energy" of the CMAP interactions system's potential energy as part of "thermodynamic output"_thermo_style.html. The "fix_modify"_fix_modify.html {virial} option is supported by this -fix to add the contribution due to the interaction between -atoms and each wall to the system's virial as part of "thermodynamic -output"_thermo_style.html. The default is {virial yes} +fix to add the contribution due to the interaction between atoms to +the system's virial as part of "thermodynamic output"_thermo_style.html. +The default is {virial yes} This fix computes a global scalar which can be accessed by various "output commands"_Section_howto.html#howto_15. The scalar is the diff --git a/doc/src/fix_efield.txt b/doc/src/fix_efield.txt index 6537898315..5d2b86fe4b 100644 --- a/doc/src/fix_efield.txt +++ b/doc/src/fix_efield.txt @@ -125,9 +125,9 @@ I.e. there is a decrease in potential energy when atoms move in the direction of the added force due to the electric field. The "fix_modify"_fix_modify.html {virial} option is supported by this -fix to add the contribution due to the interaction between -atoms and each wall to the system's virial as part of "thermodynamic -output"_thermo_style.html. The default is {virial no} +fix to add the contribution due to the added forces on atoms to the +system's virial as part of "thermodynamic output"_thermo_style.html. +The default is {virial no} The "fix_modify"_fix_modify.html {respa} option is supported by this fix. This allows to set at which level of the "r-RESPA"_run_style.html diff --git a/doc/src/fix_external.txt b/doc/src/fix_external.txt index c77a54d800..b28d33446f 100644 --- a/doc/src/fix_external.txt +++ b/doc/src/fix_external.txt @@ -132,8 +132,8 @@ decrease in potential energy when atoms move in the direction of the added force. The "fix_modify"_fix_modify.html {virial} option is supported by this -fix to add the contribution due to the interaction between -atoms and each wall to the system's virial as part of "thermodynamic +fix to add the contribution due to the interactions computed by the +external program to the system's virial as part of "thermodynamic output"_thermo_style.html. The default is {virial yes} This fix computes a global scalar which can be accessed by various diff --git a/doc/src/fix_rigid.txt b/doc/src/fix_rigid.txt index af00882c5b..99105e1350 100644 --- a/doc/src/fix_rigid.txt +++ b/doc/src/fix_rigid.txt @@ -704,9 +704,9 @@ thermostatting to the system's potential energy as part of "thermodynamic output"_thermo_style.html. The "fix_modify"_fix_modify.html {virial} option is supported by this -fix to add the contribution due to the interaction between -atoms and each wall to the system's virial as part of "thermodynamic -output"_thermo_style.html. The default is {virial yes} +fix to add the contribution due to keeping the objects rigid to the +system's virial as part of "thermodynamic output"_thermo_style.html. +The default is {virial yes} The "fix_modify"_fix_modify.html {temp} and {press} options are supported by the 4 NPT and NPH rigid styles to change the computes diff --git a/doc/src/fix_shake.txt b/doc/src/fix_shake.txt index c39ccdd07e..9f82fc0fb6 100644 --- a/doc/src/fix_shake.txt +++ b/doc/src/fix_shake.txt @@ -187,9 +187,9 @@ to 1 and recompiling LAMMPS. [Restart, fix_modify, output, run start/stop, minimize info:] The "fix_modify"_fix_modify.html {virial} option is supported by this -fix to add the contribution due to the interaction between -atoms and each wall to the system's virial as part of "thermodynamic -output"_thermo_style.html. The default is {virial yes} +fix to add the contribution due to keeping the constraints to the +system's virial as part of "thermodynamic output"_thermo_style.html. +The default is {virial yes} No information about these fixes is written to "binary restart files"_restart.html. None of the "fix_modify"_fix_modify.html options From 99e5dc7104610d1f4d6c072d6df87b97c9646c17 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 15 Sep 2017 01:21:16 -0400 Subject: [PATCH 55/55] add support for fix_modify virial yes to fix smd --- doc/src/fix_smd.txt | 5 +++++ src/USER-MISC/fix_smd.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/doc/src/fix_smd.txt b/doc/src/fix_smd.txt index dca45f4548..cb4a40f0fd 100644 --- a/doc/src/fix_smd.txt +++ b/doc/src/fix_smd.txt @@ -101,6 +101,11 @@ See the "read_restart"_read_restart.html command for info on how to re-specify a fix in an input script that reads a restart file, so that the operation of the fix continues in an uninterrupted fashion. +The "fix_modify"_fix_modify.html {virial} option is supported by this +fix to add the contribution due to the added forces on atoms to the +system's virial as part of "thermodynamic output"_thermo_style.html. +The default is {virial no} + The "fix_modify"_fix_modify.html {respa} option is supported by this fix. This allows to set at which level of the "r-RESPA"_run_style.html integrator the fix is adding its forces. Default is the outermost level. diff --git a/src/USER-MISC/fix_smd.cpp b/src/USER-MISC/fix_smd.cpp index b527e4b788..b2d3ee0779 100644 --- a/src/USER-MISC/fix_smd.cpp +++ b/src/USER-MISC/fix_smd.cpp @@ -58,6 +58,7 @@ FixSMD::FixSMD(LAMMPS *lmp, int narg, char **arg) : extvector = 1; respa_level_support = 1; ilevel_respa = 0; + virial_flag = 1; int argoffs=3; if (strcmp(arg[argoffs],"cvel") == 0) { @@ -181,6 +182,11 @@ void FixSMD::setup(int vflag) void FixSMD::post_force(int vflag) { + // energy and virial setup + + if (vflag) v_setup(vflag); + else evflag = 0; + if (styleflag & SMD_TETHER) smd_tether(); else smd_couple(); @@ -238,12 +244,15 @@ void FixSMD::smd_tether() // apply restoring force to atoms in group // f = -k*(r-r0)*mass/masstotal + double **x = atom->x; double **f = atom->f; + imageint *image = atom->image; int *mask = atom->mask; int *type = atom->type; double *mass = atom->mass; double *rmass = atom->rmass; double massfrac; + double unwrap[3],v[6]; int nlocal = atom->nlocal; ftotal[0] = ftotal[1] = ftotal[2] = 0.0; @@ -259,6 +268,16 @@ void FixSMD::smd_tether() ftotal[0] -= fx*massfrac; ftotal[1] -= fy*massfrac; ftotal[2] -= fz*massfrac; + if (evflag) { + domain->unmap(x[i],image[i],unwrap); + v[0] = fx*massfrac*unwrap[0]; + v[1] = fy*massfrac*unwrap[1]; + v[2] = fz*massfrac*unwrap[2]; + v[3] = fx*massfrac*unwrap[1]; + v[4] = fx*massfrac*unwrap[2]; + v[5] = fy*massfrac*unwrap[2]; + v_tally(i, v); + } } } else { for (int i = 0; i < nlocal; i++) @@ -270,6 +289,16 @@ void FixSMD::smd_tether() ftotal[0] -= fx*massfrac; ftotal[1] -= fy*massfrac; ftotal[2] -= fz*massfrac; + if (evflag) { + domain->unmap(x[i],image[i],unwrap); + v[0] = fx*massfrac*unwrap[0]; + v[1] = fy*massfrac*unwrap[1]; + v[2] = fz*massfrac*unwrap[2]; + v[3] = fx*massfrac*unwrap[1]; + v[4] = fx*massfrac*unwrap[2]; + v[5] = fy*massfrac*unwrap[2]; + v_tally(i, v); + } } } }