include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
-# First exclude compilers known to not work with OpenMP although claim to support it:
-# gcc 4.2.1 and gcc-llvm 4.2.1 (also claims to be 4.2.1) on Mac OS X
-# This fixes redmine 900 and needs to run before OpenMP flags are set below.
-if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
- (CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.3))
- message(STATUS "OpenMP multithreading not supported with gcc/llvm-gcc 4.2 on Mac OS X, disabled")
- set(GMX_OPENMP OFF CACHE BOOL
- "OpenMP multithreading not not supported with gcc/llvm-gcc 4.2 on Mac OS X, disabled!" FORCE)
-endif()
+######################################################################
+# Detect OpenMP
+#####################################################################
+# The OpenMP detection must come before tests for other CFLAGS.
+include(gmxManageOpenMP)
-# OpenMP check must come before other CFLAGS!
-if(GMX_OPENMP)
- find_package(OpenMP)
- if(OPENMP_FOUND)
- # CMake on Windows doesn't support linker flags passed to target_link_libraries
- # (i.e. it treats /openmp as \openmp library file). Also, no OpenMP linker flags are needed.
- if(NOT (WIN32 AND NOT CYGWIN))
- if(CMAKE_COMPILER_IS_GNUCC AND GMX_PREFER_STATIC_OPENMP AND NOT APPLE)
- set(OpenMP_LINKER_FLAGS "-Wl,-static -lgomp -lrt -Wl,-Bdynamic -lpthread")
- set(OpenMP_SHARED_LINKER_FLAGS "")
- else()
- # Only set a linker flag if the user didn't set them manually
- if(NOT DEFINED OpenMP_LINKER_FLAGS)
- set(OpenMP_LINKER_FLAGS "${OpenMP_C_FLAGS}")
- endif()
- if(NOT DEFINED OpenMP_SHARED_LINKER_FLAGS)
- set(OpenMP_SHARED_LINKER_FLAGS "${OpenMP_C_FLAGS}")
- endif()
- endif()
- endif()
- else(OPENMP_FOUND)
- message(WARNING
- "The compiler you are using does not support OpenMP parallelism. This might hurt your performance a lot, in particular with GPUs. Try using a more recent version, or a different compiler. For now, we are proceeding by turning off OpenMP.")
- set(GMX_OPENMP OFF CACHE STRING "Whether GROMACS will use OpenMP parallelism." FORCE)
- endif(OPENMP_FOUND)
-endif()
include(gmxCFlags)
# gcc 4.4.x is buggy and crashes when compiling some files with O3 and OpenMP on.
# Detect here whether applying a workaround is needed and will apply it later
-# on the affected files.
+# on the affected files. This test must come after gmx_c_flags(), since we
+# only want to enable the workaround when using the -O3 flag.
include(gmxGCC44O3BugWorkaround)
gmx_check_gcc44_bug_workaround_needed(GMX_USE_GCC44_BUG_WORKAROUND)
# assemble warning/error message
if (GMX_DETECT_GPU_AVAILABLE)
- set(_msg "
- ${GMX_DETECT_GPU_COUNT} NVIDIA GPU(s) found in the system")
+ set(_msg "${GMX_DETECT_GPU_COUNT} NVIDIA GPU(s) found in the system")
# append GPU names
if (NOT GMX_DETECT_GPU_INFO STREQUAL "")
set(_msg "${_msg}:")
foreach(gpu ${GMX_DETECT_GPU_INFO})
set(_msg "${_msg}
- ${gpu}")
+${gpu}")
endforeach()
endif()
# TODO remove the second part of the message when we'll have compute
# capability information from the detection.
set(_msg "${_msg}
- Compute capability information not available, consult the NVIDIA website:
- https://developer.nvidia.com/cuda-gpus
- ")
+Compute capability information not available, consult the NVIDIA website:
+https://developer.nvidia.com/cuda-gpus")
endif()
- set(CUDA_NOTFOUND_MESSAGE "
- mdrun supports native GPU acceleration on NVIDIA hardware with compute
- capability >=2.0 (Fermi or later). This requires the NVIDIA CUDA toolkit,
- which was not found. Its location can be hinted by setting the
- CUDA_TOOLKIT_ROOT_DIR CMake option (does not work as an environment variable).
- The typical location would be /usr/local/cuda[-version].
- Note that CPU or GPU acceleration can be selected at runtime!
+ set(CUDA_NOTFOUND_MESSAGE "mdrun supports native GPU acceleration on NVIDIA hardware with compute capability >=2.0 (Fermi or later). This requires the NVIDIA CUDA toolkit, which was not found. Its location can be hinted by setting the CUDA_TOOLKIT_ROOT_DIR CMake option (does not work as an environment variable). The typical location would be /usr/local/cuda[-version]. Note that CPU or GPU acceleration can be selected at runtime.
- ${_msg}")
+${_msg}")
unset(_msg)
if (NOT CUDA_FOUND)
# no OpenMP is no good!
if(NOT GMX_OPENMP)
- message(WARNING "
- To use GPU acceleration efficiently, mdrun requires OpenMP multi-threading.
- Without OpenMP a single CPU core can be used with a GPU which is not optimal.
- Note that with MPI multiple processes can be forced to use a single GPU, but this
- typically inefficient. Note that you need to set both C and C++ compilers that
- support OpenMP (CC and CXX environment variables, respectively) when using GPUs.")
+ message(WARNING "To use GPU acceleration efficiently, mdrun requires OpenMP multi-threading. Without OpenMP a single CPU core can be used with a GPU which is not optimal. Note that with MPI multiple processes can be forced to use a single GPU, but this is typically inefficient. You need to set both C and C++ compilers that support OpenMP (CC and CXX environment variables, respectively) when using GPUs.")
endif()
endmacro()
--- /dev/null
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2012,2013, 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.
+
+# Manage the OpenMP setup. This wrapper file checks for some known-bad compiler
+# versions before trying to detect OpenMP with the standard find-package-module,
+# and then does some additional tests for flags afterwards.
+
+# First exclude compilers known to not work with OpenMP although claim to support it:
+# gcc 4.2.1 and gcc-llvm 4.2.1 (also claims to be 4.2.1) on Mac OS X
+# This fixes redmine 900 and needs to run before OpenMP flags are set below.
+if(GMX_OPENMP)
+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
+ (CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.3))
+ message(STATUS "OpenMP multithreading not supported with gcc/llvm-gcc 4.2 on Mac OS X, disabled")
+ set(GMX_OPENMP OFF CACHE BOOL
+ "OpenMP multithreading not not supported with gcc/llvm-gcc 4.2 on Mac OS X, disabled!" FORCE)
+ else()
+ # We should do OpenMP detection if we get here
+ # OpenMP check must come before other CFLAGS!
+ find_package(OpenMP)
+ if(OPENMP_FOUND)
+ # CMake on Windows doesn't support linker flags passed to target_link_libraries
+ # (i.e. it treats /openmp as \openmp library file). Also, no OpenMP linker flags are needed.
+ if(NOT (WIN32 AND NOT CYGWIN))
+ if(CMAKE_COMPILER_IS_GNUCC AND GMX_PREFER_STATIC_OPENMP AND NOT APPLE)
+ set(OpenMP_LINKER_FLAGS "-Wl,-static -lgomp -lrt -Wl,-Bdynamic -lpthread")
+ set(OpenMP_SHARED_LINKER_FLAGS "")
+ else()
+ # Only set a linker flag if the user didn't set them manually
+ if(NOT DEFINED OpenMP_LINKER_FLAGS)
+ set(OpenMP_LINKER_FLAGS "${OpenMP_C_FLAGS}")
+ endif()
+ if(NOT DEFINED OpenMP_SHARED_LINKER_FLAGS)
+ set(OpenMP_SHARED_LINKER_FLAGS "${OpenMP_C_FLAGS}")
+ endif()
+ endif()
+ endif()
+ else(OPENMP_FOUND)
+ message(WARNING
+ "The compiler you are using does not support OpenMP parallelism. This might hurt your performance a lot, in particular with GPUs. Try using a more recent version, or a different compiler. For now, we are proceeding by turning off OpenMP.")
+ set(GMX_OPENMP OFF CACHE STRING "Whether GROMACS will use OpenMP parallelism." FORCE)
+ endif(OPENMP_FOUND)
+ endif()
+endif()