Changeset 25337e0


Ignore:
Timestamp:
Jan 17, 2022, 7:46:29 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
0fb3ee5
Parents:
0fc447c
Message:

Fix some problems with compilation of per-cpu ready queue.

File:
1 edited

Legend:

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

    r0fc447c r25337e0  
    303303                        lanes.help[idx].dst = 0;
    304304                        lanes.help[idx].tri = 0;
    305                 }
    306 
    307                 caches = alloc( cpu_info.llc_count );
    308                 for( idx; (size_t)cpu_info.llc_count ) {
    309                         (caches[idx]){};
    310305                }
    311306        #else
     
    506501        }
    507502
    508         static inline int pop_getcpu(processor * proc, __ready_queue_caches_t * caches) {
    509                 const int prv = proc->rdq.cpu;
    510                 const int cpu = __kernel_getcpu();
    511                 if( prv != proc->rdq.cpu ) {
    512                         unsigned pidx = cpu_info.llc_map[prv].cache;
    513                         /* paranoid */ verify(pidx < cpu_info.llc_count);
    514 
    515                         unsigned nidx = cpu_info.llc_map[cpu].cache;
    516                         /* paranoid */ verify(pidx < cpu_info.llc_count);
    517 
    518                         depart(caches[pidx]);
    519                         arrive(caches[nidx]);
    520 
    521                         __STATS( /* cpu migs++ */ )
    522                 }
    523                 return proc->rdq.cpu = cpu;
    524         }
    525 
    526503        // Pop from the ready queue from a given cluster
    527504        __attribute__((hot)) thread$ * pop_fast(struct cluster * cltr) with (cltr->ready_queue) {
     
    530507
    531508                processor * const proc = kernelTLS().this_processor;
    532                 const int cpu = pop_getcpu( proc, caches );
    533                 // const int cpu = __kernel_getcpu();
     509                const int cpu = __kernel_getcpu();
    534510                /* paranoid */ verify(cpu >= 0);
    535511                /* paranoid */ verify(cpu < cpu_info.hthrd_count);
     
    548524                        unsigned long long max = 0;
    549525                        for(i; READYQ_SHARD_FACTOR) {
    550                                 unsigned long long tsc = moving_average(ctsc - ts(lanes.data[start + i]), lanes.tscs[start + i].ma);
     526                                unsigned long long tsc = moving_average(ctsc, ts(lanes.data[start + i]), lanes.tscs[start + i].ma);
    551527                                if(tsc > max) max = tsc;
    552528                        }
     
    569545                        unsigned long long max = 0;
    570546                        for(i; READYQ_SHARD_FACTOR) {
    571                                 unsigned long long tsc = moving_average(ctsc - ts(lanes.data[start + i]), lanes.tscs[start + i].ma);
     547                                unsigned long long tsc = moving_average(ctsc, ts(lanes.data[start + i]), lanes.tscs[start + i].ma);
    572548                                if(tsc > max) max = tsc;
    573549                        }
     
    577553                                proc->rdq.target = MAX;
    578554                                lanes.help[target / READYQ_SHARD_FACTOR].tri++;
    579                                 if(moving_average(ctsc - lanes.tscs[target].tv, lanes.tscs[target].ma) > cutoff) {
    580                                         __STATS( __tls_stats()->ready.pop.helped[target]++; )
     555                                if(moving_average(ctsc, lanes.tscs[target].tv, lanes.tscs[target].ma) > cutoff) {
    581556                                        thread$ * t = try_pop(cltr, target __STATS(, __tls_stats()->ready.pop.help));
    582557                                        proc->rdq.last = target;
     
    587562
    588563                        unsigned last = proc->rdq.last;
    589                         if(last != MAX && moving_average(ctsc - lanes.tscs[last].tv, lanes.tscs[last].ma) > cutoff) {
    590                                 __STATS( __tls_stats()->ready.pop.helped[last]++; )
     564                        if(last != MAX && moving_average(ctsc, lanes.tscs[last].tv, lanes.tscs[last].ma) > cutoff) {
    591565                                thread$ * t = try_pop(cltr, last __STATS(, __tls_stats()->ready.pop.help));
    592566                                if(t) return t;
Note: See TracChangeset for help on using the changeset viewer.