- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/ready_queue.cfa
rf302d80 rd3ba775 398 398 399 399 if(proc->rdq.target == -1u) { 400 _Static_assert(READYQ_SHARD_FACTOR == 2); 401 unsigned idx1 = proc->rdq.id + 0; 402 unsigned idx2 = proc->rdq.id + 1; 400 proc->rdq.target = __tls_rand() % lanes.count; 401 unsigned it1 = proc->rdq.itr; 402 unsigned it2 = proc->rdq.itr + 1; 403 unsigned idx1 = proc->rdq.id + (it1 % READYQ_SHARD_FACTOR); 404 unsigned idx2 = proc->rdq.id + (it2 % READYQ_SHARD_FACTOR); 403 405 unsigned long long tsc1 = ts(lanes.data[idx1]); 404 406 unsigned long long tsc2 = ts(lanes.data[idx2]); 405 proc->rdq.target = __tls_rand() % lanes.count; 406 407 // WARNING: std::min is polymorphic and therefore causes 500% slowdown instead of the expected 2% 408 proc->rdq.cutoff = tsc1 < tsc2 ? tsc1 : tsc2; 407 proc->rdq.cutoff = min(tsc1, tsc2); 408 if(proc->rdq.cutoff == 0) proc->rdq.cutoff = -1ull; 409 409 } 410 410 else { … … 418 418 419 419 for(READYQ_SHARD_FACTOR) { 420 unsigned i = proc->rdq.id + ( proc->rdq.itr++% READYQ_SHARD_FACTOR);420 unsigned i = proc->rdq.id + (--proc->rdq.itr % READYQ_SHARD_FACTOR); 421 421 if($thread * t = try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.local))) return t; 422 422 } … … 469 469 // Actually pop the list 470 470 struct $thread * thrd; 471 unsigned long long tsv; 472 [thrd, tsv] = pop(lane); 471 thrd = pop(lane); 473 472 474 473 /* paranoid */ verify(thrd); … … 482 481 483 482 #if defined(USE_WORK_STEALING) 484 lanes.tscs[w].tv = t sv;483 lanes.tscs[w].tv = thrd->link.ts; 485 484 #endif 486 485 … … 664 663 while(!is_empty(lanes.data[idx])) { 665 664 struct $thread * thrd; 666 unsigned long long _; 667 [thrd, _] = pop(lanes.data[idx]); 665 thrd = pop(lanes.data[idx]); 668 666 669 667 push(cltr, thrd);
Note:
See TracChangeset
for help on using the changeset viewer.