added CUDA compiler flags to version header
authorSzilard Pall <pszilard@cbr.su.se>
Mon, 17 Jun 2013 22:48:30 +0000 (00:48 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Tue, 25 Jun 2013 13:54:06 +0000 (15:54 +0200)
The nvcc compiler information, compared to CPU compiler info, was
lacking both the full path to the compiler binary as well as the full
list of flags used (including the host-compiler flags if these are
passed).

Change-Id: Ic80a512bc6d5a39b6594c360d2952e48b5d43ee0

CMakeLists.txt
cmake/gmxManageGPU.cmake
cmake/gmxManageNvccConfig.cmake
src/buildinfo.h.cmakein
src/gmxlib/cuda_tools/copyrite_gpu.cu

index 8dabe69bb33de0489552dd984021b501a529fd6d..c87ad3b23fdabcf502aef8f84c446639d52d3072 100644 (file)
@@ -1175,6 +1175,10 @@ get_compiler_info(C BUILD_C_COMPILER BUILD_CFLAGS)
 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        #
index 97fee7560ec0cc0c286618647239f20a0de76787..3c4109406175b506f32824e4a504a09a46c9ae5a 100644 (file)
@@ -146,13 +146,47 @@ if(NOT GMX_GPU)
     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.
index e99ed6bc002dad0af08808762106457aee808f62..59c8516f8664645635b94e91c29e88832b50dd14 100644 (file)
@@ -152,33 +152,3 @@ if (NOT DEFINED CUDA_NVCC_FLAGS_SET)
         "${_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 ()
index 49ca7b57b9cb1b30bf315e68d932c1071357f5a7..fdbf7da824dc4c1915ad3a1e517b17fe0eaeaca0 100644 (file)
@@ -81,3 +81,5 @@
 /** 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@"
index 001ca53fc2c33920c85610471651c36651dcec01..42f0feb2d0167eff6719d1175b59929ff1c97f91 100644 (file)
@@ -50,6 +50,7 @@ extern "C" void gmx_print_version_info_gpu(FILE *fp)
 {
     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;