Unify and clarify a couple of macro definitions in NBNXM
authorArtem Zhmurov <zhmurov@gmail.com>
Thu, 18 Feb 2021 16:31:47 +0000 (19:31 +0300)
committerAndrey Alekseenko <al42and@gmail.com>
Fri, 19 Feb 2021 10:03:42 +0000 (10:03 +0000)
1. The GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY definition was
essentially duplicated in CUDA and OpenCL. This unify them.

2. The 1/sqrt(PI) macro was defined several times in OpenCL.

src/gromacs/nbnxm/cuda/nbnxm_cuda.cu
src/gromacs/nbnxm/cuda/nbnxm_cuda_types.h
src/gromacs/nbnxm/gpu_types_common.h
src/gromacs/nbnxm/opencl/nbnxm_ocl.cpp
src/gromacs/nbnxm/opencl/nbnxm_ocl_consts.h
src/gromacs/nbnxm/opencl/nbnxm_ocl_types.h

index aa5652011b1dbeb1939990919a606cfe16827b71..6796da5aac6660b63ea165d0397aadcc779d1ca4 100644 (file)
@@ -735,7 +735,7 @@ void gpu_launch_kernel_pruneonly(NbnxmGpu* nb, const InteractionLocality iloc, c
      *   and j-cluster concurrency, in x, y, and z, respectively.
      * - The 1D block-grid contains as many blocks as super-clusters.
      */
-    int num_threads_z = c_cudaPruneKernelJ4Concurrency;
+    int num_threads_z = c_pruneKernelJ4Concurrency;
     int nblock        = calc_nb_kernel_nblock(numSciInPart, &nb->deviceContext_->deviceInfo());
     KernelLaunchConfig config;
     config.blockSize[0]     = c_clSize;
index 1cd1606de36903a28a3f76921ed5336870f7c66e..65a247ad08408a498790eca6d971d8f1fd361df5 100644 (file)
 #include "gromacs/timing/gpu_timing.h"
 #include "gromacs/utility/enumerationhelpers.h"
 
-/*! \brief Macro definining default for the prune kernel's j4 processing concurrency.
- *
- *  The GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY macro allows compile-time override.
- */
-#ifndef GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY
-#    define GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY 4
-#endif
-/*! \brief Default for the prune kernel's j4 processing concurrency.
- *
- *  Initialized using the #GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY macro which allows compile-time override.
- */
-const int c_cudaPruneKernelJ4Concurrency = GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY;
-
 /* TODO: consider moving this to kernel_utils */
 /* Convenience defines */
 /*! \brief cluster size = number of atoms per cluster. */
index 26cd3c165f633817e335b1aaa1d64a3432b99b6f..ebd5db9b343981ae46000064eefe8f58b3b58472 100644 (file)
 #    include "gromacs/gpu_utils/gpuregiontimer_sycl.h"
 #endif
 
+/*! \brief Macro definining default for the prune kernel's j4 processing concurrency.
+ *
+ *  The GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY macro allows compile-time override with the default value of 4.
+ */
+#ifndef GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY
+#    define GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY 4
+#endif
+//! Default for the prune kernel's j4 processing concurrency.
+static constexpr int c_pruneKernelJ4Concurrency = GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY;
+
 /** \internal
  * \brief Parameters required for the GPU nonbonded calculations.
  */
index 16cd265d84a95c66d13760bbed60a51d74e95caf..7e4eeca4842e639421be45c3fe3c0affcf5421f9 100644 (file)
@@ -860,9 +860,7 @@ void gpu_launch_kernel_pruneonly(NbnxmGpu* nb, const InteractionLocality iloc, c
      *   and j-cluster concurrency, in x, y, and z, respectively.
      * - The 1D block-grid contains as many blocks as super-clusters.
      */
-    int num_threads_z = c_oclPruneKernelJ4ConcurrencyDEFAULT;
-
-
+    int num_threads_z = c_pruneKernelJ4Concurrency;
     /* kernel launch config */
     KernelLaunchConfig config;
     config.sharedMemorySize = calc_shmem_required_prune(num_threads_z);
index 87872c6552eec67a01d182e40fe1786a81ebe64a..bef4f21f16e282a1e0fe4e240498f5c6b52b2234 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,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.
  * \author Berk Hess <hess@kth.se>
  * \ingroup module_nbnxm
  */
-#ifndef NBNXN_OPENCL_CONSTS_H
-#define NBNXN_OPENCL_CONSTS_H
+#ifndef NBNXN_OCL_CONSTS_H
+#define NBNXN_OCL_CONSTS_H
 
-/*! \internal \file
- * \brief Macros defining platform-dependent defaults for the prune kernel's j4 processing concurrency.
- *
- *  The GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY macro allows compile-time override.
+/*! \brief Macro definining default for the prune kernel's j4 processing concurrency.
  *
- * \ingroup module_nbnxm
+ *  The GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY macro allows compile-time override with the default value of 4.
  */
-/*! @{ */
-#define GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY_DEFAULT 4
-// The following has to match getOclPruneKernelJ4Concurrency
-#define GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY_DEFAULT
-/*! @} */
+#ifndef GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY
+#    define GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY 4
+#endif
+
 #endif
index 2e7098227dbaeb3d7f4ade34a9e0a42ab2f7341d..013345b32c5132f81d9272bd3d9104d6aec28d1b 100644 (file)
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/real.h"
 
-#include "nbnxm_ocl_consts.h"
-
 struct gmx_wallclock_gpu_nbnxn_t;
 
-/* kernel does #include "gromacs/math/utilities.h" */
-/* Move the actual useful stuff here: */
-
-//! Define 1/sqrt(pi)
-#define M_FLOAT_1_SQRTPI 0.564189583547756f
-
-/*! \brief Constants for platform-dependent defaults for the prune kernel's j4 processing concurrency.
- *
- *  Initialized using macros that can be overridden at compile-time (using #GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY).
- */
-/*! @{ */
-const int c_oclPruneKernelJ4ConcurrencyDEFAULT = GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY_DEFAULT;
-/*! @} */
-
 /*! \brief Pruning kernel flavors.
  *
  * The values correspond to the first call of the pruning post-list generation