Changeset bd0bdd37 for libcfa


Ignore:
Timestamp:
Mar 25, 2021, 3:09:01 PM (3 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:
08e75215, 2d95a2d
Parents:
3143f28
Message:

Fix how bias is handled in the ready queue to be more consistent with multiple clusters.
Does not handle churn of processors yet.

Location:
libcfa/src/concurrency
Files:
4 edited

Legend:

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

    r3143f28 rbd0bdd37  
    6969        // Cluster from which to get threads
    7070        struct cluster * cltr;
     71
     72        // Id within the cluster
     73        unsigned cltr_id;
    7174
    7275        // Set to true to notify the processor should terminate
  • libcfa/src/concurrency/kernel/startup.cfa

    r3143f28 rbd0bdd37  
    486486
    487487                // Adjust the ready queue size
    488                 ready_queue_grow( cltr, target );
     488                this.cltr_id = ready_queue_grow( cltr, target );
    489489
    490490        // Unlock the RWlock
  • libcfa/src/concurrency/kernel_private.hfa

    r3143f28 rbd0bdd37  
    278278//-----------------------------------------------------------------------
    279279// Increase the width of the ready queue (number of lanes) by 4
    280 void ready_queue_grow  (struct cluster * cltr, int target);
     280unsigned ready_queue_grow  (struct cluster * cltr, int target);
    281281
    282282//-----------------------------------------------------------------------
  • libcfa/src/concurrency/ready_queue.cfa

    r3143f28 rbd0bdd37  
    252252                preferred =
    253253                        //*
    254                         kernelTLS().this_processor ? kernelTLS().this_processor->id * 4 : -1;
     254                        kernelTLS().this_processor ? kernelTLS().this_processor->cltr_id : -1;
    255255                        /*/
    256256                        thrd->link.preferred * 4;
     
    330330        #if defined(BIAS)
    331331                // Don't bother trying locally too much
    332                 preferred = kernelTLS().this_processor->id * 4;
     332                preferred = kernelTLS().this_processor->cltr_id;
    333333        #endif
    334334
     
    525525
    526526// Grow the ready queue
    527 void ready_queue_grow  (struct cluster * cltr, int target) {
     527unsigned ready_queue_grow(struct cluster * cltr, int target) {
     528        unsigned preferred;
     529        size_t ncount;
     530
    528531        /* paranoid */ verify( ready_mutate_islocked() );
    529532        __cfadbg_print_safe(ready_queue, "Kernel : Growing ready queue\n");
     
    540543                // Find new count
    541544                // Make sure we always have atleast 1 list
    542                 size_t ncount = target >= 2 ? target * 4: 1;
     545                if(target >= 2) {
     546                        ncount = target * 4;
     547                        preferred = ncount - 4;
     548                } else {
     549                        ncount = 1;
     550                        preferred = 0;
     551                }
    543552
    544553                // Allocate new array (uses realloc and memcpies the data)
     
    575584
    576585        /* paranoid */ verify( ready_mutate_islocked() );
     586        return preferred;
    577587}
    578588
Note: See TracChangeset for help on using the changeset viewer.