Extended build information output and reference build type
authorTeemu Murtola <teemu.murtola@gmail.com>
Sat, 24 Nov 2012 05:14:35 +0000 (07:14 +0200)
committerTeemu Murtola <teemu.murtola@gmail.com>
Sun, 25 Nov 2012 05:17:58 +0000 (07:17 +0200)
mdrun -version (and -version flag for other binaries as well) now
contains more information about what was compiled in, as well as
compiler information and versions of external libraries used.
Also added C++ compiler information to mdrun log output.
When GPU builds are enabled there is also version information
about CUDA SDK, nvcc, driver and runtime.

A new "Reference" build type has been added to CMake. This turns
off lots of options and should be used when generating reference
values for our regression tests.

Change-Id: I7532bebdaeb1207c4f6e69d422b0f13da83e3960

15 files changed:
.gitignore
CMakeLists.txt
cmake/gmxBuildTypeReference.cmake [new file with mode: 0644]
cmake/gmxGetCompilerInfo.cmake [new file with mode: 0644]
cmake/gmxGetCompilerVersion.cmake [deleted file]
cmake/gmxManageNvccConfig.cmake
include/vec.h
src/.gitignore [new file with mode: 0644]
src/CMakeLists.txt
src/buildinfo.h.cmakein [new file with mode: 0644]
src/config.h.cmakein
src/gmxlib/CMakeLists.txt
src/gmxlib/checkpoint.c
src/gmxlib/copyrite.c
src/gmxlib/main.c

index 317cd8eff165463821fc574208250a31d1c35f00..40901d90f3881b43614477a83ce931eebc8d7596 100644 (file)
@@ -4,7 +4,6 @@
 *.a
 *.exe
 *.lib
 *.a
 *.exe
 *.lib
-config.h
 *.cache
 log
 Makefile
 *.cache
 log
 Makefile
index 9cd938cb7eaf07254e8a0595a31933ed3c35342d..ce8335868921e2e72e00a26bcada535488585264 100644 (file)
@@ -59,8 +59,10 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND UNIX)
 set(CMAKE_INSTALL_PREFIX "/usr/local/gromacs" CACHE STRING "Installation prefix (installation will need write permissions here)" FORCE)
 endif()
 
 set(CMAKE_INSTALL_PREFIX "/usr/local/gromacs" CACHE STRING "Installation prefix (installation will need write permissions here)" FORCE)
 endif()
 
+include(gmxBuildTypeReference)
+
 if(NOT CMAKE_BUILD_TYPE)
 if(NOT CMAKE_BUILD_TYPE)
-    set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
+    set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Reference." FORCE)
 endif(NOT CMAKE_BUILD_TYPE)
 
 enable_language(C)
 endif(NOT CMAKE_BUILD_TYPE)
 
 enable_language(C)
@@ -254,7 +256,7 @@ endif()
 include(gmxCFlags)
 gmx_c_flags()
 
 include(gmxCFlags)
 gmx_c_flags()
 
-include(gmxGetCompilerVersion)
+include(gmxGetCompilerInfo)
 get_compiler_version()
 
 # gcc 4.4.x is buggy and crashes when compiling some files with O3 and OpenMP on.
 get_compiler_version()
 
 # gcc 4.4.x is buggy and crashes when compiling some files with O3 and OpenMP on.
