Merge release-5-0 into master
authorRoland Schulz <roland@utk.edu>
Sun, 21 Sep 2014 17:38:26 +0000 (13:38 -0400)
committerRoland Schulz <roland@utk.edu>
Sun, 21 Sep 2014 17:38:26 +0000 (13:38 -0400)
Conflicts:
src/gromacs/CMakeLists.txt (adjacent changes)

Change-Id: I6e5b35508b3f6f6d805a2a539e49decdef28012b

1  2 
cmake/gmxManageSharedLibraries.cmake
cmake/gmxTestSimd.cmake
src/gromacs/CMakeLists.txt
src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_data_mgmt.cu

index 4a83ebe35c7561411ee5833d40e8472f253dcd0c,0cfab0ce68c2c876b9b810c9961a6f0fbba7e781..b58a1be697620cb1ed2dfac7b9900d870e5ce391
@@@ -118,14 -118,17 +118,18 @@@ IF( WIN32 AND NOT CYGWIN
            message(WARNING "Shared system libraries requested, and static Gromacs libraries requested.")
        endif()
    else()
-       message(FATAL_ERROR "BUILD_SHARED_LIBS=ON not yet working for Windows in the master branch")
+       if(MINGW)
+           set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols ${CMAKE_SHARED_LINKER_FLAGS}")
+       else()
+           message(FATAL_ERROR "BUILD_SHARED_LIBS=ON not yet working for Windows in the master branch")
+       endif()
        if(GMX_PREFER_STATIC_LIBS)
            #this combination segfaults (illegal passing of file handles)
            message(FATAL_ERROR "Static system libraries requested, and shared Gromacs libraries requested.")
        endif()
 -      add_definitions(-DUSE_VISIBILITY -DTMPI_USE_VISIBILITY)
 -      set(PKG_CFLAGS "$PKG_CFLAGS -DUSE_VISIBILITY -DTMPI_USE_VISIBILITY")
 +      # Visibility not yet implemented
 +      # add_definitions(-DUSE_VISIBILITY -DTMPI_USE_VISIBILITY)
 +      # set(PKG_CFLAGS "$PKG_CFLAGS -DUSE_VISIBILITY -DTMPI_USE_VISIBILITY")
    endif()
  
    IF (GMX_PREFER_STATIC_LIBS)
diff --combined cmake/gmxTestSimd.cmake
index fe477d7f2f801dc11183ff6a6f6be638f2e71d4a,3dd7407e4e7a74b0535e11accbc3a6c58ad699db..db57dd3f36771c081bf0d5693486ec9e9b57cd17
@@@ -43,10 -43,10 +43,10 @@@ macro(gmx_use_clang_as_with_gnu_compile
      # does not support AVX, so we need to tell the linker to use the clang
      # compilers assembler instead - and this has to happen before we detect AVX
      # flags.
-     if(APPLE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
+     if(APPLE AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
          gmx_test_cflag(GNU_C_USE_CLANG_AS "-Wa,-q" SIMD_C_FLAGS)
      endif()
-     if(APPLE AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
+     if(APPLE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
          gmx_test_cxxflag(GNU_CXX_USE_CLANG_AS "-Wa,-q" SIMD_CXX_FLAGS)
      endif()
  endmacro()
@@@ -179,8 -179,8 +179,8 @@@ int main(){__m128 x=_mm_set1_ps(0.5);x=
      # We don't have the full compiler version string yet (BUILD_C_COMPILER),
      # so we can't distinguish vanilla from Apple clang versions, but catering for a few rare AMD
      # hackintoshes is not worth the effort.
-     if (APPLE AND (${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR
-                 ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
+     if (APPLE AND ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
+                 "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
          message(WARNING "Due to a known compiler bug, Clang up to version 3.2 (and Apple Clang up to version 4.1) produces incorrect code with AVX_128_FMA SIMD. As we cannot work around this bug on OS X, you will have to select a different compiler or SIMD instruction set.")
      endif()
  
@@@ -249,56 -249,6 +249,56 @@@ elseif(${GMX_SIMD} STREQUAL "AVX2_256"
      set(GMX_SIMD_X86_AVX2_256 1)
      set(SIMD_STATUS_MESSAGE "Enabling 256-bit AVX2 SIMD instructions")
  
 +elseif(${GMX_SIMD} STREQUAL "ARM_NEON")
 +
 +    gmx_find_cflag_for_source(CFLAGS_ARM_NEON "C compiler 32-bit ARM NEON flag"
 +                              "#include<arm_neon.h>
 +                              int main(){float32x4_t x=vdupq_n_f32(0.5);x=vmlaq_f32(x,x,x);return vgetq_lane_f32(x,0)>0;}"
 +                              SIMD_C_FLAGS
 +                              "-mfpu=neon" "")
 +    gmx_find_cxxflag_for_source(CXXFLAGS_ARM_NEON "C++ compiler 32-bit ARM NEON flag"
 +                                "#include<arm_neon.h>
 +                                int main(){float32x4_t x=vdupq_n_f32(0.5);x=vmlaq_f32(x,x,x);return vgetq_lane_f32(x,0)>0;}"
 +                                SIMD_CXX_FLAGS
 +                                "-mfpu=neon" "-D__STDC_CONSTANT_MACROS" "")
 +
 +    if(NOT CFLAGS_ARM_NEON OR NOT CXXFLAGS_ARM_NEON)
 +        message(FATAL_ERROR "Cannot find ARM 32-bit NEON compiler flag. Use a newer compiler, or disable NEON SIMD.")
 +    endif()
 +
 +    set(GMX_SIMD_ARM_NEON 1)
 +    set(SIMD_STATUS_MESSAGE "Enabling 32-bit ARM NEON SIMD instructions")
 +
 +elseif(${GMX_SIMD} STREQUAL "ARM_NEON_ASIMD")
 +    # Gcc-4.8.1 appears to have a bug where the c++ compiler requires
 +    # -D__STDC_CONSTANT_MACROS if we include arm_neon.h
 +
 +    gmx_find_cflag_for_source(CFLAGS_ARM_NEON_ASIMD "C compiler ARM NEON Advanced SIMD flag"
 +                              "#include<arm_neon.h>
 +                              int main(){float64x2_t x=vdupq_n_f64(0.5);x=vfmaq_f64(x,x,x);return vgetq_lane_f64(x,0)>0;}"
 +                              SIMD_C_FLAGS
 +                              "")
 +    gmx_find_cxxflag_for_source(CXXFLAGS_ARM_NEON_ASIMD "C++ compiler ARM NEON Advanced SIMD flag"
 +                                "#include<arm_neon.h>
 +                                int main(){float64x2_t x=vdupq_n_f64(0.5);x=vfmaq_f64(x,x,x);return vgetq_lane_f64(x,0)>0;}"
 +                                SIMD_CXX_FLAGS
 +                                "-D__STDC_CONSTANT_MACROS" "")
 +
 +    if(NOT CFLAGS_ARM_NEON_ASIMD OR NOT CXXFLAGS_ARM_NEON_ASIMD)
 +        message(FATAL_ERROR "Cannot find ARM (AArch64) NEON Advanced SIMD compiler flag. Use a newer compiler, or disable SIMD.")
 +    endif()
 +
 +    if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.9")
 +        message(WARNING "At least gcc-4.8.1 has many bugs for ARM (AArch64) NEON Advanced SIMD compilation. You might need gcc version 4.9 or later.")
 +    endif()
 +
 +    if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "3.4")
 +        message(FATAL_ERROR "Clang version 3.4 or later is required for ARM (AArch64) NEON Advanced SIMD.")
 +    endif()
 +
 +    set(GMX_SIMD_ARM_NEON_ASIMD 1)
 +    set(SIMD_STATUS_MESSAGE "Enabling ARM (AArch64) NEON Advanced SIMD instructions")
 +
  elseif(${GMX_SIMD} STREQUAL "IBM_QPX")
  
      try_compile(TEST_QPX ${CMAKE_BINARY_DIR}
          message(FATAL_ERROR "Cannot compile the requested IBM QPX intrinsics. If you are compiling for BlueGene/Q with the XL compilers, use 'cmake .. -DCMAKE_TOOLCHAIN_FILE=Platform/BlueGeneQ-static-XL-C' to set up the tool chain.")
      endif()
  
 +elseif(${GMX_SIMD} STREQUAL "IBM_VMX")
 +
 +    gmx_find_cflag_for_source(CFLAGS_IBM_VMX "C compiler IBM VMX SIMD flag"
 +                              "#include<altivec.h>
 +                              int main(){vector float x,y=vec_ctf(vec_splat_s32(1),0);x=vec_madd(y,y,y);return vec_all_ge(y,x);}"
 +                              SIMD_C_FLAGS
 +                              "-maltivec -mabi=altivec" "-qarch=auto -qaltivec")
 +    gmx_find_cxxflag_for_source(CXXFLAGS_IBM_VMX "C++ compiler IBM VMX SIMD flag"
 +                                "#include<altivec.h>
 +                                int main(){vector float x,y=vec_ctf(vec_splat_s32(1),0);x=vec_madd(y,y,y);return vec_all_ge(y,x);}"
 +                                SIMD_CXX_FLAGS
 +                                "-maltivec -mabi=altivec" "-qarch=auto -qaltivec")
 +
 +    if(NOT CFLAGS_IBM_VMX OR NOT CXXFLAGS_IBM_VMX)
 +        message(FATAL_ERROR "Cannot find IBM VMX SIMD compiler flag. Use a newer compiler, or disable VMX SIMD.")
 +    endif()
 +
 +    set(GMX_SIMD_IBM_VMX 1)
 +    set(SIMD_STATUS_MESSAGE "Enabling IBM VMX SIMD instructions")
 +
  elseif(${GMX_SIMD} STREQUAL "SPARC64_HPC_ACE")
  
      # Note that GMX_RELAXED_DOUBLE_PRECISION is enabled by default in the top-level CMakeLists.txt
index 0f8cc721cdfc39d40fa18bd5d89b9d74e9e52f62,6db37e2402e57b5ead038c6f4fe53bdebb24c2f1..912789403df6eeb2ca7239c0d6484427d8e22b3d
@@@ -77,7 -77,6 +77,7 @@@ endif(
  add_subdirectory(gmxlib)
  add_subdirectory(mdlib)
  add_subdirectory(gmxpreprocess)
 +add_subdirectory(bonded)
  add_subdirectory(commandline)
  add_subdirectory(fft)
  add_subdirectory(linearalgebra)
@@@ -85,9 -84,7 +85,9 @@@ add_subdirectory(math
  add_subdirectory(random)
  add_subdirectory(onlinehelp)
  add_subdirectory(options)
 +add_subdirectory(pbcutil)
  add_subdirectory(timing)
 +add_subdirectory(topology)
  add_subdirectory(utility)
  add_subdirectory(fileio)
  add_subdirectory(swap)
@@@ -117,43 -114,50 +117,43 @@@ list(APPEND LIBGROMACS_SOURCES ${GMXLIB
  tmpi_get_source_list(THREAD_MPI_SOURCES ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/src)
  list(APPEND LIBGROMACS_SOURCES ${THREAD_MPI_SOURCES})
  
 -file(GLOB LIBGROMACS_HEADERS *.h)
 +set(LIBGROMACS_HEADERS
 +    analysisdata.h
 +    commandline.h
 +    options.h
 +    selection.h
 +    trajectoryanalysis.h
 +    utility.h)
  configure_file(version.h.cmakein version.h)
  gmx_install_headers("" ${LIBGROMACS_HEADERS})
  gmx_install_headers("" ${CMAKE_CURRENT_BINARY_DIR}/version.h)
  
 -# Add target that generates baseversion-gen.c every time make is run
 -# if git version info is requested, or create it statically.
 -# This code is here instead of utility/CMakeLists.txt because CMake
 -# ignores set_source_file_properties from subdirectories.
 -set(GENERATED_VERSION_FILE
 -    ${CMAKE_CURRENT_BINARY_DIR}/utility/baseversion-gen.c)
 -set(GENERATED_VERSION_FILE_SOURCE
 -    ${CMAKE_CURRENT_SOURCE_DIR}/utility/baseversion-gen.c.cmakein)
 -if (GMX_GIT_VERSION_INFO)
 -    add_custom_target(gmx-version ALL
 -            COMMAND ${CMAKE_COMMAND}
 -                -D GIT_EXECUTABLE="${GIT_EXECUTABLE}"
 -                -D PROJECT_VERSION="${PROJECT_VERSION}"
 -                -D PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
 -                -D VERSION_CMAKEIN=${GENERATED_VERSION_FILE_SOURCE}
 -                -D VERSION_OUT=${GENERATED_VERSION_FILE}
 -                -P ${CMAKE_SOURCE_DIR}/cmake/gmxGenerateVersionInfo.cmake
 -            WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
 -            DEPENDS ${GENERATED_VERSION_FILE_SOURCE}
 -            COMMENT "Generating git version information")
 -    set_source_files_properties(${GENERATED_VERSION_FILE}
 -                                PROPERTIES GENERATED true)
 -else()
 -    set(GMX_PROJECT_VERSION_STR ${PROJECT_VERSION})
 -    configure_file(${GENERATED_VERSION_FILE_SOURCE} ${GENERATED_VERSION_FILE})
 -endif()
 +# This code is here instead of utility/CMakeLists.txt, because CMake
 +# custom commands and source file properties can only be set in the directory
 +# that contains the target that uses them.
 +# TODO: Generate a header instead that can be included from baseversion.c.
 +# That probably simplifies things somewhat.
 +set(GENERATED_VERSION_FILE utility/baseversion-gen.c)
 +gmx_configure_version_file(
 +    utility/baseversion-gen.c.cmakein ${GENERATED_VERSION_FILE}
 +    REMOTE_HASH SOURCE_FILE)
  list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
  
  # apply gcc 4.4.x bug workaround
  if(GMX_USE_GCC44_BUG_WORKAROUND)
     include(gmxGCC44O3BugWorkaround)
 -   gmx_apply_gcc44_bug_workaround("gmxlib/bondfree.c")
 +   gmx_apply_gcc44_bug_workaround("bonded/bonded.cpp")
     gmx_apply_gcc44_bug_workaround("mdlib/force.c")
     gmx_apply_gcc44_bug_workaround("mdlib/constr.c")
  endif()
  
 -add_library(libgromacs ${LIBGROMACS_SOURCES})
 -if (GMX_GIT_VERSION_INFO)
 -    add_dependencies(libgromacs gmx-version)
 +if (GMX_GPU)
 +    cuda_add_library(libgromacs ${LIBGROMACS_SOURCES}
 +            OPTIONS
 +            RELWITHDEBINFO -g
 +            DEBUG -g -D_DEBUG_=1)
 +else()
 +    add_library(libgromacs ${LIBGROMACS_SOURCES})
  endif()
  
  # Recent versions of gcc and clang give warnings on scanner.cpp, which
@@@ -180,6 -184,7 +180,6 @@@ set_source_files_properties(selection/s
  
  target_link_libraries(libgromacs
                        ${EXTRAE_LIBRARIES}
 -                      ${GMX_GPU_LIBRARIES}
                        ${GMX_EXTRA_LIBRARIES}
                        ${TNG_IO_LIBRARIES}
                        ${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES}
@@@ -195,13 -200,19 +195,15 @@@ set_target_properties(libgromacs PROPER
  # for the binary
  if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS)
      install(TARGETS libgromacs
 -        LIBRARY DESTINATION ${LIB_INSTALL_DIR}
 -        RUNTIME DESTINATION ${BIN_INSTALL_DIR}
 -        ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
 -        COMPONENT libraries)
 +            EXPORT libgromacs
-             DESTINATION ${LIB_INSTALL_DIR}
++            LIBRARY DESTINATION ${LIB_INSTALL_DIR}
++            RUNTIME DESTINATION ${BIN_INSTALL_DIR}
++            ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
 +            COMPONENT libraries)
  endif()
  
  if (NOT GMX_BUILD_MDRUN_ONLY)
 -    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgromacs.pc.cmakein
 -                   ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc @ONLY)
 -    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc
 -            DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
 -            RENAME "libgromacs${GMX_LIBS_SUFFIX}.pc"
 -            COMPONENT development)
 +    include(InstallLibInfo.cmake)
  endif()
  
  if (INSTALL_CUDART_LIB) #can be set manual by user
index f0e6fa8561d6e4e00aa6bf115a26cea55d632df4,9200773cb8e349d68f069a76af3d6833517ac3be..6612d13097c1625da9b67b864b5581ec51179fa3
   * To help us fund GROMACS development, we humbly ask that you cite
   * the research papers on the package. Check out http://www.gromacs.org.
   */
 -#ifdef HAVE_CONFIG_H
 -#include <config.h>
 -#endif
 +#include "gmxpre.h"
 +
 +#include "nbnxn_cuda_data_mgmt.h"
 +
 +#include "config.h"
  
  #include <assert.h>
  #include <stdarg.h>
 -#include <stdlib.h>
  #include <stdio.h>
 +#include <stdlib.h>
  
  #include <cuda.h>
  
 -#include "gmx_fatal.h"
 +#include "gromacs/gmxlib/cuda_tools/cudautils.cuh"
 +#include "gromacs/legacyheaders/gmx_detect_hardware.h"
 +#include "gromacs/legacyheaders/gpu_utils.h"
 +#include "gromacs/legacyheaders/pmalloc_cuda.h"
 +#include "gromacs/legacyheaders/tables.h"
 +#include "gromacs/legacyheaders/typedefs.h"
 +#include "gromacs/legacyheaders/types/enums.h"
 +#include "gromacs/legacyheaders/types/force_flags.h"
 +#include "gromacs/legacyheaders/types/interaction_const.h"
 +#include "gromacs/mdlib/nb_verlet.h"
 +#include "gromacs/mdlib/nbnxn_consts.h"
 +#include "gromacs/pbcutil/ishift.h"
 +#include "gromacs/utility/common.h"
 +#include "gromacs/utility/cstringutil.h"
 +#include "gromacs/utility/fatalerror.h"
  #include "gromacs/utility/smalloc.h"
 -#include "tables.h"
 -#include "typedefs.h"
 -#include "types/enums.h"
 -#include "types/nb_verlet.h"
 -#include "types/interaction_const.h"
 -#include "types/force_flags.h"
 -#include "../nbnxn_consts.h"
 -#include "gmx_detect_hardware.h"
  
  #include "nbnxn_cuda_types.h"
 -#include "../../gmxlib/cuda_tools/cudautils.cuh"
 -#include "nbnxn_cuda_data_mgmt.h"
 -#include "pmalloc_cuda.h"
 -#include "gpu_utils.h"
 -
 -#include "gromacs/utility/common.h"
  
  static bool bUseCudaEventBlockingSync = false; /* makes the CPU thread block */
  
@@@ -428,15 -426,10 +428,15 @@@ static void init_nbparam(cu_nbparam_
  
  /*! Re-generate the GPU Ewald force table, resets rlist, and update the
   *  electrostatic type switching to twin cut-off (or back) if needed. */
 -void nbnxn_cuda_pme_loadbal_update_param(nbnxn_cuda_ptr_t           cu_nb,
 -                                         const interaction_const_t *ic)
 +void nbnxn_cuda_pme_loadbal_update_param(const nonbonded_verlet_t    *nbv,
 +                                         const interaction_const_t   *ic)
  {
 -    cu_nbparam_t *nbp = cu_nb->nbparam;
 +    if (!nbv || nbv->grp[0].kernel_type != nbnxnk8x8x8_CUDA)
 +    {
 +        return;
 +    }
 +    nbnxn_cuda_ptr_t cu_nb = nbv->cu_nbv;
 +    cu_nbparam_t    *nbp   = cu_nb->nbparam;
  
      set_cutoff_parameters(nbp, ic);
  
@@@ -579,7 -572,7 +579,7 @@@ void nbnxn_cuda_init(FIL
           * priorities, because we are querying the priority range which in this
           * case will be a single value.
           */
- #if CUDA_VERSION >= 5500
+ #if CUDA_VERSION >= 5050
          {
              int highest_priority;
              stat = cudaDeviceGetStreamPriorityRange(NULL, &highest_priority);
@@@ -1084,11 -1077,11 +1084,11 @@@ wallclock_gpu_t * nbnxn_cuda_get_timing
      return (cu_nb != NULL && cu_nb->bDoTime) ? cu_nb->timings : NULL;
  }
  
 -void nbnxn_cuda_reset_timings(nbnxn_cuda_ptr_t cu_nb)
 +void nbnxn_cuda_reset_timings(nonbonded_verlet_t* nbv)
  {
 -    if (cu_nb->bDoTime)
 +    if (nbv->cu_nbv && nbv->cu_nbv->bDoTime)
      {
 -        init_timings(cu_nb->timings);
 +        init_timings(nbv->cu_nbv->timings);
      }
  }