Simplify compiling GPU code for tests
authorMark Abraham <mark.j.abraham@gmail.com>
Wed, 4 Mar 2020 17:44:34 +0000 (18:44 +0100)
committerPaul Bauer <paul.bauer.q@gmail.com>
Fri, 6 Mar 2020 18:16:46 +0000 (19:16 +0100)
Documented and extended gmx_add_gtest_executable to let us annotate
which source files may need special treatment for GPU
compilation. Those details are all now hidden in the function rather
than complicating the CMakeLists.txt files in multiple places. There's
a lot of incidental lines changed to make sure people can use the
rearrangement well, but the benefit is illustrated in the following
files:

gpu_utils/test/CMakeLists.txt
mdlib/test/CMakeLists.txt

Accordingly, various test code no longer compiles into
libgromacs. Removed some completely unnecessary compilation of CUDA
code for tests.

Compiling test .cu files that also need MPI libraries is not currently
supported. Thus, removed am unnecessary header dependency in
mdlib/tests on MPI libraries that was not needed (and awkward for nvcc
compilation).

Found and fixed a bug where
src/gromacs/gpu_utils/tests/typecasts_runner.cpp wasn't compiled when
it was intended to be.

Change-Id: I9ba624094092a9951fa63f3264c9d99d7ba0cbd1

47 files changed:
src/api/cpp/tests/CMakeLists.txt
src/api/cpp/workflow/tests/CMakeLists.txt
src/gromacs/analysisdata/tests/CMakeLists.txt
src/gromacs/applied_forces/tests/CMakeLists.txt
src/gromacs/awh/tests/CMakeLists.txt
src/gromacs/commandline/tests/CMakeLists.txt
src/gromacs/compat/tests/CMakeLists.txt
src/gromacs/coordinateio/tests/CMakeLists.txt
src/gromacs/correlationfunctions/tests/CMakeLists.txt
src/gromacs/domdec/tests/CMakeLists.txt
src/gromacs/energyanalysis/tests/CMakeLists.txt
src/gromacs/ewald/tests/CMakeLists.txt
src/gromacs/fft/tests/CMakeLists.txt
src/gromacs/fileio/tests/CMakeLists.txt
src/gromacs/gmxana/tests/CMakeLists.txt
src/gromacs/gmxlib/tests/CMakeLists.txt
src/gromacs/gmxpreprocess/tests/CMakeLists.txt
src/gromacs/gpu_utils/tests/CMakeLists.txt
src/gromacs/gpu_utils/tests/typecasts_runner.cpp
src/gromacs/hardware/tests/CMakeLists.txt
src/gromacs/listed_forces/tests/CMakeLists.txt
src/gromacs/math/tests/CMakeLists.txt
src/gromacs/mdlib/tests/CMakeLists.txt
src/gromacs/mdlib/tests/constrtestdata.cpp
src/gromacs/mdlib/tests/constrtestdata.h
src/gromacs/mdlib/tests/constrtestrunners.cpp
src/gromacs/mdlib/tests/leapfrogtestrunners.cu
src/gromacs/mdrunutility/tests/CMakeLists.txt
src/gromacs/mdspan/tests/CMakeLists.txt
src/gromacs/onlinehelp/tests/CMakeLists.txt
src/gromacs/options/tests/CMakeLists.txt
src/gromacs/pbcutil/tests/CMakeLists.txt
src/gromacs/pulling/tests/CMakeLists.txt
src/gromacs/random/tests/CMakeLists.txt
src/gromacs/restraint/tests/CMakeLists.txt
src/gromacs/selection/tests/CMakeLists.txt
src/gromacs/simd/tests/CMakeLists.txt
src/gromacs/tables/tests/CMakeLists.txt
src/gromacs/taskassignment/tests/CMakeLists.txt
src/gromacs/tools/tests/CMakeLists.txt
src/gromacs/topology/tests/CMakeLists.txt
src/gromacs/trajectoryanalysis/tests/CMakeLists.txt
src/gromacs/utility/CMakeLists.txt
src/gromacs/utility/tests/CMakeLists.txt
src/programs/mdrun/tests/CMakeLists.txt
src/testutils/TestMacros.cmake
src/testutils/tests/CMakeLists.txt

index f0ea2ce29b6a5a13917cb68bea7b90478cd9cc5d..000d3430c1c8d7d000d963c52f0390221aa87d3b 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2018,2019,2020, 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.
 # Test public interface.
 #
 
-gmx_add_gtest_executable(
-    gmxapi-test
-    restraint.cpp
-    status.cpp
-    system.cpp
-    version.cpp
-    # pseudo-library for code for mdrun
-    $<TARGET_OBJECTS:mdrun_objlib>
-    )
+gmx_add_gtest_executable(gmxapi-test
+    CPP_SOURCE_FILES
+        restraint.cpp
+        status.cpp
+        system.cpp
+        version.cpp
+        # pseudo-library for code for mdrun
+        $<TARGET_OBJECTS:mdrun_objlib>
+        )
 if(NOT GMX_USE_OPENCL)
     # GPU resources may not be properly reinitialized between simulations in
     # the same process.