@@ -548,7 +550,9 @@ if(GMX_GPU)
         message(FATAL_ERROR "
     mdrun supports native GPU acceleration on NVIDIA hardware with compute
     capability >=2.0. This requires the NVIDIA CUDA library, which was not
         message(FATAL_ERROR "
     mdrun supports native GPU acceleration on NVIDIA hardware with compute
     capability >=2.0. This requires the NVIDIA CUDA library, which was not
-    found; the location can be hinted by setting CUDA_TOOLKIT_ROOT_DIR.
+    found; the location can be hinted by setting CUDA_TOOLKIT_ROOT_DIR as
+    a CMake option (It does not work as an environment variable).
+    The typical location would be /usr/local/cuda.
 
     CPU or GPU acceleration can be selected at runtime, but if you are
     sure you can not make use of GPU acceleration, disable it by setting
 
     CPU or GPU acceleration can be selected at runtime, but if you are
     sure you can not make use of GPU acceleration, disable it by setting
@@ -557,10 +561,11 @@ if(GMX_GPU)
 
     if(NOT GMX_OPENMP)
         message(WARNING "
 
     if(NOT GMX_OPENMP)
         message(WARNING "
-    In order to use GPU acceleration efficiently, mdrun requires OpenMP multithreding.
+    In order to use GPU acceleration efficiently, mdrun requires OpenMP multithreading.
     Without OpenMP only a single CPU core per GPU can be used which is suboptimal.
     Note that with MPI multiple processes can be forced to use a single GPU, but this
     Without OpenMP only a single CPU core per GPU can be used which is suboptimal.
     Note that with MPI multiple processes can be forced to use a single GPU, but this
-    typically inefficient.")
+    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.")
     endif()
 
     include(gmxManageNvccConfig)
     endif()
 
     include(gmxManageNvccConfig)
@@ -575,6 +580,9 @@ if(GMX_GPU)
         include(ThreadMPI)
     endif()
 
         include(ThreadMPI)
     endif()
 
+    # Version info (semicolon used as line separator) for nvcc.
+    get_nvcc_version_info()
+
 endif()
 # Annoyingly enough, FindCUDA leaves a few variables behind as non-advanced.
 # We need to mark these advanced outside the conditional, otherwise, if the user
 endif()
 # Annoyingly enough, FindCUDA leaves a few variables behind as non-advanced.
 # We need to mark these advanced outside the conditional, otherwise, if the user
@@ -761,7 +769,7 @@ elseif(${GMX_CPU_ACCELERATION} STREQUAL "AVX_128_FMA" OR ${GMX_CPU_ACCELERATION}
         GMX_TEST_CFLAG(MSVC_AVX_CFLAG "/arch:AVX" GROMACS_C_FLAGS)
     endif (NOT GNU_AVX_CFLAG)
     if (NOT GNU_AVX_CFLAG AND NOT MSVC_AVX_CFLAG)
         GMX_TEST_CFLAG(MSVC_AVX_CFLAG "/arch:AVX" GROMACS_C_FLAGS)
     endif (NOT GNU_AVX_CFLAG)
     if (NOT GNU_AVX_CFLAG AND NOT MSVC_AVX_CFLAG)
-        message(WARNING "No C AVX flag found. Consider a newer compiler, or disable AVX for much lower performance.")
+        message(WARNING "No C AVX flag found. Consider a newer compiler, or try SSE4.1 (lower performance).")
     endif (NOT GNU_AVX_CFLAG AND NOT MSVC_AVX_CFLAG)
 
     if (CMAKE_CXX_COMPILER_LOADED)
     endif (NOT GNU_AVX_CFLAG AND NOT MSVC_AVX_CFLAG)
 
     if (CMAKE_CXX_COMPILER_LOADED)
@@ -770,7 +778,7 @@ elseif(${GMX_CPU_ACCELERATION} STREQUAL "AVX_128_FMA" OR ${GMX_CPU_ACCELERATION}
             GMX_TEST_CXXFLAG(MSVC_AVX_CXXFLAG "/arch:AVX" GROMACS_CXX_FLAGS)
         endif (NOT GNU_AVX_CXXFLAG)
         if (NOT GNU_AVX_CXXFLAG AND NOT MSVC_AVX_CXXFLAG)
             GMX_TEST_CXXFLAG(MSVC_AVX_CXXFLAG "/arch:AVX" GROMACS_CXX_FLAGS)
         endif (NOT GNU_AVX_CXXFLAG)
         if (NOT GNU_AVX_CXXFLAG AND NOT MSVC_AVX_CXXFLAG)
-            message(WARNING "No C++ AVX flag found. Consider a newer compiler, or disable AVX for much lower performance.")
+            message(WARNING "No C++ AVX flag found. Consider a newer compiler, or try SSE4.1 (lower performance).")
         endif (NOT GNU_AVX_CXXFLAG AND NOT MSVC_AVX_CXXFLAG)
     endif()
 
         endif (NOT GNU_AVX_CXXFLAG AND NOT MSVC_AVX_CXXFLAG)
     endif()
 
@@ -778,12 +786,12 @@ elseif(${GMX_CPU_ACCELERATION} STREQUAL "AVX_128_FMA" OR ${GMX_CPU_ACCELERATION}
     if(${GMX_CPU_ACCELERATION} STREQUAL "AVX_128_FMA" AND NOT MSVC)
         GMX_TEST_CFLAG(GNU_FMA_CFLAG "-mfma4" GROMACS_C_FLAGS)
         if (NOT GNU_FMA_CFLAG)
     if(${GMX_CPU_ACCELERATION} STREQUAL "AVX_128_FMA" AND NOT MSVC)
         GMX_TEST_CFLAG(GNU_FMA_CFLAG "-mfma4" GROMACS_C_FLAGS)
         if (NOT GNU_FMA_CFLAG)
-            message(WARNING "No C FMA4 flag found. Consider a newer compiler, or disable AVX_128_FMA for much lower performance.")
+            message(WARNING "No C FMA4 flag found. Consider a newer compiler, or try SSE4.1 (lower performance).")
         endif(NOT GNU_FMA_CFLAG)
         if (CMAKE_CXX_COMPILER_LOADED)
             GMX_TEST_CXXFLAG(GNU_FMA_CXXFLAG "-mfma4" GROMACS_CXX_FLAGS)
             if (NOT GNU_FMA_CXXFLAG)
         endif(NOT GNU_FMA_CFLAG)
         if (CMAKE_CXX_COMPILER_LOADED)
             GMX_TEST_CXXFLAG(GNU_FMA_CXXFLAG "-mfma4" GROMACS_CXX_FLAGS)
             if (NOT GNU_FMA_CXXFLAG)
-                message(WARNING "No C++ FMA flag found. Consider a newer compiler, or disable AVX_128_FMA for much lower performance.")
+                message(WARNING "No C++ FMA flag found. Consider a newer compiler, or try SSE4.1 (lower performance).")
             endif (NOT GNU_FMA_CXXFLAG)
         endif()
     endif()
             endif (NOT GNU_FMA_CXXFLAG)
         endif()
     endif()
@@ -1087,31 +1095,14 @@ if(NOT GMX_OPENMP)
     unset(OpenMP_LINKER_FLAGS CACHE)
     unset(OpenMP_SHARED_LINKER_FLAGS)
 endif()
     unset(OpenMP_LINKER_FLAGS CACHE)
     unset(OpenMP_SHARED_LINKER_FLAGS)
 endif()
+
 ######################################
 # Output compiler and CFLAGS used
 ######################################
 ######################################
 # Output compiler and CFLAGS used
 ######################################
-execute_process(COMMAND ${CMAKE_C_COMPILER} --version RESULT_VARIABLE TMP_RESULT OUTPUT_VARIABLE CC_VERSION ERROR_VARIABLE CC_VERSION)
-#try executing just the compiler command if that failed...
-if(TMP_RESULT)
-    execute_process(COMMAND ${CMAKE_C_COMPILER} RESULT_VARIABLE TMP_RESULT OUTPUT_VARIABLE CC_VERSION ERROR_VARIABLE CC_VERSION)
-endif()
-string(LENGTH "${CC_VERSION}" len)
-if(len)
-    string(REGEX MATCH "[^\n]+" CC_VERSION "${CC_VERSION}")
-endif()
-
-set(BUILD_COMPILER "@CMAKE_C_COMPILER@ @CMAKE_C_COMPILER_ID@ @CC_VERSION@")
-set(BUILD_CFLAGS "@CMAKE_C_FLAGS@")
-if(CMAKE_BUILD_TYPE STREQUAL "Debug")
-    set(BUILD_CFLAGS "@BUILD_CFLAGS@ @CMAKE_C_FLAGS_DEBUG@")
-elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
-    set(BUILD_CFLAGS "@BUILD_CFLAGS@ @CMAKE_C_FLAGS_RELEASE@")
-elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
-    set(BUILD_CFLAGS "@BUILD_CFLAGS@ @CMAKE_C_FLAGS_MINSIZEREL@")
-elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
-    set(BUILD_CFLAGS "@BUILD_CFLAGS@ @CMAKE_C_FLAGS_RELWITHDEBINFO@")
-endif()
-
+get_compiler_info(C BUILD_C_COMPILER BUILD_CFLAGS)
+if (CMAKE_CXX_COMPILER_LOADED)
+    get_compiler_info(CXX BUILD_CXX_COMPILER BUILD_CXXFLAGS)
+endif ()
 
 ########################################################################
 # Specify install locations and which subdirectories to process        #
 
 ########################################################################
 # Specify install locations and which subdirectories to process        #
diff --git a/cmake/gmxBuildTypeReference.cmake b/cmake/gmxBuildTypeReference.cmake
new file mode 100644 (file)
index 0000000..ea3b0a1
--- /dev/null
@@ -0,0 +1,20 @@
+# Custom build type "Reference", to be used for creating new
+# reference values in the Gromacs regression tests.
+set( CMAKE_CXX_FLAGS_REFERENCE "-O0 -g" CACHE STRING "C++ flags for regressiontests reference runs." FORCE)
+set( CMAKE_C_FLAGS_REFERENCE "-O0 -g" CACHE STRING "C flags for regressiontests reference runs." FORCE)
+mark_as_advanced( CMAKE_CXX_FLAGS_REFERENCE CMAKE_C_FLAGS_REFERENCE)
+
+# turn off all fancy options for the regressiontests reference build
+if("${CMAKE_BUILD_TYPE}" STREQUAL "Reference")
+    set(GMX_GPU OFF CACHE BOOL "Disabled for regressiontests reference builds" FORCE)
+    set(GMX_OPENMP OFF CACHE BOOL "Disabled for regressiontests reference builds" FORCE)
+    set(GMX_CPU_ACCELERATION "None" CACHE STRING "Disabled for regressiontests reference builds" FORCE)
+    set(GMX_FFT_LIBRARY "fftpack" CACHE STRING "Use fftpack for regressiontests reference builds" FORCE)
+    set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Disabled for regressiontests reference builds" FORCE)
+    set(GMX_THREAD_MPI OFF OFF CACHE BOOL "Disabled for regressiontests reference builds" FORCE)
+
+    if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR NOT "${C_COMPILER_VERSION}" MATCHES "4.7")
+        message(WARNING "Reference values for regressiontests should use Gromacs compiled with "
+                        "gcc-4.7, but your configuration is using ${CMAKE_C_COMPILER_ID}-${C_COMPILER_VERSION}.")
+    endif()
+endif()
diff --git a/cmake/gmxGetCompilerInfo.cmake b/cmake/gmxGetCompilerInfo.cmake
new file mode 100644 (file)
index 0000000..d70020a
--- /dev/null
@@ -0,0 +1,79 @@
+# This macro attempts to parse the version string of the C compiler in use.
+# Currently supported are only compilers that accept "-dumpversion" argument:
+# gcc, Intel Compiler (on Linux and Mac OS), Open64, EkoPath.
+#
+# C_COMPILER_VERSION    - version string of the current C compiler (CMAKE_C_COMPILER)
+# CXX_COMPILER_VERSION  - version string of the current C++ compiler (CMAKE_CXX_COMPILER)
+#
+macro(get_compiler_version)
+    if(NOT C_COMPILER_VERSION)
+        execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+            RESULT_VARIABLE _cc_dumpversion_res
+            OUTPUT_VARIABLE _cc_dumpversion_out
+           ERROR_VARIABLE  _cc_dumpversion_err
+            OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+        if (${_cc_dumpversion_res} EQUAL 0)
+            SET(C_COMPILER_VERSION ${_cc_dumpversion_out}
+                CACHE STRING "C compiler version string" FORCE)
+        else ()
+            SET(C_COMPILER_VERSION ""
+                CACHE STRING "C compiler version string not available" FORCE)
+        endif ()
+    endif()
+
+    if(NOT CXX_COMPILER_VERSION AND CMAKE_CXX_COMPILER_LOADED)
+        execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
+            RESULT_VARIABLE _cxx_dumpversion_res
+            OUTPUT_VARIABLE _cxx_dumpversion_out
+           ERROR_VARIABLE  _cxx_dumpversion_err
+            OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+        if (${_cxx_dumpversion_res} EQUAL 0)
+            SET(CXX_COMPILER_VERSION ${_cxx_dumpversion_out}
+                CACHE STRING "C++ compiler version string" FORCE)
+        else ()
+            SET(CXX_COMPILER_VERSION ""
+                CACHE STRING "C++ compiler version string not available" FORCE)
+        endif ()
+    endif ()
+
+    if (NOT "${C_COMPILER_VERSION}" STREQUAL "${CXX_COMPILER_VERSION}" AND CMAKE_CXX_COMPILER_LOADED)
+        message(WARNING "The version string of the C and C++ compilers does not match!")
+    endif ()
+
+    mark_as_advanced(C_COMPILER_VERSION CXX_COMPILER_VERSION)
+endmacro()
+
+# This macro attempts to get a reasonable version string for a compiler,
+# and also extracts compiler flags.
+#
+# Parameters:
+#   LANGUAGE       - C or CXX, the compiler to check for
+#   BUILD_COMPILER - [output variable] string with compiler path, ID and
+#                    some compiler-provided information
+#   BUILD_FLAGS    - [output variable] flags for the compiler
+#
+macro(get_compiler_info LANGUAGE BUILD_COMPILER BUILD_FLAGS)
+    execute_process(COMMAND ${CMAKE_${LANGUAGE}_COMPILER} --version
+        RESULT_VARIABLE _exec_result
+        OUTPUT_VARIABLE _compiler_version
+        ERROR_VARIABLE  _compiler_version)
+    # Try executing just the compiler command --version failed
+    if(_exec_result)
+        execute_process(COMMAND ${CMAKE_${LANGUAGE}_COMPILER}
+            RESULT_VARIABLE _exec_result
+            OUTPUT_VARIABLE _compiler_version
+            ERROR_VARIABLE  _compiler_version)
+    endif()
+    if(NOT "${_compiler_version}" STREQUAL "")
+        string(REGEX MATCH "[^\n]+" _compiler_version "${_compiler_version}")
+    endif()
+
+    set(${BUILD_COMPILER}
+        "${CMAKE_${LANGUAGE}_COMPILER} ${CMAKE_${LANGUAGE}_COMPILER_ID} ${_compiler_version}")
+    set(_build_flags "${CMAKE_${LANGUAGE}_FLAGS}")
+    string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type)
+    set(_build_flags "${_build_flags} ${CMAKE_${LANGUAGE}_FLAGS_${_build_type}}")
+    set(${BUILD_FLAGS} ${_build_flags})
+endmacro()
diff --git a/cmake/gmxGetCompilerVersion.cmake b/cmake/gmxGetCompilerVersion.cmake
deleted file mode 100644 (file)
index 10d8cfd..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-# This macro attempts to parse the version string of the C compiler in use.
-# Currently supported are only compilers that accept "-dumpversion" argument:
-# gcc, Intel Compiler (on Linux and Mac OS), Open64, EkoPath.
-#
-# C_COMPILER_VERSION    - version string of the current C compiler (CMAKE_C_COMPILER)
-# CXX_COMPILER_VERSION  - version string of the current C++ compiler (CMAKE_CXX_COMPILER)
-#
-macro(get_compiler_version)
-    if(NOT C_COMPILER_VERSION)
-        execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
-            RESULT_VARIABLE _cc_dumpversion_res
-            OUTPUT_VARIABLE _cc_dumpversion_out
-           ERROR_VARIABLE  _cc_dumpversion_err
-            OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-        if (${_cc_dumpversion_res} EQUAL 0)
-            SET(C_COMPILER_VERSION ${_cc_dumpversion_out}
-                CACHE STRING "C compiler verstion string" FORCE)
-        else ()
-            SET(C_COMPILER_VERSION ""
-                CACHE STRING "C compiler verstion string not available" FORCE)
-        endif ()
-    endif()
-
-    if(NOT CXX_COMPILER_VERSION AND CMAKE_CXX_COMPILER_LOADED)
-        execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
-            RESULT_VARIABLE _cxx_dumpversion_res
-            OUTPUT_VARIABLE _cxx_dumpversion_out
-           ERROR_VARIABLE  _cxx_dumpversion_err
-            OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-        if (${_cxx_dumpversion_res} EQUAL 0)
-            SET(CXX_COMPILER_VERSION ${_cxx_dumpversion_out}
-                CACHE STRING "C++ compiler verstion string" FORCE)
-        else ()
-            SET(CXX_COMPILER_VERSION ""
-                CACHE STRING "C++ compiler verstion string not available" FORCE)
-        endif ()
-    endif ()
-
-    if (NOT "${C_COMPILER_VERSION}" STREQUAL "${CXX_COMPILER_VERSION}" AND CMAKE_CXX_COMPILER_LOADED)
-        message(WARNING "The version string of the C and C++ compilers does not match!")
-    endif ()
-
-    mark_as_advanced(C_COMPILER_VERSION CXX_COMPILER_VERSION)
-endmacro()
index 3b55d8f4311c8d1acb560b8a331428913d7face8..b7d5998147a8746146fa03df288f7f8b0fbfd76a 100644 (file)
@@ -109,3 +109,33 @@ if (NOT DEFINED CUDA_NVCC_FLAGS_SET)
         "${_CUDA_ARCH_STR};-use_fast_math;${CUDA_NVCC_HOST_COMPILER_OPTIONS};${_FPIC_NVCC_FLAG}"
         CACHE STRING "Compiler flags for nvcc." FORCE)
 endif()
         "${_CUDA_ARCH_STR};-use_fast_math;${CUDA_NVCC_HOST_COMPILER_OPTIONS};${_FPIC_NVCC_FLAG}"
         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 fc74939b727d912ad2153f2db1cdf15085089e43..0791772eac2d845d08a21244d6f2a2f213219086 100644 (file)
@@ -147,7 +147,7 @@ typedef union
 
 
 #ifdef GMX_SOFTWARE_INVSQRT
 
 
 #ifdef GMX_SOFTWARE_INVSQRT
-static real gmx_invsqrt(real x)
+static real gmx_software_invsqrt(real x)
 {
   const real  half=0.5;
   const real  three=3.0;
 {
   const real  half=0.5;
   const real  three=3.0;
@@ -174,11 +174,12 @@ static real gmx_invsqrt(real x)
   return y;                     /* 5  Flops */
 #endif
 }
   return y;                     /* 5  Flops */
 #endif
 }
+#define gmx_invsqrt(x) gmx_software_invsqrt(x)
 #define INVSQRT_DONE 
 #endif /* gmx_invsqrt */
 
 #ifdef GMX_POWERPC_SQRT
 #define INVSQRT_DONE 
 #endif /* gmx_invsqrt */
 
 #ifdef GMX_POWERPC_SQRT
-static real gmx_invsqrt(real x)
+static real gmx_powerpc_invsqrt(real x)
 {
   const real  half=0.5;
   const real  three=3.0;
 {
   const real  half=0.5;
   const real  three=3.0;
@@ -207,6 +208,7 @@ static real gmx_invsqrt(real x)
   return y;                     /* 5  Flops */
 #endif
 }
   return y;                     /* 5  Flops */
 #endif
 }
+#define gmx_invsqrt(x) gmx_powerpc_invsqrt(x)
 #define INVSQRT_DONE
 #endif /* powerpc_invsqrt */
 
 #define INVSQRT_DONE
 #endif /* powerpc_invsqrt */
 
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644 (file)
index 0000000..0a766b1
--- /dev/null
@@ -0,0 +1,2 @@
+config.h
+buildinfo.h
index 2d61ef4ec407ec637ad886bb5b92e983e4032e00..ebe8f695443b3908411b6b18b3f7e96869a26f9d 100644 (file)
@@ -1,4 +1,5 @@
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+configure_file(config.h.cmakein config.h)
+configure_file(buildinfo.h.cmakein buildinfo.h)
 
 include(../cmake/BuildManPages.cmake)
 
 
 include(../cmake/BuildManPages.cmake)
 
diff --git a/src/buildinfo.h.cmakein b/src/buildinfo.h.cmakein
new file mode 100644 (file)
index 0000000..473c602
--- /dev/null
@@ -0,0 +1,49 @@
+/*! \internal \file
+ * \brief
+ * Build information from the build system.
+ *
+ * Used for log and version output.
+ */
+
+/** Hardware and OS version for build host */
+#define BUILD_HOST              "@BUILD_HOST@"
+
+/** Date and time for build */
+#define BUILD_TIME              "@BUILD_TIME@"
+
+/** User doing build */
+#define BUILD_USER              "@BUILD_USER@"
+
+/** CPU vendor for build host */
+#define BUILD_CPU_VENDOR        "@BUILD_CPU_VENDOR@"
+
+/** CPU brand for build host */
+#define BUILD_CPU_BRAND         "@BUILD_CPU_BRAND@"
+
+/** CPU family for build host */
+#define BUILD_CPU_FAMILY        @BUILD_CPU_FAMILY@
+
+/** CPU model for build host */
+#define BUILD_CPU_MODEL         @BUILD_CPU_MODEL@
+
+/** CPU stepping for build host */
+#define BUILD_CPU_STEPPING      @BUILD_CPU_STEPPING@
+
+/** CPU feature list for build host */
+#define BUILD_CPU_FEATURES      "@BUILD_CPU_FEATURES@"
+
+/** C compiler used to build */
+#define BUILD_C_COMPILER        "@BUILD_C_COMPILER@"
+
+/** C compiler flags used to build */
+#define BUILD_CFLAGS            "@BUILD_CFLAGS@"
+
+/** C++ compiler flags used to build, or empty string if no C++ */
+#define BUILD_CXX_COMPILER      "@BUILD_CXX_COMPILER@"
+
+/** C++ compiler flags used to build */
+#define BUILD_CXXFLAGS          "@BUILD_CXXFLAGS@"
+
+/** CUDA nvcc compiler version information */
+#define CUDA_NVCC_COMPILER_INFO "@CUDA_NVCC_COMPILER_INFO@"
+
index ba3595bd22ca3dcf6909f568c434f6aa15c79bfa..b532adf06a5a63967942c9221623bd5b8d5ea8af 100644 (file)
 /* Default location of data files */
 #define GMXLIBDIR "@GMXLIBDIR@"
 
 /* Default location of data files */
 #define GMXLIBDIR "@GMXLIBDIR@"
 
-/* Hardware and OS version for build host */
-#define BUILD_HOST "@BUILD_HOST@"
-
-/* CPU information for build host */
-#define BUILD_CPU_VENDOR "@BUILD_CPU_VENDOR@"
-
-#define BUILD_CPU_BRAND "@BUILD_CPU_BRAND@"
-
-#define BUILD_CPU_FAMILY @BUILD_CPU_FAMILY@
-
-#define BUILD_CPU_MODEL @BUILD_CPU_MODEL@
-
-#define BUILD_CPU_STEPPING @BUILD_CPU_STEPPING@
-
-#define BUILD_CPU_FEATURES "@BUILD_CPU_FEATURES@"
-
-/* Compiler and CFLAGS from build */
-#define BUILD_COMPILER "@BUILD_COMPILER@"
-
-#define BUILD_CFLAGS   "@BUILD_CFLAGS@"
-
-/* Date and time for build */
-#define BUILD_TIME "@BUILD_TIME@"
-
-/* User doing build */
-#define BUILD_USER "@BUILD_USER@"
-
 /* Turn off water-water neighborlist optimization only - not used right now */
 #cmakedefine DISABLE_WATERWATER_NLIST
 
 /* Turn off water-water neighborlist optimization only - not used right now */
 #cmakedefine DISABLE_WATERWATER_NLIST
 
index 8f414010bc5ddfc3493f02e46c2b64d2e4a4c57c..0e1cc4f0dcd32138ae515681307d1956cb01ac7f 100644 (file)
@@ -42,6 +42,11 @@ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/version.c
                 PROPERTIES GENERATED true)
 endif()
 
                 PROPERTIES GENERATED true)
 endif()
 
+# The log file output queries Cuda if GPU support is enabled
+if(GMX_GPU)
+set_source_files_properties(copyrite.c PROPERTIES COMPILE_FLAGS "-I${CUDA_TOOLKIT_INCLUDE}")
+endif()
+
 if(NOT GMX_EXTERNAL_BLAS)
   file(GLOB BLAS_SOURCES gmx_blas/*.c)
 endif(NOT GMX_EXTERNAL_BLAS)
 if(NOT GMX_EXTERNAL_BLAS)
   file(GLOB BLAS_SOURCES gmx_blas/*.c)
 endif(NOT GMX_EXTERNAL_BLAS)
@@ -55,7 +60,7 @@ endif(NOT GMX_EXTERNAL_LAPACK)
 #if(GMX_THREAD_MPI)
 #    add_subdirectory(thread_mpi)
 #endif(GMX_THREAD_MPI)
 #if(GMX_THREAD_MPI)
 #    add_subdirectory(thread_mpi)
 #endif(GMX_THREAD_MPI)
-#target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${THREAD_MPI_LIB})
+#target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${FFT_LIBRARIES} ${THREAD_MPI_LIB})
 
 # apply gcc 4.4.x bug workaround
 if(GMX_USE_GCC44_BUG_WORKAROUND)
 
 # apply gcc 4.4.x bug workaround
 if(GMX_USE_GCC44_BUG_WORKAROUND)
@@ -80,7 +85,7 @@ endif()
 
 # NONBONDED_SOURCES is imported from the nonbonded subdirectory.
 add_library(gmx ${GMXLIB_SOURCES} ${BLAS_SOURCES} ${LAPACK_SOURCES} ${THREAD_MPI_SRC} ${NONBONDED_SOURCES})
 
 # NONBONDED_SOURCES is imported from the nonbonded subdirectory.
 add_library(gmx ${GMXLIB_SOURCES} ${BLAS_SOURCES} ${LAPACK_SOURCES} ${THREAD_MPI_SRC} ${NONBONDED_SOURCES})
-target_link_libraries(gmx ${GMX_GPU_LIBRARIES} ${GMX_EXTRA_LIBRARIES} ${THREAD_LIB} ${OpenMP_SHARED_LINKER_FLAGS})
+target_link_libraries(gmx ${GMX_GPU_LIBRARIES} ${GMX_EXTRA_LIBRARIES} ${FFT_LIBRARIES} ${THREAD_LIB} ${OpenMP_SHARED_LINKER_FLAGS})
 if(USE_VERSION_H)
        add_dependencies(gmx gmx_version) 
 endif()
 if(USE_VERSION_H)
        add_dependencies(gmx gmx_version) 
 endif()
index 927f82fa384661a8eb3456882a3575435cbc4790..896bb9ed4fc92a4f0a612e13f340ea87df0ace8e 100644 (file)
@@ -56,6 +56,7 @@
 #include "string2.h"
 #include <fcntl.h>
 
 #include "string2.h"
 #include <fcntl.h>
 
+#include "buildinfo.h"
 
 #ifdef GMX_FAHCORE
 #include "corewrap.h"
 
 #ifdef GMX_FAHCORE
 #include "corewrap.h"
index 41bd02830c83ece5e28218edc9608214983e54c2..9dcee4977b5babf917ae9c5d01c5c787ca268582 100644 (file)
 #include <thread_mpi.h>
 #endif
 
 #include <thread_mpi.h>
 #endif
 
+#ifdef HAVE_LIBMKL
+#include <mkl.h>
+#endif
+#ifdef GMX_GPU
+#include <cuda.h>
+#include <cuda_runtime_api.h>
+#endif
+#ifdef GMX_FFT_FFTW3
+#include <fftw3.h>
+#endif
+
 /* This file is completely threadsafe - keep it that way! */
 
 #include <string.h>
 /* This file is completely threadsafe - keep it that way! */
 
 #include <string.h>
@@ -54,6 +65,9 @@
 #include "copyrite.h"
 #include "strdb.h"
 #include "futil.h"
 #include "copyrite.h"
 #include "strdb.h"
 #include "futil.h"
+#include "vec.h"
+#include "buildinfo.h"
+#include "gmx_cpuid.h"
 
 static void pr_two(FILE *out,int c,int i)
 {
 
 static void pr_two(FILE *out,int c,int i)
 {
@@ -609,53 +623,115 @@ void please_cite(FILE *fp,const char *key)
 static const char _gmx_ver_string[]="VERSION " VERSION;
 #endif
 
 static const char _gmx_ver_string[]="VERSION " VERSION;
 #endif
 
-/* This routine only returns a static (constant) string, so we use a 
- * mutex to initialize it. Since the string is only written to the
- * first time, there is no risk with multiple calls overwriting the
- * output for each other.
- */
 const char *GromacsVersion()
 {
   return _gmx_ver_string;
 }
 
 const char *GromacsVersion()
 {
   return _gmx_ver_string;
 }
 
-
 void gmx_print_version_info(FILE *fp)
 {
 void gmx_print_version_info(FILE *fp)
 {
-    fprintf(fp, "Version:          %s\n", _gmx_ver_string);
+#ifdef GMX_GPU
+    int cuda_driver,cuda_runtime;
+#endif
+
+    fprintf(fp, "Gromacs version:    %s\n", _gmx_ver_string);
 #ifdef USE_VERSION_H
 #ifdef USE_VERSION_H
-    fprintf(fp, "GIT SHA1 hash:    %s\n", _gmx_full_git_hash);
+    fprintf(fp, "GIT SHA1 hash:      %s\n", _gmx_full_git_hash);
     /* Only print out the branch information if present.
      * The generating script checks whether the branch point actually
      * coincides with the hash reported above, and produces an empty string
      * in such cases. */
     if (_gmx_central_base_hash[0] != 0)
     {
     /* Only print out the branch information if present.
      * The generating script checks whether the branch point actually
      * coincides with the hash reported above, and produces an empty string
      * in such cases. */
     if (_gmx_central_base_hash[0] != 0)
     {
-        fprintf(fp, "Branched from:    %s\n", _gmx_central_base_hash);
+        fprintf(fp, "Branched from:      %s\n", _gmx_central_base_hash);
     }
 #endif
 
 #ifdef GMX_DOUBLE
     }
 #endif
 
 #ifdef GMX_DOUBLE
-    fprintf(fp, "Precision:        double\n");
+    fprintf(fp, "Precision:          double\n");
 #else
 #else
-    fprintf(fp, "Precision:        single\n");
+    fprintf(fp, "Precision:          single\n");
 #endif
 
 #ifdef GMX_THREAD_MPI
 #endif
 
 #ifdef GMX_THREAD_MPI
-    fprintf(fp, "Parallellization: thread_mpi\n");
+    fprintf(fp, "MPI library:        thread_mpi\n");
 #elif defined(GMX_MPI)
 #elif defined(GMX_MPI)
-    fprintf(fp, "Parallellization: MPI\n");
+    fprintf(fp, "MPI library:        MPI\n");
 #else
 #else
-    fprintf(fp, "Parallellization: none\n");
+    fprintf(fp, "MPI library:        none\n");
 #endif
 #endif
-
+#ifdef GMX_OPENMP
+    fprintf(fp, "OpenMP support:     enabled\n");
+#else
+    fprintf(fp, "OpenMP support:     disabled\n");
+#endif
+#ifdef GMX_GPU
+    fprintf(fp, "GPU support:        enabled\n");
+#else
+    fprintf(fp, "GPU support:        disabled\n");
+#endif
+    /* A preprocessor trick to avoid duplicating logic from vec.h */
+#define gmx_stringify2(x) #x
+#define gmx_stringify(x) gmx_stringify2(x)
+    fprintf(fp, "invsqrt routine:    %s\n", gmx_stringify(gmx_invsqrt(x)));
+    fprintf(fp, "CPU acceleration:   %s\n", GMX_CPU_ACCELERATION_STRING);
+
+    /* TODO: Would be nicer to wrap this in a gmx_fft_version() call, but
+     * since that is currently in mdlib, can wait for master. */
 #ifdef GMX_FFT_FFTPACK
 #ifdef GMX_FFT_FFTPACK
-    fprintf(fp, "FFT Library:      fftpack\n");
+    fprintf(fp, "FFT library:        fftpack (built-in)\n");
+#elif defined(GMX_FFT_FFTW3) && defined(GMX_NATIVE_WINDOWS)
+    fprintf(fp, "FFT library:        %s\n", "fftw3");
+#elif defined(GMX_FFT_FFTW3) && defined(GMX_DOUBLE)
+    fprintf(fp, "FFT library:        %s\n", fftw_version);
 #elif defined(GMX_FFT_FFTW3)
 #elif defined(GMX_FFT_FFTW3)
-    fprintf(fp, "FFT Library:      fftw3\n");
+    fprintf(fp, "FFT library:        %s\n", fftwf_version);
 #elif defined(GMX_FFT_MKL)
 #elif defined(GMX_FFT_MKL)
-    fprintf(fp, "FFT Library:      MKL\n");
+    fprintf(fp, "FFT library:        MKL\n");
+#else
+    fprintf(fp, "FFT library:        unknown\n");
+#endif
+#ifdef GMX_LARGEFILES
+    fprintf(fp, "Large file support: enabled\n");
+#else
+    fprintf(fp, "Large file support: disabled\n");
+#endif
+#ifdef HAVE_RDTSCP
+    fprintf(fp, "RDTSCP usage:       enabled\n");
 #else
 #else
-    fprintf(fp, "FFT Library:      unknown\n");
+    fprintf(fp, "RDTSCP usage:       disabled\n");
+#endif
+
+    fprintf(fp, "Built on:           %s\n", BUILD_TIME);
+    fprintf(fp, "Built by:           %s\n", BUILD_USER);
+    fprintf(fp, "Build OS/arch:      %s\n", BUILD_HOST);
+    fprintf(fp, "Build CPU vendor:   %s\n", BUILD_CPU_VENDOR);
+    fprintf(fp, "Build CPU brand:    %s\n", BUILD_CPU_BRAND);
+    fprintf(fp, "Build CPU family:   %d   Model: %d   Stepping: %d\n",
+            BUILD_CPU_FAMILY, BUILD_CPU_MODEL, BUILD_CPU_STEPPING);
+    /* TODO: The below strings can be quite long, so it would be nice to wrap
+     * them. Can wait for later, as the master branch has ready code to do all
+     * that. */
+    fprintf(fp, "Build CPU features: %s\n", BUILD_CPU_FEATURES);
+    fprintf(fp, "C compiler:         %s\n", BUILD_C_COMPILER);
+    fprintf(fp, "C compiler flags:   %s\n", BUILD_CFLAGS);
+    if (BUILD_CXX_COMPILER[0] != '\0')
+    {
+        fprintf(fp, "C++ compiler:       %s\n", BUILD_CXX_COMPILER);
+        fprintf(fp, "C++ compiler flags: %s\n", BUILD_CXXFLAGS);
+    }
+#ifdef HAVE_LIBMKL
+    /* MKL might be used for LAPACK/BLAS even if FFTs use FFTW, so keep it separate */
+    fprintf(fp, "Linked with Intel MKL version %s.%s.%s.\n",
+            __INTEL_MKL__,__INTEL_MKL_MINOR__,__INTEL_MKL_UPDATE__);
+#endif
+#ifdef GMX_GPU
+    fprintf(fp, "CUDA compiler:      %s\n",CUDA_NVCC_COMPILER_INFO);
+    cuda_driver = 0;
+    cudaDriverGetVersion(&cuda_driver);
+    cuda_runtime = 0;
+    cudaRuntimeGetVersion(&cuda_runtime);
+    fprintf(fp, "CUDA driver:        %d.%d\n",cuda_driver/1000, cuda_driver%100);
+    fprintf(fp, "CUDA runtime:       %d.%d\n",cuda_runtime/1000, cuda_runtime%100);
 #endif
 }
 #endif
 }
index 4bc2066a8380c427a523152d4bf9bcbcb6add996..97bb748681463c841d5c45941aef4f44bd8373de 100644 (file)
@@ -63,6 +63,7 @@
 #include "filenm.h"
 #include "gmxfio.h"
 #include "string2.h"
 #include "filenm.h"
 #include "gmxfio.h"
 #include "string2.h"
+#include "copyrite.h"
 
 #ifdef GMX_THREAD_MPI
 #include "thread_mpi.h"
 
 #ifdef GMX_THREAD_MPI
 #include "thread_mpi.h"
@@ -321,18 +322,8 @@ void gmx_log_open(const char *lognm,const t_commrec *cr,gmx_bool bMasterOnly,
             "Log file opened on %s"
             "Host: %s  pid: %d  nodeid: %d  nnodes:  %d\n",
             timebuf,host,pid,cr->nodeid,cr->nnodes);
             "Log file opened on %s"
             "Host: %s  pid: %d  nodeid: %d  nnodes:  %d\n",
             timebuf,host,pid,cr->nodeid,cr->nnodes);
-    fprintf(fp,
-            "Built %s by %s\n"
-            "Build os/architecture: %s\n"
-            "Build CPU Vendor: %s  Brand: %s\n"
-            "Build CPU Family: %d  Model: %d  Stepping: %d\n"
-            "Build CPU Features: %s\n"
-            "Compiler: %s\n"
-            "CFLAGS: %s\n\n",
-            BUILD_TIME,BUILD_USER,BUILD_HOST,
-            BUILD_CPU_VENDOR,BUILD_CPU_BRAND,
-            BUILD_CPU_FAMILY,BUILD_CPU_MODEL,BUILD_CPU_STEPPING,
-            BUILD_CPU_FEATURES,BUILD_COMPILER,BUILD_CFLAGS);
+    gmx_print_version_info(fp);
+    fprintf(fp, "\n\n");
 
     fflush(fp);
     debug_gmx();
 
     fflush(fp);
     debug_gmx();