Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel/cluster.hfa

    r33e4968e raa144c5a  
    2121#include <limits.h>
    2222
    23 #include "clock.hfa"
    24 
    2523//-----------------------------------------------------------------------
    2624// 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 );
     25static 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 );
    3027
    3128        const unsigned long long new_val = currtsc > instsc ? currtsc - instsc : 0;
     
    3431        const unsigned long long old_weight = total_weight - new_weight;
    3532        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 );
    3833        return ret;
    3934}
    4035
    41 static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next, bool strict) {
     36static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next) {
    4237        if (ts_next == ULLONG_MAX) return;
    4338        unsigned long long now = rdtscl();
    4439        unsigned long long pma = __atomic_load_n(&tscs[ idx ].t.ma, __ATOMIC_RELAXED);
    4540        __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);
    4742}
    4843
     
    5651        Data_t * data,
    5752        __timestamp_t * tscs,
    58         const unsigned shard_factor,
    59         bool strict
     53        const unsigned shard_factor
    6054) {
    6155        unsigned start = procid;
     
    6559                if(ptsc != ULLONG_MAX) {
    6660                        /* 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);
    6862                        if(tsc > max) max = tsc;
    6963                }
Note: See TracChangeset for help on using the changeset viewer.