From 4be35c673c274442ba1c9e35db5c56c8458217d7 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sun, 6 Jul 2014 21:14:45 -0400 Subject: [PATCH] Remove individual cuda libraries Instead use CUDA_ADD_LIBRARY to build libgromacs. It builds all non CUDA files using the standard build rules. Thus this should not have any effect on non CUDA files. All CUDA files were compiled with the same nvcc OPTIONS, and thus nothing should have changed for them either. This also removes the requirement for gmxManageNvccConfig to set fPIC manually because now CUDA_ADD_LIBRARY knows when the library is shared. Change-Id: I23fe6b7a9766a39c525cdc1abfa3922ec24058d9 --- cmake/gmxManageNvccConfig.cmake | 9 --------- src/gromacs/CMakeLists.txt | 10 ++++++++-- src/gromacs/gmxlib/CMakeLists.txt | 1 - src/gromacs/gmxlib/cuda_tools/CMakeLists.txt | 7 ++----- src/gromacs/gmxlib/gpu_utils/CMakeLists.txt | 8 +------- src/gromacs/mdlib/CMakeLists.txt | 6 +++--- src/gromacs/mdlib/nbnxn_cuda/CMakeLists.txt | 9 ++------- 7 files changed, 16 insertions(+), 34 deletions(-) diff --git a/cmake/gmxManageNvccConfig.cmake b/cmake/gmxManageNvccConfig.cmake index e0a7728221..33d42ea699 100644 --- a/cmake/gmxManageNvccConfig.cmake +++ b/cmake/gmxManageNvccConfig.cmake @@ -131,15 +131,6 @@ if (NOT DEFINED CUDA_NVCC_FLAGS_SET) set(CUDA_HOST_COMPILER_OPTIONS "${CUDA_HOST_COMPILER_OPTIONS}-D__STRICT_ANSI__;") 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() - 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. diff --git a/src/gromacs/CMakeLists.txt b/src/gromacs/CMakeLists.txt index 3536e47111..a04d1dd0ee 100644 --- a/src/gromacs/CMakeLists.txt +++ b/src/gromacs/CMakeLists.txt @@ -161,7 +161,14 @@ if(GMX_USE_GCC44_BUG_WORKAROUND) gmx_apply_gcc44_bug_workaround("mdlib/constr.c") endif() -add_library(libgromacs ${LIBGROMACS_SOURCES}) +if (GMX_GPU) + cuda_add_library(libgromacs ${LIBGROMACS_SOURCES} + OPTIONS + RELWITHDEBINFO -g + DEBUG -g -D_DEBUG_=1) +else() + add_library(libgromacs ${LIBGROMACS_SOURCES}) +endif() if (GMX_GIT_VERSION_INFO) add_dependencies(libgromacs gmx-version) endif() @@ -190,7 +197,6 @@ set_source_files_properties(selection/scanner.cpp PROPERTIES COMPILE_FLAGS "${_s target_link_libraries(libgromacs ${EXTRAE_LIBRARIES} - ${GMX_GPU_LIBRARIES} ${GMX_EXTRA_LIBRARIES} ${TNG_IO_LIBRARIES} ${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES} diff --git a/src/gromacs/gmxlib/CMakeLists.txt b/src/gromacs/gmxlib/CMakeLists.txt index 5c919622bf..991123e37e 100644 --- a/src/gromacs/gmxlib/CMakeLists.txt +++ b/src/gromacs/gmxlib/CMakeLists.txt @@ -45,7 +45,6 @@ if(GMX_GPU) # The log file output queries Cuda if GPU support is enabled add_subdirectory(cuda_tools) add_subdirectory(gpu_utils) - set(GMX_GPU_LIBRARIES ${GMX_GPU_LIBRARIES} gpu_utils cuda_tools PARENT_SCOPE) endif() set(GMXLIB_SOURCES ${GMXLIB_SOURCES} ${NONBONDED_SOURCES} PARENT_SCOPE) diff --git a/src/gromacs/gmxlib/cuda_tools/CMakeLists.txt b/src/gromacs/gmxlib/cuda_tools/CMakeLists.txt index 8bbc24d10e..67d2cbe865 100644 --- a/src/gromacs/gmxlib/cuda_tools/CMakeLists.txt +++ b/src/gromacs/gmxlib/cuda_tools/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2012, by the GROMACS development team, led by +# Copyright (c) 2012,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. @@ -34,8 +34,5 @@ if(GMX_GPU) file(GLOB CUDA_TOOLS_SOURCES *.cu) - CUDA_ADD_LIBRARY(cuda_tools STATIC ${CUDA_TOOLS_SOURCES} - OPTIONS - RELWITHDEBINFO -g - DEBUG -g -D_DEBUG_=1) + set(GMXLIB_SOURCES ${GMXLIB_SOURCES} ${CUDA_TOOLS_SOURCES} PARENT_SCOPE) endif() diff --git a/src/gromacs/gmxlib/gpu_utils/CMakeLists.txt b/src/gromacs/gmxlib/gpu_utils/CMakeLists.txt index cfc7eec4b6..dee9b3ee07 100644 --- a/src/gromacs/gmxlib/gpu_utils/CMakeLists.txt +++ b/src/gromacs/gmxlib/gpu_utils/CMakeLists.txt @@ -32,12 +32,6 @@ # To help us fund GROMACS development, we humbly ask that you cite # the research papers on the package. Check out http://www.gromacs.org. -CUDA_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -set(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF) file(GLOB GPU_UTILS_SOURCES *.cu) -CUDA_ADD_LIBRARY(gpu_utils STATIC ${GPU_UTILS_SOURCES} - OPTIONS ${_os_def} - RELWITHDEBINFO -g - DEBUG -g -D_DEBUG_=1 ) +set(GMXLIB_SOURCES ${GMXLIB_SOURCES} ${GPU_UTILS_SOURCES} PARENT_SCOPE) -CUDA_BUILD_CLEAN_TARGET() diff --git a/src/gromacs/mdlib/CMakeLists.txt b/src/gromacs/mdlib/CMakeLists.txt index 703e8ac32d..fb9cfad823 100644 --- a/src/gromacs/mdlib/CMakeLists.txt +++ b/src/gromacs/mdlib/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2010,2012,2013, by the GROMACS development team, led by +# Copyright (c) 2010,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. @@ -33,9 +33,9 @@ # the research papers on the package. Check out http://www.gromacs.org. file(GLOB MDLIB_SOURCES nbnxn_kernels/simd_4xn/*.c nbnxn_kernels/simd_2xnn/*.c nbnxn_kernels/*.c *.c *.cpp) -set(MDLIB_SOURCES ${MDLIB_SOURCES} PARENT_SCOPE) if(GMX_GPU) add_subdirectory(nbnxn_cuda) - set(GMX_GPU_LIBRARIES ${GMX_GPU_LIBRARIES} nbnxn_cuda PARENT_SCOPE) endif() + +set(MDLIB_SOURCES ${MDLIB_SOURCES} PARENT_SCOPE) diff --git a/src/gromacs/mdlib/nbnxn_cuda/CMakeLists.txt b/src/gromacs/mdlib/nbnxn_cuda/CMakeLists.txt index 48a0712afa..2d5636b865 100644 --- a/src/gromacs/mdlib/nbnxn_cuda/CMakeLists.txt +++ b/src/gromacs/mdlib/nbnxn_cuda/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2012,2013, by the GROMACS development team, led by +# 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. @@ -34,10 +34,5 @@ if(GMX_GPU) file(GLOB CUDA_NB_SOURCES *.cu) - CUDA_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - CUDA_ADD_LIBRARY(nbnxn_cuda STATIC ${CUDA_NB_SOURCES} - OPTIONS - RELWITHDEBINFO -g - DEBUG -g -D_DEBUG_=1) - target_link_libraries(nbnxn_cuda cuda_tools) + set(MDLIB_SOURCES ${MDLIB_SOURCES} ${CUDA_NB_SOURCES} PARENT_SCOPE) endif() -- 2.22.0