cmake_minimum_required(VERSION 3.16.3)
cmake_policy(SET CMP0074 NEW) # From CMake 3.12
cmake_policy(SET CMP0068 NEW) # From CMake-3.9
+cmake_policy(SET CMP0048 NEW) # As of CMake 3.22, default is still "OLD"
# CMake modules/macros are in a subdirectory to keep this file cleaner
# This needs to be set before project() in order to pick up toolchain files
FORCE)
endif()
-project(Gromacs)
+# The GROMACS convention is that these are the version number of the next
+# release that is going to be made from this branch.
+project(Gromacs VERSION 2022.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(GMX_MIMIC "Enable MiMiC QM/MM interface (CPMD is required)" OFF)
+option(GMX_CP2K "Enable CP2K QM/MM interface (CP2K 8.1 or later is required)" OFF)
+
+# We need to enable Fortran, because CP2K will be linked
+if(GMX_CP2K)
+ enable_language(Fortran)
+endif()
+
option(GMX_FAHCORE "Build a library with mdrun functionality" OFF)
mark_as_advanced(GMX_FAHCORE)
"AUTO"
AUTO None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256 AVX2_128 AVX_512 AVX_512_KNL ARM_NEON_ASIMD ARM_SVE IBM_VSX Reference)
-set(GMX_FFT_LIBRARY_DEFAULT "fftw3")
+include(gmxTestIntelLLVM)
+
+if (GMX_INTEL_LLVM)
+ set(GMX_FFT_LIBRARY_DEFAULT "mkl")
+else()
+ set(GMX_FFT_LIBRARY_DEFAULT "fftw3")
+endif()
gmx_option_multichoice(
GMX_FFT_LIBRARY
mark_as_advanced(GMX_BUILD_OWN_FFTW)
mark_as_advanced(GMX_DISABLE_FFTW_MEASURE)
+gmx_dependent_option(
+ GMX_USE_HEFFTE
+ "Use HeFFTe for FFT support. Used with CUDA backend"
+ OFF
+ "GMX_GPU STREQUAL CUDA;GMX_MPI")
+
gmx_dependent_cache_variable(GMX_SIMD_REF_FLOAT_WIDTH "Reference SIMD single precision width" STRING "4" "GMX_SIMD STREQUAL REFERENCE")
gmx_dependent_cache_variable(GMX_SIMD_REF_DOUBLE_WIDTH "Reference SIMD double precision width" STRING "2" "GMX_SIMD STREQUAL REFERENCE")
########################################################################
include(gmxManageMimic)
+########################################################################
+#Process CP2K settings
+########################################################################
+include(gmxManageCP2K)
+
########################################################################
#Process shared/static library settings
########################################################################
include(gmxManageLmfit)
+include(gmxManageMuparser)
+
+##################################################
+# Process SIMD instruction settings
+##################################################
+# This checks what flags to add in order to
+# support the SIMD instructions we need, it sets
+# correct defines for the SIMD instructions supported,
+# and adds advanced options to control accuracy
+# for SIMD math operations.
+include(gmxManageSimd)
+gmx_manage_simd()
+
+
if(GMX_GPU)
string(TOUPPER "${GMX_GPU}" _gmx_gpu_uppercase)
message(WARNING "To use GPU acceleration efficiently, mdrun requires OpenMP multi-threading, which is currently not enabled.")
endif()
+ if (GMX_OPENCL_NB_CLUSTER_SIZE)
+ message(WARNING "GMX_OPENCL_NB_CLUSTER_SIZE is deprecated, use GMX_GPU_NB_CLUSTER_SIZE instead")
+ endif()
+ if (GMX_OPENCL_NB_CLUSTER_SIZE AND GMX_GPU_NB_CLUSTER_SIZE)
+ if (NOT ${GMX_OPENCL_NB_CLUSTER_SIZE} EQUAL ${GMX_GPU_NB_CLUSTER_SIZE})
+ message(FATAL_ERROR "Mismatching values passed to GMX_OPENCL_NB_CLUSTER_SIZE and GMX_GPU_NB_CLUSTER_SIZE; the former is deprecated, use only the latter!")
+ endif()
+ endif()
+ # Only OpenCL and SYCL support changing the default cluster size
+ if (${_gmx_gpu_uppercase} STREQUAL "CUDA")
+ if (GMX_GPU_NB_CLUSTER_SIZE AND NOT "${GMX_GPU_NB_CLUSTER_SIZE}" EQUAL 8)
+ message(FATAL_ERROR "Setting GMX_GPU_NB_CLUSTER_SIZE is not supported in CUDA (the default GMX_GPU_NB_CLUSTER_SIZE=8 is used)")
+ endif()
+ else()
+ # use the legacy GMX_OPENCL_NB_CLUSTER_SIZE variable if set, otherwise set the defaults
+ if (GMX_OPENCL_NB_CLUSTER_SIZE)
+ set(_gmx_gpu_nb_cluster_size_value ${GMX_OPENCL_NB_CLUSTER_SIZE})
+ else()
+ # default cluster size is 8 with OpenCL and 4 with SYCL for now
+ if(${_gmx_gpu_uppercase} STREQUAL "OPENCL")
+ set(_gmx_gpu_nb_cluster_size_value 8)
+ elseif(GMX_GPU_SYCL)
+ if (GMX_SYCL_HIPSYCL AND NOT GMX_HIPSYCL_HAVE_LEVELZERO_TARGET)
+ set(_gmx_gpu_nb_cluster_size_value 8)
+ else()
+ # Either DPCPP or hipSYCL targeting Intel Level0
+ set(_gmx_gpu_nb_cluster_size_value 4)
+ endif()
+ endif()
+ endif()
+ set(GMX_GPU_NB_CLUSTER_SIZE ${_gmx_gpu_nb_cluster_size_value} CACHE STRING "Cluster size used by the nonbonded kernel. Set to 4 for Intel GPUs.")
+ mark_as_advanced(GMX_GPU_NB_CLUSTER_SIZE)
+ endif()
+
endif()
# For build with CUDA and Lib-MPI, check if underlying MPI implementation is CUDA-aware
set(GMX_CYGWIN 1)
endif()
+if(GMX_USE_HEFFTE)
+ if(NOT GMX_GPU_CUDA)
+ message(FATAL_ERROR "HeFFTe support requires a CUDA build")
+ endif()
+ if(NOT GMX_LIB_MPI)
+ message(FATAL_ERROR "HeFFTe support requires a library MPI build")
+ endif()
+ find_package(Heffte 2.1.0 REQUIRED CUDA)
+endif()
+
if(WIN32)
set(GMX_NATIVE_WINDOWS 1)
# This makes windows.h not declare min/max as macros that would break
set(GMX_INTERNAL_XDR 1)
endif()
-
-##################################################
-# Process SIMD instruction settings
-##################################################
-# This checks what flags to add in order to
-# support the SIMD instructions we need, it sets
-# correct defines for the SIMD instructions supported,
-# and adds advanced options to control accuracy
-# for SIMD math operations.
-include(gmxManageSimd)
-gmx_manage_simd()
-
##################################################
# Process FFT library settings
##################################################
# # # # # # # # # # NO MORE TESTS AFTER THIS LINE! # # # # # # # # # # #
# these are set after everything else
if (NOT GMX_SKIP_DEFAULT_CFLAGS)
- set(CMAKE_EXE_LINKER_FLAGS "${FFT_LINKER_FLAGS} ${MPI_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS} ${DISABLE_SYCL_CXX_FLAGS}")
- set(CMAKE_SHARED_LINKER_FLAGS "${FFT_LINKER_FLAGS} ${MPI_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${DISABLE_SYCL_CXX_FLAGS}")
+ #TODO(#3672): Use target_link_libraries(... MPI::MPI_CXX) instead of ${MPI_CXX_LINK_FLAGS}
+ set(CMAKE_EXE_LINKER_FLAGS "${FFT_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS} ${DISABLE_SYCL_CXX_FLAGS}")
+ set(CMAKE_SHARED_LINKER_FLAGS "${FFT_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${DISABLE_SYCL_CXX_FLAGS}")
else()
message("Recommended flags which are not added because GMX_SKIP_DEFAULT_CFLAGS=yes:")
message("CMAKE_C_FLAGS: ${SIMD_C_FLAGS};${MPI_COMPILE_FLAGS};${EXTRA_C_FLAGS};${GMXC_CFLAGS}")
foreach(build_type ${build_types_with_explicit_flags})
message("CMAKE_CXX_FLAGS_${build_type}: ${GMXC_CXXFLAGS_${build_type}}")
endforeach()
- message("CMAKE_EXE_LINKER_FLAGS: ${FFT_LINKER_FLAGS} ${MPI_LINKER_FLAGS}")
- message("CMAKE_SHARED_LINKER_FLAGS: ${FFT_LINKER_FLAGS} ${MPI_LINKER_FLAGS}")
+ message("CMAKE_EXE_LINKER_FLAGS: ${FFT_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}")
+ message("CMAKE_SHARED_LINKER_FLAGS: ${FFT_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}")
endif()
# Allow `admin` directory to be easily conveyed to nested CMake commands.
set(GMX_ADMIN_DIR ${CMAKE_SOURCE_DIR}/admin)
include(tests/CheckTarget.cmake)
endif()
-# TODO: Determine control flow and defaults for package installation and testing use cases.
-# Ref: https://gitlab.com/gromacs/gromacs/-/issues/2896
-option(GMX_PYTHON_PACKAGE "Configure gmxapi Python package" OFF)
+option(GMX_PYTHON_PACKAGE
+ "Configure gmxapi Python package for use in build tree. Requires pybind11 installed for project Python interpreter."
+ OFF)
mark_as_advanced(GMX_PYTHON_PACKAGE)
find_package(ImageMagick QUIET COMPONENTS convert)