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)
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();
/*! \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.
*
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;
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;
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,