Changeset 5f9c42b for libcfa/src/concurrency/kernel
- Timestamp:
- Sep 29, 2022, 11:57:28 AM (23 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 77125cc
- Parents:
- 1756e08
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/cluster.hfa
r1756e08 r5f9c42b 23 23 //----------------------------------------------------------------------- 24 24 // 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 );25 static inline unsigned long long moving_average(unsigned long long currtsc, unsigned long long instsc, unsigned long long old_avg, bool strict) { 26 (void)strict; // disable the warning around the fact this is unused in release. 27 27 28 28 const unsigned long long new_val = currtsc > instsc ? currtsc - instsc : 0; … … 34 34 } 35 35 36 static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next ) {36 static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next, bool strict) { 37 37 if (ts_next == ULLONG_MAX) return; 38 38 unsigned long long now = rdtscl(); 39 39 unsigned long long pma = __atomic_load_n(&tscs[ idx ].t.ma, __ATOMIC_RELAXED); 40 40 __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);41 __atomic_store_n(&tscs[ idx ].t.ma, moving_average(now, ts_prev, pma, strict), __ATOMIC_RELAXED); 42 42 } 43 43 … … 51 51 Data_t * data, 52 52 __timestamp_t * tscs, 53 const unsigned shard_factor 53 const unsigned shard_factor, 54 bool strict 54 55 ) { 55 56 unsigned start = procid; … … 59 60 if(ptsc != ULLONG_MAX) { 60 61 /* paranoid */ verify( start + i < count ); 61 unsigned long long tsc = moving_average(ctsc, ptsc, tscs[start + i].t.ma );62 unsigned long long tsc = moving_average(ctsc, ptsc, tscs[start + i].t.ma, strict); 62 63 if(tsc > max) max = tsc; 63 64 }
Note: See TracChangeset
for help on using the changeset viewer.