From 416f52f28e6dbdec311dc9470c06d18aac2b06e2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 3 Feb 2012 23:12:01 -0500 Subject: [PATCH] fix race condition in derived neighborlist build --- src/USER-OMP/neigh_derive_omp.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/USER-OMP/neigh_derive_omp.cpp b/src/USER-OMP/neigh_derive_omp.cpp index 5f42dd2b50..187a6c8753 100644 --- a/src/USER-OMP/neigh_derive_omp.cpp +++ b/src/USER-OMP/neigh_derive_omp.cpp @@ -56,14 +56,14 @@ void Neighbor::half_from_full_no_newton_omp(NeighList *list) for (ii = ifrom; ii < ito; ii++) { +#if defined(_OPENMP) +#pragma omp critical +#endif if (pgsize - npnt < oneatom) { npnt = 0; npage += nthreads; // only one thread at a time may check whether we // need new neighbor list pages and then add to them. -#if defined(_OPENMP) -#pragma omp critical -#endif if (npage >= list->maxpage) list->add_pages(nthreads); } @@ -132,14 +132,14 @@ void Neighbor::half_from_full_newton_omp(NeighList *list) for (ii = ifrom; ii < ito; ii++) { +#if defined(_OPENMP) +#pragma omp critical +#endif if (pgsize - npnt < oneatom) { npnt = 0; npage += nthreads; // only one thread at a time may check whether we // need new neighbor list pages and then add to them. -#if defined(_OPENMP) -#pragma omp critical -#endif if (npage >= list->maxpage) list->add_pages(nthreads); }