@@ -80,15 +80,15 @@ set_tests_properties(GmxapiExternalInterfaceTests PROPERTIES
 # Test public interface with MPI.
 #
 
-gmx_add_gtest_executable(
-    gmxapi-mpi-test MPI
-    restraint.cpp
-    status.cpp
-    system.cpp
-    version.cpp
-    # pseudo-library for code for mdrun
-    $<TARGET_OBJECTS:mdrun_objlib>
-    )
+gmx_add_gtest_executable(gmxapi-mpi-test MPI
+    CPP_SOURCE_FILES
+        restraint.cpp
+        status.cpp
+        system.cpp
+        version.cpp
+        # pseudo-library for code for mdrun
+        $<TARGET_OBJECTS:mdrun_objlib>
+        )
 if(NOT GMX_USE_OPENCL)
     # GPU resources may not be properly reinitialized between simulations in
     # the same process.
index e999f58437e9a21c9d4c47e2952a6a74d576dfba..2f9afe8cd9f9c443bfc2a242679e39bd1da0ebe9 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2018,2019,2020, 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.
 # To help us fund GROMACS development, we humbly ask that you cite
 # the research papers on the package. Check out http://www.gromacs.org.
 
-#
 # Test private interface.
 #
 
-gmx_add_gtest_executable(
-    workflow-details-test
-    workflow.cpp
-    # pseudo-library for code for mdrun
-    $<TARGET_OBJECTS:mdrun_objlib>
+gmx_add_gtest_executable(workflow-details-test
+    CPP_SOURCE_FILES
+        workflow.cpp
+        # pseudo-library for code for mdrun
+        $<TARGET_OBJECTS:mdrun_objlib>
 )
 
 target_link_libraries(workflow-details-test PRIVATE Gromacs::gmxapi gmxapi-detail mdrun_test_infrastructure)
@@ -54,11 +53,11 @@ set_tests_properties(GmxapiInternalInterfaceTests PROPERTIES
 # Test with MPI.
 #
 
-gmx_add_gtest_executable(
-    workflow-details-mpi-test MPI
-    workflow.cpp
-    # pseudo-library for code for mdrun
-    $<TARGET_OBJECTS:mdrun_objlib>
+gmx_add_gtest_executable(workflow-details-mpi-test MPI
+    CPP_SOURCE_FILES
+        workflow.cpp
+        # pseudo-library for code for mdrun
+        $<TARGET_OBJECTS:mdrun_objlib>
 )
 
 target_link_libraries(workflow-details-mpi-test PRIVATE Gromacs::gmxapi gmxapi-detail mdrun_test_infrastructure)
index e0fc5e1595f7f43e1508dc16b054a1380311388b..bcecb7340e7f0ca17cbf22adf1a96d2eb4d4371f 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2011,2012,2013,2014,2019, by the GROMACS development team, led by
+# Copyright (c) 2011,2012,2013,2014,2019,2020, 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.
@@ -37,9 +37,11 @@ gmx_add_unit_test_library(analysisdata-test-shared
                           mock_datamodule.cpp)
 
 gmx_add_unit_test(AnalysisDataUnitTests analysisdata-test
-                  analysisdata.cpp
-                  arraydata.cpp
-                  average.cpp
-                  histogram.cpp
-                  lifetime.cpp)
+    CPP_SOURCE_FILES
+        analysisdata.cpp
+        arraydata.cpp
+        average.cpp
+        histogram.cpp
+        lifetime.cpp
+        )
 target_link_libraries(analysisdata-test PRIVATE analysisdata-test-shared)
index 87c0275638426bf54e56c120ab766c3afe312af6..7043e3e17d6e76b9296bafa6ff44063c440f4a20 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2015,2016,2019, by the GROMACS development team, led by
+# Copyright (c) 2015,2016,2019,2020, 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,8 +33,9 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(AppliedForcesUnitTest applied_forces-test
-                  densityfitting.cpp
-                  densityfittingoptions.cpp
-                  densityfittingamplitudelookup.cpp
-                  electricfield.cpp
-                )
+    CPP_SOURCE_FILES
+        densityfitting.cpp
+        densityfittingoptions.cpp
+        densityfittingamplitudelookup.cpp
+        electricfield.cpp
+        )
index 691be579a475da6030887ea6d7e145f21a22f896..53a53b0a0b539df488764dacdfe42ea8650b8c16 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2017, by the GROMACS development team, led by
+# Copyright (c) 2017,2020, 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,4 +33,8 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(AwhTest awh-test
-                  bias.cpp biasstate.cpp grid.cpp)
+    CPP_SOURCE_FILES
+        bias.cpp
+        biasstate.cpp
+        grid.cpp
+        )
index 493c2637eabaefb2b29950bbfc9d66d0fdbfffe2..ac4a392c58a74d66f8d6ded1b7f43c87380d74da 100644 (file)
@@ -53,12 +53,14 @@ if (UNIX)
 endif()
 
 gmx_add_unit_test(CommandLineUnitTests commandline-test
-                  cmdlinehelpmodule.cpp
-                  cmdlinehelpwriter.cpp
-                  cmdlinemodulemanager.cpp
-                  cmdlinemodulemanagertest.cpp
-                  cmdlineparser.cpp
-                  cmdlineprogramcontext.cpp
-                  filenm.cpp
-                  pargs.cpp)
+    CPP_SOURCE_FILES
+        cmdlinehelpmodule.cpp
+        cmdlinehelpwriter.cpp
+        cmdlinemodulemanager.cpp
+        cmdlinemodulemanagertest.cpp
+        cmdlineparser.cpp
+        cmdlineprogramcontext.cpp
+        filenm.cpp
+        pargs.cpp
+        )
 target_link_libraries(commandline-test PRIVATE onlinehelp-test-shared)
index 62913a4ad71e51a95e20156cb0203131f9169365..537b536671a25376ec50839586b22cb19c0831c6 100644 (file)
 
 if (GMX_BUILD_UNITTESTS)
     gmx_add_unit_test(CompatibilityHelpersTests compat-test
-                     optional.cpp
-                     pointers.cpp
-                     string_view.cpp
-                     )
+        CPP_SOURCE_FILES
+            optional.cpp
+            pointers.cpp
+            string_view.cpp
+            )
     check_cxx_compiler_flag("-Wno-unused-member-function" HAS_NO_UNUSED_MEMBER_FUNCTION)
     if (HAS_NO_UNUSED_MEMBER_FUNCTION)
         set_source_files_properties(optional.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-member-function)
index 7fe3add7c7dedda9f9e3a05cc5cedeb847790a30..611fbb21f88b98aea624b40eafe702053b406b8e 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2019, by the GROMACS development team, led by
+# Copyright (c) 2019,2020, 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.
 # To help us fund GROMACS development, we humbly ask that you cite
 # the research papers on the package. Check out http://www.gromacs.org.
 
-set(test_sources
-    builder.cpp
-    outputadaptercontainer.cpp
-    outputadapters.cpp
-    requirements.cpp
-    setatoms.cpp
-    setbothtime.cpp
-    setstarttime.cpp
-    settimestep.cpp
-    testmodule.cpp
-    )
-gmx_add_unit_test(CoordinateIOTests coordinateio-test ${test_sources})
+gmx_add_unit_test(CoordinateIOTests coordinateio-test
+    CPP_SOURCE_FILES
+        builder.cpp
+        outputadaptercontainer.cpp
+        outputadapters.cpp
+        requirements.cpp
+        setatoms.cpp
+        setbothtime.cpp
+        setstarttime.cpp
+        settimestep.cpp
+        testmodule.cpp
+        )
+
index 1bcb355f5cab07323a4114ff9c84c9e1169bd1ea..77acdcc2403db65f5072d2766f29c75250e9f391 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2016, by the GROMACS development team, led by
+# Copyright (c) 2014,2016,2020, 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.
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(CorrelationsTest  correlations-test
-  autocorr.cpp
-  manyautocorrelation.cpp
-  correlationdataset.cpp
-  expfit.cpp)
+    CPP_SOURCE_FILES
+        autocorr.cpp
+        correlationdataset.cpp
+        expfit.cpp
+        manyautocorrelation.cpp
+        )
 
index 478f578e355e54fff9ff0439f4ba8d5e48aac5bd..04beb7bb56740539c535dc35054766acaa47ac47 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2018, by the GROMACS development team, led by
+# Copyright (c) 2014,2018,2020, 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,5 +33,7 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(DomDecTests domdec-test
-            hashedmap.cpp
-            localatomsetmanager.cpp)
+    CPP_SOURCE_FILES
+        hashedmap.cpp
+        localatomsetmanager.cpp
+        )
index 5665a35b952afaec2454728d1f0fa97c49720440..ce8484aa16d3246a9603632288884314661b6fac 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+# Copyright (c) 2014,2015,2016,2017,2020, 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,5 +33,6 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(EnergyAnalysisUnitTests energyanalysis-test
+    CPP_SOURCE_FILES
         legacyenergy.cpp
-)
+        )
index 26756429a237008975a770481a48047cf47bde0c..790bb0628daa61e18de95912b1d685ca3a16e074 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2016,2017, by the GROMACS development team, led by
+# Copyright (c) 2016,2017,2020, 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.
 # To help us fund GROMACS development, we humbly ask that you cite
 # the research papers on the package. Check out http://www.gromacs.org.
 
