Simplified uniform GPU selection in CMake
authorErik Lindahl <erik.lindahl@gmail.com>
Tue, 4 Aug 2020 19:27:21 +0000 (19:27 +0000)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 4 Aug 2020 19:27:21 +0000 (19:27 +0000)
GPU selection is now done by setting GMX_GPU to either CUDA
or OpenCL, with no other variables required. As part of the
overall CMake simplification, the CMake automatic detection
of hardware and "auto" settings for GPU acceleration have
been removed. This will require the user to explicitly enable
GPU support (which is a drawback), but it leads to much
simplier and shorter CMake code, similar support for CUDA and
OpenCL, and it will make it easier to handle multiple different
APIs targeting e.g. NVIDIA GPU hardware in the near future.

76 files changed:
CMakeLists.txt
admin/gitlab-ci/documentation.gitlab-ci.yml
admin/gitlab-ci/gromacs.gitlab-ci.yml
cmake/gmxManageCuda.cmake
cmake/gmxManageOpenCL.cmake
src/CMakeLists.txt
src/api/cpp/tests/CMakeLists.txt
src/config.h.cmakein
src/gromacs/CMakeLists.txt
src/gromacs/domdec/CMakeLists.txt
src/gromacs/domdec/gpuhaloexchange_impl.cpp
src/gromacs/ewald/CMakeLists.txt
src/gromacs/ewald/pme.cpp
src/gromacs/ewald/pme_coordinate_receiver_gpu_impl.cpp
src/gromacs/ewald/pme_force_sender_gpu_impl.cpp
src/gromacs/ewald/pme_gpu.cpp
src/gromacs/ewald/pme_gpu_3dfft.h
src/gromacs/ewald/pme_gpu_constants.h
src/gromacs/ewald/pme_gpu_internal.cpp
src/gromacs/ewald/pme_gpu_program_impl.h
src/gromacs/ewald/pme_gpu_types_host.h
src/gromacs/ewald/pme_gpu_types_host_impl.h
src/gromacs/ewald/pme_only.cpp
src/gromacs/ewald/pme_pp_comm_gpu_impl.cpp
src/gromacs/fft/fft5d.cpp
src/gromacs/gpu_utils/CMakeLists.txt
src/gromacs/gpu_utils/clfftinitializer.cpp
src/gromacs/gpu_utils/device_context.h
src/gromacs/gpu_utils/device_context_ocl.cpp
src/gromacs/gpu_utils/device_context_ocl.h
src/gromacs/gpu_utils/device_stream.h
src/gromacs/gpu_utils/devicebuffer.h
src/gromacs/gpu_utils/devicebuffer_datatype.h
src/gromacs/gpu_utils/gpu_macros.h
src/gromacs/gpu_utils/gpu_utils.cpp
src/gromacs/gpu_utils/gputraits.h
src/gromacs/gpu_utils/tests/device_stream_manager.cpp
src/gromacs/gpu_utils/tests/hostallocator.cpp
src/gromacs/gpu_utils/tests/typecasts_runner.cpp
src/gromacs/gpu_utils/tests/typecasts_runner.cu
src/gromacs/hardware/detecthardware.cpp
src/gromacs/hardware/printhardware.cpp
src/gromacs/listed_forces/CMakeLists.txt
src/gromacs/listed_forces/gpubonded_impl.cpp
src/gromacs/mdlib/CMakeLists.txt
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdlib/tests/constr.cpp
src/gromacs/mdlib/tests/constrtestrunners.cpp
src/gromacs/mdlib/tests/leapfrog.cpp
src/gromacs/mdlib/tests/leapfrogtestrunners.cpp
src/gromacs/mdlib/tests/settle.cpp
src/gromacs/mdlib/tests/settletestrunners.cpp
src/gromacs/mdlib/tests/settletestrunners.cu
src/gromacs/mdlib/update_constrain_gpu_impl.cpp
src/gromacs/mdlib/vsite.cpp
src/gromacs/mdrun/runner.cpp
src/gromacs/mdtypes/CMakeLists.txt
src/gromacs/mdtypes/state_propagator_data_gpu_impl.cpp
src/gromacs/mdtypes/state_propagator_data_gpu_impl.h
src/gromacs/mdtypes/state_propagator_data_gpu_impl_gpu.cpp
src/gromacs/nbnxm/CMakeLists.txt
src/gromacs/nbnxm/cuda/CMakeLists.txt
src/gromacs/nbnxm/gpu_common.h
src/gromacs/nbnxm/gpu_common_utils.h
src/gromacs/nbnxm/gpu_types_common.h
src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp
src/gromacs/nbnxm/opencl/CMakeLists.txt
src/gromacs/nbnxm/pairlistparams.h
src/gromacs/taskassignment/decidegpuusage.cpp
src/gromacs/utility/CMakeLists.txt
src/gromacs/utility/binaryinformation.cpp
src/programs/mdrun/tests/exactcontinuation.cpp
src/programs/mdrun/tests/periodicactions.cpp
src/programs/mdrun/tests/rerun.cpp
src/programs/mdrun/tests/simulator.cpp
src/testutils/TestMacros.cmake

