Cleaning booleans in NBNXM in OpenCL build
authorArtem Zhmurov <zhmurov@gmail.com>
Thu, 30 Jan 2020 12:56:17 +0000 (13:56 +0100)
committerPaul Bauer <paul.bauer.q@gmail.com>
Thu, 30 Jan 2020 15:27:01 +0000 (16:27 +0100)
Patch 93f2f30017595e419d25c5dd6fa6a8b320a1858f changed some of the
booleans types from cl_bool to bool, but not changed how these
variables were used in some places. This caused the compiler to be
confused with the data types, trying to convert bool to int or
to cl_bool.

Change-Id: Ib8017bbdac804f3946e65698df5882c669250044

src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu
src/gromacs/nbnxm/gpu_common.h
src/gromacs/nbnxm/gpu_data_mgmt.h
src/gromacs/nbnxm/opencl/nbnxm_ocl.cpp
src/gromacs/nbnxm/opencl/nbnxm_ocl_data_mgmt.cpp

index d99bdfd7749999fb8aa9a8604f435a7eef46bd7d..b2fc758417a814784fcc3ee1b9abf8c7881aa5de 100644 (file)
@@ -417,7 +417,7 @@ NbnxmGpu* gpu_init(const gmx_device_info_t*   deviceInfo,
                    const PairlistParams&      listParams,
                    const nbnxn_atomdata_t*    nbat,
                    int /*rank*/,
-                   gmx_bool bLocalAndNonlocal)
+                   bool bLocalAndNonlocal)
 {
     cudaError_t stat;
 
index dcfd2f8fefdc9806ca805ce39f6a71dea875f101..65f38daea2b4902e243ccca4a372418f495cb493 100644 (file)
@@ -418,8 +418,7 @@ bool gpu_try_finish_task(NbnxmGpu*                nb,
         // TODO: this needs to be moved later because conditional wait could brake timing
         // with a future OpenCL implementation, but with CUDA timing is anyway disabled
         // in all cases where we skip the wait.
-        gpu_accumulate_timings(nb->timings, nb->timers, nb->plist[iLocality], aloc, stepWork,
-                               nb->bDoTime != 0);
+        gpu_accumulate_timings(nb->timings, nb->timers, nb->plist[iLocality], aloc, stepWork, nb->bDoTime);
 
         if (stepWork.computeEnergy || stepWork.computeVirial)
         {
index 30d44159cac0d592d5f0acd5f1a752cb4a531f39..9d7502cdbd20518f73b0106b52ca7478b3ec2e57 100644 (file)
@@ -69,7 +69,7 @@ NbnxmGpu* gpu_init(const gmx_device_info_t gmx_unused* deviceInfo,
                    const nbnxn_atomdata_t gmx_unused* nbat,
                    int gmx_unused rank,
                    /* true if both local and non-local are done on GPU */
-                   gmx_bool gmx_unused bLocalAndNonlocal) GPU_FUNC_TERM_WITH_RETURN(nullptr);
+                   bool gmx_unused bLocalAndNonlocal) GPU_FUNC_TERM_WITH_RETURN(nullptr);
 
 /** Initializes pair-list data for GPU, called at every pair search step. */
 GPU_FUNC_QUALIFIER
index 12d38ed2677adf97a65a55a3977e13d087d5db34..90dbf0a3362ae1fcf133b703b19f737cfa0e4a5a 100644 (file)
@@ -488,7 +488,7 @@ void gpu_copy_xq_to_gpu(NbnxmGpu* nb, const nbnxn_atomdata_t* nbatom, const Atom
     cl_timers_t*     t      = nb->timers;
     cl_command_queue stream = nb->stream[iloc];
 
-    bool bDoTime = (nb->bDoTime) != 0;
+    bool bDoTime = nb->bDoTime;
 
     /* Don't launch the non-local H2D copy if there is no dependent
        work to do: neither non-local nor other (e.g. bonded) work
@@ -588,7 +588,7 @@ void gpu_launch_kernel(NbnxmGpu* nb, const gmx::StepWorkload& stepWork, const Nb
     cl_timers_t*     t      = nb->timers;
     cl_command_queue stream = nb->stream[iloc];
 
-    bool bDoTime = (nb->bDoTime) != 0;
+    bool bDoTime = nb->bDoTime;
 
     cl_nbparam_params_t nbparams_params;
 
@@ -726,7 +726,7 @@ void gpu_launch_kernel_pruneonly(NbnxmGpu* nb, const InteractionLocality iloc, c
     cl_plist_t*      plist   = nb->plist[iloc];
     cl_timers_t*     t       = nb->timers;
     cl_command_queue stream  = nb->stream[iloc];
-    bool             bDoTime = nb->bDoTime == CL_TRUE;
+    bool             bDoTime = nb->bDoTime;
 
     if (plist->haveFreshList)
     {
@@ -861,7 +861,7 @@ void gpu_launch_cpyback(NbnxmGpu*                nb,
 
     cl_atomdata_t*   adat    = nb->atdat;
     cl_timers_t*     t       = nb->timers;
-    bool             bDoTime = nb->bDoTime == CL_TRUE;
+    bool             bDoTime = nb->bDoTime;
     cl_command_queue stream  = nb->stream[iloc];
 
     /* don't launch non-local copy-back if there was no non-local work to do */
index e7b2884f1a0032dad014e57761e8946bb31d106b..2556ea62618e7d3bc224062c4ad4d88ff1cb3d58 100644 (file)
@@ -614,7 +614,7 @@ NbnxmGpu* gpu_init(const gmx_device_info_t*   deviceInfo,
                    const PairlistParams&      listParams,
                    const nbnxn_atomdata_t*    nbat,
                    const int                  rank,
-                   const gmx_bool             bLocalAndNonlocal)
+                   const bool                 bLocalAndNonlocal)
 {
     cl_int                      cl_error;
     cl_command_queue_properties queue_properties;
@@ -630,7 +630,7 @@ NbnxmGpu* gpu_init(const gmx_device_info_t*   deviceInfo,
         snew(nb->plist[InteractionLocality::NonLocal], 1);
     }
 
-    nb->bUseTwoStreams = static_cast<cl_bool>(bLocalAndNonlocal);
+    nb->bUseTwoStreams = bLocalAndNonlocal;
 
     nb->timers = new cl_timers_t();
     snew(nb->timings, 1);
@@ -647,7 +647,7 @@ NbnxmGpu* gpu_init(const gmx_device_info_t*   deviceInfo,
     init_plist(nb->plist[InteractionLocality::Local]);
 
     /* OpenCL timing disabled if GMX_DISABLE_GPU_TIMING is defined. */
-    nb->bDoTime = static_cast<cl_bool>(getenv("GMX_DISABLE_GPU_TIMING") == nullptr);
+    nb->bDoTime = (getenv("GMX_DISABLE_GPU_TIMING") == nullptr);
 
     /* Create queues only after bDoTime has been initialized */
     if (nb->bDoTime)
@@ -762,7 +762,7 @@ void gpu_init_pairlist(NbnxmGpu* nb, const NbnxnPairlistGpu* h_plist, const Inte
     // Timing accumulation should happen only if there was work to do
     // because getLastRangeTime() gets skipped with empty lists later
     // which leads to the counter not being reset.
-    bool             bDoTime = ((nb->bDoTime == CL_TRUE) && !h_plist->sci.empty());
+    bool             bDoTime = (nb->bDoTime && !h_plist->sci.empty());
     cl_command_queue stream  = nb->stream[iloc];
     cl_plist_t*      d_plist = nb->plist[iloc];
 
@@ -837,7 +837,7 @@ void gpu_init_atomdata(NbnxmGpu* nb, const nbnxn_atomdata_t* nbat)
     cl_int           cl_error;
     int              nalloc, natoms;
     bool             realloced;
-    bool             bDoTime = nb->bDoTime == CL_TRUE;
+    bool             bDoTime = nb->bDoTime;
     cl_timers_t*     timers  = nb->timers;
     cl_atomdata_t*   d_atdat = nb->atdat;
     cl_command_queue ls      = nb->stream[InteractionLocality::Local];