Tweak PME run mode checks
authorSzilárd Páll <pall.szilard@gmail.com>
Tue, 17 Apr 2018 17:51:59 +0000 (19:51 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Sat, 21 Apr 2018 14:12:11 +0000 (16:12 +0200)
These should allow compile-time evaluation when mdrun is compiled with
GMX_GPU=OFF.

As the CPU-only build can now optimize out quite some code, this also
fixes a gcc 7 warning that an argument of pme_gpu_reduce_outputs()
may be used uninitialized.

Change-Id: I2397e0dc7e4e2f6587d01d94db27072938e85e7d

src/gromacs/ewald/pme.h
src/gromacs/mdlib/sim_util.cpp

index 168baaf0369932a279872e9851162db4d3fbcde9..f50e6c1e0e6f05865ed06ee46d807eeb6ea32f5b 100644 (file)
@@ -48,6 +48,8 @@
 #ifndef GMX_EWALD_PME_H
 #define GMX_EWALD_PME_H
 
+#include "config.h"
+
 #include <string>
 
 #include "gromacs/gpu_utils/gpu_macros.h"
@@ -264,7 +266,7 @@ PmeRunMode pme_run_mode(const gmx_pme_t *pme);
  */
 inline bool pme_gpu_task_enabled(const gmx_pme_t *pme)
 {
-    return (pme != nullptr) && (pme_run_mode(pme) != PmeRunMode::CPU);
+    return (GMX_GPU != GMX_GPU_NONE) && (pme != nullptr) && (pme_run_mode(pme) != PmeRunMode::CPU);
 }
 
 // The following functions are all the PME GPU entry points,
index 366b265a38a649b38de31c907080c8d74781e0d6..04e6b6e7eded7497705832608eb540b786149159 100644 (file)
@@ -1070,7 +1070,7 @@ static void do_force_cutsVERLET(FILE *fplog, const t_commrec *cr,
     bUseGPU       = fr->nbv->bUseGPU;
     bUseOrEmulGPU = bUseGPU || (fr->nbv->emulateGpu == EmulateGpuNonbonded::Yes);
 
-    const auto pmeRunMode = fr->pmedata ? pme_run_mode(fr->pmedata) : PmeRunMode::CPU;
+    const auto pmeRunMode = ((GMX_GPU == GMX_GPU_NONE) || fr->pmedata == nullptr) ? PmeRunMode::CPU : pme_run_mode(fr->pmedata);
     // TODO slim this conditional down - inputrec and duty checks should mean the same in proper code!
     const bool useGpuPme  = EEL_PME(fr->ic->eeltype) && thisRankHasDuty(cr, DUTY_PME) &&
         ((pmeRunMode == PmeRunMode::GPU) || (pmeRunMode == PmeRunMode::Mixed));