Changes in / [7f54356:a5db488]


Ignore:
Location:
libcfa/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/common.hfa

    r7f54356 ra5db488  
    1010// Created On       : Wed Jul 11 17:54:36 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May  5 14:02:04 2021
    13 // Update Count     : 18
     12// Last Modified On : Sat Aug 15 08:51:29 2020
     13// Update Count     : 14
    1414//
    1515
     
    6767
    6868static inline {
    69         char min( char v1, char v2 ) { return v1 < v2 ? v1 : v2; } // optimization
    70         int min( int v1, int v2 ) { return v1 < v2 ? v1 : v2; }
    71         unsigned int min( unsigned int v1, unsigned int v2 ) { return v1 < v2 ? v1 : v2; }
    72         long int min( long int v1, long int v2 ) { return v1 < v2 ? v1 : v2; }
    73         unsigned long int min( unsigned long int v1, unsigned int v2 ) { return v1 < v2 ? v1 : v2; }
    74         long long int min( long long int v1, long long int v2 ) { return v1 < v2 ? v1 : v2; }
    75         unsigned long long int min( unsigned long long int v1, unsigned int v2 ) { return v1 < v2 ? v1 : v2; }
     69        char min( char t1, char t2 ) { return t1 < t2 ? t1 : t2; } // optimization
     70        intptr_t min( intptr_t t1, intptr_t t2 ) { return t1 < t2 ? t1 : t2; } // optimization
     71        uintptr_t min( uintptr_t t1, uintptr_t t2 ) { return t1 < t2 ? t1 : t2; } // optimization
    7672        forall( T | { int ?<?( T, T ); } )
    77         T min( T v1, T v2 ) { return v1 < v2 ? v1 : v2; }
     73        T min( T t1, T t2 ) { return t1 < t2 ? t1 : t2; }
    7874
    79         char max( char v1, char v2 ) { return v1 > v2 ? v1 : v2; } // optimization
    80         int max( int v1, int v2 ) { return v1 > v2 ? v1 : v2; }
    81         unsigned int max( unsigned int v1, unsigned int v2 ) { return v1 > v2 ? v1 : v2; }
    82         long int max( long int v1, long int v2 ) { return v1 > v2 ? v1 : v2; }
    83         unsigned long int max( unsigned long int v1, unsigned long int v2 ) { return v1 > v2 ? v1 : v2; }
    84         long long int max( long long int v1, long long int v2 ) { return v1 > v2 ? v1 : v2; }
    85         unsigned long long int max( unsigned long long int v1, unsigned long long int v2 ) { return v1 > v2 ? v1 : v2; }
     75        char max( char t1, char t2 ) { return t1 > t2 ? t1 : t2; } // optimization
     76        intptr_t max( intptr_t t1, intptr_t t2 ) { return t1 > t2 ? t1 : t2; } // optimization
     77        uintptr_t max( uintptr_t t1, uintptr_t t2 ) { return t1 > t2 ? t1 : t2; } // optimization
    8678        forall( T | { int ?>?( T, T ); } )
    87         T max( T v1, T v2 ) { return v1 > v2 ? v1 : v2; }
     79        T max( T t1, T t2 ) { return t1 > t2 ? t1 : t2; }
    8880
    8981        forall( T | { T min( T, T ); T max( T, T ); } )
  • libcfa/src/concurrency/ready_queue.cfa

    r7f54356 ra5db488  
    398398
    399399                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);
    403405                        unsigned long long tsc1 = ts(lanes.data[idx1]);
    404406                        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;
    409409                }
    410410                else {
     
    418418
    419419                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);
    421421                        if($thread * t = try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.local))) return t;
    422422                }
     
    469469        // Actually pop the list
    470470        struct $thread * thrd;
    471         unsigned long long tsv;
    472         [thrd, tsv] = pop(lane);
     471        thrd = pop(lane);
    473472
    474473        /* paranoid */ verify(thrd);
     
    482481
    483482        #if defined(USE_WORK_STEALING)
    484                 lanes.tscs[w].tv = tsv;
     483                lanes.tscs[w].tv = thrd->link.ts;
    485484        #endif
    486485
     
    664663                        while(!is_empty(lanes.data[idx])) {
    665664                                struct $thread * thrd;
    666                                 unsigned long long _;
    667                                 [thrd, _] = pop(lanes.data[idx]);
     665                                thrd = pop(lanes.data[idx]);
    668666
    669667                                push(cltr, thrd);
  • libcfa/src/concurrency/ready_subqueue.hfa

    r7f54356 ra5db488  
    5353// Push a thread onto this lane
    5454// returns true of lane was empty before push, false otherwise
    55 static inline void push( __intrusive_lane_t & this, $thread * node ) {
     55void push( __intrusive_lane_t & this, $thread * node ) {
    5656        /* paranoid */ verify( node->link.next == 0p );
    5757        /* paranoid */ verify( node->link.ts   == 0  );
     
    7777// returns popped
    7878// returns true of lane was empty before push, false otherwise
    79 static inline [* $thread, unsigned long long] pop( __intrusive_lane_t & this ) {
     79$thread * pop( __intrusive_lane_t & this ) {
    8080        /* paranoid */ verify( this.anchor.next != 0p );
    8181        /* paranoid */ verify( this.anchor.ts   != 0  );
    8282
    8383        // Get the relevant nodes locally
    84         unsigned long long ts = this.anchor.ts;
    8584        $thread * node = this.anchor.next;
    8685        this.anchor.next = node->link.next;
     
    9594        /* paranoid */ verify( node->link.next == 0p );
    9695        /* paranoid */ verify( node->link.ts   == 0  );
    97         return [node, ts];
     96        return node;
    9897}
    9998
  • libcfa/src/heap.cfa

    r7f54356 ra5db488  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May  5 13:11:28 2021
    13 // Update Count     : 1035
     12// Last Modified On : Tue Apr 20 21:20:48 2021
     13// Update Count     : 1033
    1414//
    1515
     
    2828#include "bits/locks.hfa"                                                               // __spinlock_t
    2929#include "startup.hfa"                                                                  // STARTUP_PRIORITY_MEMORY
    30 #include "math.hfa"                                                                             // min
     30#include "math.hfa"                                                                             // ceiling
    3131#include "bitmanip.hfa"                                                                 // is_pow2, ceiling2
    3232
Note: See TracChangeset for help on using the changeset viewer.