Changeset b808625 for libcfa/src


Ignore:
Timestamp:
May 19, 2021, 1:37:49 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
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
Message:

Added option to ready-queue to push ignoring locality.

Location:
libcfa/src/concurrency
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.cfa

    r9cac0da rb808625  
    544544        /* paranoid */ verify( 0x0D15EA5E0D15EA5Ep == thrd->canary );
    545545
    546 
     546        const bool local = thrd->state != Start;
    547547        if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready;
    548548
     
    552552
    553553        // push the thread to the cluster ready-queue
    554         push( cl, thrd );
     554        push( cl, thrd, local );
    555555
    556556        // variable thrd is no longer safe to use
  • libcfa/src/concurrency/kernel_private.hfa

    r9cac0da rb808625  
    261261// push thread onto a ready queue for a cluster
    262262// 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);
    264264
    265265//-----------------------------------------------------------------------
  • libcfa/src/concurrency/ready_queue.cfa

    r9cac0da rb808625  
    249249        }
    250250
    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) {
    252252                __cfadbg_print_safe(ready_queue, "Kernel : Pushing %p on cluster %p\n", thrd, cltr);
    253253
    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);
    255255                /* paranoid */ verify(external || kernelTLS().this_processor->rdq.id < lanes.count );
    256256
     
    279279                push(lanes.data[i], thrd);
    280280
    281                         // Unlock and return
    282                         __atomic_unlock( &lanes.data[i].lock );
     281                // Unlock and return
     282                __atomic_unlock( &lanes.data[i].lock );
    283283
    284284                // Mark the current index in the tls rng instance as having an item
     
    336336#endif
    337337#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) {
    339339                __cfadbg_print_safe(ready_queue, "Kernel : Pushing %p on cluster %p\n", thrd, cltr);
    340340
    341341                // #define USE_PREFERRED
    342342                #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);
    344344                /* paranoid */ verify(external || kernelTLS().this_processor->rdq.id < lanes.count );
    345345                #else
    346346                        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;
    348348                        /* paranoid */ verifyf(external || preferred < lanes.count, "Invalid preferred queue %u for %u lanes", preferred, lanes.count );
    349349
     
    365365                        else {
    366366                                #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                 #else
     367                                        processor * proc = kernelTLS().this_processor;
     368                                        unsigned r = proc->rdq.its++;
     369                                        i =  proc->rdq.id + (r % READYQ_SHARD_FACTOR);
     370                                #else
    371371                                        i = start + (r++ % READYQ_SHARD_FACTOR);
    372372                                #endif
     
    378378                push(lanes.data[i], thrd);
    379379
    380                         // Unlock and return
    381                         __atomic_unlock( &lanes.data[i].lock );
     380                // Unlock and return
     381                __atomic_unlock( &lanes.data[i].lock );
    382382
    383383                #if !defined(__CFA_NO_STATISTICS__)
     
    666666                                [thrd, _] = pop(lanes.data[idx]);
    667667
    668                                 push(cltr, thrd);
     668                                push(cltr, thrd, true);
    669669
    670670                                // for printing count the number of displaced threads
Note: See TracChangeset for help on using the changeset viewer.