Task assignment for bonded interactions on CUDA GPUs
[alexxy/gromacs.git] / src / gromacs / mdlib / forcerec.cpp
index f718d22cbfb2b5102b22aa796d1665b4b37ae780..2d931d28a4700a84bf01e86c59cb30768e7a28a8 100644 (file)
@@ -2315,6 +2315,7 @@ void init_forcerec(FILE                             *fp,
                    gmx::ArrayRef<const std::string>  tabbfnm,
                    const gmx_hw_info_t              &hardwareInfo,
                    const gmx_device_info_t          *deviceInfo,
+                   const bool                        useGpuForBonded,
                    gmx_bool                          bNoSolvOpt,
                    real                              print_force)
 {
@@ -3052,15 +3053,10 @@ void init_forcerec(FILE                             *fp,
     init_bonded_threading(fp, mtop->groups.grps[egcENER].nr,
                           &fr->bondedThreading);
 
-    // TODO: Replace this condition by the GPU bonded task boolean
-    if (fr->cutoff_scheme == ecutsVERLET && getenv("GMX_TEST_GPU_BONDEDS"))
+    if (useGpuForBonded)
     {
         fr->gpuBondedLists = new GpuBondedLists;
     }
-    else
-    {
-        fr->gpuBondedLists = nullptr;
-    }
 
     fr->nthread_ewc = gmx_omp_nthreads_get(emntBonded);
     snew(fr->ewc_t, fr->nthread_ewc);
@@ -3152,6 +3148,7 @@ void done_forcerec(t_forcerec *fr, int numMolBlocks, int numEnergyGroups)
     done_ns(fr->ns, numEnergyGroups);
     sfree(fr->ewc_t);
     tear_down_bonded_threading(fr->bondedThreading);
+    delete fr->gpuBondedLists;
     fr->bondedThreading = nullptr;
     sfree(fr);
 }