Ignore:
Timestamp:
Sep 29, 2022, 11:57:28 AM (4 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
master
Children:
77125cc
Parents:
1756e08
Message:

Added strict flag to moving average to keep track of which timestamps need to be correct

File:
1 edited

Legend:

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

    r1756e08 r5f9c42b  
    2323//-----------------------------------------------------------------------
    2424// 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 );
     25static 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.
    2727
    2828        const unsigned long long new_val = currtsc > instsc ? currtsc - instsc : 0;
     
    3434}
    3535
    36 static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next) {
     36static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next, bool strict) {
    3737        if (ts_next == ULLONG_MAX) return;
    3838        unsigned long long now = rdtscl();
    3939        unsigned long long pma = __atomic_load_n(&tscs[ idx ].t.ma, __ATOMIC_RELAXED);
    4040        __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);
    4242}
    4343
     
    5151        Data_t * data,
    5252        __timestamp_t * tscs,
    53         const unsigned shard_factor
     53        const unsigned shard_factor,
     54        bool strict
    5455) {
    5556        unsigned start = procid;
     
    5960                if(ptsc != ULLONG_MAX) {
    6061                        /* 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);
    6263                        if(tsc > max) max = tsc;
    6364                }
Note: See TracChangeset for help on using the changeset viewer.