-file(GLOB EWALD_TEST_SOURCES *.cpp)
-if (GMX_USE_CUDA)
-    file(GLOB EWALD_CUDA_SOURCES ../*.cu)
-endif()
-
 gmx_add_unit_test(EwaldUnitTests ewald-test HARDWARE_DETECTION
-                  ${EWALD_TEST_SOURCES} ${EWALD_CUDA_SOURCES})
+    CPP_SOURCE_FILES
+        pmebsplinetest.cpp
+        pmegathertest.cpp
+        pmesolvetest.cpp
+        pmesplinespreadtest.cpp
+        pmetestcommon.cpp
+        testhardwarecontexts.cpp
+        )
index c7082cc657116cfe970f56ee740b6bb7bac62343..4a6e1dd848967c4c37003052cc8867eab4ad43a1 100644 (file)
@@ -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,2020, 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,4 +33,6 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(FFTUnitTests fft-test
-                  fft.cpp)
+    CPP_SOURCE_FILES
+        fft.cpp
+    )
index 47fb4b436f8999ba641ad653a7e3116ef394bc28..5017b67f4c53d98e9e17ce20f8ab08888da68dbf 100644 (file)
 # To help us fund GROMACS development, we humbly ask that you cite
 # the research papers on the package. Check out http://www.gromacs.org.
 
-set(test_sources
-    confio.cpp
-    filemd5.cpp
-    mrcserializer.cpp
-    mrcdensitymap.cpp
-    mrcdensitymapheader.cpp
-    readinp.cpp
-    fileioxdrserializer.cpp
-    xvgio.cpp
-    )
 if (GMX_USE_TNG)
-    list(APPEND test_sources tngio.cpp)
+    set(tng_sources tngio.cpp)
 endif()
-gmx_add_unit_test(FileIOTests fileio-test ${test_sources})
+gmx_add_unit_test(FileIOTests fileio-test
+    CPP_SOURCE_FILES
+        confio.cpp
+        filemd5.cpp
+        mrcserializer.cpp
+        mrcdensitymap.cpp
+        mrcdensitymapheader.cpp
+        readinp.cpp
+        fileioxdrserializer.cpp
+        ${tng_sources}
+        xvgio.cpp
+    )
index c695ab362550ed6c64bf456dc735960b31e10652..c69a17b0cfc9544a19cf49beca4e015bd25423b7 100644 (file)
 # the research papers on the package. Check out http://www.gromacs.org.
 
 set(exename gmxana-test)
-
-gmx_add_gtest_executable(
-    ${exename}
-    entropy.cpp
-    gmx_traj.cpp
-    gmx_mindist.cpp
-    gmx_msd.cpp
-    )
-gmx_register_gtest_test(GmxAnaTest ${exename} INTEGRATION_TEST)
+gmx_add_gtest_executable(${exename}
+    CPP_SOURCE_FILES
+        entropy.cpp
+        gmx_traj.cpp
+        gmx_mindist.cpp
+        gmx_msd.cpp
+        )
+gmx_register_gtest_test(GmxAnaTest ${exename} INTEGRATION_TEST)
\ No newline at end of file
index 66ee98c31e341ad53ecc557c098dba6949fe29a0..6dec70f062aaae7c5a26d0acdb3bcf9a7728be23 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2016, by the GROMACS development team, led by
+# Copyright (c) 2016,2020, 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,4 +33,5 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(GmxlibTests gmxlib-test
+    CPP_SOURCE_FILES
     )
index c164166a0b4ba95d4b806871975053644186c31d..ef193d4fd282bdf9191cafaca64fbb13794d99d5 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2015,2017,2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2014,2015,2017,2018,2019,2020, 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.
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(GmxPreprocessTests gmxpreprocess-test
-    editconf.cpp
-    genconf.cpp
-    genion.cpp
-    gpp_atomtype.cpp
-    gpp_bond_atomtype.cpp
-    insert_molecules.cpp
-    readir.cpp
-    solvate.cpp
-    topdirs.cpp
-    )
+    CPP_SOURCE_FILES
+        editconf.cpp
+        genconf.cpp
+        genion.cpp
+        gpp_atomtype.cpp
+        gpp_bond_atomtype.cpp
+        insert_molecules.cpp
+        readir.cpp
+        solvate.cpp
+        topdirs.cpp
+        )
 
 # Currently these can be slow to run in Jenkins, so they are in
 # several test binaries.
 
 set(exename pdb2gmx1-test)
 gmx_add_gtest_executable(${exename}
-   pdb2gmx.cpp
-)
+    CPP_SOURCE_FILES
+       pdb2gmx.cpp
+       )
 target_compile_definitions(${exename} PRIVATE OPLSAA=1 GROMOS=0 AMBER=0 CHARMM=0)
 gmx_register_gtest_test(Pdb2gmx1Test ${exename})
 
 set(exename pdb2gmx2-test)
 gmx_add_gtest_executable(${exename}
-    pdb2gmx.cpp
-    )
+    CPP_SOURCE_FILES
+        pdb2gmx.cpp
+        )
 target_compile_definitions(${exename} PRIVATE OPLSAA=0 GROMOS=1 AMBER=0 CHARMM=0)
 gmx_register_gtest_test(Pdb2gmx2Test ${exename})
 
 set(exename pdb2gmx3-test)
 gmx_add_gtest_executable(${exename}
-    pdb2gmx.cpp
-    )
+    CPP_SOURCE_FILES
+        pdb2gmx.cpp
+        )
 target_compile_definitions(${exename} PRIVATE OPLSAA=0 GROMOS=0 AMBER=1 CHARMM=1)
 gmx_register_gtest_test(Pdb2gmx3Test ${exename})
index 8d688e9a2d7488d519820740dd998c8bdc0e9225..f1f977877913aa643752ac48adf09a3cfa098793 100644 (file)
 # different files and strategies for the different GPU implementation
 # flavours.
 
-# Always compiled as plain C++
-file(GLOB SOURCES_FROM_CXX
-    clfftinitializer.cpp
-    hostallocator.cpp
-    )
+gmx_add_unit_test(GpuUtilsUnitTests gpu_utils-test
+    CPP_SOURCE_FILES
+        # Infrastructure
+        gputest.cpp
+        # Tests of code
+        clfftinitializer.cpp
+        hostallocator.cpp
 
-if(GMX_USE_CUDA)
-    # CUDA-only test
-    list(APPEND SOURCES_FROM_CXX
+    CUDA_CU_SOURCE_FILES
+        devicetransfers.cu
+        typecasts_runner.cu
+
+    CUDA_CPP_SOURCE_FILES
         pinnedmemorychecker.cpp
         typecasts.cpp
         typecasts_runner.cpp
-        )
-    gmx_add_libgromacs_sources(typecasts_runner.cu)
-    # TODO Making a separate library is heavy handed, but nothing else
-    # seems to work. Also don't use a hyphen in its name, because nvcc
-    # can't cope with that.
-    #
-    # Perhaps FindCUDA's support for single compilation units will help?
-    if (NOT GMX_CLANG_CUDA)
-        # Work around FindCUDA that prevents using target_link_libraries()
-        # with keywords otherwise...
-        set(CUDA_LIBRARIES PRIVATE ${CUDA_LIBRARIES})
-        cuda_add_library(gpu_utilstest_cuda
-            devicetransfers.cu
-            )
-    else()
-        include(gmxClangCudaUtils)
-        gmx_compile_cuda_file_with_clang(devicetransfers.cu)
-        add_library(gpu_utilstest_cuda
-            devicetransfers.cu
-            )
-    endif()
-
-    target_link_libraries(gpu_utilstest_cuda PRIVATE ${GMX_EXTRA_LIBRARIES} libgromacs)
-
-elseif(GMX_USE_OPENCL)
-    # Do normal compilation of OpenCL files
-    list(APPEND SOURCES_FROM_CXX
+        
+    OPENCL_CPP_SOURCE_FILES
         devicetransfers_ocl.cpp
-        )
-else()
-    # Do normal compilation of files with null implementations
-    list(APPEND SOURCES_FROM_CXX
+    
+    NON_GPU_CPP_SOURCE_FILES
         devicetransfers.cpp
-        )
-endif()
-
-gmx_add_unit_test(GpuUtilsUnitTests gpu_utils-test
-    # Infrastructure
-    gputest.cpp
-    # Tests of code
-    ${SOURCES_FROM_CXX}
+    
     )
-
-if(GMX_USE_CUDA)
-    target_link_libraries(gpu_utils-test PRIVATE gpu_utilstest_cuda)
-endif()
-if(GMX_USE_OPENCL)
-    target_link_libraries(gpu_utils-test PRIVATE ${OpenCL_LIBRARIES})
-endif()
index e63dea16b3cef41b04af9cc953f1e840bdf006d1..580e457d282060665afa67d33b376fbd40bbeb18 100644 (file)
@@ -59,16 +59,16 @@ namespace test
 void convertRVecToFloat3OnHost(std::vector<gmx::RVec>& /* rVecOutput */,
                                const std::vector<gmx::RVec>& /* rVecInput */)
 {
-    FAIL() << "Can't test float3 and RVec compatibility without CUDA.");
+    FAIL() << "Can't test float3 and RVec compatibility without CUDA.";
 }
 
 void convertRVecToFloat3OnDevice(std::vector<gmx::RVec>& /* rVecOutput */,
                                  const std::vector<gmx::RVec>& /* rVecInput*/)
 {
-    FAIL() << "Can't test float3 and RVec compatibility without CUDA.");
+    FAIL() << "Can't test float3 and RVec compatibility without CUDA.";
 }
 
 } // namespace test
 } // namespace gmx
 
