diff --git a/src/core/ActionWithValue.cpp b/src/core/ActionWithValue.cpp index 98d1c0810f31e0dc167cdcb0ef145e47f18dad7b..7a921ddbd941188b27365e8ad3d526823a80cd8c 100644 --- a/src/core/ActionWithValue.cpp +++ b/src/core/ActionWithValue.cpp @@ -70,7 +70,7 @@ void ActionWithValue::clearInputForces() { } void ActionWithValue::clearDerivatives() { - unsigned nt = OpenMP::getGoodNumThreads(values); + unsigned nt = OpenMP::getNumThreads(values); #pragma omp parallel num_threads(nt) { #pragma omp for diff --git a/src/tools/OpenMP.h b/src/tools/OpenMP.h index 43d9442e86c83bce0bae66d4bfa176050bac86bd..202f7ca58a11c445225ff85201a8eb6fa5479237 100644 --- a/src/tools/OpenMP.h +++ b/src/tools/OpenMP.h @@ -55,7 +55,7 @@ unsigned OpenMP::getGoodNumThreads(const T*x,unsigned n) { (void) p; // this is not to have warnings. notice that the pointer location is not used actually. // a factor two is necessary since there is no guarantee that x is aligned // to cache line boundary - unsigned m=n/(2*getCachelineSize()*sizeof(T)); + unsigned m=n*sizeof(T)/(2*getCachelineSize()); unsigned numThreads=getNumThreads(); if(m>numThreads) m=numThreads; if(m==0) m=1;