Skip to content
Snippets Groups Projects
Commit dcdde4c3 authored by carlocamilloni's avatar carlocamilloni
Browse files

gromacs 2019.1 patch --NOT WORKING--

this is not really working yet, but hopefully we are not far
parent af86b5a6
No related branches found
No related tags found
No related merge requests found
Showing
with 20035 additions and 0 deletions
function plumed_preliminary_test(){
# check if the README contains the word GROMACS and if gromacs has been already configured
grep -q GROMACS README 1>/dev/null 2>/dev/null
}
function plumed_patch_info(){
cat << EOF
PLUMED can be incorporated into gromacs using the standard patching procedure.
Patching must be done in the gromacs root directory _before_ the cmake command is invoked.
On clusters you may want to patch gromacs using the static version of plumed, in this case
building gromacs can result in multiple errors. One possible solution is to configure gromacs
with these additional options:
cmake -DBUILD_SHARED_LIBS=OFF -DGMX_PREFER_STATIC_LIBS=ON
To enable PLUMED in a gromacs simulation one should use
mdrun with an extra -plumed flag. The flag can be used to
specify the name of the PLUMED input file, e.g.:
gmx mdrun -plumed plumed.dat
For more information on gromacs you should visit http://www.gromacs.org
EOF
}
plumed_before_patch(){
plumed_patch_info
}
#
# This file is part of the GROMACS molecular simulation package.
#
# Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
# and including many others, as listed in the AUTHORS file in the
# top-level source directory and at http://www.gromacs.org.
#
# GROMACS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# GROMACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with GROMACS; if not, see
# http://www.gnu.org/licenses, or write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# If you want to redistribute modifications to GROMACS, please
# consider that scientific software is very special. Version
# control is crucial - bugs must be traceable. We will be happy to
# consider code for inclusion in the official distribution, but
# derived work must not be called official GROMACS. Details are found
# in the README & COPYING files - if they are missing, get the
# official version at http://www.gromacs.org.
#
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out http://www.gromacs.org.
set(LIBGROMACS_SOURCES)
if (GMX_CLANG_CUDA)
include(gmxClangCudaUtils)
endif()
set_property(GLOBAL PROPERTY GMX_LIBGROMACS_SOURCES)
set_property(GLOBAL PROPERTY GMX_LIBGROMACS_GPU_IMPL_SOURCES)
set_property(GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
set_property(GLOBAL PROPERTY GMX_AVX_512_SOURCE)
add_library(libgromacs_external OBJECT "")
if(CMAKE_COMPILER_IS_GNUCXX)
# Keep quiet about e.g. linearalgebra module
target_compile_options(libgromacs_external PRIVATE ${CXXFLAGS_NO_STRINGOP_TRUNCATION})
endif()
add_library(libgromacs_generated OBJECT "")
if (BUILD_SHARED_LIBS)
set_target_properties(libgromacs_external PROPERTIES POSITION_INDEPENDENT_CODE true)
set_target_properties(libgromacs_generated PROPERTIES POSITION_INDEPENDENT_CODE true)
endif()
function (_gmx_add_files_to_property PROPERTY)
foreach (_file ${ARGN})
if (IS_ABSOLUTE "${_file}")
set_property(GLOBAL APPEND PROPERTY ${PROPERTY} ${_file})
else()
set_property(GLOBAL APPEND PROPERTY ${PROPERTY}
${CMAKE_CURRENT_LIST_DIR}/${_file})
endif()
endforeach()
endfunction ()
function (gmx_add_libgromacs_sources)
_gmx_add_files_to_property(GMX_LIBGROMACS_SOURCES ${ARGN})
endfunction ()
# TODO Reconsider this, as the CUDA driver API is probably a simpler
# approach, at least for the build system. See Redmine #2530
function (gmx_compile_cpp_as_cuda)
_gmx_add_files_to_property(GMX_LIBGROMACS_GPU_IMPL_SOURCES ${ARGN})
endfunction ()
function (gmx_install_headers)
if (NOT GMX_BUILD_MDRUN_ONLY)
file(RELATIVE_PATH _dest ${PROJECT_SOURCE_DIR}/src ${CMAKE_CURRENT_LIST_DIR})
install(FILES ${ARGN}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_dest}"
COMPONENT development)
endif()
_gmx_add_files_to_property(GMX_INSTALLED_HEADERS ${ARGN})
endfunction ()
function (gmx_write_installed_header_list)
get_property(_list GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
string(REPLACE ";" "\n" _list "${_list}")
# TODO: Make this only update the file timestamp if the contents actually change.
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/installed-headers.txt "${_list}")
endfunction()
add_subdirectory(gmxlib)
add_subdirectory(mdlib)
add_subdirectory(applied-forces)
add_subdirectory(listed-forces)
add_subdirectory(commandline)
add_subdirectory(domdec)
add_subdirectory(ewald)
add_subdirectory(fft)
add_subdirectory(gpu_utils)
add_subdirectory(hardware)
add_subdirectory(linearalgebra)
add_subdirectory(math)
add_subdirectory(mdrun)
add_subdirectory(mdrunutility)
add_subdirectory(mdtypes)
add_subdirectory(onlinehelp)
add_subdirectory(options)
add_subdirectory(pbcutil)
add_subdirectory(random)
add_subdirectory(restraint)
add_subdirectory(tables)
add_subdirectory(taskassignment)
add_subdirectory(timing)
add_subdirectory(topology)
add_subdirectory(trajectory)
add_subdirectory(utility)
add_subdirectory(fileio)
add_subdirectory(swap)
add_subdirectory(essentialdynamics)
add_subdirectory(pulling)
add_subdirectory(awh)
add_subdirectory(simd)
add_subdirectory(imd)
add_subdirectory(compat)
add_subdirectory(mimic)
if (NOT GMX_BUILD_MDRUN_ONLY)
add_subdirectory(gmxana)
add_subdirectory(gmxpreprocess)
add_subdirectory(correlationfunctions)
add_subdirectory(statistics)
add_subdirectory(analysisdata)
add_subdirectory(selection)
add_subdirectory(trajectoryanalysis)
add_subdirectory(energyanalysis)
add_subdirectory(tools)
endif()
get_property(PROPERTY_SOURCES GLOBAL PROPERTY GMX_LIBGROMACS_SOURCES)
list(APPEND LIBGROMACS_SOURCES ${GMXLIB_SOURCES} ${MDLIB_SOURCES} ${PROPERTY_SOURCES})
# This would be the standard way to include thread_mpi, but
# we want libgromacs to link the functions directly
#if(GMX_THREAD_MPI)
# add_subdirectory(thread_mpi)
#endif()
#target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${THREAD_MPI_LIB})
tmpi_get_source_list(THREAD_MPI_SOURCES ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/src)
target_sources(libgromacs_external PRIVATE ${THREAD_MPI_SOURCES})
configure_file(version.h.cmakein version.h)
gmx_install_headers(
analysisdata.h
commandline.h
options.h
random.h
selection.h
trajectoryanalysis.h
utility.h
${CMAKE_CURRENT_BINARY_DIR}/version.h
)
# This code is here instead of utility/CMakeLists.txt, because CMake
# custom commands and source file properties can only be set in the directory
# that contains the target that uses them.
# TODO: Generate a header instead that can be included from baseversion.c.
# That probably simplifies things somewhat.
set(GENERATED_VERSION_FILE utility/baseversion-gen.cpp)
gmx_configure_version_file(
utility/baseversion-gen.cpp.cmakein ${GENERATED_VERSION_FILE}
REMOTE_HASH
EXTRA_VARS
GMX_SOURCE_DOI
)
list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE}
$<TARGET_OBJECTS:libgromacs_external>
$<TARGET_OBJECTS:libgromacs_generated>)
# Mark some shared GPU implementation files to compile with CUDA if needed
if (GMX_USE_CUDA)
get_property(LIBGROMACS_GPU_IMPL_SOURCES GLOBAL PROPERTY GMX_LIBGROMACS_GPU_IMPL_SOURCES)
set_source_files_properties(${LIBGROMACS_GPU_IMPL_SOURCES} PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ)
endif()
# set up CUDA compilation with clang
if (GMX_CLANG_CUDA)
foreach (_file ${LIBGROMACS_SOURCES})
get_filename_component(_ext ${_file} EXT)
get_source_file_property(_cuda_source_format ${_file} CUDA_SOURCE_PROPERTY_FORMAT)
if ("${_ext}" STREQUAL ".cu" OR _cuda_source_format)
gmx_compile_cuda_file_with_clang(${_file})
endif()
endforeach()
endif()
if (GMX_USE_CUDA)
# Work around FindCUDA that prevents using target_link_libraries()
# with keywords otherwise...
set(CUDA_LIBRARIES PRIVATE ${CUDA_LIBRARIES})
if (NOT GMX_CLANG_CUDA)
cuda_add_library(libgromacs ${LIBGROMACS_SOURCES})
else()
add_library(libgromacs ${LIBGROMACS_SOURCES})
endif()
target_link_libraries(libgromacs PRIVATE ${CUDA_CUFFT_LIBRARIES})
else()
add_library(libgromacs ${LIBGROMACS_SOURCES})
endif()
if (GMX_USE_OPENCL)
option(GMX_EXTERNAL_CLFFT "True if an external clFFT is required to be used" FALSE)
mark_as_advanced(GMX_EXTERNAL_CLFFT)
# Default to using clFFT found on the system
# switch to quiet at the second run.
if (DEFINED clFFT_LIBRARY)
set (clFFT_FIND_QUIETLY TRUE)
endif()
find_package(clFFT)
if (NOT clFFT_FOUND)
if (GMX_EXTERNAL_CLFFT)
message(FATAL_ERROR "Did not find required external clFFT library, consider setting clFFT_ROOT_DIR")
endif()
if(MSVC)
message(FATAL_ERROR
"An OpenCL build was requested with Visual Studio compiler, but GROMACS
requires clFFT, which was not found on your system. GROMACS does bundle
clFFT to help with building for OpenCL, but that clFFT has not yet been
ported to the more recent versions of that compiler that GROMACS itself
requires. Thus for now, OpenCL is not available with MSVC and the internal
build of clFFT in GROMACS 2019. Either change compiler, try installing
a clFFT package, or use the latest GROMACS 2018 point release.")
endif()
# Fall back on the internal version
set (_clFFT_dir ../external/clFFT/src)
add_subdirectory(${_clFFT_dir} clFFT-build)
target_sources(libgromacs PRIVATE
$<TARGET_OBJECTS:clFFT>
)
target_include_directories(libgromacs SYSTEM PRIVATE ${_clFFT_dir}/include)
# Use the magic variable for how to link any library needed for
# dlopen, etc. which is -ldl where needed, and empty otherwise
# (e.g. Windows, BSD, Mac).
target_link_libraries(libgromacs PRIVATE "${CMAKE_DL_LIBS}")
else()
target_link_libraries(libgromacs PRIVATE clFFT)
endif()
endif()
# Recent versions of gcc and clang give warnings on scanner.cpp, which
# is a generated source file. These are awkward to suppress inline, so
# we do it in the compilation command (after testing that the compiler
# supports the suppressions). Same issue exists for nonbonded kernels
# so we supress them for all generated files.
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Wno-unused -Wno-unused-parameter" HAS_NO_UNUSED)
check_cxx_compiler_flag(-Wno-missing-declarations HAS_NO_MISSING_DECL)
check_cxx_compiler_flag(-Wno-missing-prototypes HAS_NO_MISSING_PROTO)
check_cxx_compiler_flag(/wd4101 HAS_NO_MSVC_UNUSED)
if (NOT MSVC)
check_cxx_compiler_flag(-wd1419 HAS_DECL_IN_SOURCE)
endif()
if (HAS_NO_UNUSED)
target_compile_options(libgromacs_generated PRIVATE "-Wno-unused;-Wno-unused-parameter")
endif()
if (HAS_NO_MISSING_DECL)
target_compile_options(libgromacs_generated PRIVATE "-Wno-missing-declarations")
endif()
# TODO The group scheme kernels don't use proper function prototype
# declarations, and clang warns about such use, which we suppress
# rather than fix. We would prefer to use no suppressions. However
# other compilers do not support such a warning suppression for C++
# source files, and issue warnings about that. Remove the use of
# -Wno-missing-prototypes here and above when the group scheme is
# removed.
if (HAS_NO_MISSING_PROTO AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
target_compile_options(libgromacs_generated PRIVATE "-Wno-missing-prototypes")
endif()
if (HAS_NO_MSVC_UNUSED)
target_compile_options(libgromacs_generated PRIVATE "/wd4101")
endif()
if (HAS_DECL_IN_SOURCE)
target_compile_options(libgromacs_generated PRIVATE "-wd1419")
endif()
if(SIMD_AVX_512_CXX_SUPPORTED AND NOT ("${GMX_SIMD_ACTIVE}" STREQUAL "AVX_512_KNL"))
# Since we might be overriding -march=core-avx2, add a flag so we don't warn for this specific file.
# On KNL this can cause illegal instruction because the compiler might use non KNL AVX instructions
# with the SIMD_AVX_512_CXX_FLAGS flags.
set_source_files_properties(hardware/identifyavx512fmaunits.cpp PROPERTIES COMPILE_FLAGS "${SIMD_AVX_512_CXX_FLAGS} ${CXX_NO_UNUSED_OPTION_WARNING_FLAGS}")
endif()
gmx_setup_tng_for_libgromacs()
target_link_libraries(libgromacs
PRIVATE
${EXTRAE_LIBRARIES}
${GMX_EXTRA_LIBRARIES}
${GMX_COMMON_LIBRARIES}
${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES}
${THREAD_LIB} ${GMX_SHARED_LINKER_FLAGS}
${OpenCL_LIBRARIES}
${GMX_STDLIB_LIBRARIES}
PUBLIC
${GMX_PUBLIC_LIBRARIES}
${PLUMED_LOAD}
)
set_target_properties(libgromacs PROPERTIES
OUTPUT_NAME "gromacs${GMX_LIBS_SUFFIX}"
SOVERSION ${LIBRARY_SOVERSION_MAJOR}
VERSION ${LIBRARY_VERSION}
COMPILE_FLAGS "${OpenMP_C_FLAGS}")
gmx_manage_lmfit()
target_link_libraries(libgromacs PRIVATE lmfit)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION MATCHES "^6\.0")
target_compile_options(libgromacs PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Weverything ${IGNORED_CLANG_ALL_WARNINGS}>)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(libgromacs PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/analyze /analyze:stacksize 70000
#Control flow warnings are disabled because the commond line output is insufficient. There is no tool
#to convert the xml report to e.g. HTML and even in Visual Studio the viewer doesn't work with cmake support.
/wd6001 #unitialized memory
/wd6011 #derefencing NULL
/wd6053 #prior call not zero-terminate
/wd6054 #might not be zero-terminated
/wd6385 #reading invalid data
/wd6386 #buffer overrun
/wd6387 #could be '0'
/wd28199 #uninitialized memory
# For compile time constant (e.g. templates) the following warnings have flase postives
/wd6239 #(<non-zero> && <expr>)
/wd6240 #(<expr> && <non-zero>)
/wd6294 #Ill-defined for-loop
/wd6326 #comparison of constant with other constant
/wd28020 #expression involving paramter is not true
# Misc
/wd6330 #incorrect type to function (warns for char (instead of unsigned) for isspace/isalpha/isdigit/..))
/wd6993 #OpenMP ignored
#TODO
/wd6031 #return value ignored (important - mostly warnigns about sscanf)
/wd6244 #hides declaration (known issue - we ingore similar warnings for other compilers)
/wd6246 #hides declaration
>
)
endif()
if (GMX_CLANG_TIDY)
set_target_properties(libgromacs PROPERTIES CXX_CLANG_TIDY
"${CLANG_TIDY_EXE};-warnings-as-errors=*")
endif()
gmx_write_installed_header_list()
# Only install the library in mdrun-only mode if it is actually necessary
# for the binary
if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS)
install(TARGETS libgromacs
EXPORT libgromacs
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT libraries)
endif()
if (NOT GMX_BUILD_MDRUN_ONLY)
include(InstallLibInfo.cmake)
endif()
# Technically, the user could want to do this for an OpenCL build
# using the CUDA runtime, but currently there's no reason to want to
# do that.
if (INSTALL_CUDART_LIB) #can be set manual by user
if (GMX_USE_CUDA)
foreach(CUDA_LIB ${CUDA_LIBRARIES})
string(REGEX MATCH "cudart" IS_CUDART ${CUDA_LIB})
if(IS_CUDART) #libcuda should not be installed
#install also name-links (linker uses those)
file(GLOB CUDA_LIBS ${CUDA_LIB}*)
install(FILES ${CUDA_LIBS} DESTINATION
${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
endforeach()
else()
message(WARNING "INSTALL_CUDART_LIB only makes sense when configuring for CUDA support")
endif()
endif()
if(GMX_USE_OPENCL)
# Install the utility headers
file(GLOB OPENCL_INSTALLED_FILES
gpu_utils/vectype_ops.clh
gpu_utils/device_utils.clh
)
install(FILES ${OPENCL_INSTALLED_FILES}
DESTINATION ${GMX_INSTALL_OCLDIR}/gromacs/gpu_utils
COMPONENT libraries)
file(GLOB OPENCL_INSTALLED_FILES
pbcutil/ishift.h
)
install(FILES ${OPENCL_INSTALLED_FILES}
DESTINATION ${GMX_INSTALL_OCLDIR}/gromacs/pbcutil
COMPONENT libraries)
# Install the NB source and headers
file(GLOB OPENCL_INSTALLED_FILES
mdlib/nbnxn_consts.h
)
install(FILES ${OPENCL_INSTALLED_FILES}
DESTINATION ${GMX_INSTALL_OCLDIR}/gromacs/mdlib
COMPONENT libraries)
file(GLOB OPENCL_INSTALLED_FILES
mdlib/nbnxn_ocl/nbnxn_ocl_kernels.cl
mdlib/nbnxn_ocl/nbnxn_ocl_kernel.clh
mdlib/nbnxn_ocl/nbnxn_ocl_kernel_pruneonly.clh
mdlib/nbnxn_ocl/nbnxn_ocl_kernels.clh
mdlib/nbnxn_ocl/nbnxn_ocl_kernels_fastgen.clh
mdlib/nbnxn_ocl/nbnxn_ocl_kernels_fastgen_add_twincut.clh
mdlib/nbnxn_ocl/nbnxn_ocl_kernel_utils.clh
mdlib/nbnxn_ocl/nbnxn_ocl_consts.h
)
install(FILES ${OPENCL_INSTALLED_FILES}
DESTINATION ${GMX_INSTALL_OCLDIR}/gromacs/mdlib/nbnxn_ocl
COMPONENT libraries)
# Install the PME source and headers
file(GLOB OPENCL_INSTALLED_FILES
ewald/pme-spread.clh
ewald/pme-solve.clh
ewald/pme-gather.clh
ewald/pme-gpu-utils.clh
ewald/pme-program.cl
ewald/pme-gpu-types.h
)
install(FILES ${OPENCL_INSTALLED_FILES}
DESTINATION ${GMX_INSTALL_OCLDIR}/gromacs/ewald
COMPONENT libraries)
endif()
#
# This file is part of the GROMACS molecular simulation package.
#
# Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
# and including many others, as listed in the AUTHORS file in the
# top-level source directory and at http://www.gromacs.org.
#
# GROMACS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# GROMACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with GROMACS; if not, see
# http://www.gnu.org/licenses, or write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# If you want to redistribute modifications to GROMACS, please
# consider that scientific software is very special. Version
# control is crucial - bugs must be traceable. We will be happy to
# consider code for inclusion in the official distribution, but
# derived work must not be called official GROMACS. Details are found
# in the README & COPYING files - if they are missing, get the
# official version at http://www.gromacs.org.
#
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out http://www.gromacs.org.
set(LIBGROMACS_SOURCES)
if (GMX_CLANG_CUDA)
include(gmxClangCudaUtils)
endif()
set_property(GLOBAL PROPERTY GMX_LIBGROMACS_SOURCES)
set_property(GLOBAL PROPERTY GMX_LIBGROMACS_GPU_IMPL_SOURCES)
set_property(GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
set_property(GLOBAL PROPERTY GMX_AVX_512_SOURCE)
add_library(libgromacs_external OBJECT "")
if(CMAKE_COMPILER_IS_GNUCXX)
# Keep quiet about e.g. linearalgebra module
target_compile_options(libgromacs_external PRIVATE ${CXXFLAGS_NO_STRINGOP_TRUNCATION})
endif()
add_library(libgromacs_generated OBJECT "")
if (BUILD_SHARED_LIBS)
set_target_properties(libgromacs_external PROPERTIES POSITION_INDEPENDENT_CODE true)
set_target_properties(libgromacs_generated PROPERTIES POSITION_INDEPENDENT_CODE true)
endif()
function (_gmx_add_files_to_property PROPERTY)
foreach (_file ${ARGN})
if (IS_ABSOLUTE "${_file}")
set_property(GLOBAL APPEND PROPERTY ${PROPERTY} ${_file})
else()
set_property(GLOBAL APPEND PROPERTY ${PROPERTY}
${CMAKE_CURRENT_LIST_DIR}/${_file})
endif()
endforeach()
endfunction ()
function (gmx_add_libgromacs_sources)
_gmx_add_files_to_property(GMX_LIBGROMACS_SOURCES ${ARGN})
endfunction ()
# TODO Reconsider this, as the CUDA driver API is probably a simpler
# approach, at least for the build system. See Redmine #2530
function (gmx_compile_cpp_as_cuda)
_gmx_add_files_to_property(GMX_LIBGROMACS_GPU_IMPL_SOURCES ${ARGN})
endfunction ()
function (gmx_install_headers)
if (NOT GMX_BUILD_MDRUN_ONLY)
file(RELATIVE_PATH _dest ${PROJECT_SOURCE_DIR}/src ${CMAKE_CURRENT_LIST_DIR})
install(FILES ${ARGN}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_dest}"
COMPONENT development)
endif()
_gmx_add_files_to_property(GMX_INSTALLED_HEADERS ${ARGN})
endfunction ()
function (gmx_write_installed_header_list)
get_property(_list GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
string(REPLACE ";" "\n" _list "${_list}")
# TODO: Make this only update the file timestamp if the contents actually change.
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/installed-headers.txt "${_list}")
endfunction()
add_subdirectory(gmxlib)
add_subdirectory(mdlib)
add_subdirectory(applied-forces)
add_subdirectory(listed-forces)
add_subdirectory(commandline)
add_subdirectory(domdec)
add_subdirectory(ewald)
add_subdirectory(fft)
add_subdirectory(gpu_utils)
add_subdirectory(hardware)
add_subdirectory(linearalgebra)
add_subdirectory(math)
add_subdirectory(mdrun)
add_subdirectory(mdrunutility)
add_subdirectory(mdtypes)
add_subdirectory(onlinehelp)
add_subdirectory(options)
add_subdirectory(pbcutil)
add_subdirectory(random)
add_subdirectory(restraint)
add_subdirectory(tables)
add_subdirectory(taskassignment)
add_subdirectory(timing)
add_subdirectory(topology)
add_subdirectory(trajectory)
add_subdirectory(utility)
add_subdirectory(fileio)
add_subdirectory(swap)
add_subdirectory(essentialdynamics)
add_subdirectory(pulling)
add_subdirectory(awh)
add_subdirectory(simd)
add_subdirectory(imd)
add_subdirectory(compat)
add_subdirectory(mimic)
if (NOT GMX_BUILD_MDRUN_ONLY)
add_subdirectory(gmxana)
add_subdirectory(gmxpreprocess)
add_subdirectory(correlationfunctions)
add_subdirectory(statistics)
add_subdirectory(analysisdata)
add_subdirectory(selection)
add_subdirectory(trajectoryanalysis)
add_subdirectory(energyanalysis)
add_subdirectory(tools)
endif()
get_property(PROPERTY_SOURCES GLOBAL PROPERTY GMX_LIBGROMACS_SOURCES)
list(APPEND LIBGROMACS_SOURCES ${GMXLIB_SOURCES} ${MDLIB_SOURCES} ${PROPERTY_SOURCES})
# This would be the standard way to include thread_mpi, but
# we want libgromacs to link the functions directly
#if(GMX_THREAD_MPI)
# add_subdirectory(thread_mpi)
#endif()
#target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${THREAD_MPI_LIB})
tmpi_get_source_list(THREAD_MPI_SOURCES ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/src)
target_sources(libgromacs_external PRIVATE ${THREAD_MPI_SOURCES})
configure_file(version.h.cmakein version.h)
gmx_install_headers(
analysisdata.h
commandline.h
options.h
random.h
selection.h
trajectoryanalysis.h
utility.h
${CMAKE_CURRENT_BINARY_DIR}/version.h
)
# This code is here instead of utility/CMakeLists.txt, because CMake
# custom commands and source file properties can only be set in the directory
# that contains the target that uses them.
# TODO: Generate a header instead that can be included from baseversion.c.
# That probably simplifies things somewhat.
set(GENERATED_VERSION_FILE utility/baseversion-gen.cpp)
gmx_configure_version_file(
utility/baseversion-gen.cpp.cmakein ${GENERATED_VERSION_FILE}
REMOTE_HASH
EXTRA_VARS
GMX_SOURCE_DOI
)
list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE}
$<TARGET_OBJECTS:libgromacs_external>
$<TARGET_OBJECTS:libgromacs_generated>)
# Mark some shared GPU implementation files to compile with CUDA if needed
if (GMX_USE_CUDA)
get_property(LIBGROMACS_GPU_IMPL_SOURCES GLOBAL PROPERTY GMX_LIBGROMACS_GPU_IMPL_SOURCES)
set_source_files_properties(${LIBGROMACS_GPU_IMPL_SOURCES} PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ)
endif()
# set up CUDA compilation with clang
if (GMX_CLANG_CUDA)
foreach (_file ${LIBGROMACS_SOURCES})
get_filename_component(_ext ${_file} EXT)
get_source_file_property(_cuda_source_format ${_file} CUDA_SOURCE_PROPERTY_FORMAT)
if ("${_ext}" STREQUAL ".cu" OR _cuda_source_format)
gmx_compile_cuda_file_with_clang(${_file})
endif()
endforeach()
endif()
if (GMX_USE_CUDA)
# Work around FindCUDA that prevents using target_link_libraries()
# with keywords otherwise...
set(CUDA_LIBRARIES PRIVATE ${CUDA_LIBRARIES})
if (NOT GMX_CLANG_CUDA)
cuda_add_library(libgromacs ${LIBGROMACS_SOURCES})
else()
add_library(libgromacs ${LIBGROMACS_SOURCES})
endif()
target_link_libraries(libgromacs PRIVATE ${CUDA_CUFFT_LIBRARIES})
else()
add_library(libgromacs ${LIBGROMACS_SOURCES})
endif()
if (GMX_USE_OPENCL)
option(GMX_EXTERNAL_CLFFT "True if an external clFFT is required to be used" FALSE)
mark_as_advanced(GMX_EXTERNAL_CLFFT)
# Default to using clFFT found on the system
# switch to quiet at the second run.
if (DEFINED clFFT_LIBRARY)
set (clFFT_FIND_QUIETLY TRUE)
endif()
find_package(clFFT)
if (NOT clFFT_FOUND)
if (GMX_EXTERNAL_CLFFT)
message(FATAL_ERROR "Did not find required external clFFT library, consider setting clFFT_ROOT_DIR")
endif()
if(MSVC)
message(FATAL_ERROR
"An OpenCL build was requested with Visual Studio compiler, but GROMACS
requires clFFT, which was not found on your system. GROMACS does bundle
clFFT to help with building for OpenCL, but that clFFT has not yet been
ported to the more recent versions of that compiler that GROMACS itself
requires. Thus for now, OpenCL is not available with MSVC and the internal
build of clFFT in GROMACS 2019. Either change compiler, try installing
a clFFT package, or use the latest GROMACS 2018 point release.")
endif()
# Fall back on the internal version
set (_clFFT_dir ../external/clFFT/src)
add_subdirectory(${_clFFT_dir} clFFT-build)
target_sources(libgromacs PRIVATE
$<TARGET_OBJECTS:clFFT>
)
target_include_directories(libgromacs SYSTEM PRIVATE ${_clFFT_dir}/include)
# Use the magic variable for how to link any library needed for
# dlopen, etc. which is -ldl where needed, and empty otherwise
# (e.g. Windows, BSD, Mac).
target_link_libraries(libgromacs PRIVATE "${CMAKE_DL_LIBS}")
else()
target_link_libraries(libgromacs PRIVATE clFFT)
endif()
endif()
# Recent versions of gcc and clang give warnings on scanner.cpp, which
# is a generated source file. These are awkward to suppress inline, so
# we do it in the compilation command (after testing that the compiler
# supports the suppressions). Same issue exists for nonbonded kernels
# so we supress them for all generated files.
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Wno-unused -Wno-unused-parameter" HAS_NO_UNUSED)
check_cxx_compiler_flag(-Wno-missing-declarations HAS_NO_MISSING_DECL)
check_cxx_compiler_flag(-Wno-missing-prototypes HAS_NO_MISSING_PROTO)
check_cxx_compiler_flag(/wd4101 HAS_NO_MSVC_UNUSED)
if (NOT MSVC)
check_cxx_compiler_flag(-wd1419 HAS_DECL_IN_SOURCE)
endif()
if (HAS_NO_UNUSED)
target_compile_options(libgromacs_generated PRIVATE "-Wno-unused;-Wno-unused-parameter")
endif()
if (HAS_NO_MISSING_DECL)
target_compile_options(libgromacs_generated PRIVATE "-Wno-missing-declarations")
endif()
# TODO The group scheme kernels don't use proper function prototype
# declarations, and clang warns about such use, which we suppress
# rather than fix. We would prefer to use no suppressions. However
# other compilers do not support such a warning suppression for C++
# source files, and issue warnings about that. Remove the use of
# -Wno-missing-prototypes here and above when the group scheme is
# removed.
if (HAS_NO_MISSING_PROTO AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
target_compile_options(libgromacs_generated PRIVATE "-Wno-missing-prototypes")
endif()
if (HAS_NO_MSVC_UNUSED)
target_compile_options(libgromacs_generated PRIVATE "/wd4101")
endif()
if (HAS_DECL_IN_SOURCE)
target_compile_options(libgromacs_generated PRIVATE "-wd1419")
endif()
if(SIMD_AVX_512_CXX_SUPPORTED AND NOT ("${GMX_SIMD_ACTIVE}" STREQUAL "AVX_512_KNL"))
# Since we might be overriding -march=core-avx2, add a flag so we don't warn for this specific file.
# On KNL this can cause illegal instruction because the compiler might use non KNL AVX instructions
# with the SIMD_AVX_512_CXX_FLAGS flags.
set_source_files_properties(hardware/identifyavx512fmaunits.cpp PROPERTIES COMPILE_FLAGS "${SIMD_AVX_512_CXX_FLAGS} ${CXX_NO_UNUSED_OPTION_WARNING_FLAGS}")
endif()
gmx_setup_tng_for_libgromacs()
target_link_libraries(libgromacs
PRIVATE
${EXTRAE_LIBRARIES}
${GMX_EXTRA_LIBRARIES}
${GMX_COMMON_LIBRARIES}
${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES}
${THREAD_LIB} ${GMX_SHARED_LINKER_FLAGS}
${OpenCL_LIBRARIES}
${GMX_STDLIB_LIBRARIES}
PUBLIC
${GMX_PUBLIC_LIBRARIES}
)
set_target_properties(libgromacs PROPERTIES
OUTPUT_NAME "gromacs${GMX_LIBS_SUFFIX}"
SOVERSION ${LIBRARY_SOVERSION_MAJOR}
VERSION ${LIBRARY_VERSION}
COMPILE_FLAGS "${OpenMP_C_FLAGS}")
gmx_manage_lmfit()
target_link_libraries(libgromacs PRIVATE lmfit)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION MATCHES "^6\.0")
target_compile_options(libgromacs PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Weverything ${IGNORED_CLANG_ALL_WARNINGS}>)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(libgromacs PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/analyze /analyze:stacksize 70000
#Control flow warnings are disabled because the commond line output is insufficient. There is no tool
#to convert the xml report to e.g. HTML and even in Visual Studio the viewer doesn't work with cmake support.
/wd6001 #unitialized memory
/wd6011 #derefencing NULL
/wd6053 #prior call not zero-terminate
/wd6054 #might not be zero-terminated
/wd6385 #reading invalid data
/wd6386 #buffer overrun
/wd6387 #could be '0'
/wd28199 #uninitialized memory
# For compile time constant (e.g. templates) the following warnings have flase postives
/wd6239 #(<non-zero> && <expr>)
/wd6240 #(<expr> && <non-zero>)
/wd6294 #Ill-defined for-loop
/wd6326 #comparison of constant with other constant
/wd28020 #expression involving paramter is not true
# Misc
/wd6330 #incorrect type to function (warns for char (instead of unsigned) for isspace/isalpha/isdigit/..))
/wd6993 #OpenMP ignored
#TODO
/wd6031 #return value ignored (important - mostly warnigns about sscanf)
/wd6244 #hides declaration (known issue - we ingore similar warnings for other compilers)
/wd6246 #hides declaration
>
)
endif()
if (GMX_CLANG_TIDY)
set_target_properties(libgromacs PROPERTIES CXX_CLANG_TIDY
"${CLANG_TIDY_EXE};-warnings-as-errors=*")
endif()
gmx_write_installed_header_list()
# Only install the library in mdrun-only mode if it is actually necessary
# for the binary
if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS)
install(TARGETS libgromacs
EXPORT libgromacs
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT libraries)
endif()
if (NOT GMX_BUILD_MDRUN_ONLY)
include(InstallLibInfo.cmake)
endif()
# Technically, the user could want to do this for an OpenCL build
# using the CUDA runtime, but currently there's no reason to want to
# do that.
if (INSTALL_CUDART_LIB) #can be set manual by user
if (GMX_USE_CUDA)
foreach(CUDA_LIB ${CUDA_LIBRARIES})
string(REGEX MATCH "cudart" IS_CUDART ${CUDA_LIB})
if(IS_CUDART) #libcuda should not be installed
#install also name-links (linker uses those)
file(GLOB CUDA_LIBS ${CUDA_LIB}*)
install(FILES ${CUDA_LIBS} DESTINATION
${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
endforeach()
else()
message(WARNING "INSTALL_CUDART_LIB only makes sense when configuring for CUDA support")
endif()
endif()
if(GMX_USE_OPENCL)
# Install the utility headers
file(GLOB OPENCL_INSTALLED_FILES
gpu_utils/vectype_ops.clh
gpu_utils/device_utils.clh
)
install(FILES ${OPENCL_INSTALLED_FILES}
DESTINATION ${GMX_INSTALL_OCLDIR}/gromacs/gpu_utils
COMPONENT libraries)
file(GLOB OPENCL_INSTALLED_FILES
pbcutil/ishift.h
)
install(FILES ${OPENCL_INSTALLED_FILES}
DESTINATION ${GMX_INSTALL_OCLDIR}/gromacs/pbcutil
COMPONENT libraries)
# Install the NB source and headers
file(GLOB OPENCL_INSTALLED_FILES
mdlib/nbnxn_consts.h
)
install(FILES ${OPENCL_INSTALLED_FILES}
DESTINATION ${GMX_INSTALL_OCLDIR}/gromacs/mdlib
COMPONENT libraries)
file(GLOB OPENCL_INSTALLED_FILES
mdlib/nbnxn_ocl/nbnxn_ocl_kernels.cl
mdlib/nbnxn_ocl/nbnxn_ocl_kernel.clh
mdlib/nbnxn_ocl/nbnxn_ocl_kernel_pruneonly.clh
mdlib/nbnxn_ocl/nbnxn_ocl_kernels.clh
mdlib/nbnxn_ocl/nbnxn_ocl_kernels_fastgen.clh
mdlib/nbnxn_ocl/nbnxn_ocl_kernels_fastgen_add_twincut.clh
mdlib/nbnxn_ocl/nbnxn_ocl_kernel_utils.clh
mdlib/nbnxn_ocl/nbnxn_ocl_consts.h
)
install(FILES ${OPENCL_INSTALLED_FILES}
DESTINATION ${GMX_INSTALL_OCLDIR}/gromacs/mdlib/nbnxn_ocl
COMPONENT libraries)
# Install the PME source and headers
file(GLOB OPENCL_INSTALLED_FILES
ewald/pme-spread.clh
ewald/pme-solve.clh
ewald/pme-gather.clh
ewald/pme-gpu-utils.clh
ewald/pme-program.cl
ewald/pme-gpu-types.h
)
install(FILES ${OPENCL_INSTALLED_FILES}
DESTINATION ${GMX_INSTALL_OCLDIR}/gromacs/ewald
COMPONENT libraries)
endif()
This diff is collapsed.
This diff is collapsed.
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* GROMACS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GROMACS; if not, see
* http://www.gnu.org/licenses, or write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* If you want to redistribute modifications to GROMACS, please
* consider that scientific software is very special. Version
* control is crucial - bugs must be traceable. We will be happy to
* consider code for inclusion in the official distribution, but
* derived work must not be called official GROMACS. Details are found
* in the README & COPYING files - if they are missing, get the
* official version at http://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
/*! \internal \file
*
* \brief This file declares helper functionality for legacy option handling for mdrun
*
* \author Berk Hess <hess@kth.se>
* \author David van der Spoel <david.vanderspoel@icm.uu.se>
* \author Erik Lindahl <erik@kth.se>
* \author Mark Abraham <mark.j.abraham@gmail.com>
*
* \ingroup module_mdrun
*/
#include "gmxpre.h"
#include "legacymdrunoptions.h"
#include "config.h"
#include <cstring>
#include "gromacs/gmxlib/network.h"
#include "gromacs/math/functions.h"
#include "gromacs/mdrun/multisim.h"
#include "gromacs/mdrunutility/handlerestart.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/fatalerror.h"
/* PLUMED */
#include "../../../Plumed.h"
extern int plumedswitch;
extern plumed plumedmain;
extern void(*plumedcmd)(plumed,const char*,const void*);
/* END PLUMED */
namespace gmx
{
/*! \brief Return whether the command-line parameter that
* will trigger a multi-simulation is set */
static bool is_multisim_option_set(int argc, const char *const argv[])
{
for (int i = 0; i < argc; ++i)
{
if (strcmp(argv[i], "-multidir") == 0)
{
return true;
}
}
return false;
}
int LegacyMdrunOptions::updateFromCommandLine(int argc, char **argv, ArrayRef<const char *> desc)
{
unsigned long PCA_Flags = PCA_CAN_SET_DEFFNM;
// With -multidir, the working directory still needs to be
// changed, so we can't check for the existence of files during
// parsing. It isn't useful to do any completion based on file
// system contents, either.
if (is_multisim_option_set(argc, argv))
{
PCA_Flags |= PCA_DISABLE_INPUT_FILE_CHECKING;
}
if (!parse_common_args(&argc, argv, PCA_Flags,
static_cast<int>(filenames.size()), filenames.data(), asize(pa), pa,
static_cast<int>(desc.size()), desc.data(), 0, nullptr, &oenv))
{
return 0;
}
// Handle the options that permits the user to either declare
// which compatible GPUs are availble for use, or to select a GPU
// task assignment. Either could be in an environment variable (so
// that there is a way to customize it, when using MPI in
// heterogeneous contexts).
{
// TODO Argument parsing can't handle std::string. We should
// fix that by changing the parsing, once more of the roles of
// handling, validating and implementing defaults for user
// command-line options have been seperated.
hw_opt.gpuIdsAvailable = gpuIdsAvailable;
hw_opt.userGpuTaskAssignment = userGpuTaskAssignment;
const char *env = getenv("GMX_GPU_ID");
if (env != nullptr)
{
if (!hw_opt.gpuIdsAvailable.empty())
{
gmx_fatal(FARGS, "GMX_GPU_ID and -gpu_id can not be used at the same time");
}
hw_opt.gpuIdsAvailable = env;
}
env = getenv("GMX_GPUTASKS");
if (env != nullptr)
{
if (!hw_opt.userGpuTaskAssignment.empty())
{
gmx_fatal(FARGS, "GMX_GPUTASKS and -gputasks can not be used at the same time");
}
hw_opt.userGpuTaskAssignment = env;
}
if (!hw_opt.gpuIdsAvailable.empty() && !hw_opt.userGpuTaskAssignment.empty())
{
gmx_fatal(FARGS, "-gpu_id and -gputasks cannot be used at the same time");
}
}
hw_opt.thread_affinity = nenum(thread_aff_opt_choices);
// now check for a multi-simulation
ArrayRef<const std::string> multidir = opt2fnsIfOptionSet("-multidir",
static_cast<int>(filenames.size()),
filenames.data());
if (replExParams.exchangeInterval != 0 && multidir.size() < 2)
{
gmx_fatal(FARGS, "Need at least two replicas for replica exchange (use option -multidir)");
}
if (replExParams.numExchanges < 0)
{
gmx_fatal(FARGS, "Replica exchange number of exchanges needs to be positive");
}
ms = init_multisystem(MPI_COMM_WORLD, multidir);
/* Prepare the intra-simulation communication */
// TODO consolidate this with init_commrec, after changing the
// relative ordering of init_commrec and init_multisystem
#if GMX_MPI
if (ms != nullptr)
{
cr->nnodes = cr->nnodes / ms->nsim;
MPI_Comm_split(MPI_COMM_WORLD, ms->sim, cr->sim_nodeid, &cr->mpi_comm_mysim);
cr->mpi_comm_mygroup = cr->mpi_comm_mysim;
MPI_Comm_rank(cr->mpi_comm_mysim, &cr->sim_nodeid);
MPI_Comm_rank(cr->mpi_comm_mygroup, &cr->nodeid);
}
#endif
if (!opt2bSet("-cpi",
static_cast<int>(filenames.size()), filenames.data()))
{
// If we are not starting from a checkpoint we never allow files to be appended
// to, since that has caused a ton of strange behaviour and bugs in the past.
if (opt2parg_bSet("-append", asize(pa), pa))
{
// If the user explicitly used the -append option, explain that it is not possible.
gmx_fatal(FARGS, "GROMACS can only append to files when restarting from a checkpoint.");
}
else
{
// If the user did not say anything explicit, just disable appending.
bTryToAppendFiles = FALSE;
}
}
ContinuationOptions &continuationOptions = mdrunOptions.continuationOptions;
continuationOptions.appendFilesOptionSet = opt2parg_bSet("-append", asize(pa), pa);
handleRestart(cr, ms, bTryToAppendFiles,
static_cast<int>(filenames.size()),
filenames.data(),
&continuationOptions.appendFiles,
&continuationOptions.startedFromCheckpoint);
mdrunOptions.rerun = opt2bSet("-rerun",
static_cast<int>(filenames.size()),
filenames.data());
mdrunOptions.ntompOptionIsSet = opt2parg_bSet("-ntomp", asize(pa), pa);
domdecOptions.rankOrder = static_cast<DdRankOrder>(nenum(ddrank_opt_choices));
domdecOptions.dlbOption = static_cast<DlbOption>(nenum(dddlb_opt_choices));
domdecOptions.numCells[XX] = roundToInt(realddxyz[XX]);
domdecOptions.numCells[YY] = roundToInt(realddxyz[YY]);
domdecOptions.numCells[ZZ] = roundToInt(realddxyz[ZZ]);
/* PLUMED */
plumedswitch=0;
if (opt2bSet("-plumed", static_cast<int>(filenames.size()), filenames.data())) plumedswitch=1;
if(plumedswitch){
plumedcmd=plumed_cmd;
int real_precision=sizeof(real);
real energyUnits=1.0;
real lengthUnits=1.0;
real timeUnits=1.0;
if(!plumed_installed()){
gmx_fatal(FARGS,"Plumed is not available. Check your PLUMED_KERNEL variable.");
}
plumedmain=plumed_create();
plumed_cmd(plumedmain,"setRealPrecision",&real_precision);
// this is not necessary for gromacs units:
plumed_cmd(plumedmain,"setMDEnergyUnits",&energyUnits);
plumed_cmd(plumedmain,"setMDLengthUnits",&lengthUnits);
plumed_cmd(plumedmain,"setMDTimeUnits",&timeUnits);
//
plumed_cmd(plumedmain,"setPlumedDat",ftp2fn(efDAT,static_cast<int>(filenames.size()), filenames.data()));
plumedswitch=1;
}
/* PLUMED HREX*/
if(getenv("PLUMED_HREX")) plumed_hrex=1;
if(plumed_hrex){
if(!plumedswitch) gmx_fatal(FARGS,"-hrex (or PLUMED_HREX) requires -plumed");
if(replExParams.exchangeInterval==0) gmx_fatal(FARGS,"-hrex (or PLUMED_HREX) replica exchange");
if(replExParams.numExchanges!=0) gmx_fatal(FARGS,"-hrex (or PLUMED_HREX) not compatible with -nex");
}
/* END PLUMED HREX */
/* END PLUMED */
return 1;
}
LegacyMdrunOptions::~LegacyMdrunOptions()
{
if (GMX_LIB_MPI)
{
done_commrec(cr);
}
done_multisim(ms);
}
} // namespace gmx
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* GROMACS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GROMACS; if not, see
* http://www.gnu.org/licenses, or write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* If you want to redistribute modifications to GROMACS, please
* consider that scientific software is very special. Version
* control is crucial - bugs must be traceable. We will be happy to
* consider code for inclusion in the official distribution, but
* derived work must not be called official GROMACS. Details are found
* in the README & COPYING files - if they are missing, get the
* official version at http://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
/*! \internal \file
*
* \brief This file declares helper functionality for legacy option handling for mdrun
*
* \author Berk Hess <hess@kth.se>
* \author David van der Spoel <david.vanderspoel@icm.uu.se>
* \author Erik Lindahl <erik@kth.se>
* \author Mark Abraham <mark.j.abraham@gmail.com>
*
* \ingroup module_mdrun
*/
#include "gmxpre.h"
#include "legacymdrunoptions.h"
#include "config.h"
#include <cstring>
#include "gromacs/gmxlib/network.h"
#include "gromacs/math/functions.h"
#include "gromacs/mdrun/multisim.h"
#include "gromacs/mdrunutility/handlerestart.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/fatalerror.h"
namespace gmx
{
/*! \brief Return whether the command-line parameter that
* will trigger a multi-simulation is set */
static bool is_multisim_option_set(int argc, const char *const argv[])
{
for (int i = 0; i < argc; ++i)
{
if (strcmp(argv[i], "-multidir") == 0)
{
return true;
}
}
return false;
}
int LegacyMdrunOptions::updateFromCommandLine(int argc, char **argv, ArrayRef<const char *> desc)
{
unsigned long PCA_Flags = PCA_CAN_SET_DEFFNM;
// With -multidir, the working directory still needs to be
// changed, so we can't check for the existence of files during
// parsing. It isn't useful to do any completion based on file
// system contents, either.
if (is_multisim_option_set(argc, argv))
{
PCA_Flags |= PCA_DISABLE_INPUT_FILE_CHECKING;
}
if (!parse_common_args(&argc, argv, PCA_Flags,
static_cast<int>(filenames.size()), filenames.data(), asize(pa), pa,
static_cast<int>(desc.size()), desc.data(), 0, nullptr, &oenv))
{
return 0;
}
// Handle the options that permits the user to either declare
// which compatible GPUs are availble for use, or to select a GPU
// task assignment. Either could be in an environment variable (so
// that there is a way to customize it, when using MPI in
// heterogeneous contexts).
{
// TODO Argument parsing can't handle std::string. We should
// fix that by changing the parsing, once more of the roles of
// handling, validating and implementing defaults for user
// command-line options have been seperated.
hw_opt.gpuIdsAvailable = gpuIdsAvailable;
hw_opt.userGpuTaskAssignment = userGpuTaskAssignment;
const char *env = getenv("GMX_GPU_ID");
if (env != nullptr)
{
if (!hw_opt.gpuIdsAvailable.empty())
{
gmx_fatal(FARGS, "GMX_GPU_ID and -gpu_id can not be used at the same time");
}
hw_opt.gpuIdsAvailable = env;
}
env = getenv("GMX_GPUTASKS");
if (env != nullptr)
{
if (!hw_opt.userGpuTaskAssignment.empty())
{
gmx_fatal(FARGS, "GMX_GPUTASKS and -gputasks can not be used at the same time");
}
hw_opt.userGpuTaskAssignment = env;
}
if (!hw_opt.gpuIdsAvailable.empty() && !hw_opt.userGpuTaskAssignment.empty())
{
gmx_fatal(FARGS, "-gpu_id and -gputasks cannot be used at the same time");
}
}
hw_opt.thread_affinity = nenum(thread_aff_opt_choices);
// now check for a multi-simulation
ArrayRef<const std::string> multidir = opt2fnsIfOptionSet("-multidir",
static_cast<int>(filenames.size()),
filenames.data());
if (replExParams.exchangeInterval != 0 && multidir.size() < 2)
{
gmx_fatal(FARGS, "Need at least two replicas for replica exchange (use option -multidir)");
}
if (replExParams.numExchanges < 0)
{
gmx_fatal(FARGS, "Replica exchange number of exchanges needs to be positive");
}
ms = init_multisystem(MPI_COMM_WORLD, multidir);
/* Prepare the intra-simulation communication */
// TODO consolidate this with init_commrec, after changing the
// relative ordering of init_commrec and init_multisystem
#if GMX_MPI
if (ms != nullptr)
{
cr->nnodes = cr->nnodes / ms->nsim;
MPI_Comm_split(MPI_COMM_WORLD, ms->sim, cr->sim_nodeid, &cr->mpi_comm_mysim);
cr->mpi_comm_mygroup = cr->mpi_comm_mysim;
MPI_Comm_rank(cr->mpi_comm_mysim, &cr->sim_nodeid);
MPI_Comm_rank(cr->mpi_comm_mygroup, &cr->nodeid);
}
#endif
if (!opt2bSet("-cpi",
static_cast<int>(filenames.size()), filenames.data()))
{
// If we are not starting from a checkpoint we never allow files to be appended
// to, since that has caused a ton of strange behaviour and bugs in the past.
if (opt2parg_bSet("-append", asize(pa), pa))
{
// If the user explicitly used the -append option, explain that it is not possible.
gmx_fatal(FARGS, "GROMACS can only append to files when restarting from a checkpoint.");
}
else
{
// If the user did not say anything explicit, just disable appending.
bTryToAppendFiles = FALSE;
}
}
ContinuationOptions &continuationOptions = mdrunOptions.continuationOptions;
continuationOptions.appendFilesOptionSet = opt2parg_bSet("-append", asize(pa), pa);
handleRestart(cr, ms, bTryToAppendFiles,
static_cast<int>(filenames.size()),
filenames.data(),
&continuationOptions.appendFiles,
&continuationOptions.startedFromCheckpoint);
mdrunOptions.rerun = opt2bSet("-rerun",
static_cast<int>(filenames.size()),
filenames.data());
mdrunOptions.ntompOptionIsSet = opt2parg_bSet("-ntomp", asize(pa), pa);
domdecOptions.rankOrder = static_cast<DdRankOrder>(nenum(ddrank_opt_choices));
domdecOptions.dlbOption = static_cast<DlbOption>(nenum(dddlb_opt_choices));
domdecOptions.numCells[XX] = roundToInt(realddxyz[XX]);
domdecOptions.numCells[YY] = roundToInt(realddxyz[YY]);
domdecOptions.numCells[ZZ] = roundToInt(realddxyz[ZZ]);
return 1;
}
LegacyMdrunOptions::~LegacyMdrunOptions()
{
if (GMX_LIB_MPI)
{
done_commrec(cr);
}
done_multisim(ms);
}
} // namespace gmx
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* GROMACS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GROMACS; if not, see
* http://www.gnu.org/licenses, or write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* If you want to redistribute modifications to GROMACS, please
* consider that scientific software is very special. Version
* control is crucial - bugs must be traceable. We will be happy to
* consider code for inclusion in the official distribution, but
* derived work must not be called official GROMACS. Details are found
* in the README & COPYING files - if they are missing, get the
* official version at http://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
/*! \libinternal \file
*
* \brief This file declares helper functionality for legacy option handling for mdrun
*
* \author Berk Hess <hess@kth.se>
* \author David van der Spoel <david.vanderspoel@icm.uu.se>
* \author Erik Lindahl <erik@kth.se>
* \author Mark Abraham <mark.j.abraham@gmail.com>
*
* \ingroup module_mdrun
* \inlibraryapi
*/
#ifndef GMX_MDRUN_LEGACYMDRUNOPTIONS_H
#define GMX_MDRUN_LEGACYMDRUNOPTIONS_H
#include "gromacs/commandline/filenm.h"
#include "gromacs/commandline/pargs.h"
#include "gromacs/domdec/domdec.h"
#include "gromacs/hardware/hw_info.h"
#include "gromacs/mdlib/mdrun.h"
#include "gromacs/mdrun/logging.h"
#include "replicaexchange.h"
/* PLUMED */
#include "../../../Plumed.h"
extern int plumedswitch;
extern plumed plumedmain;
extern void(*plumedcmd)(plumed,const char*,const void*);
/* END PLUMED */
/* PLUMED HREX */
int plumed_hrex;
/* END PLUMED HREX */
struct gmx_multisim_t;
namespace gmx
{
/*! \libinternal
* \brief This class provides the same command-line option
* functionality to both CLI and API sessions.
*
* This class should not exist, but is necessary now to introduce
* support for the CLI and API without duplicating code. It should be
* eliminated following the TODOs below.
*
* \todo Modules in mdrun should acquire proper option handling so
* that all of these declarations and defaults are local to the
* modules.
*
* \todo Contextual aspects, such as working directory, MPI
* environment, and environment variable handling are more properly
* the role of SimulationContext, and should be moved there */
class LegacyMdrunOptions
{
public:
//! Ongoing collection of mdrun options
MdrunOptions mdrunOptions;
//! Options for the domain decomposition.
DomdecOptions domdecOptions;
//! Parallelism-related user options.
gmx_hw_opt_t hw_opt;
//! Command-line override for the duration of a neighbor list with the Verlet scheme.
int nstlist_cmdline = 0;
//! Parameters for replica-exchange simulations.
ReplicaExchangeParameters replExParams;
//! Filename options to fill from command-line argument values.
std::vector<t_filenm> filenames =
{{{ efTPR, nullptr, nullptr, ffREAD },
{ efTRN, "-o", nullptr, ffWRITE },
{ efCOMPRESSED, "-x", nullptr, ffOPTWR },
{ efCPT, "-cpi", nullptr, ffOPTRD | ffALLOW_MISSING },
{ efCPT, "-cpo", nullptr, ffOPTWR },
{ efSTO, "-c", "confout", ffWRITE },
{ efEDR, "-e", "ener", ffWRITE },
{ efLOG, "-g", "md", ffWRITE },
{ efXVG, "-dhdl", "dhdl", ffOPTWR },
{ efXVG, "-field", "field", ffOPTWR },
{ efXVG, "-table", "table", ffOPTRD },
{ efXVG, "-tablep", "tablep", ffOPTRD },
{ efXVG, "-tableb", "table", ffOPTRDMULT },
{ efTRX, "-rerun", "rerun", ffOPTRD },
{ efXVG, "-tpi", "tpi", ffOPTWR },
{ efXVG, "-tpid", "tpidist", ffOPTWR },
{ efEDI, "-ei", "sam", ffOPTRD },
{ efXVG, "-eo", "edsam", ffOPTWR },
{ efXVG, "-devout", "deviatie", ffOPTWR },
{ efXVG, "-runav", "runaver", ffOPTWR },
{ efXVG, "-px", "pullx", ffOPTWR },
{ efXVG, "-pf", "pullf", ffOPTWR },
{ efXVG, "-ro", "rotation", ffOPTWR },
{ efLOG, "-ra", "rotangles", ffOPTWR },
{ efLOG, "-rs", "rotslabs", ffOPTWR },
{ efLOG, "-rt", "rottorque", ffOPTWR },
{ efMTX, "-mtx", "nm", ffOPTWR },
{ efRND, "-multidir", nullptr, ffOPTRDMULT},
{ efXVG, "-awh", "awhinit", ffOPTRD },
{ efDAT, "-plumed", "plumed", ffOPTRD }, /* PLUMED */
{ efDAT, "-membed", "membed", ffOPTRD },
{ efTOP, "-mp", "membed", ffOPTRD },
{ efNDX, "-mn", "membed", ffOPTRD },
{ efXVG, "-if", "imdforces", ffOPTWR },
{ efXVG, "-swap", "swapions", ffOPTWR }}};
//! Print a warning if any force is larger than this (in kJ/mol nm).
real pforce = -1;
/*! \brief Output context for writing text files
*
* \todo Clarify initialization, ownership, and lifetime. */
gmx_output_env_t *oenv = nullptr;
//! Handle to file used for logging.
LogFilePtr logFileGuard = nullptr;
/*! \brief Command line options, defaults, docs and storage for them to fill. */
/*! \{ */
rvec realddxyz = {0, 0, 0};
const char *ddrank_opt_choices[static_cast<int>(DdRankOrder::nr)+1] =
{ nullptr, "interleave", "pp_pme", "cartesian", nullptr };
const char *dddlb_opt_choices[static_cast<int>(DlbOption::nr)+1] =
{ nullptr, "auto", "no", "yes", nullptr };
const char *thread_aff_opt_choices[threadaffNR+1] =
{ nullptr, "auto", "on", "off", nullptr };
const char *nbpu_opt_choices[5] =
{ nullptr, "auto", "cpu", "gpu", nullptr };
const char *pme_opt_choices[5] =
{ nullptr, "auto", "cpu", "gpu", nullptr };
const char *pme_fft_opt_choices[5] =
{ nullptr, "auto", "cpu", "gpu", nullptr };
const char *bonded_opt_choices[5] =
{ nullptr, "auto", "cpu", "gpu", nullptr };
gmx_bool bTryToAppendFiles = TRUE;
const char *gpuIdsAvailable = "";
const char *userGpuTaskAssignment = "";
ImdOptions &imdOptions = mdrunOptions.imdOptions;
t_pargs pa[49] = {
{ "-dd", FALSE, etRVEC, {&realddxyz},
"Domain decomposition grid, 0 is optimize" },
{ "-ddorder", FALSE, etENUM, {ddrank_opt_choices},
"DD rank order" },
{ "-npme", FALSE, etINT, {&domdecOptions.numPmeRanks},
"Number of separate ranks to be used for PME, -1 is guess" },
{ "-nt", FALSE, etINT, {&hw_opt.nthreads_tot},
"Total number of threads to start (0 is guess)" },
{ "-ntmpi", FALSE, etINT, {&hw_opt.nthreads_tmpi},
"Number of thread-MPI ranks to start (0 is guess)" },
{ "-ntomp", FALSE, etINT, {&hw_opt.nthreads_omp},
"Number of OpenMP threads per MPI rank to start (0 is guess)" },
{ "-ntomp_pme", FALSE, etINT, {&hw_opt.nthreads_omp_pme},
"Number of OpenMP threads per MPI rank to start (0 is -ntomp)" },
{ "-pin", FALSE, etENUM, {thread_aff_opt_choices},
"Whether mdrun should try to set thread affinities" },
{ "-pinoffset", FALSE, etINT, {&hw_opt.core_pinning_offset},
"The lowest logical core number to which mdrun should pin the first thread" },
{ "-pinstride", FALSE, etINT, {&hw_opt.core_pinning_stride},
"Pinning distance in logical cores for threads, use 0 to minimize the number of threads per physical core" },
{ "-gpu_id", FALSE, etSTR, {&gpuIdsAvailable},
"List of unique GPU device IDs available to use" },
{ "-gputasks", FALSE, etSTR, {&userGpuTaskAssignment},
"List of GPU device IDs, mapping each PP task on each node to a device" },
{ "-ddcheck", FALSE, etBOOL, {&domdecOptions.checkBondedInteractions},
"Check for all bonded interactions with DD" },
{ "-ddbondcomm", FALSE, etBOOL, {&domdecOptions.useBondedCommunication},
"HIDDENUse special bonded atom communication when [TT]-rdd[tt] > cut-off" },
{ "-rdd", FALSE, etREAL, {&domdecOptions.minimumCommunicationRange},
"The maximum distance for bonded interactions with DD (nm), 0 is determine from initial coordinates" },
{ "-rcon", FALSE, etREAL, {&domdecOptions.constraintCommunicationRange},
"Maximum distance for P-LINCS (nm), 0 is estimate" },
{ "-dlb", FALSE, etENUM, {dddlb_opt_choices},
"Dynamic load balancing (with DD)" },
{ "-dds", FALSE, etREAL, {&domdecOptions.dlbScaling},
"Fraction in (0,1) by whose reciprocal the initial DD cell size will be increased in order to "
"provide a margin in which dynamic load balancing can act while preserving the minimum cell size." },
{ "-ddcsx", FALSE, etSTR, {&domdecOptions.cellSizeX},
"HIDDENA string containing a vector of the relative sizes in the x "
"direction of the corresponding DD cells. Only effective with static "
"load balancing." },
{ "-ddcsy", FALSE, etSTR, {&domdecOptions.cellSizeY},
"HIDDENA string containing a vector of the relative sizes in the y "
"direction of the corresponding DD cells. Only effective with static "
"load balancing." },
{ "-ddcsz", FALSE, etSTR, {&domdecOptions.cellSizeZ},
"HIDDENA string containing a vector of the relative sizes in the z "
"direction of the corresponding DD cells. Only effective with static "
"load balancing." },
{ "-gcom", FALSE, etINT, {&mdrunOptions.globalCommunicationInterval},
"Global communication frequency" },
{ "-nb", FALSE, etENUM, {nbpu_opt_choices},
"Calculate non-bonded interactions on" },
{ "-nstlist", FALSE, etINT, {&nstlist_cmdline},
"Set nstlist when using a Verlet buffer tolerance (0 is guess)" },
{ "-tunepme", FALSE, etBOOL, {&mdrunOptions.tunePme},
"Optimize PME load between PP/PME ranks or GPU/CPU (only with the Verlet cut-off scheme)" },
{ "-pme", FALSE, etENUM, {pme_opt_choices},
"Perform PME calculations on" },
{ "-pmefft", FALSE, etENUM, {pme_fft_opt_choices},
"Perform PME FFT calculations on" },
{ "-bonded", FALSE, etENUM, {bonded_opt_choices},
"Perform bonded calculations on" },
{ "-v", FALSE, etBOOL, {&mdrunOptions.verbose},
"Be loud and noisy" },
{ "-pforce", FALSE, etREAL, {&pforce},
"Print all forces larger than this (kJ/mol nm)" },
{ "-reprod", FALSE, etBOOL, {&mdrunOptions.reproducible},
"Try to avoid optimizations that affect binary reproducibility" },
{ "-cpt", FALSE, etREAL, {&mdrunOptions.checkpointOptions.period},
"Checkpoint interval (minutes)" },
{ "-cpnum", FALSE, etBOOL, {&mdrunOptions.checkpointOptions.keepAndNumberCheckpointFiles},
"Keep and number checkpoint files" },
{ "-append", FALSE, etBOOL, {&bTryToAppendFiles},
"Append to previous output files when continuing from checkpoint instead of adding the simulation part number to all file names" },
{ "-nsteps", FALSE, etINT64, {&mdrunOptions.numStepsCommandline},
"Run this number of steps, overrides .mdp file option (-1 means infinite, -2 means use mdp option, smaller is invalid)" },
{ "-maxh", FALSE, etREAL, {&mdrunOptions.maximumHoursToRun},
"Terminate after 0.99 times this time (hours)" },
{ "-replex", FALSE, etINT, {&replExParams.exchangeInterval},
"Attempt replica exchange periodically with this period (steps)" },
{ "-nex", FALSE, etINT, {&replExParams.numExchanges},
"Number of random exchanges to carry out each exchange interval (N^3 is one suggestion). -nex zero or not specified gives neighbor replica exchange." },
{ "-reseed", FALSE, etINT, {&replExParams.randomSeed},
"Seed for replica exchange, -1 is generate a seed" },
{ "-hrex", FALSE, etBOOL, {&plumed_hrex}, /* PLUMED HREX */
"Enable hamiltonian replica exchange" },
{ "-imdport", FALSE, etINT, {&imdOptions.port},
"HIDDENIMD listening port" },
{ "-imdwait", FALSE, etBOOL, {&imdOptions.wait},
"HIDDENPause the simulation while no IMD client is connected" },
{ "-imdterm", FALSE, etBOOL, {&imdOptions.terminatable},
"HIDDENAllow termination of the simulation from IMD client" },
{ "-imdpull", FALSE, etBOOL, {&imdOptions.pull},
"HIDDENAllow pulling in the simulation from IMD client" },
{ "-rerunvsite", FALSE, etBOOL, {&mdrunOptions.rerunConstructVsites},
"HIDDENRecalculate virtual site coordinates with [TT]-rerun[tt]" },
{ "-confout", FALSE, etBOOL, {&mdrunOptions.writeConfout},
"HIDDENWrite the last configuration with [TT]-c[tt] and force checkpointing at the last step" },
{ "-stepout", FALSE, etINT, {&mdrunOptions.verboseStepPrintInterval},
"HIDDENFrequency of writing the remaining wall clock time for the run" },
{ "-resetstep", FALSE, etINT, {&mdrunOptions.timingOptions.resetStep},
"HIDDENReset cycle counters after these many time steps" },
{ "-resethway", FALSE, etBOOL, {&mdrunOptions.timingOptions.resetHalfway},
"HIDDENReset the cycle counters after half the number of steps or halfway [TT]-maxh[tt]" }
};
/*! \} */
//! Handle to communication object.
t_commrec *cr = nullptr;
//! Multi-simulation object.
gmx_multisim_t *ms = nullptr;
//! Parses the command-line input and prepares to start mdrun.
int updateFromCommandLine(int argc, char **argv, ArrayRef<const char *> desc);
~LegacyMdrunOptions();
};
} // end namespace gmx
#endif
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* GROMACS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GROMACS; if not, see
* http://www.gnu.org/licenses, or write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* If you want to redistribute modifications to GROMACS, please
* consider that scientific software is very special. Version
* control is crucial - bugs must be traceable. We will be happy to
* consider code for inclusion in the official distribution, but
* derived work must not be called official GROMACS. Details are found
* in the README & COPYING files - if they are missing, get the
* official version at http://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
/*! \libinternal \file
*
* \brief This file declares helper functionality for legacy option handling for mdrun
*
* \author Berk Hess <hess@kth.se>
* \author David van der Spoel <david.vanderspoel@icm.uu.se>
* \author Erik Lindahl <erik@kth.se>
* \author Mark Abraham <mark.j.abraham@gmail.com>
*
* \ingroup module_mdrun
* \inlibraryapi
*/
#ifndef GMX_MDRUN_LEGACYMDRUNOPTIONS_H
#define GMX_MDRUN_LEGACYMDRUNOPTIONS_H
#include "gromacs/commandline/filenm.h"
#include "gromacs/commandline/pargs.h"
#include "gromacs/domdec/domdec.h"
#include "gromacs/hardware/hw_info.h"
#include "gromacs/mdlib/mdrun.h"
#include "gromacs/mdrun/logging.h"
#include "replicaexchange.h"
struct gmx_multisim_t;
namespace gmx
{
/*! \libinternal
* \brief This class provides the same command-line option
* functionality to both CLI and API sessions.
*
* This class should not exist, but is necessary now to introduce
* support for the CLI and API without duplicating code. It should be
* eliminated following the TODOs below.
*
* \todo Modules in mdrun should acquire proper option handling so
* that all of these declarations and defaults are local to the
* modules.
*
* \todo Contextual aspects, such as working directory, MPI
* environment, and environment variable handling are more properly
* the role of SimulationContext, and should be moved there */
class LegacyMdrunOptions
{
public:
//! Ongoing collection of mdrun options
MdrunOptions mdrunOptions;
//! Options for the domain decomposition.
DomdecOptions domdecOptions;
//! Parallelism-related user options.
gmx_hw_opt_t hw_opt;
//! Command-line override for the duration of a neighbor list with the Verlet scheme.
int nstlist_cmdline = 0;
//! Parameters for replica-exchange simulations.
ReplicaExchangeParameters replExParams;
//! Filename options to fill from command-line argument values.
std::vector<t_filenm> filenames =
{{{ efTPR, nullptr, nullptr, ffREAD },
{ efTRN, "-o", nullptr, ffWRITE },
{ efCOMPRESSED, "-x", nullptr, ffOPTWR },
{ efCPT, "-cpi", nullptr, ffOPTRD | ffALLOW_MISSING },
{ efCPT, "-cpo", nullptr, ffOPTWR },
{ efSTO, "-c", "confout", ffWRITE },
{ efEDR, "-e", "ener", ffWRITE },
{ efLOG, "-g", "md", ffWRITE },
{ efXVG, "-dhdl", "dhdl", ffOPTWR },
{ efXVG, "-field", "field", ffOPTWR },
{ efXVG, "-table", "table", ffOPTRD },
{ efXVG, "-tablep", "tablep", ffOPTRD },
{ efXVG, "-tableb", "table", ffOPTRDMULT },
{ efTRX, "-rerun", "rerun", ffOPTRD },
{ efXVG, "-tpi", "tpi", ffOPTWR },
{ efXVG, "-tpid", "tpidist", ffOPTWR },
{ efEDI, "-ei", "sam", ffOPTRD },
{ efXVG, "-eo", "edsam", ffOPTWR },
{ efXVG, "-devout", "deviatie", ffOPTWR },
{ efXVG, "-runav", "runaver", ffOPTWR },
{ efXVG, "-px", "pullx", ffOPTWR },
{ efXVG, "-pf", "pullf", ffOPTWR },
{ efXVG, "-ro", "rotation", ffOPTWR },
{ efLOG, "-ra", "rotangles", ffOPTWR },
{ efLOG, "-rs", "rotslabs", ffOPTWR },
{ efLOG, "-rt", "rottorque", ffOPTWR },
{ efMTX, "-mtx", "nm", ffOPTWR },
{ efRND, "-multidir", nullptr, ffOPTRDMULT},
{ efXVG, "-awh", "awhinit", ffOPTRD },
{ efDAT, "-membed", "membed", ffOPTRD },
{ efTOP, "-mp", "membed", ffOPTRD },
{ efNDX, "-mn", "membed", ffOPTRD },
{ efXVG, "-if", "imdforces", ffOPTWR },
{ efXVG, "-swap", "swapions", ffOPTWR }}};
//! Print a warning if any force is larger than this (in kJ/mol nm).
real pforce = -1;
/*! \brief Output context for writing text files
*
* \todo Clarify initialization, ownership, and lifetime. */
gmx_output_env_t *oenv = nullptr;
//! Handle to file used for logging.
LogFilePtr logFileGuard = nullptr;
/*! \brief Command line options, defaults, docs and storage for them to fill. */
/*! \{ */
rvec realddxyz = {0, 0, 0};
const char *ddrank_opt_choices[static_cast<int>(DdRankOrder::nr)+1] =
{ nullptr, "interleave", "pp_pme", "cartesian", nullptr };
const char *dddlb_opt_choices[static_cast<int>(DlbOption::nr)+1] =
{ nullptr, "auto", "no", "yes", nullptr };
const char *thread_aff_opt_choices[threadaffNR+1] =
{ nullptr, "auto", "on", "off", nullptr };
const char *nbpu_opt_choices[5] =
{ nullptr, "auto", "cpu", "gpu", nullptr };
const char *pme_opt_choices[5] =
{ nullptr, "auto", "cpu", "gpu", nullptr };
const char *pme_fft_opt_choices[5] =
{ nullptr, "auto", "cpu", "gpu", nullptr };
const char *bonded_opt_choices[5] =
{ nullptr, "auto", "cpu", "gpu", nullptr };
gmx_bool bTryToAppendFiles = TRUE;
const char *gpuIdsAvailable = "";
const char *userGpuTaskAssignment = "";
ImdOptions &imdOptions = mdrunOptions.imdOptions;
t_pargs pa[48] = {
{ "-dd", FALSE, etRVEC, {&realddxyz},
"Domain decomposition grid, 0 is optimize" },
{ "-ddorder", FALSE, etENUM, {ddrank_opt_choices},
"DD rank order" },
{ "-npme", FALSE, etINT, {&domdecOptions.numPmeRanks},
"Number of separate ranks to be used for PME, -1 is guess" },
{ "-nt", FALSE, etINT, {&hw_opt.nthreads_tot},
"Total number of threads to start (0 is guess)" },
{ "-ntmpi", FALSE, etINT, {&hw_opt.nthreads_tmpi},
"Number of thread-MPI ranks to start (0 is guess)" },
{ "-ntomp", FALSE, etINT, {&hw_opt.nthreads_omp},
"Number of OpenMP threads per MPI rank to start (0 is guess)" },
{ "-ntomp_pme", FALSE, etINT, {&hw_opt.nthreads_omp_pme},
"Number of OpenMP threads per MPI rank to start (0 is -ntomp)" },
{ "-pin", FALSE, etENUM, {thread_aff_opt_choices},
"Whether mdrun should try to set thread affinities" },
{ "-pinoffset", FALSE, etINT, {&hw_opt.core_pinning_offset},
"The lowest logical core number to which mdrun should pin the first thread" },
{ "-pinstride", FALSE, etINT, {&hw_opt.core_pinning_stride},
"Pinning distance in logical cores for threads, use 0 to minimize the number of threads per physical core" },
{ "-gpu_id", FALSE, etSTR, {&gpuIdsAvailable},
"List of unique GPU device IDs available to use" },
{ "-gputasks", FALSE, etSTR, {&userGpuTaskAssignment},
"List of GPU device IDs, mapping each PP task on each node to a device" },
{ "-ddcheck", FALSE, etBOOL, {&domdecOptions.checkBondedInteractions},
"Check for all bonded interactions with DD" },
{ "-ddbondcomm", FALSE, etBOOL, {&domdecOptions.useBondedCommunication},
"HIDDENUse special bonded atom communication when [TT]-rdd[tt] > cut-off" },
{ "-rdd", FALSE, etREAL, {&domdecOptions.minimumCommunicationRange},
"The maximum distance for bonded interactions with DD (nm), 0 is determine from initial coordinates" },
{ "-rcon", FALSE, etREAL, {&domdecOptions.constraintCommunicationRange},
"Maximum distance for P-LINCS (nm), 0 is estimate" },
{ "-dlb", FALSE, etENUM, {dddlb_opt_choices},
"Dynamic load balancing (with DD)" },
{ "-dds", FALSE, etREAL, {&domdecOptions.dlbScaling},
"Fraction in (0,1) by whose reciprocal the initial DD cell size will be increased in order to "
"provide a margin in which dynamic load balancing can act while preserving the minimum cell size." },
{ "-ddcsx", FALSE, etSTR, {&domdecOptions.cellSizeX},
"HIDDENA string containing a vector of the relative sizes in the x "
"direction of the corresponding DD cells. Only effective with static "
"load balancing." },
{ "-ddcsy", FALSE, etSTR, {&domdecOptions.cellSizeY},
"HIDDENA string containing a vector of the relative sizes in the y "
"direction of the corresponding DD cells. Only effective with static "
"load balancing." },
{ "-ddcsz", FALSE, etSTR, {&domdecOptions.cellSizeZ},
"HIDDENA string containing a vector of the relative sizes in the z "
"direction of the corresponding DD cells. Only effective with static "
"load balancing." },
{ "-gcom", FALSE, etINT, {&mdrunOptions.globalCommunicationInterval},
"Global communication frequency" },
{ "-nb", FALSE, etENUM, {nbpu_opt_choices},
"Calculate non-bonded interactions on" },
{ "-nstlist", FALSE, etINT, {&nstlist_cmdline},
"Set nstlist when using a Verlet buffer tolerance (0 is guess)" },
{ "-tunepme", FALSE, etBOOL, {&mdrunOptions.tunePme},
"Optimize PME load between PP/PME ranks or GPU/CPU (only with the Verlet cut-off scheme)" },
{ "-pme", FALSE, etENUM, {pme_opt_choices},
"Perform PME calculations on" },
{ "-pmefft", FALSE, etENUM, {pme_fft_opt_choices},
"Perform PME FFT calculations on" },
{ "-bonded", FALSE, etENUM, {bonded_opt_choices},
"Perform bonded calculations on" },
{ "-v", FALSE, etBOOL, {&mdrunOptions.verbose},
"Be loud and noisy" },
{ "-pforce", FALSE, etREAL, {&pforce},
"Print all forces larger than this (kJ/mol nm)" },
{ "-reprod", FALSE, etBOOL, {&mdrunOptions.reproducible},
"Try to avoid optimizations that affect binary reproducibility" },
{ "-cpt", FALSE, etREAL, {&mdrunOptions.checkpointOptions.period},
"Checkpoint interval (minutes)" },
{ "-cpnum", FALSE, etBOOL, {&mdrunOptions.checkpointOptions.keepAndNumberCheckpointFiles},
"Keep and number checkpoint files" },
{ "-append", FALSE, etBOOL, {&bTryToAppendFiles},
"Append to previous output files when continuing from checkpoint instead of adding the simulation part number to all file names" },
{ "-nsteps", FALSE, etINT64, {&mdrunOptions.numStepsCommandline},
"Run this number of steps, overrides .mdp file option (-1 means infinite, -2 means use mdp option, smaller is invalid)" },
{ "-maxh", FALSE, etREAL, {&mdrunOptions.maximumHoursToRun},
"Terminate after 0.99 times this time (hours)" },
{ "-replex", FALSE, etINT, {&replExParams.exchangeInterval},
"Attempt replica exchange periodically with this period (steps)" },
{ "-nex", FALSE, etINT, {&replExParams.numExchanges},
"Number of random exchanges to carry out each exchange interval (N^3 is one suggestion). -nex zero or not specified gives neighbor replica exchange." },
{ "-reseed", FALSE, etINT, {&replExParams.randomSeed},
"Seed for replica exchange, -1 is generate a seed" },
{ "-imdport", FALSE, etINT, {&imdOptions.port},
"HIDDENIMD listening port" },
{ "-imdwait", FALSE, etBOOL, {&imdOptions.wait},
"HIDDENPause the simulation while no IMD client is connected" },
{ "-imdterm", FALSE, etBOOL, {&imdOptions.terminatable},
"HIDDENAllow termination of the simulation from IMD client" },
{ "-imdpull", FALSE, etBOOL, {&imdOptions.pull},
"HIDDENAllow pulling in the simulation from IMD client" },
{ "-rerunvsite", FALSE, etBOOL, {&mdrunOptions.rerunConstructVsites},
"HIDDENRecalculate virtual site coordinates with [TT]-rerun[tt]" },
{ "-confout", FALSE, etBOOL, {&mdrunOptions.writeConfout},
"HIDDENWrite the last configuration with [TT]-c[tt] and force checkpointing at the last step" },
{ "-stepout", FALSE, etINT, {&mdrunOptions.verboseStepPrintInterval},
"HIDDENFrequency of writing the remaining wall clock time for the run" },
{ "-resetstep", FALSE, etINT, {&mdrunOptions.timingOptions.resetStep},
"HIDDENReset cycle counters after these many time steps" },
{ "-resethway", FALSE, etBOOL, {&mdrunOptions.timingOptions.resetHalfway},
"HIDDENReset the cycle counters after half the number of steps or halfway [TT]-maxh[tt]" }
};
/*! \} */
//! Handle to communication object.
t_commrec *cr = nullptr;
//! Multi-simulation object.
gmx_multisim_t *ms = nullptr;
//! Parses the command-line input and prepares to start mdrun.
int updateFromCommandLine(int argc, char **argv, ArrayRef<const char *> desc);
~LegacyMdrunOptions();
};
} // end namespace gmx
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2011,2012,2013,2014,2015,2017,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* GROMACS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GROMACS; if not, see
* http://www.gnu.org/licenses, or write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* If you want to redistribute modifications to GROMACS, please
* consider that scientific software is very special. Version
* control is crucial - bugs must be traceable. We will be happy to
* consider code for inclusion in the official distribution, but
* derived work must not be called official GROMACS. Details are found
* in the README & COPYING files - if they are missing, get the
* official version at http://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
/*! \libinternal \file
*
* \brief Declares the routines for replica exchange.
*
* \author David van der Spoel <david.vanderspoel@icm.uu.se>
* \author Mark Abraham <mark.j.abraham@gmail.com>
*
* \ingroup module_mdrun
*/
#ifndef GMX_MDRUN_REPLICAEXCHANGE_H
#define GMX_MDRUN_REPLICAEXCHANGE_H
#include <cstdio>
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
struct gmx_enerdata_t;
struct gmx_multisim_t;
struct t_commrec;
struct t_inputrec;
class t_state;
/*! \libinternal
* \brief The parameters for the replica exchange algorithm. */
struct ReplicaExchangeParameters
{
//! Interval in steps at which to attempt exchanges, 0 means no replica exchange.
int exchangeInterval = 0;
//! The number of exchanges to attempt at an exchange step.
int numExchanges = 0;
//! The random seed, -1 means generate a seed.
int randomSeed = -1;
};
//! Abstract type for replica exchange
typedef struct gmx_repl_ex *gmx_repl_ex_t;
/*! \brief Setup function.
*
* Should only be called on the master ranks */
gmx_repl_ex_t
init_replica_exchange(FILE *fplog,
const gmx_multisim_t *ms,
int numAtomsInSystem,
const t_inputrec *ir,
const ReplicaExchangeParameters &replExParams);
/*! \brief Attempts replica exchange.
*
* Should be called on all ranks. When running each replica in
* parallel, this routine collects the state on the master rank before
* exchange. With domain decomposition, the global state after
* exchange is stored in state and still needs to be redistributed
* over the ranks.
*
* \returns TRUE if the state has been exchanged.
*/
gmx_bool replica_exchange(FILE *fplog,
const t_commrec *cr,
const gmx_multisim_t *ms,
gmx_repl_ex_t re,
t_state *state, const gmx_enerdata_t *enerd,
t_state *state_local,
int64_t step, real time);
/*! \brief Prints replica exchange statistics to the log file.
*
* Should only be called on the master ranks */
void print_replica_exchange_statistics(FILE *fplog, gmx_repl_ex_t re);
/* PLUMED HREX */
extern int replica_exchange_get_repl(const gmx_repl_ex_t re);
extern int replica_exchange_get_nrepl(const gmx_repl_ex_t re);
extern void pd_collect_state(const t_commrec *cr, t_state *state);
extern void exchange_state(const gmx_multisim_t *ms, int b, t_state *state);
extern void copy_state_serial(const t_state *src, t_state *dest);
/* END PLUMED HREX */
#endif
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2011,2012,2013,2014,2015,2017,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* GROMACS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GROMACS; if not, see
* http://www.gnu.org/licenses, or write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* If you want to redistribute modifications to GROMACS, please
* consider that scientific software is very special. Version
* control is crucial - bugs must be traceable. We will be happy to
* consider code for inclusion in the official distribution, but
* derived work must not be called official GROMACS. Details are found
* in the README & COPYING files - if they are missing, get the
* official version at http://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
/*! \libinternal \file
*
* \brief Declares the routines for replica exchange.
*
* \author David van der Spoel <david.vanderspoel@icm.uu.se>
* \author Mark Abraham <mark.j.abraham@gmail.com>
*
* \ingroup module_mdrun
*/
#ifndef GMX_MDRUN_REPLICAEXCHANGE_H
#define GMX_MDRUN_REPLICAEXCHANGE_H
#include <cstdio>
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
struct gmx_enerdata_t;
struct gmx_multisim_t;
struct t_commrec;
struct t_inputrec;
class t_state;
/*! \libinternal
* \brief The parameters for the replica exchange algorithm. */
struct ReplicaExchangeParameters
{
//! Interval in steps at which to attempt exchanges, 0 means no replica exchange.
int exchangeInterval = 0;
//! The number of exchanges to attempt at an exchange step.
int numExchanges = 0;
//! The random seed, -1 means generate a seed.
int randomSeed = -1;
};
//! Abstract type for replica exchange
typedef struct gmx_repl_ex *gmx_repl_ex_t;
/*! \brief Setup function.
*
* Should only be called on the master ranks */
gmx_repl_ex_t
init_replica_exchange(FILE *fplog,
const gmx_multisim_t *ms,
int numAtomsInSystem,
const t_inputrec *ir,
const ReplicaExchangeParameters &replExParams);
/*! \brief Attempts replica exchange.
*
* Should be called on all ranks. When running each replica in
* parallel, this routine collects the state on the master rank before
* exchange. With domain decomposition, the global state after
* exchange is stored in state and still needs to be redistributed
* over the ranks.
*
* \returns TRUE if the state has been exchanged.
*/
gmx_bool replica_exchange(FILE *fplog,
const t_commrec *cr,
const gmx_multisim_t *ms,
gmx_repl_ex_t re,
t_state *state, const gmx_enerdata_t *enerd,
t_state *state_local,
int64_t step, real time);
/*! \brief Prints replica exchange statistics to the log file.
*
* Should only be called on the master ranks */
void print_replica_exchange_statistics(FILE *fplog, gmx_repl_ex_t re);
#endif
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment