Ignore:
Timestamp:
Jul 28, 2022, 12:04:25 PM (22 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
32d1383, d0fcc82
Parents:
3f95dab (diff), 2af1943 (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.cfa

    r3f95dab rc4c8571  
    229229                        for( idx ; lanes_count ) {
    230230                                __intrusive_lane_t & sl = readyQ.data[idx];
    231                                 assert(!readyQ.data[idx].lock);
     231                                assert(!readyQ.data[idx].l.lock);
    232232
    233233                                        if(is_empty(sl)) {
    234                                                 assert( sl.anchor.next == 0p );
    235                                                 assert( sl.anchor.ts   == MAX );
    236                                                 assert( mock_head(sl)  == sl.prev );
     234                                                assert( sl.l.anchor.next == 0p );
     235                                                assert( sl.l.anchor.ts   == MAX );
     236                                                assert( mock_head(sl)  == sl.l.prev );
    237237                                        } else {
    238                                                 assert( sl.anchor.next != 0p );
    239                                                 assert( sl.anchor.ts   != MAX );
    240                                                 assert( mock_head(sl)  != sl.prev );
     238                                                assert( sl.l.anchor.next != 0p );
     239                                                assert( sl.l.anchor.ts   != MAX );
     240                                                assert( mock_head(sl)  != sl.l.prev );
    241241                                        }
    242242                        }
     
    249249static inline void fix(__intrusive_lane_t & ll) {
    250250        if(is_empty(ll)) {
    251                 verify(ll.anchor.next == 0p);
    252                 ll.prev = mock_head(ll);
     251                verify(ll.l.anchor.next == 0p);
     252                ll.l.prev = mock_head(ll);
    253253        }
    254254}
     
    299299        tscs = alloc(count, tscs`realloc);
    300300        for(i; count) {
    301                 tscs[i].tv = rdtscl();
    302                 tscs[i].ma = 0;
     301                tscs[i].t.tv = rdtscl();
     302                tscs[i].t.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].lock);
     402                        __attribute__((unused)) bool locked = __atomic_try_acquire(&readyQ.data[idx].l.lock);
    403403                        verify(locked);
    404404
     
    418418
    419419                        // Unlock the lane
    420                         __atomic_unlock(&readyQ.data[idx].lock);
     420                        __atomic_unlock(&readyQ.data[idx].l.lock);
    421421
    422422                        // TODO print the queue statistics here
     
    467467}
    468468
     469#define nested_offsetof(type, field) ((off_t)(&(((type*)0)-> field)))
     470
    469471// Ctor
    470472void ?{}( __intrusive_lane_t & this ) {
    471         this.lock = false;
    472         this.prev = mock_head(this);
    473         this.anchor.next = 0p;
    474         this.anchor.ts   = MAX;
     473        this.l.lock = false;
     474        this.l.prev = mock_head(this);
     475        this.l.anchor.next = 0p;
     476        this.l.anchor.ts   = MAX;
    475477        #if !defined(__CFA_NO_STATISTICS__)
    476                 this.cnt  = 0;
     478                this.l.cnt  = 0;
    477479        #endif
    478480
    479481        // We add a boat-load of assertions here because the anchor code is very fragile
    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   );
     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   );
    485487        /* paranoid */ verify( mock_head(this)->link.next == 0p );
    486488        /* paranoid */ verify( mock_head(this)->link.ts   == MAX );
    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 }
     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
    492496
    493497// Dtor is trivial
    494498void ^?{}( __intrusive_lane_t & this ) {
    495499        // Make sure the list is empty
    496         /* paranoid */ verify( this.anchor.next == 0p );
    497         /* paranoid */ verify( this.anchor.ts   == MAX );
    498         /* paranoid */ verify( mock_head(this)  == this.prev );
     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 );
    499503}
    500504
Note: See TracChangeset for help on using the changeset viewer.