#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2012, by the GROMACS development team, led by
-# David van der Spoel, Berk Hess, Erik Lindahl, and including many
-# others, as listed in the AUTHORS file in the top-level source
-# directory and at http://www.gromacs.org.
+# Copyright (c) 2012,2013,2014, 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
#
# 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 CUDA nvcc compilation configuration, try to be smart to ease the users'
# pain as much as possible:
# - use the CUDA_HOST_COMPILER if defined by the user, otherwise
# On *nix force icc in gcc 4.4 compatibility mode with CUDA 3.2/4.0 and
# gcc 4.5 compatibility mode with later CUDA versions. This is needed
- # as even with icc use as host compiler, when icc's gcc compatibility
+ # as even with icc used as host compiler, when icc's gcc compatibility
# mode is higher than the max gcc version officially supported by CUDA,
# nvcc will freak out.
if (UNIX AND CMAKE_C_COMPILER_ID MATCHES "Intel" AND
mark_as_advanced(CUDA_HOST_COMPILER CUDA_HOST_COMPILER_OPTIONS)
endif()
- # on Linux we need to add -fPIC when building shared gmx libs
- # Note: will add -fPIC for any compiler that supports it as it shouldn't hurt
- if(BUILD_SHARED_LIBS)
- GMX_TEST_CXXFLAG(CXXFLAG_FPIC "-fPIC" _FPIC_NVCC_FLAG)
- if(_FPIC_NVCC_FLAG)
- set(CUDA_HOST_COMPILER_OPTIONS "${CUDA_HOST_COMPILER_OPTIONS}-Xcompiler;${_FPIC_NVCC_FLAG}")
- endif()
+ if(APPLE AND CMAKE_C_COMPILER_ID MATCHES "GNU")
+ # Some versions of gcc-4.8 and gcc-4.9 produce errors (in particular on OS X)
+ # if we do not use -D__STRICT_ANSI__. It is harmless, so we might as well add it for all versions.
+ set(CUDA_HOST_COMPILER_OPTIONS "${CUDA_HOST_COMPILER_OPTIONS}-D__STRICT_ANSI__;")
+ endif()
+
+ # the legacy CUDA kernels have been dropped, warn with CUDA 4.0
+ if (CUDA_VERSION VERSION_EQUAL "4.0")
+ message(WARNING "The legacy GPU kernels optimized for older CUDA compilers, including the detected version 4.0, have been removed. To avoid performance loss, we strongly recommend upgrading to a newer CUDA toolkit.
+ ")
endif()
# Set the CUDA GPU architectures to compile for:
# - with CUDA >v4.2 compute capability 2.0, 2.1 is, but 3.0 is not supported:
# => compile sm_20, sm_21 cubin, and compute_20 PTX
- # - with CUDA >=4.2 compute capabity <=3.0 is supported:
+ # - with CUDA >=4.2 compute capability <=3.0 is supported:
# => compile sm_20, sm_21, sm_30 cubin, and compute_30 PTX
- # - with CUDA 5.0 compute capabity 3.5 is supported, but generating code
- # optimized for sm_35 results in lower performance than with sm_30.
+ # - with CUDA 5.0 and later compute capability 3.5 is supported
+ # => compile sm_20, sm_21, sm_30, sm_35 cubin, and compute_35 PTX
if(CUDA_VERSION VERSION_LESS "4.2")
set(_CUDA_ARCH_STR "-gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_20,code=compute_20")
- else()
+ elseif(CUDA_VERSION VERSION_LESS "5.0")
set(_CUDA_ARCH_STR "-gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_30,code=compute_30")
+ else()
+ set(_CUDA_ARCH_STR "-gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_35,code=compute_35")
endif()
# finally set the damn flags
"${_CUDA_ARCH_STR};-use_fast_math;${_HOST_COMPILER_OPTION_STRING}${CUDA_HOST_COMPILER_OPTIONS}"
CACHE STRING "Compiler flags for nvcc." FORCE)
endif()
-
-
-# Try to execute ${CUDA_NVCC_EXECUTABLE} --version and set the output
-# (or an error string) in the argument variable.
-#
-# returned in argument: CUDA nvcc compiler version string
-#
-macro(get_nvcc_version_info)
- if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_NVCC_COMPILER_INFO)
-
- # Get the nvcc version string. This is multi-line, but since it is only 4 lines
- # and might change in the future it is better to store than trying to parse out
- # the version from the current format.
- execute_process(COMMAND ${CUDA_NVCC_EXECUTABLE} --version
- RESULT_VARIABLE _nvcc_version_res
- OUTPUT_VARIABLE _nvcc_version_out
- ERROR_VARIABLE _nvcc_version_err
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (${_nvcc_version_res} EQUAL 0)
- # Fix multi-line mess: Replace newline with ";" so we can use it in a define
- string(REPLACE "\n" ";" _nvcc_info_singleline ${_nvcc_version_out})
- SET(CUDA_NVCC_COMPILER_INFO ${_nvcc_info_singleline}
- CACHE STRING "CUDA nvcc compiler version string" FORCE)
- else ()
- SET(CUDA_NVCC_COMPILER_INFO ""
- CACHE STRING "CUDA nvcc compiler version string not available" FORCE)
- endif ()
- endif ()
- mark_as_advanced(CUDA_NVCC_COMPILER_INFO)
-endmacro ()