Ignore:
File:
1 edited

Legend:

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

    r2af1943 r5024df4  
    229229                        for( idx ; lanes_count ) {
    230230                                __intrusive_lane_t & sl = readyQ.data[idx];
    231                                 assert(!readyQ.data[idx].l.lock);
     231                                assert(!readyQ.data[idx].lock);
    232232
    233233                                        if(is_empty(sl)) {
    234                                                 assert( sl.l.anchor.next == 0p );
    235                                                 assert( sl.l.anchor.ts   == MAX );
    236                                                 assert( mock_head(sl)  == sl.l.prev );
     234                                                assert( sl.anchor.next == 0p );
     235                                                assert( sl.anchor.ts   == MAX );
     236                                                assert( mock_head(sl)  == sl.prev );
    237237                                        } else {
    238                                                 assert( sl.l.anchor.next != 0p );
    239                                                 assert( sl.l.anchor.ts   != MAX );
    240                                                 assert( mock_head(sl)  != sl.l.prev );
     238                                                assert( sl.anchor.next != 0p );
     239                                                assert( sl.anchor.ts   != MAX );
     240                                                assert( mock_head(sl)  != sl.prev );
    241241                                        }
    242242                        }
     
    249249static inline void fix(__intrusive_lane_t & ll) {
    250250        if(is_empty(ll)) {
    251                 verify(ll.l.anchor.next == 0p);
    252                 ll.l.prev = mock_head(ll);
     251                verify(ll.anchor.next == 0p);
     252                ll.prev = mock_head(ll);
    253253        }
    254254}
     
    299299        tscs = alloc(count, tscs`realloc);
    300300        for(i; count) {
    301                 tscs[i].t.tv = rdtscl();
    302                 tscs[i].t.ma = 0;
     301                tscs[i].tv = rdtscl();
     302                tscs[i].ma = 0;
    303303        }
    304304}
     
    400400                for( idx; ncount ~ ocount) {
    401401                        // Lock is not strictly needed but makes checking invariants much easier
    402                         __attribute__((unused)) bool locked = __atomic_try_acquire(&readyQ.data[idx].l.lock);
     402                        __attribute__((unused)) bool locked = __atomic_try_acquire(&readyQ.data[idx].lock);
    403403                        verify(locked);
    404404
     
    418418
    419419                        // Unlock the lane
    420                         __atomic_unlock(&readyQ.data[idx].l.lock);
     420                        __atomic_unlock(&readyQ.data[idx].lock);
    421421
    422422                        // TODO print the queue statistics here
     
    467467}
    468468
    469 #define nested_offsetof(type, field) ((off_t)(&(((type*)0)-> field)))
    470 
    471469// Ctor
    472470void ?{}( __intrusive_lane_t & this ) {
    473         this.l.lock = false;
    474         this.l.prev = mock_head(this);
    475         this.l.anchor.next = 0p;
    476         this.l.anchor.ts   = MAX;
     471        this.lock = false;
     472        this.prev = mock_head(this);
     473        this.anchor.next = 0p;
     474        this.anchor.ts   = MAX;
    477475        #if !defined(__CFA_NO_STATISTICS__)
    478                 this.l.cnt  = 0;
     476                this.cnt  = 0;
    479477        #endif
    480478
    481479        // We add a boat-load of assertions here because the anchor code is very fragile
    482         /* paranoid */ _Static_assert( offsetof( thread$, link ) == nested_offsetof(__intrusive_lane_t, l.anchor) );
    483         /* paranoid */ verify( offsetof( thread$, link ) == nested_offsetof(__intrusive_lane_t, l.anchor) );
    484         /* paranoid */ verify( ((uintptr_t)( mock_head(this) ) + offsetof( thread$, link )) == (uintptr_t)(&this.l.anchor) );
    485         /* paranoid */ verify( &mock_head(this)->link.next == &this.l.anchor.next );
    486         /* paranoid */ verify( &mock_head(this)->link.ts   == &this.l.anchor.ts   );
     480        /* paranoid */ _Static_assert( offsetof( thread$, link ) == offsetof(__intrusive_lane_t, anchor) );
     481        /* paranoid */ verify( offsetof( thread$, link ) == offsetof(__intrusive_lane_t, anchor) );
     482        /* paranoid */ verify( ((uintptr_t)( mock_head(this) ) + offsetof( thread$, link )) == (uintptr_t)(&this.anchor) );
     483        /* paranoid */ verify( &mock_head(this)->link.next == &this.anchor.next );
     484        /* paranoid */ verify( &mock_head(this)->link.ts   == &this.anchor.ts   );
    487485        /* paranoid */ verify( mock_head(this)->link.next == 0p );
    488486        /* paranoid */ verify( mock_head(this)->link.ts   == MAX );
    489         /* paranoid */ verify( mock_head(this) == this.l.prev );
    490         /* paranoid */ verify( __alignof__(__intrusive_lane_t) == 64 );
    491         /* paranoid */ verify( __alignof__(this) == 64 );
    492         /* paranoid */ verifyf( ((intptr_t)(&this) % 64) == 0, "Expected address to be aligned %p %% 64 == %zd", &this, ((intptr_t)(&this) % 64) );
    493 }
    494 
    495 #undef nested_offsetof
     487        /* paranoid */ verify( mock_head(this) == this.prev );
     488        /* paranoid */ verify( __alignof__(__intrusive_lane_t) == 128 );
     489        /* paranoid */ verify( __alignof__(this) == 128 );
     490        /* paranoid */ verifyf( ((intptr_t)(&this) % 128) == 0, "Expected address to be aligned %p %% 128 == %zd", &this, ((intptr_t)(&this) % 128) );
     491}
    496492
    497493// Dtor is trivial
    498494void ^?{}( __intrusive_lane_t & this ) {
    499495        // Make sure the list is empty
    500         /* paranoid */ verify( this.l.anchor.next == 0p );
    501         /* paranoid */ verify( this.l.anchor.ts   == MAX );
    502         /* paranoid */ verify( mock_head(this)    == this.l.prev );
     496        /* paranoid */ verify( this.anchor.next == 0p );
     497        /* paranoid */ verify( this.anchor.ts   == MAX );
     498        /* paranoid */ verify( mock_head(this)  == this.prev );
    503499}
    504500
Note: See TracChangeset for help on using the changeset viewer.