Ignore:
Timestamp:
Mar 15, 2022, 5:11:50 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
9d8124f
Parents:
a552a8c
Message:

Some more cleanup and grow/shrink now readjusts io timestamps.
(They are still unused).

Location:
libcfa/src/concurrency/kernel
Files:
1 added
2 edited
1 moved

Legend:

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

    ra552a8c r708ae38  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // cluster.cfa.cfa -- file that includes helpers for subsystem that need
    8 //                              cluster wide support
     7// cluster.cfa -- file that includes helpers for subsystem that need cluster wide support
    98//
    109// Author           : Thierry Delisle
    11 // Created On       : Fri 03 11 12:39:24 2022
     10// Created On       : Fri Mar 11 12:39:24 2022
    1211// Last Modified By :
    1312// Last Modified On :
     
    2019#include "bits/defs.hfa"
    2120#include "device/cpu.hfa"
    22 #include "kernel_private.hfa"
     21#include "kernel/cluster.hfa"
     22#include "kernel/private.hfa"
    2323
    2424#include "stdlib.hfa"
     
    247247// fixes the list so that the pointers back to anchors aren't left dangling
    248248static inline void fix(__intrusive_lane_t & ll) {
    249                         if(is_empty(ll)) {
    250                                 verify(ll.anchor.next == 0p);
    251                                 ll.prev = mock_head(ll);
    252                         }
     249        if(is_empty(ll)) {
     250                verify(ll.anchor.next == 0p);
     251                ll.prev = mock_head(ll);
     252        }
    253253}
    254254
     
    321321        }
    322322
     323        // Fix the io times
     324        cltr->sched.io.count = target;
     325        fix_times(cltr->sched.io.tscs, cltr->sched.io.count);
     326
    323327        // realloc the caches
    324328        cltr->sched.caches = alloc( target, cltr->sched.caches`realloc );
     
    406410        cltr->sched.caches = alloc( target, cltr->sched.caches`realloc );
    407411
    408 
     412        // Fix the io times
     413        cltr->sched.io.count = target;
     414        fix_times(cltr->sched.io.tscs, cltr->sched.io.count);
    409415
    410416        reassign_cltr_id(cltr);
  • libcfa/src/concurrency/kernel/private.hfa

    ra552a8c r708ae38  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // kernel_private.hfa --
     7// kernel/private.hfa --
    88//
    99// Author           : Thierry Delisle
     
    1717
    1818#if !defined(__cforall_thread__)
    19         #error kernel_private.hfa should only be included in libcfathread source
     19        #error kernel/private.hfa should only be included in libcfathread source
    2020#endif
    2121
     
    3333#else
    3434        #ifndef _GNU_SOURCE
    35         #error kernel_private requires gnu_source
     35        #error kernel/private requires gnu_source
    3636        #endif
    3737        #include <sched.h>
     
    369369void ready_queue_close(struct cluster * cltr);
    370370
    371 //-----------------------------------------------------------------------
    372 // Calc moving average based on existing average, before and current time.
    373 static inline unsigned long long moving_average(unsigned long long currtsc, unsigned long long instsc, unsigned long long old_avg) {
    374         /* paranoid */ verifyf( currtsc < 45000000000000000, "Suspiciously large current time: %'llu (%llx)\n", currtsc, currtsc );
    375         /* paranoid */ verifyf( instsc  < 45000000000000000, "Suspiciously large insert time: %'llu (%llx)\n", instsc, instsc );
    376         /* paranoid */ verifyf( old_avg < 15000000000000, "Suspiciously large previous average: %'llu (%llx)\n", old_avg, old_avg );
    377 
    378         const unsigned long long new_val = currtsc > instsc ? currtsc - instsc : 0;
    379         const unsigned long long total_weight = 16;
    380         const unsigned long long new_weight   = 4;
    381         const unsigned long long old_weight = total_weight - new_weight;
    382         const unsigned long long ret = ((new_weight * new_val) + (old_weight * old_avg)) / total_weight;
    383         return ret;
    384 }
    385 
    386 //-----------------------------------------------------------------------
    387 // Calc age a timestamp should be before needing help.
    388 forall(Data_t * | { unsigned long long ts(Data_t & this); })
    389 static inline unsigned long long calc_cutoff(
    390         const unsigned long long ctsc,
    391         const processor * proc,
    392         size_t count,
    393         Data_t * data,
    394         __timestamp_t * tscs,
    395         const unsigned shard_factor
    396 ) {
    397         unsigned start = proc->rdq.id;
    398         unsigned long long max = 0;
    399         for(i; shard_factor) {
    400                 unsigned long long ptsc = ts(data[start + i]);
    401                 if(ptsc != -1ull) {
    402                         /* paranoid */ verify( start + i < count );
    403                         unsigned long long tsc = moving_average(ctsc, ptsc, tscs[start + i].ma);
    404                         if(tsc > max) max = tsc;
    405                 }
    406         }
    407         return (max + 2 * max) / 2;
    408 }
    409 
    410 static struct {
    411         const unsigned readyq;
    412 } __shard_factor __attribute__((unused)) = { 2 };
    413 
    414371// Local Variables: //
    415372// mode: c //
  • libcfa/src/concurrency/kernel/startup.cfa

    ra552a8c r708ae38  
    3232
    3333// CFA Includes
    34 #include "kernel_private.hfa"
     34#include "kernel/private.hfa"
    3535#include "startup.hfa"                                  // STARTUP_PRIORITY_XXX
    3636#include "limits.hfa"
Note: See TracChangeset for help on using the changeset viewer.