From 76905a9810c2a730e3e42c9067dd950a8f9dcbde Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Thu, 22 Jun 2017 19:17:57 +0200 Subject: [PATCH] Cleaned up high-level boolean variable naming 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 | 12 +++++----- src/gromacs/mdlib/calc_verletbuf.h | 8 +++---- src/programs/mdrun/runner.cpp | 33 ++++++++++++++-------------- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/gromacs/mdlib/calc_verletbuf.cpp b/src/gromacs/mdlib/calc_verletbuf.cpp index fcc6b690e5..2b5c938127 100644 --- a/src/gromacs/mdlib/calc_verletbuf.cpp +++ b/src/gromacs/mdlib/calc_verletbuf.cpp @@ -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); diff --git a/src/gromacs/mdlib/calc_verletbuf.h b/src/gromacs/mdlib/calc_verletbuf.h index 097e900d78..1f073ff758 100644 --- a/src/gromacs/mdlib/calc_verletbuf.h +++ b/src/gromacs/mdlib/calc_verletbuf.h @@ -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); diff --git a/src/programs/mdrun/runner.cpp b/src/programs/mdrun/runner.cpp index 769346196e..4aa7d11b81 100644 --- a/src/programs/mdrun/runner.cpp +++ b/src/programs/mdrun/runner.cpp @@ -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"); -- 2.22.0