yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #06743
[Branch ~yade-dev/yade/trunk] Rev 2662: Fix cache line size in OpenMPArrayAccumulator
------------------------------------------------------------
revno: 2662
committer: Giulia Macaro <giulia@engs-19155>
branch nick: yade
timestamp: Wed 2011-01-19 10:21:31 +0000
message:
Fix cache line size in OpenMPArrayAccumulator
modified:
lib/base/openmp-accu.hpp
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'lib/base/openmp-accu.hpp'
--- lib/base/openmp-accu.hpp 2010-11-25 20:20:58 +0000
+++ lib/base/openmp-accu.hpp 2011-01-19 10:21:31 +0000
@@ -28,8 +28,8 @@
size_t nCL; // current number of allocated cache lines
int nCL_for_N(size_t n){ return n/perCL+(n%perCL==0 ? 0 : 1); } // return number of cache lines to allocate for given number of elements
public:
- OpenMPArrayAccumulator() : CLS(sysconf(_SC_LEVEL1_DCACHE_LINESIZE)), nThreads(omp_get_max_threads()), perCL(CLS/sizeof(T)), chunks(nThreads,NULL), sz(0), nCL(0) { }
- OpenMPArrayAccumulator(size_t n): CLS(sysconf(_SC_LEVEL1_DCACHE_LINESIZE)), nThreads(omp_get_max_threads()), perCL(CLS/sizeof(T)), chunks(nThreads,NULL), sz(0), nCL(0) { resize(n); }
+ OpenMPArrayAccumulator() : CLS(sysconf(_SC_LEVEL1_DCACHE_LINESIZE)>0 ? sysconf(_SC_LEVEL1_DCACHE_LINESIZE) : 64), nThreads(omp_get_max_threads()), perCL(CLS/sizeof(T)), chunks(nThreads,NULL), sz(0), nCL(0) { }
+ OpenMPArrayAccumulator(size_t n): CLS(sysconf(_SC_LEVEL1_DCACHE_LINESIZE)>0 ? sysconf(_SC_LEVEL1_DCACHE_LINESIZE) : 64), nThreads(omp_get_max_threads()), perCL(CLS/sizeof(T)), chunks(nThreads,NULL), sz(0), nCL(0) { resize(n); }
// change number of elements
void resize(size_t n){
if(n==sz) return; // nothing to do