-#endif // GMX_GPU != GMX_GPU_CUDA
\ No newline at end of file
+#endif // GMX_GPU != GMX_GPU_CUDA
index e90b7b60286b803cff29589f3ec58f57ff54cf42..9d28379c504caea5dfb7f71493a216af1c8cb569 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2015, by the GROMACS development team, led by
+# Copyright (c) 2015,2020, 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,5 +33,7 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(HardwareUnitTests hardware-test
-                  cpuinfo.cpp
-                  hardwaretopology.cpp)
+    CPP_SOURCE_FILES
+        cpuinfo.cpp
+        hardwaretopology.cpp
+        )
index e987e69a4b8281460b2f3092b0d62efef939c00f..ffe786b4b24c6bdfca4012a73d6a37d1b30bec86 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2016,2019, by the GROMACS development team, led by
+# Copyright (c) 2016,2019,2020, 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,5 +33,7 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(ListedForcesTest listed_forces-test
-  bonded.cpp)
+    CPP_SOURCE_FILES
+        bonded.cpp
+        )
 
index c55a804f2e9febc62d3f4acfee3dc18144c83a5b..ebdc7a03d3bbd750f39923bc4cf0085fb4a753c5 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2015,2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2014,2015,2018,2019,2020, 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.
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(MathUnitTests math-test
-                  arrayrefwithpadding.cpp
-                  coordinatetransformation.cpp
-                  densityfit.cpp
-                  dofit.cpp
-                  exponentialmovingaverage.cpp
-                  functions.cpp
-                  gausstransform.cpp
-                  densityfittingforce.cpp
-                  invertmatrix.cpp
-                  matrix.cpp
-                  multidimarray.cpp
-                  paddedvector.cpp
-                  vectypes.cpp
-                  )
+    CPP_SOURCE_FILES
+        arrayrefwithpadding.cpp
+        coordinatetransformation.cpp
+        densityfit.cpp
+        dofit.cpp
+        exponentialmovingaverage.cpp
+        functions.cpp
+        gausstransform.cpp
+        densityfittingforce.cpp
+        invertmatrix.cpp
+        matrix.cpp
+        multidimarray.cpp
+        paddedvector.cpp
+        vectypes.cpp
+        )
index 496b51d655103cfbcfe761f5baa4e6486a308673..12cdd137e2a402877e412f478e66214746940a4a 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2016,2017,2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2014,2016,2017,2018,2019,2020, 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.
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(MdlibUnitTest mdlib-test
-                  calc_verletbuf.cpp
-                  constr.cpp
-                  constrtestdata.cpp
-                  constrtestrunners.cpp
-                  ebin.cpp
-                  energyoutput.cpp
-                  leapfrog.cpp
-                  leapfrogtestdata.cpp
-                  leapfrogtestrunners.cpp
-                  settle.cpp
-                  settletestdata.cpp
-                  settletestrunners.cpp
-                  shake.cpp
-                  simulationsignal.cpp
-                  updategroups.cpp
-                  updategroupscog.cpp)
-
-# TODO: Make CUDA source to compile inside the testing framework
-if(GMX_USE_CUDA)
-    gmx_add_libgromacs_sources(constrtestrunners.cu
-                               leapfrogtestrunners.cu
-                               settletestrunners.cu)
-endif()
+    CPP_SOURCE_FILES
+        calc_verletbuf.cpp
+        constr.cpp
+        constrtestdata.cpp
+        constrtestrunners.cpp
+        ebin.cpp
+        energyoutput.cpp
+        leapfrog.cpp
+        leapfrogtestdata.cpp
+        leapfrogtestrunners.cpp
+        settle.cpp
+        settletestdata.cpp
+        settletestrunners.cpp
+        shake.cpp
+        simulationsignal.cpp
+        updategroups.cpp
+        updategroupscog.cpp
+    CUDA_CU_SOURCE_FILES
+        constrtestrunners.cu
+        leapfrogtestrunners.cu
+        settletestrunners.cu
+        )
index 2062db55344bbd896dd6ceeca523226d0ceda386..b410504f8d4ff846b2cb551159d0dc0ff407d822 100644 (file)
@@ -95,14 +95,6 @@ ConstraintsTestData::ConstraintsTestData(const std::string&       title,
 
     invdt_ = 1.0 / timestep; // Inverse timestep
 
-    // Communication record
-    cr_.nnodes = 1;
-    cr_.dd     = nullptr;
-
-    // Multisim data
-    ms_.sim  = 0;
-    ms_.nsim = 1;
-
     // Input record - data that usually comes from configuration file (.mdp)
     ir_.efep    = 0;
     ir_.init_t  = initialTime;
index 17a82e00bce9e6865db6e314e748920dc9e34219..7374fa19243eb448696be7744910d5bede2ce679 100644 (file)
@@ -57,8 +57,6 @@
 #include "gromacs/mdlib/gmx_omp_nthreads.h"
 #include "gromacs/mdlib/lincs.h"
 #include "gromacs/mdlib/shake.h"
-#include "gromacs/mdrunutility/multisim.h"
-#include "gromacs/mdtypes/commrec.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/mdatom.h"
 #include "gromacs/pbcutil/pbc.h"
@@ -90,16 +88,12 @@ public:
     std::vector<real> masses_;
     //! Inverse masses
     std::vector<real> invmass_;
-    //! Communication record
-    t_commrec cr_;
     //! Input record (info that usually in .mdp file)
     t_inputrec ir_;
     //! Local topology
     std::unique_ptr<InteractionDefinitions> idef_;
     //! MD atoms
     t_mdatoms md_;
-    //! Multisim data
-    gmx_multisim_t ms_;
     //! Computational time array (normally used to benchmark performance)
     t_nrnb nrnb_;
 
index 243a0200c4cf208b085be0387a96cc7fb66d489c..11a29c483daf076c6b72aba3c0e7ed37fba04494 100644 (file)
@@ -63,6 +63,7 @@
 #include "gromacs/mdlib/constr.h"
 #include "gromacs/mdlib/lincs.h"
 #include "gromacs/mdlib/shake.h"
+#include "gromacs/mdrunutility/multisim.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/mdatom.h"
@@ -114,6 +115,14 @@ void applyLincs(ConstraintsTestData* testData, t_pbc pbc)
     int    warncount_lincs = 0;
     gmx_omp_nthreads_set(emntLINCS, 1);
 
+    // Communication record
+    t_commrec cr;
+    cr.nnodes = 1;
+    cr.dd     = nullptr;
+
+    // Multi-sim record
+    gmx_multisim_t ms;
+
     // Make blocka structure for faster LINCS setup
     std::vector<ListOfLists<int>> at2con_mt;
     at2con_mt.reserve(testData->mtop_.moltype.size());
@@ -126,11 +135,11 @@ void applyLincs(ConstraintsTestData* testData, t_pbc pbc)
     // Initialize LINCS
     lincsd = init_lincs(nullptr, testData->mtop_, testData->nflexcon_, at2con_mt, false,
                         testData->ir_.nLincsIter, testData->ir_.nProjOrder);
-    set_lincs(*testData->idef_, testData->md_, EI_DYNAMICS(testData->ir_.eI), &testData->cr_, lincsd);
+    set_lincs(*testData->idef_, testData->md_, EI_DYNAMICS(testData->ir_.eI), &cr, lincsd);
 
     // Evaluate constraints
     bool success = constrain_lincs(
-            false, testData->ir_, 0, lincsd, testData->md_, &testData->cr_, &testData->ms_,
+            false, testData->ir_, 0, lincsd, testData->md_, &cr, &ms,
             testData->x_.arrayRefWithPadding(), testData->xPrime_.arrayRefWithPadding(),
             testData->xPrime2_.arrayRefWithPadding().unpaddedArrayRef(), pbc.box, &pbc,
             testData->md_.lambda, &testData->dHdLambda_, testData->invdt_,
index df88a1b6e0c4b78dd656e7794251e13a69c73c48..1c3afdd1b00806340efabd4fce0d9a5a80b2e721 100644 (file)
@@ -44,8 +44,6 @@
 
 #include "leapfrogtestrunners.h"
 
-#include "config.h"
-
 #include <assert.h>
 
 #include <cmath>
@@ -66,8 +64,6 @@ namespace gmx
 namespace test
 {
 
-#if GMX_GPU == GMX_GPU_CUDA
-
 void integrateLeapFrogGpu(LeapFrogTestData* testData, int numSteps)
 {
     int numAtoms = testData->numAtoms_;
@@ -114,7 +110,5 @@ void integrateLeapFrogGpu(LeapFrogTestData* testData, int numSteps)
     freeDeviceBuffer(&d_f);
 }
 
-#endif // GMX_GPU == GMX_GPU_CUDA
-
 } // namespace test
 } // namespace gmx
index 7dc3d14faaaab930298b52bd4c7cd2a354e9aeda..e538b8ffeddf3529ba31202757571cc24022d46f 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2016,2017,2019, by the GROMACS development team, led by
+# Copyright (c) 2016,2017,2019,2020, 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.
@@ -36,11 +36,15 @@ gmx_add_unit_test_library(mdrunutility-test-shared
                           threadaffinitytest.cpp)
 
 gmx_add_unit_test(MdrunUtilityUnitTests mdrunutility-test
-                  threadaffinity.cpp)
+    CPP_SOURCE_FILES
+        threadaffinity.cpp
+        )
 target_link_libraries(mdrunutility-test PRIVATE mdrunutility-test-shared)
 
 gmx_add_mpi_unit_test(MdrunUtilityMpiUnitTests mdrunutility-mpi-test 4
-                      threadaffinity_mpi.cpp)
+    CPP_SOURCE_FILES
+        threadaffinity_mpi.cpp
+        )
 # TODO This target does not exist in a non-MPI build. It would be preferable
 # to change functions like gmx_add_mpi_unit_test to add link-time dependencies
 # as well as source files.
