Changeset ae151cf for libcfa/src/concurrency/kernel/cluster.hfa
- Timestamp:
- Oct 2, 2022, 10:00:43 PM (6 months ago)
- Branches:
- master
- Children:
- 815943f
- Parents:
- f704974 (diff), f92e7b9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/cluster.hfa
rf704974 rae151cf 21 21 #include <limits.h> 22 22 23 #include "clock.hfa" 24 23 25 //----------------------------------------------------------------------- 24 26 // Calc moving average based on existing average, before and current time. 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 ); 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 ); 27 30 28 31 const unsigned long long new_val = currtsc > instsc ? currtsc - instsc : 0; … … 31 34 const unsigned long long old_weight = total_weight - new_weight; 32 35 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 ); 33 38 return ret; 34 39 } 35 40 36 static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next ) {41 static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next, bool strict) { 37 42 if (ts_next == ULLONG_MAX) return; 38 43 unsigned long long now = rdtscl(); 39 44 unsigned long long pma = __atomic_load_n(&tscs[ idx ].t.ma, __ATOMIC_RELAXED); 40 45 __atomic_store_n(&tscs[ idx ].t.tv, ts_next, __ATOMIC_RELAXED); 41 __atomic_store_n(&tscs[ idx ].t.ma, moving_average(now, ts_prev, pma ), __ATOMIC_RELAXED);46 __atomic_store_n(&tscs[ idx ].t.ma, moving_average(now, ts_prev, pma, strict), __ATOMIC_RELAXED); 42 47 } 43 48 … … 51 56 Data_t * data, 52 57 __timestamp_t * tscs, 53 const unsigned shard_factor 58 const unsigned shard_factor, 59 bool strict 54 60 ) { 55 61 unsigned start = procid; … … 59 65 if(ptsc != ULLONG_MAX) { 60 66 /* paranoid */ verify( start + i < count ); 61 unsigned long long tsc = moving_average(ctsc, ptsc, tscs[start + i].t.ma );67 unsigned long long tsc = moving_average(ctsc, ptsc, tscs[start + i].t.ma, strict); 62 68 if(tsc > max) max = tsc; 63 69 }
Note: See TracChangeset
for help on using the changeset viewer.