- File:
-
- 1 edited
-
libcfa/src/concurrency/ready_queue.cfa (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/ready_queue.cfa
re84ab3d r6ba6846 67 67 #endif 68 68 69 static inline struct thread$* try_pop(struct cluster * cltr, unsigned w __STATS(, __stats_readyQ_pop_t & stats));70 static inline struct thread$* try_pop(struct cluster * cltr, unsigned i, unsigned j __STATS(, __stats_readyQ_pop_t & stats));71 static inline struct thread$* search(struct cluster * cltr);69 static inline struct $thread * try_pop(struct cluster * cltr, unsigned w __STATS(, __stats_readyQ_pop_t & stats)); 70 static inline struct $thread * try_pop(struct cluster * cltr, unsigned i, unsigned j __STATS(, __stats_readyQ_pop_t & stats)); 71 static inline struct $thread * search(struct cluster * cltr); 72 72 static inline [unsigned, bool] idx_from_r(unsigned r, unsigned preferred); 73 73 … … 274 274 //----------------------------------------------------------------------- 275 275 #if defined(USE_CPU_WORK_STEALING) 276 __attribute__((hot)) void push(struct cluster * cltr, struct thread$* thrd, bool push_local) with (cltr->ready_queue) {276 __attribute__((hot)) void push(struct cluster * cltr, struct $thread * thrd, bool push_local) with (cltr->ready_queue) { 277 277 __cfadbg_print_safe(ready_queue, "Kernel : Pushing %p on cluster %p\n", thrd, cltr); 278 278 … … 316 316 317 317 // Pop from the ready queue from a given cluster 318 __attribute__((hot)) thread$* pop_fast(struct cluster * cltr) with (cltr->ready_queue) {318 __attribute__((hot)) $thread * pop_fast(struct cluster * cltr) with (cltr->ready_queue) { 319 319 /* paranoid */ verify( lanes.count > 0 ); 320 320 /* paranoid */ verify( kernelTLS().this_processor ); … … 371 371 proc->rdq.target = -1u; 372 372 if(lanes.tscs[target].tv < cutoff && ts(lanes.data[target]) < cutoff) { 373 thread$* t = try_pop(cltr, target __STATS(, __tls_stats()->ready.pop.help));373 $thread * t = try_pop(cltr, target __STATS(, __tls_stats()->ready.pop.help)); 374 374 proc->rdq.last = target; 375 375 if(t) return t; … … 379 379 unsigned last = proc->rdq.last; 380 380 if(last != -1u && lanes.tscs[last].tv < cutoff && ts(lanes.data[last]) < cutoff) { 381 thread$* t = try_pop(cltr, last __STATS(, __tls_stats()->ready.pop.help));381 $thread * t = try_pop(cltr, last __STATS(, __tls_stats()->ready.pop.help)); 382 382 if(t) return t; 383 383 } … … 389 389 for(READYQ_SHARD_FACTOR) { 390 390 unsigned i = start + (proc->rdq.itr++ % READYQ_SHARD_FACTOR); 391 if( thread$* t = try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.local))) return t;391 if($thread * t = try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.local))) return t; 392 392 } 393 393 … … 396 396 } 397 397 398 __attribute__((hot)) struct thread$* pop_slow(struct cluster * cltr) with (cltr->ready_queue) {398 __attribute__((hot)) struct $thread * pop_slow(struct cluster * cltr) with (cltr->ready_queue) { 399 399 processor * const proc = kernelTLS().this_processor; 400 400 unsigned last = proc->rdq.last; 401 401 if(last != -1u) { 402 struct thread$* t = try_pop(cltr, last __STATS(, __tls_stats()->ready.pop.steal));402 struct $thread * t = try_pop(cltr, last __STATS(, __tls_stats()->ready.pop.steal)); 403 403 if(t) return t; 404 404 proc->rdq.last = -1u; … … 408 408 return try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.steal)); 409 409 } 410 __attribute__((hot)) struct thread$* pop_search(struct cluster * cltr) {410 __attribute__((hot)) struct $thread * pop_search(struct cluster * cltr) { 411 411 return search(cltr); 412 412 } … … 435 435 } 436 436 437 __attribute__((hot)) void push(struct cluster * cltr, struct thread$* thrd, bool push_local) with (cltr->ready_queue) {437 __attribute__((hot)) void push(struct cluster * cltr, struct $thread * thrd, bool push_local) with (cltr->ready_queue) { 438 438 __cfadbg_print_safe(ready_queue, "Kernel : Pushing %p on cluster %p\n", thrd, cltr); 439 439 … … 482 482 483 483 // Pop from the ready queue from a given cluster 484 __attribute__((hot)) thread$* pop_fast(struct cluster * cltr) with (cltr->ready_queue) {484 __attribute__((hot)) $thread * pop_fast(struct cluster * cltr) with (cltr->ready_queue) { 485 485 /* paranoid */ verify( lanes.count > 0 ); 486 486 /* paranoid */ verify( kernelTLS().this_processor ); … … 506 506 507 507 // try popping from the 2 picked lists 508 struct thread$* thrd = try_pop(cltr, i, j __STATS(, *(locali || localj ? &__tls_stats()->ready.pop.local : &__tls_stats()->ready.pop.help)));508 struct $thread * thrd = try_pop(cltr, i, j __STATS(, *(locali || localj ? &__tls_stats()->ready.pop.local : &__tls_stats()->ready.pop.help))); 509 509 if(thrd) { 510 510 return thrd; … … 516 516 } 517 517 518 __attribute__((hot)) struct thread$* pop_slow(struct cluster * cltr) { return pop_fast(cltr); }519 __attribute__((hot)) struct thread$* pop_search(struct cluster * cltr) {518 __attribute__((hot)) struct $thread * pop_slow(struct cluster * cltr) { return pop_fast(cltr); } 519 __attribute__((hot)) struct $thread * pop_search(struct cluster * cltr) { 520 520 return search(cltr); 521 521 } 522 522 #endif 523 523 #if defined(USE_WORK_STEALING) 524 __attribute__((hot)) void push(struct cluster * cltr, struct thread$* thrd, bool push_local) with (cltr->ready_queue) {524 __attribute__((hot)) void push(struct cluster * cltr, struct $thread * thrd, bool push_local) with (cltr->ready_queue) { 525 525 __cfadbg_print_safe(ready_queue, "Kernel : Pushing %p on cluster %p\n", thrd, cltr); 526 526 … … 576 576 577 577 // Pop from the ready queue from a given cluster 578 __attribute__((hot)) thread$* pop_fast(struct cluster * cltr) with (cltr->ready_queue) {578 __attribute__((hot)) $thread * pop_fast(struct cluster * cltr) with (cltr->ready_queue) { 579 579 /* paranoid */ verify( lanes.count > 0 ); 580 580 /* paranoid */ verify( kernelTLS().this_processor ); … … 598 598 const unsigned long long cutoff = proc->rdq.cutoff > bias ? proc->rdq.cutoff - bias : proc->rdq.cutoff; 599 599 if(lanes.tscs[target].tv < cutoff && ts(lanes.data[target]) < cutoff) { 600 thread$* t = try_pop(cltr, target __STATS(, __tls_stats()->ready.pop.help));600 $thread * t = try_pop(cltr, target __STATS(, __tls_stats()->ready.pop.help)); 601 601 if(t) return t; 602 602 } … … 605 605 for(READYQ_SHARD_FACTOR) { 606 606 unsigned i = proc->rdq.id + (proc->rdq.itr++ % READYQ_SHARD_FACTOR); 607 if( thread$* t = try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.local))) return t;607 if($thread * t = try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.local))) return t; 608 608 } 609 609 return 0p; 610 610 } 611 611 612 __attribute__((hot)) struct thread$* pop_slow(struct cluster * cltr) with (cltr->ready_queue) {612 __attribute__((hot)) struct $thread * pop_slow(struct cluster * cltr) with (cltr->ready_queue) { 613 613 unsigned i = __tls_rand() % lanes.count; 614 614 return try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.steal)); 615 615 } 616 616 617 __attribute__((hot)) struct thread$* pop_search(struct cluster * cltr) with (cltr->ready_queue) {617 __attribute__((hot)) struct $thread * pop_search(struct cluster * cltr) with (cltr->ready_queue) { 618 618 return search(cltr); 619 619 } … … 628 628 //----------------------------------------------------------------------- 629 629 // try to pop from a lane given by index w 630 static inline struct thread$* try_pop(struct cluster * cltr, unsigned w __STATS(, __stats_readyQ_pop_t & stats)) with (cltr->ready_queue) {630 static inline struct $thread * try_pop(struct cluster * cltr, unsigned w __STATS(, __stats_readyQ_pop_t & stats)) with (cltr->ready_queue) { 631 631 __STATS( stats.attempt++; ) 632 632 … … 651 651 652 652 // Actually pop the list 653 struct thread$* thrd;653 struct $thread * thrd; 654 654 unsigned long long tsv; 655 655 [thrd, tsv] = pop(lane); … … 678 678 // try to pop from any lanes making sure you don't miss any threads push 679 679 // before the start of the function 680 static inline struct thread$* search(struct cluster * cltr) with (cltr->ready_queue) {680 static inline struct $thread * search(struct cluster * cltr) with (cltr->ready_queue) { 681 681 /* paranoid */ verify( lanes.count > 0 ); 682 682 unsigned count = __atomic_load_n( &lanes.count, __ATOMIC_RELAXED ); … … 684 684 for(i; count) { 685 685 unsigned idx = (offset + i) % count; 686 struct thread$* thrd = try_pop(cltr, idx __STATS(, __tls_stats()->ready.pop.search));686 struct $thread * thrd = try_pop(cltr, idx __STATS(, __tls_stats()->ready.pop.search)); 687 687 if(thrd) { 688 688 return thrd; … … 719 719 //----------------------------------------------------------------------- 720 720 // Given 2 indexes, pick the list with the oldest push an try to pop from it 721 static inline struct thread$* try_pop(struct cluster * cltr, unsigned i, unsigned j __STATS(, __stats_readyQ_pop_t & stats)) with (cltr->ready_queue) {721 static inline struct $thread * try_pop(struct cluster * cltr, unsigned i, unsigned j __STATS(, __stats_readyQ_pop_t & stats)) with (cltr->ready_queue) { 722 722 // Pick the bet list 723 723 int w = i; … … 854 854 // As long as we can pop from this lane to push the threads somewhere else in the queue 855 855 while(!is_empty(lanes.data[idx])) { 856 struct thread$* thrd;856 struct $thread * thrd; 857 857 unsigned long long _; 858 858 [thrd, _] = pop(lanes.data[idx]);
Note:
See TracChangeset
for help on using the changeset viewer.