Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / mdlib / nbnxn_search.c
index 5b16fc06a7326e90b870e86a9aee0ee89260229b..d0f32ee8e1b8e3ce4c8bdfcc74c72912315474fe 100644 (file)
@@ -4800,6 +4800,7 @@ void nbnxn_make_pairlist(const nbnxn_search_t nbs,
                          t_nrnb *nrnb)
 {
     nbnxn_grid_t *gridi,*gridj;
+    gmx_bool bGPUCPU;
     int nzi,zi,zj0,zj1,zj;
     int nsubpair_max;
     int th;
@@ -4809,6 +4810,9 @@ void nbnxn_make_pairlist(const nbnxn_search_t nbs,
     gmx_bool CombineNBLists;
     int np_tot,np_noq,np_hlj,nap;
 
+    /* Check if we are running hybrid GPU + CPU nbnxn mode */
+    bGPUCPU = (!nbs->grid[0].bSimple && nbl_list->bSimple);
+
     nnbl            = nbl_list->nnbl;
     nbl             = nbl_list->nbl;
     CombineNBLists  = nbl_list->bCombined;
@@ -4819,7 +4823,8 @@ void nbnxn_make_pairlist(const nbnxn_search_t nbs,
     }
 
     nbat->bUseBufferFlags = (nbat->nout > 1);
-    if (nbat->bUseBufferFlags && LOCAL_I(iloc))
+    /* We should re-init the flags before making the first list */
+    if (nbat->bUseBufferFlags && (LOCAL_I(iloc) || bGPUCPU))
     {
         init_buffer_flags(&nbat->buffer_flags,nbat->natoms);
     }
@@ -4916,7 +4921,11 @@ void nbnxn_make_pairlist(const nbnxn_search_t nbs,
 #pragma omp parallel for num_threads(nnbl) schedule(static)
             for(th=0; th<nnbl; th++)
             {
-                if (nbat->bUseBufferFlags && zi == 0 && zj == 0)
+                /* Re-init the thread-local work flag data before making
+                 * the first list (not an elegant conditional).
+                 */
+                if (nbat->bUseBufferFlags && ((zi == 0 && zj == 0) ||
+                                              (bGPUCPU && zi == 0 && zj == 1)))
                 {
                     init_buffer_flags(&nbs->work[th].buffer_flags,nbat->natoms);
                 }