index cecf464d0f264821b2113a224565582269e8b572..79e8dc9776474dd51f6a032e066896fe31a0bc41 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2018,2019,2020, 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.
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(MDSpanTests mdspan-test
-                  accessor_policy.cpp
-                  extents.cpp
-                  extensions.cpp
-                  layouts.cpp
-                  mdspan.cpp
-                 )
+    CPP_SOURCE_FILES
+        accessor_policy.cpp
+        extents.cpp
+        extensions.cpp
+        layouts.cpp
+        mdspan.cpp
+        )
index 41dfd64f0473023bfa45cf12f68d9142701edfde..ad53c3b6ddb9fa2528a29c0bc9dd616a86073494 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2014,2015,2016,2019, by the GROMACS development team, led by
+# Copyright (c) 2012,2014,2015,2016,2019,2020, 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.
@@ -36,7 +36,9 @@ gmx_add_unit_test_library(onlinehelp-test-shared
                           mock_helptopic.cpp)
 
 gmx_add_unit_test(OnlineHelpUnitTests onlinehelp-test
-                  helpformat.cpp
-                  helpmanager.cpp
-                  helpwritercontext.cpp)
+    CPP_SOURCE_FILES
+        helpformat.cpp
+        helpmanager.cpp
+        helpwritercontext.cpp
+        )
 target_link_libraries(onlinehelp-test PRIVATE onlinehelp-test-shared)
index e99c2a97750dff81e3e373d85cc5b80eeda24715..398ffa76716367c9cbae82f16f8a3156df9f4405 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2010,2011,2012,2014,2016, by the GROMACS development team, led by
+# Copyright (c) 2010,2011,2012,2014,2016,2020, 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.
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(OptionsUnitTests options-test
-                  abstractoptionstorage.cpp
-                  filenameoption.cpp
-                  filenameoptionmanager.cpp
-                  option.cpp
-                  optionsassigner.cpp
-                  repeatingsection.cpp
-                  timeunitmanager.cpp
-                  treesupport.cpp
-                  )
+    CPP_SOURCE_FILES
+        abstractoptionstorage.cpp
+        filenameoption.cpp
+        filenameoptionmanager.cpp
+        option.cpp
+        optionsassigner.cpp
+        repeatingsection.cpp
+        timeunitmanager.cpp
+        treesupport.cpp
+        )
index 2b9cfd5e66b298f0d10c71e9f060345a96660f2e..c05c9b5b07b88782feab0f8ba2ea4aa355a1761f 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2015,2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2014,2015,2018,2019,2020, 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,6 +33,7 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(PbcutilUnitTest pbcutil-test
-                  pbc.cpp
-                  pbcenums.cpp
-                  )
+    CPP_SOURCE_FILES
+        pbc.cpp
+        pbcenums.cpp
+        )
index 537fbb6220b3a097df10bdafa3e0a7b4e9f7dd72..99e8e7ae7a884e746de5cd9371e0b65718674bbe 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2016, by the GROMACS development team, led by
+# Copyright (c) 2016,2020, 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,5 +33,7 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(PullTest  pull-test
-  pull.cpp)
+    CPP_SOURCE_FILES
+        pull.cpp
+        )
 
