Cleaned up high-level boolean variable naming
authorMark Abraham <mark.j.abraham@gmail.com>
Thu, 22 Jun 2017 17:17:57 +0000 (19:17 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 28 Jun 2017 15:24:01 +0000 (17:24 +0200)
Variables like bSIMD and bGPU were rather unclear about what
they actually meant.

Modernized to remove b prefixes and to use C++ bool type. Clarified
that some variables related to the use of a physical, rather than
emulated, GPU.

No changes to logic, just renaming.

Change-Id: I2bce7e1d554d3910fbbe685bae0d6a32bf50ac91

src/gromacs/mdlib/calc_verletbuf.cpp
src/gromacs/mdlib/calc_verletbuf.h
src/programs/mdrun/runner.cpp

index fcc6b690e5631efe78bc0b8a55de2dd7a61c392e..2b5c938127646fe6a09c8461f0ceece59623e025 100644 (file)
@@ -107,8 +107,8 @@ typedef struct
     real  md3; // -V''' at the cutoff
 } pot_derivatives_t;
 
-void verletbuf_get_list_setup(gmx_bool gmx_unused     bSIMD,
-                              gmx_bool                bGPU,
+void verletbuf_get_list_setup(bool                    makeSimdPairList,
+                              bool                    makeGpuPairList,
                               verletbuf_list_setup_t *list_setup)
 {
     /* When calling this function we often don't know which kernel type we
@@ -119,9 +119,9 @@ void verletbuf_get_list_setup(gmx_bool gmx_unused     bSIMD,
      * of size 1, 2 or 4, so for 4x8 or 8x8 we use the estimate for 4x4.
      */
 
-    if (bGPU)
+    if (makeGpuPairList)
     {
-        /* The CUDA kernels split the j-clusters in two halves */
+        /* The GPU kernels split the j-clusters in two halves */
         list_setup->cluster_size_i = nbnxn_kernel_to_cluster_i_size(nbnxnk8x8x8_GPU);
         list_setup->cluster_size_j = nbnxn_kernel_to_cluster_j_size(nbnxnk8x8x8_GPU)/2;
     }
@@ -131,8 +131,7 @@ void verletbuf_get_list_setup(gmx_bool gmx_unused     bSIMD,
 
         kernel_type = nbnxnk4x4_PlainC;
 
-#if GMX_SIMD
-        if (bSIMD)
+        if (GMX_SIMD && makeSimdPairList)
         {
 #ifdef GMX_NBNXN_SIMD_2XNN
             /* We use the smallest cluster size to be on the safe side */
@@ -141,7 +140,6 @@ void verletbuf_get_list_setup(gmx_bool gmx_unused     bSIMD,
             kernel_type = nbnxnk4xN_SIMD_4xN;
 #endif
         }
-#endif
 
         list_setup->cluster_size_i = nbnxn_kernel_to_cluster_i_size(kernel_type);
         list_setup->cluster_size_j = nbnxn_kernel_to_cluster_j_size(kernel_type);
index 097e900d788855d500e6b61e3bf2a4706e16c6f0..1f073ff758578baeac9b962df31000a64bac9437 100644 (file)
@@ -67,11 +67,11 @@ static const real verlet_buffer_ratio_NVE_T0     = 0.10;
 /* Sets the pair-list setup assumed for the current Gromacs configuration.
  * The setup with smallest cluster sizes is return, such that the Verlet
  * buffer size estimated with this setup will be conservative.
- * bSIMD tells if to take into account SIMD, when supported.
- * bGPU tells to estimate for GPU kernels (bSIMD is ignored with bGPU=TRUE)
+ * makeSimdPairList tells if to take into account SIMD, when supported.
+ * makeGpuPairList tells to estimate for GPU kernels (makeSimdPairList is ignored with makeGpuPairList==true)
  */
-void verletbuf_get_list_setup(gmx_bool                bSIMD,
-                              gmx_bool                bGPU,
+void verletbuf_get_list_setup(bool                    makeSimdPairList,
+                              bool                    makeGpuPairList,
                               verletbuf_list_setup_t *list_setup);
 
 
index 769346196e51da399c731a3d565f68193c2181c1..4aa7d11b81a00ad4a661eac2d54d6171592033dd 100644 (file)
@@ -338,7 +338,7 @@ static const float  nbnxn_gpu_listfac_max   = 1.30;
 static void increase_nstlist(FILE *fp, t_commrec *cr,
                              t_inputrec *ir, int nstlist_cmdline,
                              const gmx_mtop_t *mtop, matrix box,
-                             gmx_bool bGPU, const gmx::CpuInfo &cpuinfo)
+                             bool makeGpuPairList, const gmx::CpuInfo &cpuinfo)
 {
     float                  listfac_ok, listfac_max;
     int                    nstlist_orig, nstlist_prev;
@@ -364,7 +364,7 @@ static void increase_nstlist(FILE *fp, t_commrec *cr,
             return;
         }
 
-        if (fp != nullptr && bGPU && ir->nstlist < nstlist_try[0])
+        if (fp != nullptr && makeGpuPairList && ir->nstlist < nstlist_try[0])
         {
             fprintf(fp, nstl_gpu, ir->nstlist);
         }
@@ -394,7 +394,7 @@ static void increase_nstlist(FILE *fp, t_commrec *cr,
         return;
     }
 
-    if (ir->verletbuf_tol == 0 && bGPU)
+    if (ir->verletbuf_tol == 0 && makeGpuPairList)
     {
         gmx_fatal(FARGS, "You are using an old tpr file with a GPU, please generate a new tpr file with an up to date version of grompp");
     }
@@ -413,7 +413,7 @@ static void increase_nstlist(FILE *fp, t_commrec *cr,
         return;
     }
 
-    if (bGPU)
+    if (makeGpuPairList)
     {
         listfac_ok  = nbnxn_gpu_listfac_ok;
         listfac_max = nbnxn_gpu_listfac_max;
@@ -440,7 +440,7 @@ static void increase_nstlist(FILE *fp, t_commrec *cr,
         ir->nstlist = nstlist_cmdline;
     }
 
-    verletbuf_get_list_setup(TRUE, bGPU, &ls);
+    verletbuf_get_list_setup(true, makeGpuPairList, &ls);
 
     /* Allow rlist to make the list a given factor larger than the list
      * would be with the reference value for nstlist (10).
@@ -553,7 +553,7 @@ static void prepare_verlet_scheme(FILE                           *fplog,
                                   int                             nstlist_cmdline,
                                   const gmx_mtop_t               *mtop,
                                   matrix                          box,
-                                  gmx_bool                        bUseGPU,
+                                  bool                            makeGpuPairList,
                                   const gmx::CpuInfo             &cpuinfo)
 {
     /* For NVE simulations, we will retain the initial list buffer */
@@ -569,7 +569,7 @@ static void prepare_verlet_scheme(FILE                           *fplog,
          * calc_verlet_buffer_size gives the same results for 4x8 and 4x4
          * and 4x2 gives a larger buffer than 4x4, this is ok.
          */
-        verletbuf_get_list_setup(TRUE, bUseGPU, &ls);
+        verletbuf_get_list_setup(true, makeGpuPairList, &ls);
 
         calc_verlet_buffer_size(mtop, det(box), ir, -1, &ls, nullptr, &rlist_new);
 
@@ -594,7 +594,7 @@ static void prepare_verlet_scheme(FILE                           *fplog,
     if (EI_DYNAMICS(ir->eI))
     {
         /* Set or try nstlist values */
-        increase_nstlist(fplog, cr, ir, nstlist_cmdline, mtop, box, bUseGPU, cpuinfo);
+        increase_nstlist(fplog, cr, ir, nstlist_cmdline, mtop, box, makeGpuPairList, cpuinfo);
     }
 }
 
@@ -760,7 +760,6 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
              real pforce, real cpt_period, real max_hours,
              int imdport, unsigned long Flags)
 {
-    gmx_bool                  bForceUseGPU, bTryUseGPU, bRerunMD;
     matrix                    box;
     gmx_ddbox_t               ddbox = {0};
     int                       npme_major, npme_minor;
@@ -798,7 +797,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
     }
 
     bool doMembed = opt2bSet("-membed", nfile, fnm);
-    bRerunMD     = (Flags & MD_RERUN);
+    bool doRerun  = (Flags & MD_RERUN);
 
     /* Handle GPU-related user options. Later, we check consistency
      * with things like whether support is compiled, or tMPI thread
@@ -810,8 +809,8 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
     {
         gmx_fatal(FARGS, "GPU IDs were specified, and short-ranged interactions were assigned to the CPU. Make no more than one of these choices.");
     }
-    bForceUseGPU       = (strncmp(nbpu_opt, "gpu", 3) == 0) || userSetGpuIds;
-    bTryUseGPU         = (strncmp(nbpu_opt, "auto", 4) == 0) || bForceUseGPU;
+    bool forceUsePhysicalGpu = (strncmp(nbpu_opt, "gpu", 3) == 0) || userSetGpuIds;
+    bool tryUsePhysicalGpu   = (strncmp(nbpu_opt, "auto", 4) == 0) || forceUsePhysicalGpu;
 
     // Here we assume that SIMMASTER(cr) does not change even after the
     // threads are started.
@@ -820,7 +819,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
 
     /* Detect hardware, gather information. This is an operation that is
      * global for this process (MPI rank). */
-    hwinfo = gmx_detect_hardware(mdlog, cr, bTryUseGPU);
+    hwinfo = gmx_detect_hardware(mdlog, cr, tryUsePhysicalGpu);
 
     gmx_print_detected_hardware(fplog, cr, mdlog, hwinfo);
 
@@ -844,7 +843,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
         /* Read (nearly) all data required for the simulation */
         read_tpx_state(ftp2fn(efTPR, nfile, fnm), inputrec, state, mtop);
 
-        exitIfCannotForceGpuRun(bForceUseGPU,
+        exitIfCannotForceGpuRun(forceUsePhysicalGpu,
                                 inputrec->cutoff_scheme == ecutsVERLET,
                                 compatibleGpusFound(hwinfo->gpu_info));
 
@@ -855,10 +854,10 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
                        getenv("GMX_EMULATE_GPU") != nullptr);
 
             if (bUseGPU &&
-                !gpuAccelerationIsUseful(mdlog, inputrec, bRerunMD))
+                !gpuAccelerationIsUseful(mdlog, inputrec, doRerun))
             {
                 /* Fallback message printed by nbnxn_acceleration_supported */
-                if (bForceUseGPU)
+                if (forceUsePhysicalGpu)
                 {
                     gmx_fatal(FARGS, "GPU acceleration requested, but not supported with the given input settings");
                 }
@@ -986,7 +985,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
                   );
     }
 
-    if (bRerunMD &&
+    if (doRerun &&
         (EI_ENERGY_MINIMIZATION(inputrec->eI) || eiNM == inputrec->eI))
     {
         gmx_fatal(FARGS, "The .mdp file specified an energy mininization or normal mode algorithm, and these are not compatible with mdrun -rerun");