Add tests for PME tuning and fix mixed PME mode with tuning
authorAleksei Iupinov <a.yupinov@gmail.com>
Mon, 27 Nov 2017 09:50:23 +0000 (10:50 +0100)
committerAleksei Iupinov <a.yupinov@gmail.com>
Mon, 27 Nov 2017 17:39:43 +0000 (18:39 +0100)
Fixes #2303

Change-Id: Id9acd3d9b01b585d772b2009dcea9a9e0b8b0539

src/gromacs/ewald/pme-gpu-internal.cpp
src/gromacs/ewald/pme-solve.cpp
src/programs/mdrun/tests/pmetest.cpp

index 58bacd6dbd04df68b69e1d95c697a697b8c229cc..9edcb6ad08c9f5ac5236355d4ef8d08487133e1e 100644 (file)
@@ -417,6 +417,10 @@ void pme_gpu_reinit(gmx_pme_t *pme, gmx_device_info_t *gpuInfo)
 
     pme_gpu_reinit_grids(pme->gpu);
     pme_gpu_reinit_computation(pme->gpu);
+    /* Clear the previous box - doesn't hurt, and forces the PME CPU recipbox
+     * update for mixed mode on grid switch. TODO: use shared recipbox field.
+     */
+    std::memset(pme->gpu->common->previousBox, 0, sizeof(pme->gpu->common->previousBox));
 }
 
 void pme_gpu_destroy(PmeGpu *pmeGPU)
index a51039d8560e70e36b3742b2c19faf1cb784a1dc..28a020ae892ef44836e712ad0a0d95d8ddcf8966 100644 (file)
@@ -364,6 +364,8 @@ int solve_pme_yzx(const gmx_pme_t *pme, t_complex *grid, real vol,
     rzy = pme->recipbox[ZZ][YY];
     rzz = pme->recipbox[ZZ][ZZ];
 
+    GMX_ASSERT(rxx != 0.0, "Someone broke the reciprocal box again");
+
     maxkx = (nx+1)/2;
     maxky = (ny+1)/2;
 
index e1acdc8dee1c4940e0e01673959b7f3ebd58b422..57ae23e152f422767b151c97c2ca13806a624c37 100644 (file)
@@ -133,6 +133,10 @@ TEST_F(PmeTest, ReproducesEnergies)
     runModes["PmeOnGpuFftOnCpu"] = {"-pme", "gpu", "-pmefft", "cpu"};
     runModes["PmeOnGpuFftOnGpu"] = {"-pme", "gpu", "-pmefft", "gpu"};
     runModes["PmeOnGpuFftAuto"]  = {"-pme", "gpu", "-pmefft", "auto"};
+    // same manual modes but marked for PME tuning
+    runModes["PmeOnCpuTune"]         = {"-pme", "cpu"};
+    runModes["PmeOnGpuFftOnCpuTune"] = {"-pme", "gpu", "-pmefft", "cpu"};
+    runModes["PmeOnGpuFftOnGpuTune"] = {"-pme", "gpu", "-pmefft", "gpu"};
     TestReferenceData    refData;
     TestReferenceChecker rootChecker(refData.rootChecker());
     const bool           thisRankChecks = (gmx_node_rank() == 0);
@@ -154,7 +158,17 @@ TEST_F(PmeTest, ReproducesEnergies)
         runner_.edrFileName_ = fileManager_.getTemporaryFilePath(inputFile + "_" + mode.first + ".edr");
 
         CommandLine commandLine(mode.second);
-        commandLine.append("-notunepme"); // for reciprocal energy reproducibility
+
+        const bool  usePmeTuning = (mode.first.find("Tune") != std::string::npos);
+        if (usePmeTuning)
+        {
+            commandLine.append("-tunepme");
+            commandLine.addOption("-nstlist", 1); // a new grid every step
+        }
+        else
+        {
+            commandLine.append("-notunepme"); // for reciprocal energy reproducibility
+        }
         if (useSeparatePme)
         {
             commandLine.addOption("-npme", 1);
@@ -182,7 +196,10 @@ TEST_F(PmeTest, ReproducesEnergies)
                     conservedChecker.setDefaultTolerance(conservedTolerance);
                 }
                 conservedChecker.checkReal(conservedEnergy, stepNum.c_str());
-                reciprocalChecker.checkReal(reciprocalEnergy, stepNum.c_str());
+                if (!usePmeTuning) // with PME tuning come differing grids and differing reciprocal energy
+                {
+                    reciprocalChecker.checkReal(reciprocalEnergy, stepNum.c_str());
+                }
             }
         }
         // FIXME: without this barrier, one of the mdruns was somehow having a non-PME inputrec (!)