Changeset b808625 for libcfa/src
- Timestamp:
- May 19, 2021, 1:37:49 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 77f1265
- Parents:
- 9cac0da
- Location:
- libcfa/src/concurrency
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
r9cac0da rb808625 544 544 /* paranoid */ verify( 0x0D15EA5E0D15EA5Ep == thrd->canary ); 545 545 546 546 const bool local = thrd->state != Start; 547 547 if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready; 548 548 … … 552 552 553 553 // push the thread to the cluster ready-queue 554 push( cl, thrd );554 push( cl, thrd, local ); 555 555 556 556 // variable thrd is no longer safe to use -
libcfa/src/concurrency/kernel_private.hfa
r9cac0da rb808625 261 261 // push thread onto a ready queue for a cluster 262 262 // returns true if the list was previously empty, false otherwise 263 __attribute__((hot)) void push(struct cluster * cltr, struct $thread * thrd );263 __attribute__((hot)) void push(struct cluster * cltr, struct $thread * thrd, bool local); 264 264 265 265 //----------------------------------------------------------------------- -
libcfa/src/concurrency/ready_queue.cfa
r9cac0da rb808625 249 249 } 250 250 251 __attribute__((hot)) void push(struct cluster * cltr, struct $thread * thrd ) with (cltr->ready_queue) {251 __attribute__((hot)) void push(struct cluster * cltr, struct $thread * thrd, bool push_local) with (cltr->ready_queue) { 252 252 __cfadbg_print_safe(ready_queue, "Kernel : Pushing %p on cluster %p\n", thrd, cltr); 253 253 254 const bool external = (!kernelTLS().this_processor) || (cltr != kernelTLS().this_processor->cltr);254 const bool external = !push_local || (!kernelTLS().this_processor) || (cltr != kernelTLS().this_processor->cltr); 255 255 /* paranoid */ verify(external || kernelTLS().this_processor->rdq.id < lanes.count ); 256 256 … … 279 279 push(lanes.data[i], thrd); 280 280 281 282 281 // Unlock and return 282 __atomic_unlock( &lanes.data[i].lock ); 283 283 284 284 // Mark the current index in the tls rng instance as having an item … … 336 336 #endif 337 337 #if defined(USE_WORK_STEALING) 338 __attribute__((hot)) void push(struct cluster * cltr, struct $thread * thrd ) with (cltr->ready_queue) {338 __attribute__((hot)) void push(struct cluster * cltr, struct $thread * thrd, bool push_local) with (cltr->ready_queue) { 339 339 __cfadbg_print_safe(ready_queue, "Kernel : Pushing %p on cluster %p\n", thrd, cltr); 340 340 341 341 // #define USE_PREFERRED 342 342 #if !defined(USE_PREFERRED) 343 const bool external = (!kernelTLS().this_processor) || (cltr != kernelTLS().this_processor->cltr);343 const bool external = !push_local || (!kernelTLS().this_processor) || (cltr != kernelTLS().this_processor->cltr); 344 344 /* paranoid */ verify(external || kernelTLS().this_processor->rdq.id < lanes.count ); 345 345 #else 346 346 unsigned preferred = thrd->preferred; 347 const bool external = (!kernelTLS().this_processor) || preferred == -1u || thrd->curr_cluster != cltr;347 const bool external = push_local || (!kernelTLS().this_processor) || preferred == -1u || thrd->curr_cluster != cltr; 348 348 /* paranoid */ verifyf(external || preferred < lanes.count, "Invalid preferred queue %u for %u lanes", preferred, lanes.count ); 349 349 … … 365 365 else { 366 366 #if !defined(USE_PREFERRED) 367 processor * proc = kernelTLS().this_processor;368 unsigned r = proc->rdq.its++;369 i = proc->rdq.id + (r % READYQ_SHARD_FACTOR);370 #else367 processor * proc = kernelTLS().this_processor; 368 unsigned r = proc->rdq.its++; 369 i = proc->rdq.id + (r % READYQ_SHARD_FACTOR); 370 #else 371 371 i = start + (r++ % READYQ_SHARD_FACTOR); 372 372 #endif … … 378 378 push(lanes.data[i], thrd); 379 379 380 381 380 // Unlock and return 381 __atomic_unlock( &lanes.data[i].lock ); 382 382 383 383 #if !defined(__CFA_NO_STATISTICS__) … … 666 666 [thrd, _] = pop(lanes.data[idx]); 667 667 668 push(cltr, thrd );668 push(cltr, thrd, true); 669 669 670 670 // for printing count the number of displaced threads
Note: See TracChangeset
for help on using the changeset viewer.