index cbc6a16be48a01e28662ca701923c0f971cc38a0..94afc5a6f6c664cf3e4cc1224bae9641175e7dd0 100644 (file)
@@ -204,8 +204,8 @@ option(GMX_INSTALL_LEGACY_API "Install legacy headers" OFF)
 gmx_option_multichoice(
     GMX_GPU
     "Framework for GPU acceleration"
-    None
-    None CUDA OpenCL)
+    OFF
+    OFF CUDA OpenCL)
 
 gmx_option_multichoice(
     GMX_SIMD
@@ -568,9 +568,9 @@ include(gmxManageTNG)
 
 include(gmxManageLmfit)
 
-string(TOUPPER "${GMX_GPU}" _gmx_gpu_uppercase)
-if(NOT ${_gmx_gpu_uppercase} STREQUAL "NONE")
+if(GMX_GPU)
 
+    string(TOUPPER "${GMX_GPU}" _gmx_gpu_uppercase)
     if(${_gmx_gpu_uppercase} STREQUAL "CUDA")
         include(gmxManageCuda)
     elseif(${_gmx_gpu_uppercase} STREQUAL "OPENCL")
@@ -582,10 +582,6 @@ if(NOT ${_gmx_gpu_uppercase} STREQUAL "NONE")
 
 endif()
 
-# Not ideal to set this without the GPU acceleration, but the source presently requires GMX_GPU
-# to be set to GMX_GPU_None for a non-GPU build to work.
-set(GMX_GPU_ACCELERATION_FRAMEWORK "GMX_GPU_${_gmx_gpu_uppercase}")
-
 if(CYGWIN)
     set(GMX_CYGWIN 1)
 endif()
index 4087a7c8cb5a891574504e3f5fc52b994c918848..15dede0c5e1795eea7234ed7e4a854992c4a3d5d 100644 (file)
@@ -19,7 +19,7 @@
     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=OFF"
     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug"
-    CMAKE_GPU_OPTIONS: "-DGMX_GPU=None"
+    CMAKE_GPU_OPTIONS: "-DGMX_GPU=OFF"
     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=ON"
   script:
     - if [[ ! -z $GROMACS_RELEASE && $GROMACS_RELEASE == "true" ]] ; then
@@ -86,7 +86,7 @@
     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=ON"
     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug"
-    CMAKE_GPU_OPTIONS: "-DGMX_GPU=None"
+    CMAKE_GPU_OPTIONS: "-DGMX_GPU=OFF"
     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=ON"
     RELEASE_BUILD_DIR: release-doc-builds
     RELEASE_SOURCE: release-source-from-tarball
index 84f1008ce3d6f971c0f5c553d7283d87663363a4..4c38a6f15dca829fbb4b75caaae75f48b2546b72 100644 (file)
@@ -17,7 +17,7 @@ simple-build:
     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=ON"
     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug"
-    CMAKE_GPU_OPTIONS: "-DGMX_GPU=None"
+    CMAKE_GPU_OPTIONS: "-DGMX_GPU=OFF"
     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=OFF"
     COMPILER_MAJOR_VERSION: 9
     BUILD_DIR: simple-build
@@ -93,7 +93,7 @@ simple-build:
     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=ON"
     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=Debug"
-    CMAKE_GPU_OPTIONS: "-DGMX_GPU=None"
+    CMAKE_GPU_OPTIONS: "-DGMX_GPU=OFF"
   script:
     - echo $CMAKE_COMPILER_SCRIPT
     - echo $CMAKE_EXTRA_OPTIONS
@@ -145,7 +145,7 @@ simple-build:
     CMAKE_MPI_OPTIONS: "-DGMX_THREAD_MPI=ON"
     CMAKE_PRECISION_OPTIONS: "-DGMX_DOUBLE=OFF"
     CMAKE_BUILD_TYPE_OPTIONS: "-DCMAKE_BUILD_TYPE=RelWithAssert"
-    CMAKE_GPU_OPTIONS: "-DGMX_GPU=None"
+    CMAKE_GPU_OPTIONS: "-DGMX_GPU=OFF"
     CMAKE_REGRESSIONTEST_OPTIONS: "-DREGRESSIONTEST_PATH=../\\$RELEASE_REGRESSIONTESTS"
     RELEASE_BUILD_DIR: release-builds
     RELEASE_SOURCE: release-source-from-tarball
index 6d90f0e2e54e6c67ead7428bfeff54527f21d648..96aaa27c4e6454a3b5be6f2ff957fa63cb556efa 100644 (file)
@@ -38,7 +38,7 @@
 set(REQUIRED_CUDA_VERSION 9.0)
 set(REQUIRED_CUDA_COMPUTE_CAPABILITY 3.0)
 
-set(GMX_USE_CUDA ON)
+set(GMX_GPU_CUDA ON)
 
 option(GMX_CLANG_CUDA "Use clang for CUDA" OFF)
 
index 402ecacb455ecf21673b692448581e2d44c87f8a..3f849e9e2893d2fb63ac116ee316a7e7a210631f 100644 (file)
@@ -38,7 +38,7 @@ set(REQUIRED_OPENCL_MIN_VERSION_MAJOR 1)
 set(REQUIRED_OPENCL_MIN_VERSION_MINOR 2)
 set(REQUIRED_OPENCL_MIN_VERSION ${REQUIRED_OPENCL_MIN_VERSION_MAJOR}.${REQUIRED_OPENCL_MIN_VERSION_MINOR})
 
-set(GMX_USE_OPENCL ON)
+set(GMX_GPU_OPENCL ON)
 
 if(GMX_DOUBLE)
     message(FATAL_ERROR "OpenCL acceleration is not available in double precision")
index 8c7107072d8429bae262c9e975d5bea2043b96a4..e05d603e4940c77f35b545daf24d07095d6c1817 100644 (file)
@@ -40,7 +40,7 @@
 include(GetCompilerInfo.cmake)
 get_compiler_info(C BUILD_C_COMPILER)
 get_compiler_info(CXX BUILD_CXX_COMPILER)
-if(GMX_USE_CUDA)
+if(GMX_GPU_CUDA)
     if(NOT GMX_CLANG_CUDA)
         GMX_SET_CUDA_NVCC_FLAGS()
     endif()
index e7c6498c0dc05e82afed96bafd27b1d9e0f17d47..e674ac44e62f765512797c05e21648084bde5382 100644 (file)
@@ -60,7 +60,7 @@ gmx_add_gtest_executable(gmxapi-test
         # pseudo-library for code for mdrun
         $<TARGET_OBJECTS:mdrun_objlib>
         )
-if(NOT GMX_USE_OPENCL)
+if(NOT GMX_GPU_OPENCL)
     # GPU resources may not be properly reinitialized between simulations in
     # the same process.
     # TODO: include this with the other test sources once the issue is resolved
@@ -89,7 +89,7 @@ gmx_add_gtest_executable(gmxapi-mpi-test MPI
         # pseudo-library for code for mdrun
         $<TARGET_OBJECTS:mdrun_objlib>
         )
-if(NOT GMX_USE_OPENCL)
+if(NOT GMX_GPU_OPENCL)
     # GPU resources may not be properly reinitialized between simulations in
     # the same process.
     # TODO: include this with the other test sources once the issue is resolved
index 524ff47a535cfa47f62132d3e8e7caf30d035788..32e7026306a7c4bc3e51f813fe75781031435577 100644 (file)
 /* Enable x86 gcc inline assembly */
 #cmakedefine01 GMX_X86_GCC_INLINE_ASM
 
-/* Define constants useful for handling GPU support */
-#define GMX_GPU_NONE   0
-#define GMX_GPU_CUDA   1
-#define GMX_GPU_OPENCL 2
-/* Which kind of GPU support is configured */
-#define GMX_GPU @GMX_GPU_ACCELERATION_FRAMEWORK@
+/* Define if any type of GPU acceleration is compiled */
+#cmakedefine01 GMX_GPU
+
+/* Define if CUDA GPU acceleration is compiled */
+#cmakedefine01 GMX_GPU_CUDA
+
+/* Define if OpenCL GPU acceleration is compiled */
+#cmakedefine01 GMX_GPU_OPENCL
 
 /* Use a single compilation unit when compiling the CUDA (non-bonded) kernels.  */
 #cmakedefine01 GMX_CUDA_NB_SINGLE_COMPILATION_UNIT
index caa8d41d82367a157168befc677a3db86d04da1d..3416b466805d64c36d78753c147c740d156c78a5 100644 (file)
@@ -167,7 +167,7 @@ gmx_configure_version_file(
 list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
 
 # Mark some shared GPU implementation files to compile with CUDA if needed
-if (GMX_USE_CUDA)
+if (GMX_GPU_CUDA)
     get_property(LIBGROMACS_GPU_IMPL_SOURCES GLOBAL PROPERTY GMX_LIBGROMACS_GPU_IMPL_SOURCES)
     set_source_files_properties(${LIBGROMACS_GPU_IMPL_SOURCES} PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ)
 endif()
@@ -183,7 +183,7 @@ if (GMX_CLANG_CUDA)
     endforeach()
 endif()
 
-if (GMX_USE_CUDA)
+if (GMX_GPU_CUDA)
     # Work around FindCUDA that prevents using target_link_libraries()
     # with keywords otherwise...
     set(CUDA_LIBRARIES PRIVATE ${CUDA_LIBRARIES})
@@ -222,7 +222,7 @@ gmx_target_compile_options(libgromacs)
 target_compile_definitions(libgromacs PRIVATE HAVE_CONFIG_H)
 target_include_directories(libgromacs SYSTEM BEFORE PRIVATE ${PROJECT_SOURCE_DIR}/src/external/thread_mpi/include)
 
-if (GMX_USE_OPENCL)
+if (GMX_GPU_OPENCL)
     option(GMX_EXTERNAL_CLFFT "True if an external clFFT is required to be used" FALSE)
     mark_as_advanced(GMX_EXTERNAL_CLFFT)
 
@@ -381,7 +381,7 @@ endif()
 # using the CUDA runtime, but currently there's no reason to want to
 # do that.
 if (INSTALL_CUDART_LIB) #can be set manual by user
-    if (GMX_USE_CUDA)
+    if (GMX_GPU_CUDA)
         foreach(CUDA_LIB ${CUDA_LIBRARIES})
             string(REGEX MATCH "cudart" IS_CUDART ${CUDA_LIB})
             if(IS_CUDART) #libcuda should not be installed
@@ -396,7 +396,7 @@ if (INSTALL_CUDART_LIB) #can be set manual by user
     endif()
 endif()
 
-if(GMX_USE_OPENCL)
+if(GMX_GPU_OPENCL)
     # Install the utility headers
     file(GLOB OPENCL_INSTALLED_FILES
         gpu_utils/vectype_ops.clh
index c4fca1e308a2c540ee356a939067a407ad91d719..d57300371103bb1f17b690a93ac1716f31560432 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2014,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.
@@ -34,7 +34,7 @@
 
 file(GLOB DOMDEC_SOURCES *.cpp)
 
-if(GMX_USE_CUDA)
+if(GMX_GPU_CUDA)
   file(GLOB DOMDEC_CUDA_SOURCES gpuhaloexchange_impl.cu)
 endif()
 
index 247c65b4e03959d02b4be10e3124d92a477b1f56..a6a0915fc789fcd26ea847971a201bcf060e7e88 100644 (file)
@@ -49,7 +49,7 @@
 
 #include "gromacs/domdec/gpuhaloexchange.h"
 
-#if GMX_GPU != GMX_GPU_CUDA
+#if !GMX_GPU_CUDA
 
 namespace gmx
 {
@@ -109,4 +109,4 @@ GpuEventSynchronizer* GpuHaloExchange::getForcesReadyOnDeviceEvent()
 
 } // namespace gmx
 
-#endif /* GMX_GPU != GMX_GPU_CUDA */
+#endif // !GMX_GPU_CUDA
index 15bd872bf43db48e9def322d9a9e1f8c39375d56..52c57a9a76043f3b33139d673bdf46b57d0475d6 100644 (file)
@@ -54,7 +54,7 @@ gmx_add_libgromacs_sources(
     pme_coordinate_receiver_gpu_impl.cpp
     pme_force_sender_gpu_impl.cpp
     )
-if (GMX_USE_CUDA)
+if (GMX_GPU_CUDA)
     gmx_add_libgromacs_sources(
         # CUDA-specific sources
         pme_gather.cu
@@ -70,7 +70,7 @@ if (GMX_USE_CUDA)
         pme_gpu_internal.cpp
         pme_gpu_timings.cpp
         )
-elseif (GMX_USE_OPENCL)
+elseif (GMX_GPU_OPENCL)
     gmx_add_libgromacs_sources(
         # OpenCL-specific sources
         pme_gpu_3dfft_ocl.cpp
index f26c2f6fe3bfac37e1bdecba86a0a874deb22a28..403ea96095cd975f6ef1a666e28980394079ba03 100644 (file)
@@ -159,7 +159,7 @@ bool pme_gpu_supports_build(std::string* error)
     {
         errorReasons.emplace_back("a double-precision build");
     }
-    if (GMX_GPU == GMX_GPU_NONE)
+    if (!GMX_GPU)
     {
         errorReasons.emplace_back("a non-GPU build");
     }
@@ -170,7 +170,7 @@ bool pme_gpu_supports_hardware(const gmx_hw_info_t gmx_unused& hwinfo, std::stri
 {
     std::list<std::string> errorReasons;
 
-    if (GMX_GPU == GMX_GPU_OPENCL)
+    if (GMX_GPU_OPENCL)
     {
 #ifdef __APPLE__
         errorReasons.emplace_back("Apple OS X operating system");
@@ -231,7 +231,7 @@ static bool pme_gpu_check_restrictions(const gmx_pme_t* pme, std::string* error)
     {
         errorReasons.emplace_back("double precision");
     }
-    if (GMX_GPU == GMX_GPU_NONE)
+    if (!GMX_GPU)
     {
         errorReasons.emplace_back("non-GPU build of GROMACS");
     }
index e377cb87313cb65f0e1189ff4d98babdad11d792..be4cf2a16acb58f9945a184020b31572e6201e92 100644 (file)
 #include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/gmxassert.h"
 
-#if GMX_GPU != GMX_GPU_CUDA
+#if !GMX_GPU_CUDA
 
 namespace gmx
 {
 
-/*!\brief Impl class stub. */
+/*!\brief \internal Impl class stub. */
 class PmeCoordinateReceiverGpu::Impl
 {
 };
@@ -98,4 +98,4 @@ void PmeCoordinateReceiverGpu::enqueueWaitReceiveCoordinatesFromPpCudaDirect()
 
 } // namespace gmx
 
-#endif /* GMX_GPU != GMX_GPU_CUDA */
+#endif // !GMX_GPU_CUDA
index aa046ee718d307236bbef46d82f3082284122baa..9a05facec46fe6ad4a4e709b7020cf6a521a057f 100644 (file)
 #include "gromacs/ewald/pme_force_sender_gpu.h"
 #include "gromacs/utility/arrayref.h"
 
-#if GMX_GPU != GMX_GPU_CUDA
+#if !GMX_GPU_CUDA
 
 namespace gmx
 {
 
-/*!\brief Impl class stub. */
+/*!\brief \internal Impl class stub. */
 class PmeForceSenderGpu::Impl
 {
 };
@@ -90,4 +90,4 @@ void PmeForceSenderGpu::sendFToPpCudaDirect(int /* ppRank */)
 
 } // namespace gmx
 
-#endif /* GMX_GPU != GMX_GPU_CUDA */
+#endif // !GMX_GPU_CUDA
index bcac411467a5dca9f9be50875c3890ca6fb7556f..19215fa90fff848956a4cd0e8c562f43a54bf65b 100644 (file)
@@ -195,7 +195,7 @@ void pme_gpu_launch_spread(gmx_pme_t*            pme,
                            const real            lambdaQ)
 {
     GMX_ASSERT(pme_gpu_active(pme), "This should be a GPU run of PME but it is not enabled.");
-    GMX_ASSERT(xReadyOnDevice || !pme->bPPnode || (GMX_GPU != GMX_GPU_CUDA),
+    GMX_ASSERT(!GMX_GPU_CUDA || xReadyOnDevice || !pme->bPPnode,
                "Need a valid xReadyOnDevice on PP+PME ranks with CUDA.");
     GMX_ASSERT(pme->doCoulomb, "Only Coulomb PME can be run on GPU.");
 
@@ -344,7 +344,8 @@ bool pme_gpu_try_finish_task(gmx_pme_t*               pme,
     // time needed for that checking, but do not yet record that the
     // gather has occured.
     bool           needToSynchronize      = true;
-    constexpr bool c_streamQuerySupported = (GMX_GPU == GMX_GPU_CUDA);
+    constexpr bool c_streamQuerySupported = bool(GMX_GPU_CUDA);
+
     // TODO: implement c_streamQuerySupported with an additional GpuEventSynchronizer per stream (#2521)
     if ((completionKind == GpuTaskCompletion::Check) && c_streamQuerySupported)
     {
index 96cfa9ed6aeeb845aa9b23cf9f74aaa94e233f7c..c334d013e3abdc513750fadcba3b3e30ff422bcb 100644 (file)
 
 #include <vector>
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include <cufft.h>
 
 #    include "gromacs/gpu_utils/gputraits.cuh"
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
 #    include <clFFT.h>
 
 #    include "gromacs/gpu_utils/gmxopencl.h"
@@ -86,12 +86,12 @@ public:
     void perform3dFft(gmx_fft_direction dir, CommandEvent* timingEvent);
 
 private:
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
     cufftHandle   planR2C_;
     cufftHandle   planC2R_;
     cufftReal*    realGrid_;
     cufftComplex* complexGrid_;
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
     clfftPlanHandle               planR2C_;
     clfftPlanHandle               planC2R_;
     std::vector<cl_command_queue> deviceStreams_;
index 5bfe1c3ddef33bc72622e297d4505cbeb56a94b3..d2503cb948ab84e6e8d13badf25a122544c48797 100644 (file)
@@ -53,7 +53,7 @@
 
 #include "config.h"
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include "gromacs/gpu_utils/cuda_arch_utils.cuh" // for warp_size
 #endif
 
@@ -143,7 +143,7 @@ constexpr int c_solveMaxWarpsPerBlock = 8;
 //! Gathering max block width in warps - picked empirically among 2, 4, 8, 16 for max. occupancy and min. runtime
 constexpr int c_gatherMaxWarpsPerBlock = 4;
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 /* All the fields below are dependent on warp_size and should
  * ideally be removed from the device-side code, as we have to
  * do that for OpenCL already.
@@ -164,6 +164,6 @@ static constexpr int c_gatherMaxThreadsPerBlock = c_gatherMaxWarpsPerBlock * war
 //! Gathering min blocks per CUDA multiprocessor
 static constexpr int c_gatherMinBlocksPerMP = GMX_CUDA_MAX_THREADS_PER_MP / c_gatherMaxThreadsPerBlock;
 
-#endif // GMX_GPU == GMX_GPU_CUDA
+#endif // GMX_GPU_CUDA
 
 #endif
index 635f0f1a62130fafa5b9aed31c2a0844d20d48f5..24e9a4ba4be122b5413bc314e300f72a90f2f586 100644 (file)
 #include "gromacs/utility/logger.h"
 #include "gromacs/utility/stringutil.h"
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include "gromacs/gpu_utils/pmalloc_cuda.h"
 
 #    include "pme.cuh"
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
 #    include "gromacs/gpu_utils/gmxopencl.h"
 #endif
 
@@ -421,12 +421,12 @@ void pme_gpu_realloc_and_copy_fract_shifts(PmeGpu* pmeGpu)
 void pme_gpu_free_fract_shifts(const PmeGpu* pmeGpu)
 {
     auto* kernelParamsPtr = pmeGpu->kernelParams.get();
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
     destroyParamLookupTable(&kernelParamsPtr->grid.d_fractShiftsTable,
                             kernelParamsPtr->fractShiftsTableTexture);
     destroyParamLookupTable(&kernelParamsPtr->grid.d_gridlineIndicesTable,
                             kernelParamsPtr->gridlineIndicesTableTexture);
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
     freeDeviceBuffer(&kernelParamsPtr->grid.d_fractShiftsTable);
     freeDeviceBuffer(&kernelParamsPtr->grid.d_gridlineIndicesTable);
 #endif
@@ -502,7 +502,7 @@ void pme_gpu_sync_spread_grid(const PmeGpu* pmeGpu)
  */
 static void pme_gpu_init_internal(PmeGpu* pmeGpu, const DeviceContext& deviceContext, const DeviceStream& deviceStream)
 {
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
     // Prepare to use the device that this PME task was assigned earlier.
     // Other entities, such as CUDA timing events, are known to implicitly use the device context.
     CU_RET_ERR(cudaSetDevice(deviceContext.deviceInfo().id), "Switching to PME CUDA device");
@@ -518,11 +518,12 @@ static void pme_gpu_init_internal(PmeGpu* pmeGpu, const DeviceContext& deviceCon
      * TODO: PME could also try to pick up nice grid sizes (with factors of 2, 3, 5, 7).
      */
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
     pmeGpu->maxGridWidthX = deviceContext.deviceInfo().prop.maxGridSize[0];
-#elif GMX_GPU == GMX_GPU_OPENCL
-    pmeGpu->maxGridWidthX = INT32_MAX / 2;
+#else
+    // Use this path for any non-CUDA GPU acceleration
     // TODO: is there no really global work size limit in OpenCL?
+    pmeGpu->maxGridWidthX = INT32_MAX / 2;
 #endif
 }
 
@@ -763,7 +764,7 @@ static void pme_gpu_copy_common_data_from(const gmx_pme_t* pme)
  */
 static void pme_gpu_select_best_performing_pme_spreadgather_kernels(PmeGpu* pmeGpu)
 {
-    if (pmeGpu->kernelParams->atoms.nAtoms > c_pmeGpuPerformanceAtomLimit && (GMX_GPU == GMX_GPU_CUDA))
+    if (GMX_GPU_CUDA && pmeGpu->kernelParams->atoms.nAtoms > c_pmeGpuPerformanceAtomLimit)
     {
         pmeGpu->settings.threadsPerAtom     = ThreadsPerAtom::Order;
         pmeGpu->settings.recalculateSplines = true;
@@ -1187,11 +1188,12 @@ void pme_gpu_spread(const PmeGpu*         pmeGpu,
     const int  threadsPerAtom =
             (pmeGpu->settings.threadsPerAtom == ThreadsPerAtom::Order ? order : order * order);
     const bool recalculateSplines = pmeGpu->settings.recalculateSplines;
-#if GMX_GPU == GMX_GPU_OPENCL
-    GMX_ASSERT(pmeGpu->settings.threadsPerAtom == ThreadsPerAtom::OrderSquared,
+
+    GMX_ASSERT(!GMX_GPU_OPENCL || pmeGpu->settings.threadsPerAtom == ThreadsPerAtom::OrderSquared,
                "Only 16 threads per atom supported in OpenCL");
-    GMX_ASSERT(!recalculateSplines, "Recalculating splines not supported in OpenCL");
-#endif
+    GMX_ASSERT(!GMX_GPU_OPENCL || !recalculateSplines,
+               "Recalculating splines not supported in OpenCL");
+
     const int atomsPerBlock = blockSize / threadsPerAtom;
 
     // TODO: pick smaller block size in runtime if needed
@@ -1206,9 +1208,10 @@ void pme_gpu_spread(const PmeGpu*         pmeGpu,
     // Ensure that coordinates are ready on the device before launching spread;
     // only needed with CUDA on PP+PME ranks, not on separate PME ranks, in unit tests
     // nor in OpenCL as these cases use a single stream (hence xReadyOnDevice == nullptr).
-    GMX_ASSERT(xReadyOnDevice != nullptr || (GMX_GPU != GMX_GPU_CUDA)
-                       || pmeGpu->common->isRankPmeOnly || pme_gpu_settings(pmeGpu).copyAllOutputs,
+    GMX_ASSERT(!GMX_GPU_CUDA || xReadyOnDevice != nullptr || pmeGpu->common->isRankPmeOnly
+                       || pme_gpu_settings(pmeGpu).copyAllOutputs,
                "Need a valid coordinate synchronizer on PP+PME ranks with CUDA.");
+
     if (xReadyOnDevice)
     {
         xReadyOnDevice->enqueueWaitEvent(pmeGpu->archSpecific->pmeStream_);
@@ -1356,7 +1359,7 @@ void pme_gpu_solve(const PmeGpu* pmeGpu,
     const int warpSize  = pmeGpu->programHandle_->warpSize();
     const int blockSize = (cellsPerBlock + warpSize - 1) / warpSize * warpSize;
 
-    static_assert(GMX_GPU != GMX_GPU_CUDA || c_solveMaxWarpsPerBlock / 2 >= 4,
+    static_assert(!GMX_GPU_CUDA || c_solveMaxWarpsPerBlock / 2 >= 4,
                   "The CUDA solve energy kernels needs at least 4 warps. "
                   "Here we launch at least half of the max warps.");
 
@@ -1528,11 +1531,12 @@ void pme_gpu_gather(PmeGpu* pmeGpu, real** h_grids, const float lambda)
     const int threadsPerAtom =
             (pmeGpu->settings.threadsPerAtom == ThreadsPerAtom::Order ? order : order * order);
     const bool recalculateSplines = pmeGpu->settings.recalculateSplines;
-#if GMX_GPU == GMX_GPU_OPENCL
-    GMX_ASSERT(pmeGpu->settings.threadsPerAtom == ThreadsPerAtom::OrderSquared,
+
+    GMX_ASSERT(!GMX_GPU_OPENCL || pmeGpu->settings.threadsPerAtom == ThreadsPerAtom::OrderSquared,
                "Only 16 threads per atom supported in OpenCL");
-    GMX_ASSERT(!recalculateSplines, "Recalculating splines not supported in OpenCL");
-#endif
+    GMX_ASSERT(!GMX_GPU_OPENCL || !recalculateSplines,
+               "Recalculating splines not supported in OpenCL");
+
     const int atomsPerBlock = blockSize / threadsPerAtom;
 
     GMX_ASSERT(!(c_pmeAtomDataBlockSize % atomsPerBlock),
index 75d3f881d061e3b19115fc840020cb6057ed2f8a..254a1ab215083dfae50aad5d6114771bde2f645b 100644 (file)
@@ -80,9 +80,9 @@ struct PmeGpuProgramImpl
     const DeviceContext& deviceContext_;
 
     //! Conveniently all the PME kernels use the same single argument type
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
     using PmeKernelHandle = void (*)(const struct PmeGpuCudaKernelParams);
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
     using PmeKernelHandle = cl_kernel;
 #else
     using PmeKernelHandle = void*;
index f8e42f7fb64902194020ac58f1428ac193ade251..26405433f53ab92397a24e24b8fb8a2a6db633be 100644 (file)
@@ -67,18 +67,18 @@ namespace gmx
 class PmeDeviceBuffers;
 } // namespace gmx
 
-#if GMX_GPU != GMX_GPU_NONE
+#if GMX_GPU
 struct PmeGpuSpecific;
 #else
 /*! \brief A dummy typedef for the GPU host data placeholder on non-GPU builds */
 typedef int PmeGpuSpecific;
 #endif
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 struct PmeGpuCudaKernelParams;
 /*! \brief A typedef for including the GPU kernel arguments data by pointer */
 typedef PmeGpuCudaKernelParams PmeGpuKernelParams;
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
 struct PmeGpuKernelParamsBase;
 /*! \brief A typedef for including the GPU kernel arguments data by pointer */
 typedef PmeGpuKernelParamsBase PmeGpuKernelParams;
index f3deae28428c692669f84d28e93e6a472023534b..cf98d701c54fe4f3c6fd9cd2f8eece9b03a0d31a 100644 (file)
 #include <set>
 #include <vector>
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include "gromacs/gpu_utils/gpueventsynchronizer.cuh"
 #    include "gromacs/gpu_utils/gpuregiontimer.cuh"
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
 #    include "gromacs/gpu_utils/gpueventsynchronizer_ocl.h"
 #    include "gromacs/gpu_utils/gpuregiontimer_ocl.h"
 #endif
index 1a33cc8ed06e55e7604ff69b2af43b919c212ef9..de9386f63979df36dce8bf7f62fe8149c5739180 100644 (file)
 
 /*! \brief environment variable to enable GPU P2P communication */
 static const bool c_enableGpuPmePpComms =
-        (getenv("GMX_GPU_PME_PP_COMMS") != nullptr) && GMX_THREAD_MPI && (GMX_GPU == GMX_GPU_CUDA);
+        GMX_GPU_CUDA && GMX_THREAD_MPI && (getenv("GMX_GPU_PME_PP_COMMS") != nullptr);
 
 /*! \brief Master PP-PME communication data structure */
 struct gmx_pme_pp
index d194b73c206deb2928776346770844a37d375728..0259cd0229bbd37ffea2c53619837a51c4ed0c6a 100644 (file)
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/gmxmpi.h"
 
-#if GMX_GPU != GMX_GPU_CUDA
+#if !GMX_GPU_CUDA
 
 namespace gmx
 {
 
-/*!\brief Impl class stub. */
+/*!\brief \internal Impl class stub. */
 class PmePpCommGpu::Impl
 {
 };
@@ -120,4 +120,4 @@ void* PmePpCommGpu::getForcesReadySynchronizer()
 
 } // namespace gmx
 
-#endif /* GMX_GPU != GMX_GPU_CUDA */
+#endif // !GMX_GPU_CUDA
index 29618ee086aadf4bd269dec351bdc0542fa9f892..e01d28027b527bac7492abfb37e25badf4383483 100644 (file)
@@ -431,7 +431,7 @@ fft5d_plan fft5d_plan_3d(int                NG,
     if (!(flags & FFT5D_NOMALLOC))
     {
         // only needed for PME GPU mixed mode
-        if (realGridAllocationPinningPolicy == gmx::PinningPolicy::PinnedIfSupported && GMX_GPU == GMX_GPU_CUDA)
+        if (GMX_GPU_CUDA && realGridAllocationPinningPolicy == gmx::PinningPolicy::PinnedIfSupported)
         {
             const std::size_t numBytes = lsize * sizeof(t_complex);
             lin = static_cast<t_complex*>(gmx::PageAlignedAllocationPolicy::malloc(numBytes));
index f889cde431d2b5db905d2eeeacfc0398ed21aeb7..4db569f5fa89ab4bd9cb18e97c1a60059a425cf3 100644 (file)
@@ -43,7 +43,7 @@ gmx_add_libgromacs_sources(
         gpu_utils.cpp
         gpu_testutils.cpp
         )
-if(GMX_USE_OPENCL)
+if(GMX_GPU_OPENCL)
     gmx_add_libgromacs_sources(
         device_context_ocl.cpp
         device_stream_ocl.cpp
@@ -52,7 +52,7 @@ if(GMX_USE_OPENCL)
         ocl_caching.cpp
         oclutils.cpp
         )
-elseif(GMX_USE_CUDA)
+elseif(GMX_GPU_CUDA)
     gmx_add_libgromacs_sources(
         device_stream.cu
         gpu_utils.cu
index ca6b0c21450248e631b3756e61e7989ed3cb035b..2d1ff2470ef812da2f0e4e3b4bf8d38102a41b10 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.
@@ -50,7 +50,7 @@
 #include "gromacs/utility/mutex.h"
 #include "gromacs/utility/stringutil.h"
 
-#if GMX_GPU == GMX_GPU_OPENCL
+#if GMX_GPU_OPENCL
 #    include <clFFT.h>
 #endif
 
@@ -74,7 +74,7 @@ gmx::Mutex      g_clfftMutex;
 
 ClfftInitializer::ClfftInitializer()
 {
-#if GMX_GPU == GMX_GPU_OPENCL
+#if GMX_GPU_OPENCL
     gmx::lock_guard<gmx::Mutex> guard(g_clfftMutex);
     clfftSetupData              fftSetup;
     int                         initErrorCode = clfftInitSetupData(&fftSetup);
@@ -97,7 +97,7 @@ ClfftInitializer::ClfftInitializer()
 
 ClfftInitializer::~ClfftInitializer()
 {
-#if GMX_GPU == GMX_GPU_OPENCL
+#if GMX_GPU_OPENCL
     gmx::lock_guard<gmx::Mutex> guard(g_clfftMutex);
     if (g_clfftInitialized)
     {
index e1eb23255a1e6ce1deed171bac86ac3727e6be2f..b3044c891258f53cfc2355829eab622f82a061ff 100644 (file)
@@ -50,7 +50,7 @@
 
 #include "config.h"
 
-#if GMX_GPU == GMX_GPU_OPENCL
+#if GMX_GPU_OPENCL
 #    include "gromacs/gpu_utils/device_context_ocl.h"
 #else
 #    include "gromacs/utility/classhelpers.h"
@@ -75,6 +75,6 @@ private:
 
     GMX_DISALLOW_COPY_MOVE_AND_ASSIGN(DeviceContext);
 };
-#endif // GMX_GPU != GMX_GPU_OPENCL
+#endif // !GMX_GPU_OPENCL
 
 #endif // GMX_GPU_UTILS_DEVICE_CONTEXT_H
index 2f7babd320064063c1627faac4053f6dc59e7d25..cfbd60c1a389e793dc9233bf2430a49aedd8b769 100644 (file)
@@ -60,6 +60,8 @@
 #define CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL 0x4
 /**@}*/
 
+#ifndef DOXYGEN
+
 DeviceContext::DeviceContext(const DeviceInformation& deviceInfo) : deviceInfo_(deviceInfo)
 {
     cl_platform_id                     platformId = deviceInfo.oclPlatformId;
@@ -105,3 +107,5 @@ cl_context DeviceContext::context() const
 {
     return context_;
 }
+
+#endif
index 090943962df80b7a0f4ffcfd5e1ee199985159ef..c754ad54b05c3c113846b88204e57a030ff85c59 100644 (file)
  * \inlibraryapi
  */
 
-#include "gromacs/gpu_utils/gmxopencl.h"
-#include "gromacs/utility/classhelpers.h"
+#ifndef DOXYGEN
+
+#    include "gromacs/gpu_utils/gmxopencl.h"
+#    include "gromacs/utility/classhelpers.h"
 
 struct DeviceInformation;
 
@@ -81,4 +83,5 @@ private:
     GMX_DISALLOW_COPY_MOVE_AND_ASSIGN(DeviceContext);
 };
 
+#endif // !defined DOXYGEN
 #endif // GMX_GPU_UTILS_DEVICE_CONTEXT_OCL_H
index 9880de747eb92e32ed5857265c5ca676815c33ff..5b74f590f29210d473f66dc2af91c3bc6145c92f 100644 (file)
 
 #include "config.h"
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include <cuda_runtime.h>
 
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
 #    include "gromacs/gpu_utils/gmxopencl.h"
 #endif
 #include "gromacs/utility/classhelpers.h"
@@ -120,7 +120,7 @@ public:
     //! Synchronize the steam
     void synchronize() const;
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 
     //! Getter
     cudaStream_t stream() const;
@@ -130,7 +130,7 @@ public:
 private:
     cudaStream_t stream_ = nullptr;
 
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL || defined DOXYGEN
 
     //! Getter
     cl_command_queue stream() const;
index c0cdfec32963b3a058477439fe9e1a7700349183..8aaea7226320564886844aeca3167cd87a26cd66 100644 (file)
@@ -50,9 +50,9 @@
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/smalloc.h" // TODO: this is only for over_alloc_large
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include "gromacs/gpu_utils/devicebuffer.cuh"
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
 #    include "gromacs/gpu_utils/devicebuffer_ocl.h"
 #else
 #    error "devicebuffer.h included on non-GPU build!"
index 9ee6517318346a6766a67c7faf87a03012aa896e..c1aec1fa51341c81814f1af153909da32857b9f8 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.
 
 #include "config.h"
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 
 //! \brief A device-side buffer of ValueTypes
 template<typename ValueType>
 using DeviceBuffer = ValueType*;
 
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
 
 #    include "gromacs/gpu_utils/gputraits_ocl.h"
 
index 4f6d557537bacfbb126066b5fd81e98f45f99fd1..8eef2307d9f43dfb40f9afde969697cd64da9cd3 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.
@@ -74,7 +74,7 @@
 #    define OPENCL_FUNC_TERM REAL_FUNC_TERM
 #    define OPENCL_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
 
-#elif GMX_GPU != GMX_GPU_NONE
+#elif GMX_GPU
 
 /* GPU support is enabled, so these functions will have real code
  * defined somewhere */
@@ -83,7 +83,7 @@
 #    define GPU_FUNC_TERM REAL_FUNC_TERM
 #    define GPU_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
 
-#    if GMX_GPU == GMX_GPU_OPENCL
+#    if GMX_GPU_OPENCL
 
 /* OpenCL support is enabled, so CUDA-specific functions need empty
  * implementations, while OpenCL-specific functions will have real
@@ -98,7 +98,7 @@
 #        define OPENCL_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
 
 #    endif
-#    if GMX_GPU == GMX_GPU_CUDA
+#    if GMX_GPU_CUDA
 
 /* CUDA support is enabled, so OpenCL-specific functions need empty
  * implementations, while CUDA-specific functions will have real
 
 #    endif
 
-#elif GMX_GPU == GMX_GPU_NONE
+#elif !GMX_GPU
 
 /* No GPU support is configured, so none of these functions will have
  * real definitions. */
index fcfb1cc374306016ea3eca2ac325b9a24d5d50ae..004ad30c86c7ccda5baef58c2ca9d057a0b150da 100644 (file)
@@ -55,7 +55,7 @@
 #endif
 
 //! Constant used to help minimize preprocessed code
-static constexpr bool c_binarySupportsGpus = (GMX_GPU != GMX_GPU_NONE);
+static constexpr bool c_binarySupportsGpus = (GMX_GPU != 0);
 
 bool canPerformGpuDetection()
 {
@@ -69,7 +69,7 @@ bool canPerformGpuDetection()
     }
 }
 
-#if GMX_GPU == GMX_GPU_NONE
+#if !GMX_GPU
 DeviceStatus gpu_info_get_stat(const gmx_gpu_info_t& /*unused*/, int /*unused*/)
 {
     return DeviceStatus::Nonexistent;
index 9ae87f1436aabe7a6c04298e2a0839dc5ada17d9..e3a3a9275eb471193f6c42b2b227239ed125f01b 100644 (file)
 
 #include "config.h"
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 
 #    include "gromacs/gpu_utils/gputraits.cuh"
 
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
 
 #    include "gromacs/gpu_utils/gputraits_ocl.h"
 
@@ -59,7 +59,7 @@
 
 using DeviceTexture = void*;
 
-//! Stub for device information.
+//! \internal Stub for device information.
 struct DeviceInformation
 {
     // No member needed
index 3698f290a80b6c0e041cdc34851f1b77b7aeb466..149166920155ac1e3af8bd9a2f57b6e2d71249b2 100644 (file)
@@ -71,7 +71,7 @@ const EnumerationArray<DeviceStreamType, std::string> c_deviceStreamNames = {
 
 /*! \brief Non-GPU builds return nullptr instead of streams,
  * so we have to expect that in such build configurations. */
-const bool c_canExpectValidStreams = (GMX_GPU != GMX_GPU_NONE);
+constexpr bool c_canExpectValidStreams = (GMX_GPU != 0);
 
 //! Helper function to implement readable testing
 void expectValidStreams(DeviceStreamManager* manager, std::initializer_list<DeviceStreamType> types)
index 41d38eb4173666bfd677902da383e4543de0e07b..baf475a1568a948b6e21c623c8a140e1003b484a 100644 (file)
@@ -286,7 +286,7 @@ TYPED_TEST(HostAllocatorTestNoMem, Comparison)
     EXPECT_NE(AllocatorType{}, AllocatorType{ PinningPolicy::PinnedIfSupported });
 }
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 
 // Policy suitable for pinning is only supported for a CUDA build
 
index 580e457d282060665afa67d33b376fbd40bbeb18..71135fe85e642b2e0d38c9cf3685bc1bf27c8798 100644 (file)
@@ -48,7 +48,7 @@
 
 #include "testutils/testasserts.h"
 
-#if GMX_GPU != GMX_GPU_CUDA
+#if !GMX_GPU_CUDA
 
 namespace gmx
 {
@@ -71,4 +71,4 @@ void convertRVecToFloat3OnDevice(std::vector<gmx::RVec>& /* rVecOutput */,
 } // namespace test
 } // namespace gmx
 
-#endif // GMX_GPU != GMX_GPU_CUDA
+#endif // !GMX_GPU_CUDA
index 1488edbed96e26886689c7e9fa45ae01a97e3064..1aedf1a16658c9c5560b250c0e799c27969e6b25 100644 (file)
@@ -42,8 +42,6 @@
 
 #include "typecasts_runner.h"
 
-#include "config.h"
-
 #include <vector>
 
 #include "gromacs/gpu_utils/cudautils.cuh"
@@ -52,8 +50,6 @@
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/stringutil.h"
 
-#if GMX_GPU == GMX_GPU_CUDA
-
 namespace gmx
 {
 
@@ -150,5 +146,3 @@ void convertRVecToFloat3OnDevice(std::vector<gmx::RVec>& h_rVecOutput, const std
 
 } // namespace test
 } // namespace gmx
-
-#endif // GMX_GPU == GMX_GPU_CUDA
\ No newline at end of file
index 969399b3eccbd073d9361083781512fae30164d5..e88d642dc328f334139236e69dbe0f7c01d0814c 100644 (file)
@@ -132,8 +132,8 @@ static void gmx_detect_gpus(const gmx::MDLogger&             mdlog,
     /* The OpenCL support requires us to run detection on all ranks.
      * With CUDA we don't need to, and prefer to detect on one rank
      * and send the information to the other ranks over MPI. */
-    bool allRanksMustDetectGpus = (GMX_GPU == GMX_GPU_OPENCL);
-    bool gpusCanBeDetected      = false;
+    constexpr bool allRanksMustDetectGpus = (GMX_GPU_OPENCL != 0);
+    bool           gpusCanBeDetected      = false;
     if (isMasterRankOfPhysicalNode || allRanksMustDetectGpus)
     {
         std::string errorMessage;
index e729876458ef07910a186f1bf7ce578a7db77c18..4283441c0e2dd90f6696323800b9e46d7fb4f6c0 100644 (file)
@@ -61,7 +61,7 @@
 #include "gromacs/utility/sysinfo.h"
 
 //! Constant used to help minimize preprocessed code
-static const bool bGPUBinary = GMX_GPU != GMX_GPU_NONE;
+static constexpr bool bGPUBinary = (GMX_GPU != 0);
 
 /*! \internal \brief
  * Returns the GPU information text, one GPU per line.
index 22936e1e5b4be51197832c9e2777fffb27c71396..fa1fa07902081be0d7027030b1aa0903dd2a58a2 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014,2015,2016,2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2014,2015,2016,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.
@@ -45,7 +45,7 @@ gmx_add_libgromacs_sources(
     restcbt.cpp
     )
 
-if(GMX_USE_CUDA)
+if(GMX_GPU_CUDA)
     gmx_add_libgromacs_sources(
        gpubonded_impl.cu
        gpubondedkernels.cu
index da40157866e672222a00479490c0316fa63b497e..af62aac7a0a6f2c257f58d348d105af71a196c0f 100644 (file)
@@ -120,11 +120,11 @@ bool buildSupportsGpuBondeds(std::string* error)
     {
         errorReasons.emplace_back("not supported with double precision");
     }
-    if (GMX_GPU == GMX_GPU_OPENCL)
+    if (GMX_GPU_OPENCL)
     {
         errorReasons.emplace_back("not supported with OpenCL build of GROMACS");
     }
-    else if (GMX_GPU == GMX_GPU_NONE)
+    else if (!GMX_GPU)
     {
         errorReasons.emplace_back("not supported with CPU-only build of GROMACS");
     }
@@ -156,7 +156,7 @@ bool inputSupportsGpuBondeds(const t_inputrec& ir, const gmx_mtop_t& mtop, std::
     return addMessageIfNotSupported(errorReasons, error);
 }
 
-#if GMX_GPU != GMX_GPU_CUDA
+#if !GMX_GPU_CUDA
 
 class GpuBonded::Impl
 {
@@ -205,6 +205,6 @@ void GpuBonded::waitAccumulateEnergyTerms(gmx_enerdata_t* /* enerd */) {}
 
 void GpuBonded::clearEnergies() {}
 
-#endif /* GMX_GPU != GMX_GPU_CUDA */
+#endif // !GMX_GPU_CUDA
 
 } // namespace gmx
index 770028ba3b14d0e315ce66156b0c5672044f1f8a..c2795481475b5fb1232cbc745019586ce3cd4f16 100644 (file)
@@ -39,7 +39,7 @@ set(MDLIB_SOURCES ${MDLIB_SOURCES} PARENT_SCOPE)
 if (BUILD_TESTING)
     add_subdirectory(tests)
 endif()
-if(GMX_USE_CUDA)
+if(GMX_GPU_CUDA)
     gmx_add_libgromacs_sources(
        leapfrog_gpu.cu
        lincs_gpu.cu
index 1d61a68c59a3456ccfc2157437ff7d9abcb0fe55..d8fc0267f7a435d6aded8248996496ae5ae68db3 100644 (file)
@@ -1263,7 +1263,7 @@ void do_force(FILE*                               fplog,
         // For force buffer ops, we use the below conditon rather than
         // useGpuFBufferOps to ensure that init is performed even if this
         // NS step is also a virial step (on which f buf ops are deactivated).
-        if (simulationWork.useGpuBufferOps && simulationWork.useGpuNonbonded && (GMX_GPU == GMX_GPU_CUDA))
+        if (GMX_GPU_CUDA && simulationWork.useGpuBufferOps && simulationWork.useGpuNonbonded)
         {
             GMX_ASSERT(stateGpu, "stateGpu should be valid when buffer ops are offloaded");
             nbv->atomdata_init_add_nbat_f_to_f_gpu(stateGpu->fReducedOnDevice());
index 88f5e76c8c04352cbf1031f5ebaa6a78bb5d8fb6..35d9adce3254cafb9327d85323b998a989a39720 100644 (file)
@@ -89,7 +89,7 @@ std::vector<std::string> getRunnersNames()
 {
     runnersNames.emplace_back("SHAKE");
     runnersNames.emplace_back("LINCS");
-    if (GMX_GPU == GMX_GPU_CUDA && canComputeOnGpu())
+    if (GMX_GPU_CUDA && canComputeOnGpu())
     {
         runnersNames.emplace_back("LINCS_GPU");
     }
index 7959cdd9287c4281e25213fba863eb4f3254c310..5fca4c06b31b94774d0d6b560b35d1467a1f7bc6 100644 (file)
@@ -149,7 +149,7 @@ void applyLincs(ConstraintsTestData* testData, t_pbc pbc)
     done_lincs(lincsd);
 }
 
-#if GMX_GPU != GMX_GPU_CUDA
+#if !GMX_GPU_CUDA
 /*! \brief
  * Stub for GPU version of LINCS constraints to satisfy compiler.
  *
@@ -160,7 +160,7 @@ void applyLincsGpu(ConstraintsTestData gmx_unused* testData, t_pbc gmx_unused pb
 {
     FAIL() << "Dummy LINCS CUDA function was called instead of the real one.";
 }
-#endif
+#endif // !GMX_GPU_CUDA
 
 } // namespace test
 } // namespace gmx
index 1a03709ac6e3f1fb1d67e027656092c2c45df688..4ff12126e8e14142372f9174fdab0d893a2e261e 100644 (file)
@@ -153,7 +153,7 @@ public:
         // All runners should be registered here under appropriate conditions
         //
         s_runners_["LeapFrogSimple"] = integrateLeapFrogSimple;
-        if (GMX_GPU == GMX_GPU_CUDA && canComputeOnGpu())
+        if (GMX_GPU_CUDA && canComputeOnGpu())
         {
             s_runners_["LeapFrogGpu"] = integrateLeapFrogGpu;
         }
index 939ac5c16894beeacf4f6569bfa641848cffa082..492fb8e080065729c6896cca710802c5b2e5fb83 100644 (file)
@@ -103,14 +103,14 @@ void integrateLeapFrogSimple(LeapFrogTestData* testData, int numSteps)
     }
 }
 
-#if GMX_GPU != GMX_GPU_CUDA
+#if !GMX_GPU_CUDA
 
 void integrateLeapFrogGpu(gmx_unused LeapFrogTestData* testData, gmx_unused int numSteps)
 {
     FAIL() << "Dummy Leap-Frog CUDA function was called instead of the real one.";
 }
 
-#endif // GMX_GPU != GMX_GPU_CUDA
+#endif // !GMX_GPU_CUDA
 
 } // namespace test
 } // namespace gmx
index 3a08231685b5c66b282910157a62076bd5a95793..41552e2f5844a967610362616c2e619592bea3b0 100644 (file)
@@ -187,12 +187,9 @@ public:
         // 2. There is a CUDA-capable GPU in a system
         // 3. This GPU is detectable
         // 4. GPU detection was not disabled by GMX_DISABLE_GPU_DETECTION environment variable
-        if (s_hasCompatibleGpus)
+        if (GMX_GPU_CUDA && s_hasCompatibleGpus)
         {
-            if (GMX_GPU == GMX_GPU_CUDA && s_hasCompatibleGpus)
-            {
-                runners_["SETTLE_GPU"] = applySettleGpu;
-            }
+            runners_["SETTLE_GPU"] = applySettleGpu;
         }
     }
 
index 4c266b90385abeed0df30c0ccb5d28d3354f4d8e..3fd90dc6892272e3f181bc5b949a694f2ef0df41 100644 (file)
@@ -78,7 +78,7 @@ void applySettle(SettleTestData*    testData,
     EXPECT_FALSE(errorOccured) << testDescription;
 }
 
-#if GMX_GPU != GMX_GPU_CUDA
+#if !GMX_GPU_CUDA
 
 void applySettleGpu(gmx_unused SettleTestData* testData,
                     gmx_unused const t_pbc pbc,
index ddb8e04b633012241d65d9205ae6af378e0edc5b..f9cf9867f392938203f0ee369fc563c1e442d11b 100644 (file)
@@ -80,8 +80,7 @@ void applySettleGpu(SettleTestData*  testData,
 {
     // These should never fail since this function should only be called if CUDA is enabled and
     // there is a CUDA-capable device available.
-    GMX_RELEASE_ASSERT(GMX_GPU == GMX_GPU_CUDA,
-                       "CUDA version of SETTLE was called from non-CUDA build.");
+    GMX_RELEASE_ASSERT(GMX_GPU_CUDA, "CUDA version of SETTLE was called from non-CUDA build.");
 
     // TODO: Here we should check that at least 1 suitable GPU is available
     GMX_RELEASE_ASSERT(canPerformGpuDetection(), "Can't detect CUDA-capable GPUs.");
index e290939c09e436556d9492d28da0b9a1e5108b7f..d3d50c257896f649724f9936bcb0e89f872e8d4d 100644 (file)
@@ -46,7 +46,7 @@
 
 #include "gromacs/mdlib/update_constrain_gpu.h"
 
-#if GMX_GPU != GMX_GPU_CUDA
+#if !GMX_GPU_CUDA
 
 namespace gmx
 {
@@ -120,4 +120,4 @@ bool UpdateConstrainGpu::isNumCoupledConstraintsSupported(const gmx_mtop_t& /* m
 
 } // namespace gmx
 
-#endif /* GMX_GPU != GMX_GPU_CUDA */
+#endif /* !GMX_GPU_CUDA */
index 879a28a692300812386962321a3c4598c9034de9..6a6aa97675af8cf73e27aba6cb537de36921ece2 100644 (file)
  *
  * Any remaining vsites are assigned to a separate master thread task.
  */
-
 namespace gmx
 {
 
 //! VirialHandling is often used outside VirtualSitesHandler class members
 using VirialHandling = VirtualSitesHandler::VirialHandling;
 
-/*! \libinternal
- * \brief Information on PBC and domain decomposition for virtual sites
+/*! \brief Information on PBC and domain decomposition for virtual sites
  */
 struct DomainInfo
 {
@@ -126,8 +124,7 @@ public:
     const gmx_domdec_t* domdec_ = nullptr;
 };
 
-/*! \libinternal
- * \brief List of atom indices belonging to a task
+/*! \brief List of atom indices belonging to a task
  */
 struct AtomIndex
 {
@@ -135,8 +132,7 @@ struct AtomIndex
     std::vector<int> atom;
 };
 
-/*! \libinternal
- * \brief Data structure for thread tasks that use constructing atoms outside their own atom range
+/*! \brief Data structure for thread tasks that use constructing atoms outside their own atom range
  */
 struct InterdependentTask
 {
@@ -158,8 +154,7 @@ struct InterdependentTask
     std::vector<int> reduceTask;
 };
 
-/*! \libinternal
- * \brief Vsite thread task data structure
+/*! \brief Vsite thread task data structure
  */
 struct VsiteThread
 {
@@ -193,8 +188,7 @@ struct VsiteThread
 };
 
 
-/*! \libinternal
- * \brief Information on how the virtual site work is divided over thread tasks
+/*! \brief Information on how the virtual site work is divided over thread tasks
  */
 class ThreadingInfo
 {
@@ -232,8 +226,7 @@ private:
     std::vector<int> taskIndex_;
 };
 
-/*! \libinternal
- * \brief Impl class for VirtualSitesHandler
+/*! \brief Impl class for VirtualSitesHandler
  */
 class VirtualSitesHandler::Impl
 {
index a32dc97a706f6bc91da652cc99a623b190b4b816..c2664db220091cccd397be3faec40faccd22597f 100644 (file)
@@ -202,13 +202,13 @@ static DevelopmentFeatureFlags manageDevelopmentFeatures(const gmx::MDLogger& md
     // getenv results are ignored when clearly they are used.
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-    devFlags.enableGpuBufferOps = (getenv("GMX_USE_GPU_BUFFER_OPS") != nullptr)
-                                  && (GMX_GPU == GMX_GPU_CUDA) && useGpuForNonbonded;
-    devFlags.forceGpuUpdateDefault = (getenv("GMX_FORCE_UPDATE_DEFAULT_GPU") != nullptr);
-    devFlags.enableGpuHaloExchange =
-            (getenv("GMX_GPU_DD_COMMS") != nullptr && GMX_THREAD_MPI && (GMX_GPU == GMX_GPU_CUDA));
+
+    devFlags.enableGpuBufferOps =
+            GMX_GPU_CUDA && useGpuForNonbonded && (getenv("GMX_USE_GPU_BUFFER_OPS") != nullptr);
+    devFlags.enableGpuHaloExchange = GMX_GPU_CUDA && GMX_THREAD_MPI && getenv("GMX_GPU_DD_COMMS") != nullptr;
     devFlags.enableGpuPmePPComm =
-            (getenv("GMX_GPU_PME_PP_COMMS") != nullptr && GMX_THREAD_MPI && (GMX_GPU == GMX_GPU_CUDA));
+            GMX_GPU_CUDA && GMX_THREAD_MPI && getenv("GMX_GPU_PME_PP_COMMS") != nullptr;
+
 #pragma GCC diagnostic pop
 
     if (devFlags.enableGpuBufferOps)
@@ -1165,7 +1165,8 @@ int Mdrunner::mdrunner()
 
     // timing enabling - TODO put this in gpu_utils (even though generally this is just option handling?)
     bool useTiming = true;
-    if (GMX_GPU == GMX_GPU_CUDA)
+
+    if (GMX_GPU_CUDA)
     {
         /* WARNING: CUDA timings are incorrect with multiple streams.
          *          This is the main reason why they are disabled by default.
@@ -1173,7 +1174,7 @@ int Mdrunner::mdrunner()
         // TODO: Consider turning on by default when we can detect nr of streams.
         useTiming = (getenv("GMX_ENABLE_GPU_TIMING") != nullptr);
     }
-    else if (GMX_GPU == GMX_GPU_OPENCL)
+    else if (GMX_GPU_OPENCL)
     {
         useTiming = (getenv("GMX_DISABLE_GPU_TIMING") == nullptr);
     }
index da3cecf4375736b59b085145ff523e0b97e97abb..f13e63c8d8b402d12c50eab52bf3ddf22bc94eab 100644 (file)
@@ -42,7 +42,7 @@ file(GLOB MDTYPES_SOURCES
     observableshistory.cpp
     state.cpp)
 
-if(GMX_USE_CUDA OR GMX_USE_OPENCL)
+if(GMX_GPU)
     gmx_add_libgromacs_sources(
        state_propagator_data_gpu_impl_gpu.cpp
        )
index 1600c7a062fbc9c26a162b57a0b7fa7dc99d5b0e..3274d3dd02bf8892e3de11f951669fcdb578e1f7 100644 (file)
@@ -46,7 +46,7 @@
 
 #include "gromacs/mdtypes/state_propagator_data_gpu.h"
 
-#if GMX_GPU == GMX_GPU_NONE
+#if !GMX_GPU
 namespace gmx
 {
 
@@ -265,4 +265,4 @@ int StatePropagatorDataGpu::numAtomsAll()
 
 } // namespace gmx
 
-#endif // GMX_GPU == GMX_GPU_NONE
+#endif // !GMX_GPU
index fd9ff197addc5c3ee41dd21c7bfb9063802a4150..f4457311e1137fed0cf9e8ceab0114c55ec0711f 100644 (file)
@@ -48,9 +48,9 @@
 #include "config.h"
 
 #include "gromacs/gpu_utils/devicebuffer.h"
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include "gromacs/gpu_utils/gpueventsynchronizer.cuh"
-#elif GMX_GPU == GMX_GPU_OPENCL
+#elif GMX_GPU_OPENCL
 #    include "gromacs/gpu_utils/gpueventsynchronizer_ocl.h"
 #endif
 #include "gromacs/math/vectypes.h"
index bf927f2da297084caae44ef98a499038fabbccc7..995976b46188fc57fe79b392b63396a88c948edb 100644 (file)
@@ -44,7 +44,7 @@
 
 #include "config.h"
 
-#if GMX_GPU != GMX_GPU_NONE
+#if GMX_GPU
 
 #    include "gromacs/gpu_utils/device_stream_manager.h"
 #    include "gromacs/gpu_utils/devicebuffer.h"
@@ -70,7 +70,7 @@ StatePropagatorDataGpu::Impl::Impl(const DeviceStreamManager& deviceStreamManage
     wcycle_(wcycle)
 {
     static_assert(
-            GMX_GPU != GMX_GPU_NONE,
+            GMX_GPU,
             "GPU state propagator data object should only be constructed on the GPU code-paths.");
 
     // We need to keep local copies for re-initialization.
@@ -78,14 +78,8 @@ StatePropagatorDataGpu::Impl::Impl(const DeviceStreamManager& deviceStreamManage
     localStream_    = &deviceStreamManager.stream(DeviceStreamType::NonBondedLocal);
     nonLocalStream_ = &deviceStreamManager.stream(DeviceStreamType::NonBondedNonLocal);
     // PME stream is used in OpenCL for H2D coordinate transfer
-    if (GMX_GPU == GMX_GPU_OPENCL)
-    {
-        updateStream_ = &deviceStreamManager.stream(DeviceStreamType::Pme);
-    }
-    else
-    {
-        updateStream_ = &deviceStreamManager.stream(DeviceStreamType::UpdateAndConstraints);
-    }
+    updateStream_ = &deviceStreamManager.stream(
+            GMX_GPU_OPENCL ? DeviceStreamType::Pme : DeviceStreamType::UpdateAndConstraints);
 
     // Map the atom locality to the stream that will be used for coordinates,
     // velocities and forces transfers. Same streams are used for H2D and D2H copies.
@@ -114,7 +108,7 @@ StatePropagatorDataGpu::Impl::Impl(const DeviceStream*  pmeStream,
     wcycle_(wcycle)
 {
     static_assert(
-            GMX_GPU != GMX_GPU_NONE,
+            GMX_GPU,
             "GPU state propagator data object should only be constructed on the GPU code-paths.");
 
     GMX_ASSERT(pmeStream->isValid(), "GPU PME stream should be valid.");
@@ -172,10 +166,11 @@ void StatePropagatorDataGpu::Impl::reinit(int numAtomsLocal, int numAtomsAll)
     reallocateDeviceBuffer(&d_v_, numAtomsAll_, &d_vSize_, &d_vCapacity_, deviceContext_);
     const int d_fOldCapacity = d_fCapacity_;
     reallocateDeviceBuffer(&d_f_, numAtomsAll_, &d_fSize_, &d_fCapacity_, deviceContext_);
+
     // Clearing of the forces can be done in local stream since the nonlocal stream cannot reach
     // the force accumulation stage before syncing with the local stream. Only done in CUDA,
     // since the force buffer ops are not implemented in OpenCL.
-    if (GMX_GPU == GMX_GPU_CUDA && d_fCapacity_ != d_fOldCapacity)
+    if (GMX_GPU_CUDA && d_fCapacity_ != d_fOldCapacity)
     {
         clearDeviceBufferAsync(&d_f_, 0, d_fCapacity_, *localStream_);
     }
@@ -306,7 +301,7 @@ void StatePropagatorDataGpu::Impl::copyCoordinatesToGpu(const gmx::ArrayRef<cons
     //   - it's not needed, copy is done in the same stream as the only consumer task (PME)
     //   - we don't consume the events in OpenCL which is not allowed by GpuEventSynchronizer (would leak memory).
     // TODO: remove this by adding an event-mark free flavor of this function
-    if (GMX_GPU == GMX_GPU_CUDA)
+    if (GMX_GPU_CUDA)
     {
         xReadyOnDevice_[atomLocality].markEvent(*deviceStream);
     }
@@ -328,7 +323,7 @@ StatePropagatorDataGpu::Impl::getCoordinatesReadyOnDeviceEvent(AtomLocality atom
     // TODO: This should be reconsidered to support the halo exchange.
     //
     // In OpenCL no events are used as coordinate sync is not necessary
-    if (GMX_GPU == GMX_GPU_OPENCL)
+    if (GMX_GPU_OPENCL)
     {
         return nullptr;
     }
@@ -667,4 +662,4 @@ int StatePropagatorDataGpu::numAtomsAll()
 
 } // namespace gmx
 
-#endif // GMX_GPU == GMX_GPU_NONE
+#endif // GMX_GPU
index 497ba6d631e52667e9115e9fa911b0cd19dd3621..ba6126b3e7d887f7687c057800599f62ffc6d7a1 100644 (file)
@@ -61,12 +61,12 @@ file (GLOB NBNXM_SOURCES
     benchmark/bench_system.cpp
     )
 
-if(GMX_USE_CUDA)
+if(GMX_GPU_CUDA)
     add_subdirectory(cuda)
     gmx_add_libgromacs_sources(nbnxm_gpu_data_mgmt.cpp)
 endif()
 
-if(GMX_USE_OPENCL)
+if(GMX_GPU_OPENCL)
     add_subdirectory(opencl)
     set(NBNXM_OPENCL_KERNELS ${NBNXM_OPENCL_KERNELS} PARENT_SCOPE)
     gmx_add_libgromacs_sources(nbnxm_gpu_data_mgmt.cpp)
index ab3e6e8882482ca2a58c085b344a6851121295cb..15c047605a625e164b3d502c541f831e8b82f2c9 100644 (file)
@@ -33,7 +33,7 @@
 # To help us fund GROMACS development, we humbly ask that you cite
 # the research papers on the package. Check out http://www.gromacs.org.
 
-if(GMX_USE_CUDA)
+if(GMX_GPU_CUDA)
     if(NOT GMX_CUDA_NB_SINGLE_COMPILATION_UNIT)
         set(NBNXM_CUDA_KERNEL_SOURCES
                 nbnxm_cuda_kernel_F_noprune.cu
index 1185ebae110ebbd47a0cebf96c8fea450c984ec1..7d41ee618022e3dbb6bfb18b6c9f22aeeda9c622 100644 (file)
 
 #include <string>
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include "cuda/nbnxm_cuda_types.h"
 #endif
 
-#if GMX_GPU == GMX_GPU_OPENCL
+#if GMX_GPU_OPENCL
 #    include "opencl/nbnxm_ocl_types.h"
 #endif
 
index 4882c3530ee147eb992079cc0d49f906c5ca102d..af0c69f36c8ddb12e49849ae742616a289d99c93 100644 (file)
 
 #include "gromacs/nbnxm/nbnxm.h"
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include "cuda/nbnxm_cuda_types.h"
 #endif
 
-#if GMX_GPU == GMX_GPU_OPENCL
+#if GMX_GPU_OPENCL
 #    include "opencl/nbnxm_ocl_types.h"
 #endif
 
index 17b66e49d8243df0609f06577997b280526035e8..9166a3e50a2497cfedbbee4c4a09ef4de12034e5 100644 (file)
 
 #include "pairlist.h"
 
-#if GMX_GPU == GMX_GPU_OPENCL
+#if GMX_GPU_OPENCL
 #    include "gromacs/gpu_utils/gpuregiontimer_ocl.h"
 #endif
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include "gromacs/gpu_utils/gpuregiontimer.cuh"
 #endif
 
index 7f6e433054c5e941160ef5583963018c979ad00f..105ceefb724c4fba642aa45bf0881aa6506a4b46 100644 (file)
 
 #include "config.h"
 
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
 #    include "cuda/nbnxm_cuda_types.h"
 #endif
 
-#if GMX_GPU == GMX_GPU_OPENCL
+#if GMX_GPU_OPENCL
 #    include "opencl/nbnxm_ocl_types.h"
 #endif
 
index 0c3690645790d03e61cb88beff6ef8b09d8a6524..69d86e96ba2bcbaa229bef10f3b5acd7e369af94 100644 (file)
@@ -33,7 +33,7 @@
 # To help us fund GROMACS development, we humbly ask that you cite
 # the research papers on the package. Check out http://www.gromacs.org.
 
-if(GMX_USE_OPENCL)
+if(GMX_GPU_OPENCL)
     file(GLOB OPENCL_NB_SOURCES *.cpp)
     set(NBNXM_SOURCES ${NBNXM_SOURCES} ${OPENCL_NB_SOURCES} PARENT_SCOPE)
 endif()
index 063f6dbf599a7e46277bfd113766aa268df0096c..92826f070d64cb247de959686d8ee3f91f9b855a 100644 (file)
@@ -60,7 +60,7 @@ enum class KernelType;
 static constexpr int c_nbnxnCpuIClusterSize = 4;
 
 //! The i- and j-cluster size for GPU lists, 8 atoms for CUDA, set at compile time for OpenCL
-#if GMX_GPU == GMX_GPU_OPENCL
+#if GMX_GPU_OPENCL
 static constexpr int c_nbnxnGpuClusterSize = GMX_OPENCL_NB_CLUSTER_SIZE;
 #else
 static constexpr int c_nbnxnGpuClusterSize = 8;
index e8a9e697f63d0f3a8024d55e96438d27c89c74c0..f2ae54cc0825b55e0f21d281b67433ce75320ec6 100644 (file)
@@ -85,12 +85,12 @@ namespace
 const char* g_specifyEverythingFormatString =
         "When you use mdrun -gputasks, %s must be set to non-default "
         "values, so that the device IDs can be interpreted correctly."
-#if GMX_GPU != GMX_GPU_NONE
+#if GMX_GPU
         " If you simply want to restrict which GPUs are used, then it is "
         "better to use mdrun -gpu_id. Otherwise, setting the "
-#    if GMX_GPU == GMX_GPU_CUDA
+#    if GMX_GPU_CUDA
         "CUDA_VISIBLE_DEVICES"
-#    elif GMX_GPU == GMX_GPU_OPENCL
+#    elif GMX_GPU_OPENCL
         // Technically there is no portable way to do this offered by the
         // OpenCL standard, but the only current relevant case for GROMACS
         // is AMD OpenCL, which offers this variable.
@@ -602,7 +602,7 @@ bool decideWhetherToUseGpuForUpdate(const bool                     isDomainDecom
     {
         errorMessage += "Compatible GPUs must have been found.\n";
     }
-    if (GMX_GPU != GMX_GPU_CUDA)
+    if (!GMX_GPU_CUDA)
     {
         errorMessage += "Only a CUDA build is supported.\n";
     }
index fef7f2cb9091af653cd24ef1dd42663f6cc0a61f..7e3f5cfc2b061729d770b40108c6ff5f5145b81c 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_USE_CUDA)
+if (GMX_GPU_CUDA)
     gmx_add_libgromacs_sources(cuda_version_information.cu)
 endif()
 set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${UTILITY_SOURCES} PARENT_SCOPE)
index 1ce4dd4804abe91fc47e0bd290ee51bf99966c6b..8548a1818bac48a02dbe0a80da89901f70b4643c 100644 (file)
@@ -308,12 +308,12 @@ void gmx_print_version_info(gmx::TextWriter* writer)
     writer->writeLine(formatString("Linked with Intel MKL version %d.%d.%d.", __INTEL_MKL__,
                                    __INTEL_MKL_MINOR__, __INTEL_MKL_UPDATE__));
 #endif
-#if GMX_GPU == GMX_GPU_OPENCL
+#if GMX_GPU_OPENCL
     writer->writeLine(formatString("OpenCL include dir: %s", OPENCL_INCLUDE_DIR));
     writer->writeLine(formatString("OpenCL library:     %s", OPENCL_LIBRARY));
     writer->writeLine(formatString("OpenCL version:     %s", OPENCL_VERSION_STRING));
 #endif
-#if GMX_GPU == GMX_GPU_CUDA
+#if GMX_GPU_CUDA
     writer->writeLine(formatString("CUDA compiler:      %s", CUDA_COMPILER_INFO));
     writer->writeLine(formatString("CUDA compiler flags:%s %s", CUDA_COMPILER_FLAGS,
                                    CMAKE_BUILD_CONFIGURATION_CXX_FLAGS));
index 772544d328e44893817632dc0379d2ad8a97d3a0..ca57f3422c548152063d2a7e634b04eacd614539 100644 (file)
@@ -435,7 +435,7 @@ TEST_P(MdrunNoAppendContinuationIsExact, WithinTolerances)
 // TODO The time for OpenCL kernel compilation means these tests time
 // out. Once that compilation is cached for the whole process, these
 // tests can run in such configurations.
-#if GMX_GPU != GMX_GPU_OPENCL
+#if !GMX_GPU_OPENCL
 
 INSTANTIATE_TEST_CASE_P(
         NormalIntegrators,
index a909f4e6506289c519f25b98e6568c11e34f0361..887d1a8d9ab7b6b4037e25f037e1df5ff3f1a03f 100644 (file)
@@ -439,7 +439,7 @@ using ::testing::ValuesIn;
 // TODO The time for OpenCL kernel compilation means these tests time
 // out. Once that compilation is cached for the whole process, these
 // tests can run in such configurations.
-#if GMX_GPU != GMX_GPU_OPENCL
+#if !GMX_GPU_OPENCL
 INSTANTIATE_TEST_CASE_P(BasicPropagators,
                         PeriodicActionsTest,
                         Combine(ValuesIn(simplePropagationParameters()), Values(outputParameters)));
index b490d79901d05ae1bae88b9f44c48933165b66ed..72b23235840b3a881b81945017f11f02be28543a 100644 (file)
@@ -193,7 +193,7 @@ TEST_P(MdrunRerunTest, WithinTolerances)
 // TODO The time for OpenCL kernel compilation means these tests time
 // out. Once that compilation is cached for the whole process, these
 // tests can run in such configurations.
-#if GMX_GPU != GMX_GPU_OPENCL
+#if !GMX_GPU_OPENCL
 INSTANTIATE_TEST_CASE_P(
         NormalMdrunIsReproduced,
         MdrunRerunTest,
@@ -252,7 +252,7 @@ TEST_P(MdrunRerunFreeEnergyTest, WithinTolerances)
 // TODO The time for OpenCL kernel compilation means these tests time
 // out. Once that compilation is cached for the whole process, these
 // tests can run in such configurations.
-#if GMX_GPU != GMX_GPU_OPENCL
+#if !GMX_GPU_OPENCL
 INSTANTIATE_TEST_CASE_P(MdrunIsReproduced,
                         MdrunRerunFreeEnergyTest,
                         ::testing::Combine(::testing::Values("nonanol_vacuo"),
index e6c3fa3188912d3c1ff977aec088efc24606833a..eae77384e775dfe167f40a28d418ea2bf72da951 100644 (file)
@@ -207,7 +207,7 @@ TEST_P(SimulatorComparisonTest, WithinTolerances)
 //       tests can run in such configurations.
 // These tests are very sensitive, so we only run them in double precision.
 // As we change call ordering, they might actually become too strict to be useful.
-#if GMX_GPU != GMX_GPU_OPENCL && GMX_DOUBLE
+#if !GMX_GPU_OPENCL && GMX_DOUBLE
 INSTANTIATE_TEST_CASE_P(SimulatorsAreEquivalentDefaultModular,
                         SimulatorComparisonTest,
                         ::testing::Combine(::testing::Combine(::testing::Values("argon12", "tip3p5"),
index 8d5cf3b733863c5e4d248a3d60fce86fb8e4833e..a9fb476a567abcb23ddfc4419308a66f82190f29 100644 (file)
@@ -109,7 +109,7 @@ function (gmx_add_gtest_executable EXENAME)
                  TEST_USES_HARDWARE_DETECTION=true)
         endif()
 
-        if (GMX_USE_CUDA AND NOT GMX_CLANG_CUDA)
+        if (GMX_GPU_CUDA AND NOT GMX_CLANG_CUDA)
             # Work around FindCUDA that prevents using target_link_libraries()
             # with keywords otherwise...
             set(CUDA_LIBRARIES PRIVATE ${CUDA_LIBRARIES})
@@ -124,7 +124,7 @@ function (gmx_add_gtest_executable EXENAME)
                 ${TESTUTILS_DIR}/unittest_main.cpp)
         endif()
 
-        if (GMX_USE_CUDA)
+        if (GMX_GPU_CUDA)
             if (GMX_CLANG_CUDA)
                 target_sources(${EXENAME} PRIVATE
                     ${ARG_CUDA_CU_SOURCE_FILES}
@@ -135,7 +135,7 @@ function (gmx_add_gtest_executable EXENAME)
                     target_link_libraries(${EXENAME} PRIVATE ${GMX_EXTRA_LIBRARIES})
                 endif()
             endif()
-        elseif (GMX_USE_OPENCL)
+        elseif (GMX_GPU_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})
@@ -203,7 +203,7 @@ function (gmx_register_gtest_test NAME EXENAME)
             # Both OpenCL (from JIT) and ThreadSanitizer (from how it
             # checks) can take signficantly more time than other
             # configurations.
-            if (GMX_USE_OPENCL)
+            if (GMX_GPU_OPENCL)
                 set(_timeout 240)
             elseif (${CMAKE_BUILD_TYPE} STREQUAL TSAN)
                 set(_timeout 300)