Changeset c4c8571 for libcfa/src/concurrency/kernel/cluster.cfa
- Timestamp:
- Jul 28, 2022, 12:04:25 PM (2 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/cluster.cfa
r3f95dab rc4c8571 229 229 for( idx ; lanes_count ) { 230 230 __intrusive_lane_t & sl = readyQ.data[idx]; 231 assert(!readyQ.data[idx].l ock);231 assert(!readyQ.data[idx].l.lock); 232 232 233 233 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 ); 237 237 } 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 ); 241 241 } 242 242 } … … 249 249 static inline void fix(__intrusive_lane_t & ll) { 250 250 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); 253 253 } 254 254 } … … 299 299 tscs = alloc(count, tscs`realloc); 300 300 for(i; count) { 301 tscs[i].t v = rdtscl();302 tscs[i]. ma = 0;301 tscs[i].t.tv = rdtscl(); 302 tscs[i].t.ma = 0; 303 303 } 304 304 } … … 400 400 for( idx; ncount ~ ocount) { 401 401 // Lock is not strictly needed but makes checking invariants much easier 402 __attribute__((unused)) bool locked = __atomic_try_acquire(&readyQ.data[idx].l ock);402 __attribute__((unused)) bool locked = __atomic_try_acquire(&readyQ.data[idx].l.lock); 403 403 verify(locked); 404 404 … … 418 418 419 419 // Unlock the lane 420 __atomic_unlock(&readyQ.data[idx].l ock);420 __atomic_unlock(&readyQ.data[idx].l.lock); 421 421 422 422 // TODO print the queue statistics here … … 467 467 } 468 468 469 #define nested_offsetof(type, field) ((off_t)(&(((type*)0)-> field))) 470 469 471 // Ctor 470 472 void ?{}( __intrusive_lane_t & this ) { 471 this.l ock = 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; 475 477 #if !defined(__CFA_NO_STATISTICS__) 476 this. cnt = 0;478 this.l.cnt = 0; 477 479 #endif 478 480 479 481 // 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 ); 485 487 /* paranoid */ verify( mock_head(this)->link.next == 0p ); 486 488 /* 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 492 496 493 497 // Dtor is trivial 494 498 void ^?{}( __intrusive_lane_t & this ) { 495 499 // 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 ); 499 503 } 500 504
Note: See TracChangeset
for help on using the changeset viewer.