Merge "Merge branch release-2016 into release-2018" into release-2018
authorBerk Hess <hess@kth.se>
Mon, 4 Dec 2017 12:38:52 +0000 (13:38 +0100)
committerBerk Hess <hess@kth.se>
Mon, 4 Dec 2017 12:38:52 +0000 (13:38 +0100)
src/gromacs/gpu_utils/gpu_utils.cu
src/gromacs/gpu_utils/gpu_utils.h
src/gromacs/mdlib/nbnxn_kernels/simd_2xnn/nbnxn_kernel_simd_2xnn_prune.cpp
src/gromacs/mdlib/nbnxn_kernels/simd_4xn/nbnxn_kernel_simd_4xn_prune.cpp
src/programs/mdrun/md.cpp

index 4e2200794089385cc0310117b7e24ca7064de543..273c3baba17bd3c76f90a916035361f1ed61d334 100644 (file)
@@ -536,6 +536,14 @@ void init_gpu(const gmx::MDLogger &mdlog,
 
 void free_gpu(const gmx_device_info_t *deviceInfo)
 {
+    // One should only attempt to clear the device context when
+    // it has been used, but currently the only way to know that a GPU
+    // device was used is that deviceInfo will be non-null.
+    if (deviceInfo == nullptr)
+    {
+        return;
+    }
+
     cudaError_t  stat;
 
     if (debug)
@@ -546,12 +554,9 @@ void free_gpu(const gmx_device_info_t *deviceInfo)
         fprintf(stderr, "Cleaning up context on GPU ID #%d\n", gpuid);
     }
 
-    if (deviceInfo != nullptr)
+    if (!reset_gpu_application_clocks(deviceInfo))
     {
-        if (!reset_gpu_application_clocks(deviceInfo))
-        {
-            gmx_warning("Failed to reset GPU application clocks on GPU #%d", deviceInfo->id);
-        }
+        gmx_warning("Failed to reset GPU application clocks on GPU #%d", deviceInfo->id);
     }
 
     stat = cudaDeviceReset();
index b1cc07b51f9b656dcd9d46f6575537638ae33d93..a3254bd467cdc9cf9226459d570cc326ec333ef1 100644 (file)
@@ -125,8 +125,12 @@ void init_gpu(const gmx::MDLogger &GPU_FUNC_ARGUMENT(mdlog),
 
 /*! \brief Frees up the CUDA GPU used by the active context at the time of calling.
  *
- * The context is explicitly destroyed and therefore all data uploaded to the GPU
- * is lost. This should only be called when none of this data is required anymore.
+ * If \c deviceInfo is nullptr, then it is understood that no device
+ * was selected so no context is active to be freed. Otherwise, the
+ * context is explicitly destroyed and therefore all data uploaded to
+ * the GPU is lost. This must only be called when none of this data is
+ * required anymore, because subsequent attempts to free memory
+ * associated with the context will otherwise fail.
  *
  * Calls gmx_warning upon errors.
  *
index 034d5b31dea185e812995e867d44fcc754f30d0e..eb3b8ba53e36f84b814d092248cd8ed0eaad3edf 100644 (file)
@@ -111,8 +111,8 @@ nbnxn_kernel_prune_2xnn(nbnxn_pairlist_t *         nbl,
             int cj      = cjOuter[cjind].cj;
 
             /* Atom indices (of the first atom in the cluster) */
-            int aj      = cj*UNROLLJ;
 #if UNROLLJ == STRIDE
+            int aj      = cj*UNROLLJ;
             int ajx     = aj*DIM;
 #else
             int ajx     = (cj >> 1)*DIM*STRIDE + (cj & 1)*UNROLLJ;
index d59d88e94df330a9c5cddee359973184b41d1dda..6072f56a270a1e6f095f8c06f43e4c9f1dba1da1 100644 (file)
@@ -117,8 +117,8 @@ nbnxn_kernel_prune_4xn(nbnxn_pairlist_t *         nbl,
             int cj      = cjOuter[cjind].cj;
 
             /* Atom indices (of the first atom in the cluster) */
-            int aj      = cj*UNROLLJ;
 #if UNROLLJ == STRIDE
+            int aj      = cj*UNROLLJ;
             int ajx     = aj*DIM;
 #else
             int ajx     = (cj >> 1)*DIM*STRIDE + (cj & 1)*UNROLLJ;
index 1f88f24d300f1343218c0286bbd42bd98ef7ed93..9604388c079c4816c219896a0d3b6edb17e2ee92 100644 (file)
@@ -721,6 +721,7 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
         if (bStopCM && cgloIteration == 0)
         {
             cglo_flags_iteration |= CGLO_STOPCM;
+            cglo_flags_iteration &= ~CGLO_TEMPERATURE;
         }
         compute_globals(fplog, gstat, cr, ir, fr, ekind, state, mdatoms, nrnb, vcm,
                         nullptr, enerd, force_vir, shake_vir, total_vir, pres, mu_tot,