fixed nbnxn hybrid mode with OpenMP
authorBerk Hess <hess@kth.se>
Fri, 11 Jan 2013 13:59:31 +0000 (14:59 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 17 Jan 2013 00:31:29 +0000 (01:31 +0100)
Fixes #1100

Change-Id: I2f3c95f698852ab496a648a04555c0e9ecb57463

src/mdlib/nbnxn_search.c

index 000f0806bf0f14f39601aad215c8a35f07553e4d..32c5113b3b3d0c977cb3f082f1822f19a8420c17 100644 (file)
@@ -4806,6 +4806,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;
@@ -4815,6 +4816,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;
@@ -4825,7 +4829,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);
     }
@@ -4922,7 +4927,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);
                 }