- File:
-
- 1 edited
-
libcfa/src/concurrency/kernel/cluster.hfa (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/cluster.hfa
r33e4968e raa144c5a 21 21 #include <limits.h> 22 22 23 #include "clock.hfa"24 25 23 //----------------------------------------------------------------------- 26 24 // Calc moving average based on existing average, before and current time. 27 static inline unsigned long long moving_average(unsigned long long currtsc, unsigned long long instsc, unsigned long long old_avg, bool strict) { 28 (void)strict; // disable the warning around the fact this is unused in release. 29 /* paranoid */ warnf( !strict || old_avg < 33_000_000_000, "Suspiciously large previous average: %'llu (%llx), %'ldms \n", old_avg, old_avg, program()`ms ); 25 static inline unsigned long long moving_average(unsigned long long currtsc, unsigned long long instsc, unsigned long long old_avg) { 26 /* paranoid */ verifyf( old_avg < 15000000000000, "Suspiciously large previous average: %'llu (%llx)\n", old_avg, old_avg ); 30 27 31 28 const unsigned long long new_val = currtsc > instsc ? currtsc - instsc : 0; … … 34 31 const unsigned long long old_weight = total_weight - new_weight; 35 32 const unsigned long long ret = ((new_weight * new_val) + (old_weight * old_avg)) / total_weight; 36 37 /* paranoid */ warnf( !strict || ret < 33_000_000_000, "Suspiciously large new average after %'ldms cputime: %'llu (%llx) from %'llu-%'llu (%'llu, %'llu) and %'llu\n", program()`ms, ret, ret, currtsc, instsc, new_val, new_val / 1000000, old_avg );38 33 return ret; 39 34 } 40 35 41 static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next , bool strict) {36 static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next) { 42 37 if (ts_next == ULLONG_MAX) return; 43 38 unsigned long long now = rdtscl(); 44 39 unsigned long long pma = __atomic_load_n(&tscs[ idx ].t.ma, __ATOMIC_RELAXED); 45 40 __atomic_store_n(&tscs[ idx ].t.tv, ts_next, __ATOMIC_RELAXED); 46 __atomic_store_n(&tscs[ idx ].t.ma, moving_average(now, ts_prev, pma , strict), __ATOMIC_RELAXED);41 __atomic_store_n(&tscs[ idx ].t.ma, moving_average(now, ts_prev, pma), __ATOMIC_RELAXED); 47 42 } 48 43 … … 56 51 Data_t * data, 57 52 __timestamp_t * tscs, 58 const unsigned shard_factor, 59 bool strict 53 const unsigned shard_factor 60 54 ) { 61 55 unsigned start = procid; … … 65 59 if(ptsc != ULLONG_MAX) { 66 60 /* paranoid */ verify( start + i < count ); 67 unsigned long long tsc = moving_average(ctsc, ptsc, tscs[start + i].t.ma , strict);61 unsigned long long tsc = moving_average(ctsc, ptsc, tscs[start + i].t.ma); 68 62 if(tsc > max) max = tsc; 69 63 }
Note:
See TracChangeset
for help on using the changeset viewer.