index e40918c3479756ee7cfe88e71bbb597193ef58bf..9618198a3e76f7d5d3ded0022ff63d0e2a307030 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2015,2016, by the GROMACS development team, led by
+# Copyright (c) 2014,2015,2016,2020, 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.
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(RandomUnitTests random-test
-                  exponentialdistribution.cpp
-                  gammadistribution.cpp
-                  normaldistribution.cpp
-                  seed.cpp
-                  tabulatednormaldistribution.cpp
-                  threefry.cpp
-                  uniformintdistribution.cpp
-                  uniformrealdistribution.cpp
-                  )
+    CPP_SOURCE_FILES
+        exponentialdistribution.cpp
+        gammadistribution.cpp
+        normaldistribution.cpp
+        seed.cpp
+        tabulatednormaldistribution.cpp
+        threefry.cpp
+        uniformintdistribution.cpp
+        uniformrealdistribution.cpp
+        )
index 3d5a420fd1c5ccc159a6f9eb2b88c082fce1c84b..6f09cf42e6b55265073bcfeb64eb2789d8b4edda 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2018, by the GROMACS development team, led by
+# Copyright (c) 2018,2020, 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,4 +33,6 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(RestraintTests restraintpotential-test
-                  manager.cpp)
+    CPP_SOURCE_FILES
+        manager.cpp
+        )
index 8c9046376b08ef47858920ec5d8650a72d7a3ce1..fb22371e0be04d697ee7fe6d8f7efd1b63c09d9d 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
+# Copyright (c) 2010,2011,2012,2013,2020, 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.
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(SelectionUnitTests selection-test
-                  indexutil.cpp
-                  nbsearch.cpp
-                  poscalc.cpp
-                  selectioncollection.cpp
-                  selectionoption.cpp
-                  toputils.cpp)
+    CPP_SOURCE_FILES
+        indexutil.cpp
+        nbsearch.cpp
+        poscalc.cpp
+        selectioncollection.cpp
+        selectionoption.cpp
+        toputils.cpp
+        )
index 78730cef426b1e024c1308753de44c3b66cfffe9..6f7bea406c8ac459a268e6d9d8b557b642bffa26 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2015,2016,2017,2018, by the GROMACS development team, led by
+# Copyright (c) 2014,2015,2016,2017,2018,2020, 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.
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(SimdUnitTests simd-test
-                  bootstrap_loadstore.cpp
-                 base.cpp
-                  simd.cpp
-                 simd_floatingpoint.cpp
-                  simd_floatingpoint_util.cpp
-                  simd_vector_operations.cpp
-                  simd_math.cpp
-                  simd_memory.cpp
-                 simd_integer.cpp
-                  simd4.cpp
-                  simd4_floatingpoint.cpp
-                  simd4_vector_operations.cpp
-                  simd4_math.cpp
-                  scalar.cpp
-                  scalar_util.cpp
-                  scalar_math.cpp)
+    CPP_SOURCE_FILES
+        base.cpp
+        bootstrap_loadstore.cpp
+        scalar.cpp
+        scalar_util.cpp
+        scalar_math.cpp
+        simd.cpp
+        simd_floatingpoint.cpp
+        simd_floatingpoint_util.cpp
+        simd_integer.cpp
+        simd_math.cpp
+        simd_memory.cpp
+        simd_vector_operations.cpp
+        simd4.cpp
+        simd4_floatingpoint.cpp
+        simd4_math.cpp
+        simd4_vector_operations.cpp
+        )
index c1cd34191ba983fb66c5e618497a2512411a1f7e..d40f412d7c341d36be0a8760da33b1561b716143 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2016, by the GROMACS development team, led by
+# Copyright (c) 2016,2020, 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,5 +33,6 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(TableUnitTests table-test
-                  splinetable.cpp
-                  )
+    CPP_SOURCE_FILES
+        splinetable.cpp
+        )
index 1525d1a761b6f819cfbd29f43a238703c1257b33..13710c2e176ec96050c72d2e140386a6f390cea9 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2017, by the GROMACS development team, led by
+# Copyright (c) 2017,2020, 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,5 +33,6 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(TaskAssignmentUnitTests taskassignment-test
-                  usergpuids.cpp
-                  )
+    CPP_SOURCE_FILES
+        usergpuids.cpp
+        )
index 6796538f7cda0fc23eae5e0988a228af720ae324..54c7c87c0f4c7a733d20cbbf28f61d41f2802caf 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2018,2019,2020, 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,7 +33,9 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(ToolUnitTests tool-test
-                  dump.cpp
-                  report_methods.cpp
-                  trjconv.cpp)
+    CPP_SOURCE_FILES
+        dump.cpp
+        report_methods.cpp
+        trjconv.cpp
+        )
 
index 534a756cc1844021a5a9d273d7f34134d1209a62..ea56790423c4054fa2a1589e701ed823f011637f 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2019, by the GROMACS development team, led by
+# Copyright (c) 2019,2020, 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,7 +33,9 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(TopologyTest topology-test
-  exclusionblocks.cpp
-  mtop.cpp
-  symtab.cpp)
+    CPP_SOURCE_FILES
+        exclusionblocks.cpp
+        mtop.cpp
+        symtab.cpp
+        )
 
index 9a48251b8cf6c4b05dd04d9945c9d28f2b44d84d..d52d2c5c4d0f98d779c872af64fed2aede534e86 100644 (file)
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(TrajectoryAnalysisUnitTests trajectoryanalysis-test
-                  moduletest.cpp
-                  clustsize.cpp
-                  cmdlinerunner.cpp
-                  angle.cpp
-                  convert_trj.cpp
-                  distance.cpp
-                  extract_cluster.cpp
-                  freevolume.cpp
-                  pairdist.cpp
-                  rdf.cpp
-                  sasa.cpp
-                  select.cpp
-                  surfacearea.cpp
-                  topologyinformation.cpp
-                  trajectory.cpp
-                  unionfind.cpp)
+    CPP_SOURCE_FILES
+        # Infrastructure
+        moduletest.cpp
+        # Tests
+        angle.cpp
+        clustsize.cpp
+        cmdlinerunner.cpp
+        convert_trj.cpp
+        distance.cpp
+        extract_cluster.cpp
+        freevolume.cpp
+        pairdist.cpp
+        rdf.cpp
+        sasa.cpp
+        select.cpp
+        surfacearea.cpp
+        topologyinformation.cpp
+        trajectory.cpp
+        unionfind.cpp
+        )
 target_link_libraries(trajectoryanalysis-test PRIVATE analysisdata-test-shared)
 
 add_executable(test_selection ${UNITTEST_TARGET_OPTIONS} test_selection.cpp)
index cbeb92b044da48a0d71050d3d9f6ca0ca7f7ada0..151cfa112c2e76aa84474d819c32999f8df6e6cc 100644 (file)
@@ -34,7 +34,7 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 file(GLOB UTILITY_SOURCES *.cpp)
-if (GMX_GPU AND NOT GMX_USE_OPENCL)
+if (GMX_USE_CUDA)
     gmx_add_libgromacs_sources(cuda_version_information.cu)
 endif()
 set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${UTILITY_SOURCES} PARENT_SCOPE)
