diff --git a/src/core/ActionWithValue.cpp b/src/core/ActionWithValue.cpp index ef05e47fd748fb5041912230aa59a36c1ba50b17..63e2a3af1045007c2c99a3fa342fb257b5c66e97 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;