if (CMAKE_CXX_COMPILER_LOADED)
get_compiler_info(CXX BUILD_CXX_COMPILER BUILD_CXXFLAGS)
endif ()
+if(GMX_GPU)
+ get_cuda_compiler_info(CUDA_NVCC_COMPILER_INFO CUDA_NVCC_COMPILER_FLAGS)
+endif(GMX_GPU)
+
########################################################################
# Specify install locations and which subdirectories to process #
mark_as_advanced(CUDA_TOOLKIT_ROOT_DIR)
endif()
+# Try to execute ${CUDA_NVCC_EXECUTABLE} --version and set the output
+# (or an error string) in the argument variable.
+# Note that semicolon is used as separator for nvcc.
+#
+# Parameters:
+# COMPILER_INFO - [output variable] string with compiler path, ID and
+# some compiler-provided information
+# COMPILER_FLAGS - [output variable] flags for the compiler
+#
+macro(get_cuda_compiler_info COMPILER_INFO COMPILER_FLAGS)
+ if(CUDA_NVCC_EXECUTABLE)
+
+ # 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(${COMPILER_INFO} "${CUDA_NVCC_EXECUTABLE} ${_nvcc_info_singleline}")
+ string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type)
+ SET(_compiler_flags "${CUDA_NVCC_FLAGS_${_build_type}}")
+ if(CUDA_PROPAGATE_HOST_FLAGS)
+ string(REGEX REPLACE "[ ]+" ";" _cxx_flags_nospace "${BUILD_CXXFLAGS}")
+ endif()
+ SET(${COMPILER_FLAGS} "${CUDA_NVCC_FLAGS}${CUDA_NVCC_FLAGS_${_build_type}}; ${_cxx_flags_nospace}")
+ else ()
+ SET(${COMPILER_INFO} "N/A")
+ SET(${COMPILER_FLAGS} "N/A")
+ endif ()
+ endif ()
+endmacro ()
+
macro(gmx_gpu_setup)
# set up nvcc options
include(gmxManageNvccConfig)
- # Version info (semicolon used as line separator) for nvcc.
- get_nvcc_version_info()
-
# Atomic operations used for polling wait for GPU
# (to avoid the cudaStreamSynchronize + ECC bug).
# ThreadMPI is now always included. Thus, we don't check for Atomics anymore here.
"${_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 ()
/** CUDA nvcc compiler version information */
#define CUDA_NVCC_COMPILER_INFO "@CUDA_NVCC_COMPILER_INFO@"
+/** CUDA nvcc compiler flags */
+#define CUDA_NVCC_COMPILER_FLAGS "@CUDA_NVCC_COMPILER_FLAGS@"
{
int cuda_driver,cuda_runtime;
fprintf(fp, "CUDA compiler: %s\n",CUDA_NVCC_COMPILER_INFO);
+ fprintf(fp, "CUDA compiler flags:%s\n",CUDA_NVCC_COMPILER_FLAGS);
cuda_driver = 0;
cudaDriverGetVersion(&cuda_driver);
cuda_runtime = 0;