From 33588f49fb750f81eb4db6f7da6f809590bfd58f Mon Sep 17 00:00:00 2001 From: Artem Zhmurov Date: Mon, 16 Aug 2021 19:04:30 +0300 Subject: [PATCH] Add common header to GpuEventSynchronizer Move the pre-processor conditional to a common header, that can be included unconditionally. Will simplify code unification further on. --- src/gromacs/domdec/gpuhaloexchange_impl.cu | 2 +- src/gromacs/domdec/gpuhaloexchange_impl.cuh | 2 +- src/gromacs/domdec/tests/haloexchange_mpi.cpp | 4 +- .../ewald/pme_coordinate_receiver_gpu_impl.cu | 2 +- .../ewald/pme_force_sender_gpu_impl.cu | 2 +- src/gromacs/ewald/pme_gpu_types_host_impl.h | 5 +- src/gromacs/ewald/pme_pp_comm_gpu_impl.cu | 2 +- src/gromacs/ewald/pme_pp_comm_gpu_impl.h | 2 +- src/gromacs/gpu_utils/gpueventsynchronizer.h | 54 +++++++++++++++++++ src/gromacs/mdlib/gpuforcereduction_impl.cpp | 6 +-- .../gpuforcereduction_impl_internal_sycl.cpp | 2 +- .../mdlib/update_constrain_gpu_impl.cpp | 6 +-- .../mdtypes/state_propagator_data_gpu_impl.h | 9 +--- src/gromacs/nbnxm/cuda/nbnxm_cuda.cu | 2 +- .../nbnxm/cuda/nbnxm_cuda_data_mgmt.cu | 2 +- src/gromacs/nbnxm/cuda/nbnxm_cuda_types.h | 2 +- src/gromacs/nbnxm/nbnxm_gpu_buffer_ops.cpp | 8 +-- src/gromacs/nbnxm/opencl/nbnxm_ocl_types.h | 2 +- src/gromacs/nbnxm/sycl/nbnxm_sycl_types.h | 2 +- 19 files changed, 74 insertions(+), 42 deletions(-) create mode 100644 src/gromacs/gpu_utils/gpueventsynchronizer.h diff --git a/src/gromacs/domdec/gpuhaloexchange_impl.cu b/src/gromacs/domdec/gpuhaloexchange_impl.cu index 3a245e21e4..5796b96980 100644 --- a/src/gromacs/domdec/gpuhaloexchange_impl.cu +++ b/src/gromacs/domdec/gpuhaloexchange_impl.cu @@ -58,7 +58,7 @@ #include "gromacs/gpu_utils/cudautils.cuh" #include "gromacs/gpu_utils/device_context.h" #include "gromacs/gpu_utils/devicebuffer.h" -#include "gromacs/gpu_utils/gpueventsynchronizer.cuh" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/gpu_utils/typecasts.cuh" #include "gromacs/gpu_utils/vectype_ops.cuh" #include "gromacs/math/vectypes.h" diff --git a/src/gromacs/domdec/gpuhaloexchange_impl.cuh b/src/gromacs/domdec/gpuhaloexchange_impl.cuh index 89ee12a2ea..6190a56b95 100644 --- a/src/gromacs/domdec/gpuhaloexchange_impl.cuh +++ b/src/gromacs/domdec/gpuhaloexchange_impl.cuh @@ -48,7 +48,7 @@ #include "gromacs/domdec/gpuhaloexchange.h" #include "gromacs/gpu_utils/device_context.h" -#include "gromacs/gpu_utils/gpueventsynchronizer.cuh" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/gpu_utils/hostallocator.h" #include "gromacs/utility/gmxmpi.h" diff --git a/src/gromacs/domdec/tests/haloexchange_mpi.cpp b/src/gromacs/domdec/tests/haloexchange_mpi.cpp index c763db0a9e..1f1138fb36 100644 --- a/src/gromacs/domdec/tests/haloexchange_mpi.cpp +++ b/src/gromacs/domdec/tests/haloexchange_mpi.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2020, by the GROMACS development team, led by + * Copyright (c) 2020,2021, 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. @@ -63,8 +63,8 @@ #if GMX_GPU_CUDA # include "gromacs/gpu_utils/device_stream.h" # include "gromacs/gpu_utils/devicebuffer.h" -# include "gromacs/gpu_utils/gpueventsynchronizer.cuh" #endif +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/gpu_utils/hostallocator.h" #include "gromacs/mdtypes/inputrec.h" diff --git a/src/gromacs/ewald/pme_coordinate_receiver_gpu_impl.cu b/src/gromacs/ewald/pme_coordinate_receiver_gpu_impl.cu index 6991fe77be..9de7c6676f 100644 --- a/src/gromacs/ewald/pme_coordinate_receiver_gpu_impl.cu +++ b/src/gromacs/ewald/pme_coordinate_receiver_gpu_impl.cu @@ -50,7 +50,7 @@ #include "gromacs/ewald/pme_force_sender_gpu.h" #include "gromacs/gpu_utils/cudautils.cuh" -#include "gromacs/gpu_utils/gpueventsynchronizer.cuh" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/utility/gmxmpi.h" namespace gmx diff --git a/src/gromacs/ewald/pme_force_sender_gpu_impl.cu b/src/gromacs/ewald/pme_force_sender_gpu_impl.cu index 105437e7f8..e037679cec 100644 --- a/src/gromacs/ewald/pme_force_sender_gpu_impl.cu +++ b/src/gromacs/ewald/pme_force_sender_gpu_impl.cu @@ -48,7 +48,7 @@ #include "config.h" #include "gromacs/gpu_utils/cudautils.cuh" -#include "gromacs/gpu_utils/gpueventsynchronizer.cuh" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/utility/gmxmpi.h" namespace gmx diff --git a/src/gromacs/ewald/pme_gpu_types_host_impl.h b/src/gromacs/ewald/pme_gpu_types_host_impl.h index 39b195d329..e1f7f17b90 100644 --- a/src/gromacs/ewald/pme_gpu_types_host_impl.h +++ b/src/gromacs/ewald/pme_gpu_types_host_impl.h @@ -52,16 +52,15 @@ #include #if GMX_GPU_CUDA -# include "gromacs/gpu_utils/gpueventsynchronizer.cuh" # include "gromacs/gpu_utils/gpuregiontimer.cuh" #elif GMX_GPU_OPENCL -# include "gromacs/gpu_utils/gpueventsynchronizer_ocl.h" # include "gromacs/gpu_utils/gpuregiontimer_ocl.h" #elif GMX_GPU_SYCL -# include "gromacs/gpu_utils/gpueventsynchronizer_sycl.h" # include "gromacs/gpu_utils/gpuregiontimer_sycl.h" #endif +#include "gromacs/gpu_utils/gpueventsynchronizer.h" + #include "gromacs/fft/gpu_3dfft.h" #include "gromacs/timing/gpu_timing.h" // for gtPME_EVENT_COUNT diff --git a/src/gromacs/ewald/pme_pp_comm_gpu_impl.cu b/src/gromacs/ewald/pme_pp_comm_gpu_impl.cu index e7d05b01f5..1ec7104ef1 100644 --- a/src/gromacs/ewald/pme_pp_comm_gpu_impl.cu +++ b/src/gromacs/ewald/pme_pp_comm_gpu_impl.cu @@ -52,7 +52,7 @@ #include "gromacs/gpu_utils/device_context.h" #include "gromacs/gpu_utils/device_stream.h" #include "gromacs/gpu_utils/devicebuffer.h" -#include "gromacs/gpu_utils/gpueventsynchronizer.cuh" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/gpu_utils/typecasts.cuh" #include "gromacs/utility/gmxmpi.h" diff --git a/src/gromacs/ewald/pme_pp_comm_gpu_impl.h b/src/gromacs/ewald/pme_pp_comm_gpu_impl.h index c9ac0d6dd2..13b72cc66a 100644 --- a/src/gromacs/ewald/pme_pp_comm_gpu_impl.h +++ b/src/gromacs/ewald/pme_pp_comm_gpu_impl.h @@ -44,7 +44,7 @@ #define GMX_PME_PP_COMM_GPU_IMPL_H #include "gromacs/ewald/pme_pp_comm_gpu.h" -#include "gromacs/gpu_utils/gpueventsynchronizer.cuh" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/math/vectypes.h" #include "gromacs/utility/gmxmpi.h" diff --git a/src/gromacs/gpu_utils/gpueventsynchronizer.h b/src/gromacs/gpu_utils/gpueventsynchronizer.h new file mode 100644 index 0000000000..3045c34e38 --- /dev/null +++ b/src/gromacs/gpu_utils/gpueventsynchronizer.h @@ -0,0 +1,54 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 2021, 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. + * + * GROMACS is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * GROMACS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with GROMACS; if not, see + * http://www.gnu.org/licenses, or write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * If you want to redistribute modifications to GROMACS, please + * consider that scientific software is very special. Version + * control is crucial - bugs must be traceable. We will be happy to + * consider code for inclusion in the official distribution, but + * derived work must not be called official GROMACS. Details are found + * in the README & COPYING files - if they are missing, get the + * official version 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. + */ +/*! \libinternal \file + * \brief Implements a GpuEventSynchronizer class for CUDA. + * + * \author Aleksei Iupinov + * \inlibraryapi + */ +#ifndef GMX_GPU_UTILS_GPUEVENTSYNCHRONIZER_H +#define GMX_GPU_UTILS_GPUEVENTSYNCHRONIZER_H + +#include "config.h" + +#if GMX_GPU_CUDA +# include "gromacs/gpu_utils/gpueventsynchronizer.cuh" +#elif GMX_GPU_OPENCL +# include "gromacs/gpu_utils/gpueventsynchronizer_ocl.h" +#elif GMX_GPU_SYCL +# include "gromacs/gpu_utils/gpueventsynchronizer_sycl.h" +#endif + +#endif // GMX_GPU_UTILS_GPUEVENTSYNCHRONIZER_H diff --git a/src/gromacs/mdlib/gpuforcereduction_impl.cpp b/src/gromacs/mdlib/gpuforcereduction_impl.cpp index 73972c3f66..fb9ab131bd 100644 --- a/src/gromacs/mdlib/gpuforcereduction_impl.cpp +++ b/src/gromacs/mdlib/gpuforcereduction_impl.cpp @@ -47,11 +47,7 @@ #include "gromacs/gpu_utils/device_stream.h" #include "gromacs/gpu_utils/devicebuffer.h" -#if GMX_GPU_CUDA -# include "gromacs/gpu_utils/gpueventsynchronizer.cuh" -#elif GMX_GPU_SYCL -# include "gromacs/gpu_utils/gpueventsynchronizer_sycl.h" -#endif +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/mdlib/gpuforcereduction_impl_internal.h" #include "gromacs/utility/gmxassert.h" diff --git a/src/gromacs/mdlib/gpuforcereduction_impl_internal_sycl.cpp b/src/gromacs/mdlib/gpuforcereduction_impl_internal_sycl.cpp index e2ee7b4697..0ccbc98e09 100644 --- a/src/gromacs/mdlib/gpuforcereduction_impl_internal_sycl.cpp +++ b/src/gromacs/mdlib/gpuforcereduction_impl_internal_sycl.cpp @@ -51,7 +51,7 @@ #include "gromacs/gpu_utils/gmxsycl.h" #include "gromacs/gpu_utils/devicebuffer.h" #include "gromacs/gpu_utils/gpu_utils.h" -#include "gromacs/gpu_utils/gpueventsynchronizer_sycl.h" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/utility/template_mp.h" //! \brief Class name for reduction kernel diff --git a/src/gromacs/mdlib/update_constrain_gpu_impl.cpp b/src/gromacs/mdlib/update_constrain_gpu_impl.cpp index 96d447d36c..9eceea17f1 100644 --- a/src/gromacs/mdlib/update_constrain_gpu_impl.cpp +++ b/src/gromacs/mdlib/update_constrain_gpu_impl.cpp @@ -59,11 +59,7 @@ #include "gromacs/gpu_utils/device_context.h" #include "gromacs/gpu_utils/device_stream.h" #include "gromacs/gpu_utils/devicebuffer.h" -#if GMX_GPU_CUDA -# include "gromacs/gpu_utils/gpueventsynchronizer.cuh" -#elif GMX_GPU_SYCL -# include "gromacs/gpu_utils/gpueventsynchronizer_sycl.h" -#endif +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/gpu_utils/gputraits.h" #include "gromacs/mdlib/leapfrog_gpu.h" #include "gromacs/mdlib/update_constrain_gpu.h" diff --git a/src/gromacs/mdtypes/state_propagator_data_gpu_impl.h b/src/gromacs/mdtypes/state_propagator_data_gpu_impl.h index cfceab3bff..ca319810cc 100644 --- a/src/gromacs/mdtypes/state_propagator_data_gpu_impl.h +++ b/src/gromacs/mdtypes/state_propagator_data_gpu_impl.h @@ -50,14 +50,7 @@ #include #include "gromacs/gpu_utils/devicebuffer.h" -#if GMX_GPU_CUDA -# include "gromacs/gpu_utils/gpueventsynchronizer.cuh" -#elif GMX_GPU_OPENCL -# include "gromacs/gpu_utils/gpueventsynchronizer_ocl.h" -#elif GMX_GPU_SYCL -# include "gromacs/gpu_utils/gpueventsynchronizer_sycl.h" -#endif - +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/math/vectypes.h" #include "gromacs/mdtypes/state_propagator_data_gpu.h" #include "gromacs/utility/enumerationhelpers.h" diff --git a/src/gromacs/nbnxm/cuda/nbnxm_cuda.cu b/src/gromacs/nbnxm/cuda/nbnxm_cuda.cu index ac5e50c8b1..093bbe01f0 100644 --- a/src/gromacs/nbnxm/cuda/nbnxm_cuda.cu +++ b/src/gromacs/nbnxm/cuda/nbnxm_cuda.cu @@ -55,7 +55,7 @@ #include "nbnxm_cuda.h" #include "gromacs/gpu_utils/gpu_utils.h" -#include "gromacs/gpu_utils/gpueventsynchronizer.cuh" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/gpu_utils/typecasts.cuh" #include "gromacs/gpu_utils/vectype_ops.cuh" #include "gromacs/hardware/device_information.h" diff --git a/src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu b/src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu index 20ea65b673..539a168229 100644 --- a/src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu +++ b/src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu @@ -53,7 +53,7 @@ #include "gromacs/gpu_utils/cudautils.cuh" #include "gromacs/gpu_utils/device_context.h" #include "gromacs/gpu_utils/gpu_utils.h" -#include "gromacs/gpu_utils/gpueventsynchronizer.cuh" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/gpu_utils/pmalloc.h" #include "gromacs/hardware/device_information.h" #include "gromacs/hardware/device_management.h" diff --git a/src/gromacs/nbnxm/cuda/nbnxm_cuda_types.h b/src/gromacs/nbnxm/cuda/nbnxm_cuda_types.h index 91464b8010..2d818afafa 100644 --- a/src/gromacs/nbnxm/cuda/nbnxm_cuda_types.h +++ b/src/gromacs/nbnxm/cuda/nbnxm_cuda_types.h @@ -50,7 +50,7 @@ #include "gromacs/gpu_utils/cudautils.cuh" #include "gromacs/gpu_utils/devicebuffer.h" #include "gromacs/gpu_utils/devicebuffer_datatype.h" -#include "gromacs/gpu_utils/gpueventsynchronizer.cuh" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/gpu_utils/gputraits.cuh" #include "gromacs/mdtypes/interaction_const.h" #include "gromacs/nbnxm/gpu_types_common.h" diff --git a/src/gromacs/nbnxm/nbnxm_gpu_buffer_ops.cpp b/src/gromacs/nbnxm/nbnxm_gpu_buffer_ops.cpp index f2ea0f2a7c..4a3b29cc04 100644 --- a/src/gromacs/nbnxm/nbnxm_gpu_buffer_ops.cpp +++ b/src/gromacs/nbnxm/nbnxm_gpu_buffer_ops.cpp @@ -44,13 +44,7 @@ #include "config.h" #include "gromacs/gpu_utils/device_stream.h" -#if GMX_GPU_CUDA -# include "gromacs/gpu_utils/gpueventsynchronizer.cuh" -#elif GMX_GPU_OPENCL -# include "gromacs/gpu_utils/gpueventsynchronizer_ocl.h" -#elif GMX_GPU_SYCL -# include "gromacs/gpu_utils/gpueventsynchronizer_sycl.h" -#endif +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/mdtypes/locality.h" #include "gromacs/nbnxm/gridset.h" #include "gromacs/nbnxm/nbnxm_gpu.h" diff --git a/src/gromacs/nbnxm/opencl/nbnxm_ocl_types.h b/src/gromacs/nbnxm/opencl/nbnxm_ocl_types.h index 3037663842..d2db1952ae 100644 --- a/src/gromacs/nbnxm/opencl/nbnxm_ocl_types.h +++ b/src/gromacs/nbnxm/opencl/nbnxm_ocl_types.h @@ -48,7 +48,7 @@ #include "gromacs/gpu_utils/devicebuffer.h" #include "gromacs/gpu_utils/gmxopencl.h" -#include "gromacs/gpu_utils/gpueventsynchronizer_ocl.h" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/gpu_utils/gputraits_ocl.h" #include "gromacs/gpu_utils/oclutils.h" #include "gromacs/mdtypes/interaction_const.h" diff --git a/src/gromacs/nbnxm/sycl/nbnxm_sycl_types.h b/src/gromacs/nbnxm/sycl/nbnxm_sycl_types.h index a0d8c914fc..babea21881 100644 --- a/src/gromacs/nbnxm/sycl/nbnxm_sycl_types.h +++ b/src/gromacs/nbnxm/sycl/nbnxm_sycl_types.h @@ -46,7 +46,7 @@ #include "gromacs/gpu_utils/devicebuffer.h" #include "gromacs/gpu_utils/devicebuffer_sycl.h" #include "gromacs/gpu_utils/gmxsycl.h" -#include "gromacs/gpu_utils/gpueventsynchronizer_sycl.h" +#include "gromacs/gpu_utils/gpueventsynchronizer.h" #include "gromacs/gpu_utils/gputraits.h" #include "gromacs/gpu_utils/syclutils.h" #include "gromacs/nbnxm/gpu_types_common.h" -- 2.22.0