index 5c3fb9161434dadcb0c78e3605f73e1447fe8f50..38cc4f5115a4c61515394f7db2238dd200266b3e 100644 (file)
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(UtilityUnitTests utility-test
-                  alignedallocator.cpp
-                  arrayref.cpp
-                  bitmask32.cpp bitmask64.cpp bitmask128.cpp
-                  cstringutil.cpp
-                  defaultinitializationallocator.cpp
-                  enumerationhelpers.cpp
-                  fixedcapacityvector.cpp
-                  inmemoryserializer.cpp
-                  keyvaluetreeserializer.cpp
-                  keyvaluetreetransform.cpp
-                  listoflists.cpp
-                  logger.cpp
-                  mdmodulenotification-impl.cpp
-                  mutex.cpp
-                  path.cpp
-                  physicalnodecommunicator.cpp
-                  stringutil.cpp
-                  textreader.cpp
-                  textwriter.cpp
-                  typetraits.cpp
-                  )
+    CPP_SOURCE_FILES
+        alignedallocator.cpp
+        arrayref.cpp
+        bitmask32.cpp bitmask64.cpp bitmask128.cpp
+        cstringutil.cpp
+        defaultinitializationallocator.cpp
+        enumerationhelpers.cpp
+        fixedcapacityvector.cpp
+        inmemoryserializer.cpp
+        keyvaluetreeserializer.cpp
+        keyvaluetreetransform.cpp
+        listoflists.cpp
+        logger.cpp
+        mdmodulenotification-impl.cpp
+        mutex.cpp
+        path.cpp
+        physicalnodecommunicator.cpp
+        stringutil.cpp
+        textreader.cpp
+        textwriter.cpp
+        typetraits.cpp
+        )
 
 gmx_add_mpi_unit_test(UtilityMpiUnitTests utility-mpi-test 4
-                  physicalnodecommunicator_mpi.cpp
-                  )
+    CPP_SOURCE_FILES
+        physicalnodecommunicator_mpi.cpp
+        )
index aa8d74e9514296d07b36dad2aa17c9b47ec155ce..12d6b2aeafa510dc7a068500110fc3d885fbfa78 100644 (file)
@@ -42,33 +42,34 @@ gmx_add_unit_test_library(mdrun_test_infrastructure
     terminationhelper.cpp
     trajectorycomparison.cpp
     trajectoryreader.cpp
+    # pseudo-library for code for mdrun
+    $<TARGET_OBJECTS:mdrun_objlib>
     )
 target_include_directories(mdrun_test_infrastructure SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/external)
 
 set(testname "MdrunTests")
 set(exename "mdrun-test")
 
-gmx_add_gtest_executable(
-    ${exename}
-    # files with code for tests
-    compressed_x_output.cpp
-    densityfittingmodule.cpp
-    exactcontinuation.cpp
-    grompp.cpp
-    helpwriting.cpp
-    initialconstraints.cpp
-    interactiveMD.cpp
-    outputfiles.cpp
-    orires.cpp
-    pmetest.cpp
-    simulator.cpp
-    swapcoords.cpp
-    tabulated_bonded_interactions.cpp
-    termination.cpp
-    trajectory_writing.cpp
-    mimic.cpp
-    # pseudo-library for code for mdrun
-    $<TARGET_OBJECTS:mdrun_objlib>
+gmx_add_gtest_executable(${exename}
+    CPP_SOURCE_FILES
+        compressed_x_output.cpp
+        densityfittingmodule.cpp
+        exactcontinuation.cpp
+        grompp.cpp
+        helpwriting.cpp
+        initialconstraints.cpp
+        interactiveMD.cpp
+        orires.cpp
+        outputfiles.cpp
+        pmetest.cpp
+        simulator.cpp
+        swapcoords.cpp
+        tabulated_bonded_interactions.cpp
+        termination.cpp
+        trajectory_writing.cpp
+        mimic.cpp
+        # pseudo-library for code for mdrun
+        $<TARGET_OBJECTS:mdrun_objlib>
     )
 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST)
@@ -79,17 +80,17 @@ gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST
 set(testname "MdrunNonIntegratorTests")
 set(exename "mdrun-non-integrator-test")
 
-gmx_add_gtest_executable(
-    ${exename}
-    # files with code for tests
-    minimize.cpp
-    nonbonded_bench.cpp
-    normalmodes.cpp
-    rerun.cpp
-    simple_mdrun.cpp
-    # pseudo-library for code for mdrun
-    $<TARGET_OBJECTS:mdrun_objlib>
-    )
+gmx_add_gtest_executable(${exename}
+    CPP_SOURCE_FILES
+        # files with code for tests
+        minimize.cpp
+        nonbonded_bench.cpp
+        normalmodes.cpp
+        rerun.cpp
+        simple_mdrun.cpp
+        # pseudo-library for code for mdrun
+        $<TARGET_OBJECTS:mdrun_objlib>
+        )
 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST)
 
@@ -97,13 +98,13 @@ gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST
 set(testname "MdrunTpiTests")
 set(exename "mdrun-tpi-test")
 
-gmx_add_gtest_executable(
-    ${exename}
-    # files with code for tests
-    tpitest.cpp
-    # pseudo-library for code for mdrun
-    $<TARGET_OBJECTS:mdrun_objlib>
-    )
+gmx_add_gtest_executable(${exename}
+    CPP_SOURCE_FILES
+        # files with code for tests
+        tpitest.cpp
+        # pseudo-library for code for mdrun
+        $<TARGET_OBJECTS:mdrun_objlib>
+        )
 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
 gmx_register_gtest_test(${testname} ${exename} INTEGRATION_TEST)
 
@@ -112,31 +113,31 @@ gmx_register_gtest_test(${testname} ${exename} INTEGRATION_TEST)
 set(testname "MdrunMpiTests")
 set(exename "mdrun-mpi-test")
 
-gmx_add_gtest_executable(
-    ${exename} MPI
-    # files with code for tests
-    domain_decomposition.cpp
-    minimize.cpp
-    mimic.cpp
-    multisim.cpp
-    multisimtest.cpp
-    pmetest.cpp
-    replicaexchange.cpp
-    # pseudo-library for code for mdrun
-    $<TARGET_OBJECTS:mdrun_objlib>
-    )
+gmx_add_gtest_executable(${exename} MPI
+    CPP_SOURCE_FILES
+        # files with code for tests
+        domain_decomposition.cpp
+        minimize.cpp
+        mimic.cpp
+        multisim.cpp
+        multisimtest.cpp
+        pmetest.cpp
+        replicaexchange.cpp
+        # pseudo-library for code for mdrun
+        $<TARGET_OBJECTS:mdrun_objlib>
+        )
 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
 gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST)
 
 # Slow-running tests that target testing multiple-rank coordination behaviors
 set(exename "mdrun-mpi-coordination-test")
-gmx_add_gtest_executable(
-    ${exename} MPI
-    # files with code for tests
-    periodicactions.cpp
-    # pseudo-library for code for mdrun
-    $<TARGET_OBJECTS:mdrun_objlib>
-    )
+gmx_add_gtest_executable(${exename} MPI
+    CPP_SOURCE_FILES
+        # files with code for tests
+        periodicactions.cpp
+        # pseudo-library for code for mdrun
+        $<TARGET_OBJECTS:mdrun_objlib>
+        )
 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
 
 # These tests are extremely slow without optimization or OpenMP, so only run them for
