Fix compiler warning and use static_assert
authorArtem Zhmurov <zhmurov@gmail.com>
Tue, 11 May 2021 05:34:06 +0000 (08:34 +0300)
committerArtem Zhmurov <zhmurov@gmail.com>
Tue, 11 May 2021 07:44:13 +0000 (07:44 +0000)
1. The compiler assumes that GMX_GPU_CUDA and GMX_GPU_SYCL
   may be bit-fields and thus issue a warning if the logical
   or is used (constant-logical-operand). Casting them to
   booleans supresses the warning.
2. Change to use static_assert instead of the GMX_RELEASE_ASSERT
   because this code on a hot path.

src/gromacs/nbnxm/nbnxm_gpu_buffer_ops.cpp

index d24babbfda6a7b6eb20ccf87fc9333aa427ee15f..62ef8788aa7334e96d05a2d8501ac29ee1f2691b 100644 (file)
@@ -72,8 +72,8 @@ void nbnxn_gpu_x_to_nbat_x(const Nbnxm::Grid&      grid,
                            int                     numColumnsMax,
                            bool                    mustInsertNonLocalDependency)
 {
-    GMX_RELEASE_ASSERT(GMX_GPU_CUDA || GMX_GPU_SYCL,
-                       "nbnxn_gpu_x_to_nbat_x only supported with CUDA and SYCL");
+    static_assert((bool)GMX_GPU_CUDA || (bool)GMX_GPU_SYCL,
+                  "nbnxn_gpu_x_to_nbat_x only supported with CUDA and SYCL");
     GMX_ASSERT(nb, "Need a valid nbnxn_gpu object");
     gmx::InteractionLocality interactionLoc = gmx::atomToInteractionLocality(locality);