Changeset 78d6c803
- Timestamp:
- Apr 15, 2021, 4:01:50 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3531e09
- Parents:
- e2cc3c7
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.hfa
re2cc3c7 r78d6c803 159 159 // Structure holding the relaxed ready queue 160 160 struct __ready_queue_t { 161 // Data tracking how many/which lanes are used162 // Aligned to 128 for cache locality163 __snzi_t snzi;164 165 161 // Data tracking the actual lanes 166 162 // On a seperate cacheline from the used struct since -
libcfa/src/concurrency/ready_queue.cfa
re2cc3c7 r78d6c803 17 17 // #define __CFA_DEBUG_PRINT_READY_QUEUE__ 18 18 19 // #define USE_SNZI20 19 // #define USE_MPSC 21 20 … … 29 28 #include <unistd.h> 30 29 31 #include "snzi.hfa"32 30 #include "ready_subqueue.hfa" 33 31 … … 202 200 void ^?{}(__ready_queue_t & this) with (this) { 203 201 verify( 1 == lanes.count ); 204 #ifdef USE_SNZI205 verify( !query( snzi ) );206 #endif207 202 free(lanes.data); 208 203 } … … 210 205 //----------------------------------------------------------------------- 211 206 __attribute__((hot)) bool query(struct cluster * cltr) { 212 #ifdef USE_SNZI213 return query(cltr->ready_queue.snzi);214 #endif215 207 return true; 216 208 } … … 293 285 294 286 // Actually push it 295 #ifdef USE_SNZI296 bool lane_first =297 #endif298 299 287 push(lanes.data[i], thrd); 300 301 #ifdef USE_SNZI302 // If this lane used to be empty we need to do more303 if(lane_first) {304 // Check if the entire queue used to be empty305 first = !query(snzi);306 307 // Update the snzi308 arrive( snzi, i );309 }310 #endif311 288 312 289 #if !defined(USE_MPSC) … … 351 328 352 329 // As long as the list is not empty, try finding a lane that isn't empty and pop from it 353 #ifdef USE_SNZI 354 while( query(snzi) ) { 355 #else 356 for(25) { 357 #endif 330 for(25) { 358 331 // Pick two lists at random 359 332 // unsigned ri = __tls_rand(); … … 447 420 /* paranoid */ verify(lane.lock); 448 421 449 #ifdef USE_SNZI450 // If this was the last element in the lane451 if(emptied) {452 depart( snzi, w );453 }454 #endif455 456 422 // Unlock and return 457 423 __atomic_unlock(&lane.lock); … … 484 450 485 451 removed = true; 486 #ifdef USE_SNZI487 if(emptied) {488 depart( snzi, i );489 }490 #endif491 452 } 492 453 __atomic_unlock(&lane.lock); … … 571 532 // grow the ready queue 572 533 with( cltr->ready_queue ) { 573 #ifdef USE_SNZI574 ^(snzi){};575 #endif576 577 534 // Find new count 578 535 // Make sure we always have atleast 1 list … … 598 555 // Update original 599 556 lanes.count = ncount; 600 601 #ifdef USE_SNZI602 // Re-create the snzi603 snzi{ log2( lanes.count / 8 ) };604 for( idx; (size_t)lanes.count ) {605 if( !is_empty(lanes.data[idx]) ) {606 arrive(snzi, idx);607 }608 }609 #endif610 557 } 611 558 … … 631 578 632 579 with( cltr->ready_queue ) { 633 #ifdef USE_SNZI634 ^(snzi){};635 #endif636 637 580 // Remember old count 638 581 size_t ocount = lanes.count; … … 685 628 fix(lanes.data[idx]); 686 629 } 687 688 #ifdef USE_SNZI689 // Re-create the snzi690 snzi{ log2( lanes.count / 8 ) };691 for( idx; (size_t)lanes.count ) {692 if( !is_empty(lanes.data[idx]) ) {693 arrive(snzi, idx);694 }695 }696 #endif697 630 } 698 631
Note: See TracChangeset
for help on using the changeset viewer.