Ignore:
Timestamp:
Oct 2, 2022, 10:00:43 PM (6 months ago)
Author:
Peter A. Buhr <pabuhr@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    rf704974 rae151cf  
    2121#include <limits.h>
    2222
     23#include "clock.hfa"
     24
    2325//-----------------------------------------------------------------------
    2426// 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 );
     27static 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 );
    2730
    2831        const unsigned long long new_val = currtsc > instsc ? currtsc - instsc : 0;
     
    3134        const unsigned long long old_weight = total_weight - new_weight;
    3235        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 );
    3338        return ret;
    3439}
    3540
    36 static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next) {
     41static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next, bool strict) {
    3742        if (ts_next == ULLONG_MAX) return;
    3843        unsigned long long now = rdtscl();
    3944        unsigned long long pma = __atomic_load_n(&tscs[ idx ].t.ma, __ATOMIC_RELAXED);
    4045        __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);
    4247}
    4348
     
    5156        Data_t * data,
    5257        __timestamp_t * tscs,
    53         const unsigned shard_factor
     58        const unsigned shard_factor,
     59        bool strict
    5460) {
    5561        unsigned start = procid;
     
    5965                if(ptsc != ULLONG_MAX) {
    6066                        /* 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);
    6268                        if(tsc > max) max = tsc;
    6369                }
Note: See TracChangeset for help on using the changeset viewer.