index 14fb7433129ea73fc9747ac71a71346bf03b92ec..de1bd9720ed2231e45bd4b7f0ce1ce2eda3f7d46 100644 (file)
@@ -34,6 +34,7 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 include(CMakeParseArguments)
+include(gmxClangCudaUtils)
 
 function (gmx_add_unit_test_library NAME)
     if (GMX_BUILD_UNITTESTS AND BUILD_TESTING)
@@ -45,11 +46,41 @@ function (gmx_add_unit_test_library NAME)
     endif()
 endfunction ()
 
+# This function creates a GoogleTest test executable for a module.  It
+# hides all the complexity of how to treat different source files
+# under different configuration conditions. It should be extended
+# if we ever support another GPU compilation approach.
+#
+# It can be called with extra options and arguments:
+#   MPI
+#     To trigger the ctest runner to run this test with multiple ranks
+#   HARDWARE_DETECTION
+#     To trigger the test executable setup code to run hardware detection
+#   CPP_SOURCE_FILES          file1.cpp file2.cpp ...
+#     All the normal C++ .cpp source files
+#   GPU_CPP_SOURCE_FILES  file1.cpp file2.cpp ...
+#     All the C++ .cpp source files that are always needed, but must be
+#     compiled in the way that suits GMX_GPU.
+#   CUDA_CU_SOURCE_FILES      file1.cu  file2.cu  ...
+#     All the normal CUDA .cu source files
+#   CUDA_CPP_SOURCE_FILES     file1.cpp file2.cpp ...
+#     All the other .cpp source files to be compiled as CUDA
+#   OPENCL_CPP_SOURCE_FILES   file1.cpp file2.cpp ...
+#     All the other C++ .cpp source files needed only with OpenCL
+#   NON_GPU_CPP_SOURCE_FILES  file1.cpp file2.cpp ...
+#     All the other C++ .cpp source files needed only with neither OpenCL nor CUDA
 function (gmx_add_gtest_executable EXENAME)
     if (GMX_BUILD_UNITTESTS AND BUILD_TESTING)
         set(_options MPI HARDWARE_DETECTION)
-        cmake_parse_arguments(ARG "${_options}" "" "" ${ARGN})
-        set(_source_files ${ARG_UNPARSED_ARGUMENTS})
+        set(_multi_value_keywords
+            CPP_SOURCE_FILES
+            CUDA_CU_SOURCE_FILES
+            GPU_CPP_SOURCE_FILES
+            CUDA_CPP_SOURCE_FILES
+            OPENCL_CPP_SOURCE_FILES
+            NON_GPU_CPP_SOURCE_FILES
+            )
+        cmake_parse_arguments(ARG "${_options}" "" "${_multi_value_keywords}" ${ARGN})
 
         file(RELATIVE_PATH _input_files_path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
         set(_temporary_files_path "${CMAKE_CURRENT_BINARY_DIR}/Testing/Temporary")
@@ -73,8 +104,43 @@ function (gmx_add_gtest_executable EXENAME)
                  TEST_USES_HARDWARE_DETECTION=true)
         endif()
 
-        add_executable(${EXENAME} ${UNITTEST_TARGET_OPTIONS}
-            ${_source_files} ${TESTUTILS_DIR}/unittest_main.cpp)
+        if (GMX_USE_CUDA AND NOT GMX_CLANG_CUDA)
+            # Work around FindCUDA that prevents using target_link_libraries()
+            # with keywords otherwise...
+            set(CUDA_LIBRARIES PRIVATE ${CUDA_LIBRARIES})
+            cuda_add_executable(${EXENAME} ${UNITTEST_TARGET_OPTIONS}
+                ${ARG_CPP_SOURCE_FILES}
+                ${ARG_CUDA_CU_SOURCE_FILES}
+                ${ARG_CUDA_CPP_SOURCE_FILES}
+                ${ARG_GPU_CPP_SOURCE_FILES}
+                ${TESTUTILS_DIR}/unittest_main.cpp)
+        else()
+            add_executable(${EXENAME} ${UNITTEST_TARGET_OPTIONS}
+                ${ARG_CPP_SOURCE_FILES}
+                ${TESTUTILS_DIR}/unittest_main.cpp)
+        endif()
+
+        if (GMX_USE_CUDA)
+            if (GMX_CLANG_CUDA)
+                target_sources(${EXENAME} PRIVATE
+                    ${ARG_CUDA_CU_SOURCE_FILES}
+                    ${ARG_CUDA_CPP_SOURCE_FILES}
+                    ${ARG_GPU_CPP_SOURCE_FILES})
+                set_source_files_properties(${ARG_CUDA_CPP_SOURCE_FILES} ${ARG_GPU_CPP_SOURCE_FILES} PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ)
+                gmx_compile_cuda_file_with_clang(${ARG_CUDA_CU_SOURCE_FILES})
+                if(ARG_CUDA_CPP_SOURCE_FILES OR ARG_CUDA_CU_SOURCE_FILES OR ARG_GPU_CPP_SOURCE_FILES)
+                    target_link_libraries(${EXENAME} PRIVATE ${GMX_EXTRA_LIBRARIES})
+                endif()
+            endif()
+        elseif (GMX_USE_OPENCL)
+            target_sources(${EXENAME} PRIVATE ${ARG_OPENCL_CPP_SOURCE_FILES} ${ARG_GPU_CPP_SOURCE_FILES})
+            if(ARG_OPENCL_CPP_SOURCE_FILES OR ARG_GPU_CPP_SOURCE_FILES)
+                target_link_libraries(${EXENAME} PRIVATE ${OpenCL_LIBRARIES})
+            endif()
+        else()
+            target_sources(${EXENAME} PRIVATE ${ARG_NON_GPU_CPP_SOURCE_FILES} ${ARG_GPU_CPP_SOURCE_FILES})
+        endif()
+
         gmx_target_compile_options(${EXENAME})
         target_compile_definitions(${EXENAME} PRIVATE HAVE_CONFIG_H ${EXTRA_COMPILE_DEFINITIONS})
         target_include_directories(${EXENAME} SYSTEM BEFORE PRIVATE ${PROJECT_SOURCE_DIR}/src/external/thread_mpi/include)
index 3070802cbf1f6398423ba507ab41f43d4a575b9a..7a6d651ab43e09df488764b9644772482ae9d6b7 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2011,2012,2014,2015,2016, by the GROMACS development team, led by
+# Copyright (c) 2011,2012,2014,2015,2016,2020, 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.
 # the research papers on the package. Check out http://www.gromacs.org.
 
 gmx_add_unit_test(TestUtilsUnitTests testutils-test
-                  interactivetest.cpp
-                  refdata_tests.cpp
-                  testasserts_tests.cpp
-                  xvgtest_tests.cpp)
+    CPP_SOURCE_FILES
+        interactivetest.cpp
+        refdata_tests.cpp
+        testasserts_tests.cpp
+        xvgtest_tests.cpp
+        )
 
 gmx_add_mpi_unit_test(TestUtilsMpiUnitTests testutils-mpi-test 2
-                      mpitest.cpp)
+    CPP_SOURCE_FILES
+        mpitest.cpp
+        )