Changeset 708ae38
- Timestamp:
- Mar 15, 2022, 5:11:50 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 9d8124f
- Parents:
- a552a8c
- Location:
- libcfa/src
- Files:
-
- 1 added
- 14 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/Makefile.am
ra552a8c r708ae38 119 119 concurrency/exception.hfa \ 120 120 concurrency/kernel.hfa \ 121 concurrency/kernel/cluster.hfa \ 121 122 concurrency/locks.hfa \ 122 123 concurrency/monitor.hfa \ … … 134 135 concurrency/io/call.cfa \ 135 136 concurrency/iofwd.hfa \ 136 concurrency/kernel/cluster.cfa \ 137 concurrency/kernel_private.hfa \ 137 concurrency/kernel/private.hfa \ 138 138 concurrency/kernel/startup.cfa \ 139 139 concurrency/preemption.cfa \ -
libcfa/src/concurrency/coroutine.cfa
ra552a8c r708ae38 27 27 #include <unwind.h> 28 28 29 #include "kernel _private.hfa"29 #include "kernel/private.hfa" 30 30 #include "exception.hfa" 31 31 #include "math.hfa" -
libcfa/src/concurrency/io.cfa
ra552a8c r708ae38 41 41 #include "kernel.hfa" 42 42 #include "kernel/fwd.hfa" 43 #include "kernel _private.hfa"43 #include "kernel/private.hfa" 44 44 #include "io/types.hfa" 45 45 -
libcfa/src/concurrency/io/setup.cfa
ra552a8c r708ae38 59 59 #include "bitmanip.hfa" 60 60 #include "fstream.hfa" 61 #include "kernel _private.hfa"61 #include "kernel/private.hfa" 62 62 #include "thread.hfa" 63 63 #pragma GCC diagnostic pop -
libcfa/src/concurrency/kernel.cfa
ra552a8c r708ae38 35 35 36 36 //CFA Includes 37 #include "kernel _private.hfa"37 #include "kernel/private.hfa" 38 38 #include "preemption.hfa" 39 39 #include "strstream.hfa" -
libcfa/src/concurrency/kernel.hfa
ra552a8c r708ae38 227 227 228 228 struct { 229 // Number of I/O subqueues 230 volatile size_t count; 231 232 // Time since subqueues were processed 229 // Time since subqueues were processed 233 230 __timestamp_t * volatile tscs; 231 232 // Number of I/O subqueues 233 size_t count; 234 234 } io; 235 235 -
libcfa/src/concurrency/kernel/cluster.cfa
ra552a8c r708ae38 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 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 9 8 // 10 9 // Author : Thierry Delisle 11 // Created On : Fri 0311 12:39:24 202210 // Created On : Fri Mar 11 12:39:24 2022 12 11 // Last Modified By : 13 12 // Last Modified On : … … 20 19 #include "bits/defs.hfa" 21 20 #include "device/cpu.hfa" 22 #include "kernel_private.hfa" 21 #include "kernel/cluster.hfa" 22 #include "kernel/private.hfa" 23 23 24 24 #include "stdlib.hfa" … … 247 247 // fixes the list so that the pointers back to anchors aren't left dangling 248 248 static inline void fix(__intrusive_lane_t & ll) { 249 250 251 252 249 if(is_empty(ll)) { 250 verify(ll.anchor.next == 0p); 251 ll.prev = mock_head(ll); 252 } 253 253 } 254 254 … … 321 321 } 322 322 323 // Fix the io times 324 cltr->sched.io.count = target; 325 fix_times(cltr->sched.io.tscs, cltr->sched.io.count); 326 323 327 // realloc the caches 324 328 cltr->sched.caches = alloc( target, cltr->sched.caches`realloc ); … … 406 410 cltr->sched.caches = alloc( target, cltr->sched.caches`realloc ); 407 411 408 412 // Fix the io times 413 cltr->sched.io.count = target; 414 fix_times(cltr->sched.io.tscs, cltr->sched.io.count); 409 415 410 416 reassign_cltr_id(cltr); -
libcfa/src/concurrency/kernel/private.hfa
ra552a8c r708ae38 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // kernel _private.hfa --7 // kernel/private.hfa -- 8 8 // 9 9 // Author : Thierry Delisle … … 17 17 18 18 #if !defined(__cforall_thread__) 19 #error kernel _private.hfa should only be included in libcfathread source19 #error kernel/private.hfa should only be included in libcfathread source 20 20 #endif 21 21 … … 33 33 #else 34 34 #ifndef _GNU_SOURCE 35 #error kernel _private requires gnu_source35 #error kernel/private requires gnu_source 36 36 #endif 37 37 #include <sched.h> … … 369 369 void ready_queue_close(struct cluster * cltr); 370 370 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_factor396 ) {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 414 371 // Local Variables: // 415 372 // mode: c // -
libcfa/src/concurrency/kernel/startup.cfa
ra552a8c r708ae38 32 32 33 33 // CFA Includes 34 #include "kernel _private.hfa"34 #include "kernel/private.hfa" 35 35 #include "startup.hfa" // STARTUP_PRIORITY_XXX 36 36 #include "limits.hfa" -
libcfa/src/concurrency/locks.cfa
ra552a8c r708ae38 19 19 20 20 #include "locks.hfa" 21 #include "kernel _private.hfa"21 #include "kernel/private.hfa" 22 22 23 23 #include <kernel.hfa> -
libcfa/src/concurrency/monitor.cfa
ra552a8c r708ae38 22 22 #include <inttypes.h> 23 23 24 #include "kernel _private.hfa"24 #include "kernel/private.hfa" 25 25 26 26 #include "bits/algorithm.hfa" -
libcfa/src/concurrency/mutex.cfa
ra552a8c r708ae38 21 21 #include "mutex.hfa" 22 22 23 #include "kernel _private.hfa"23 #include "kernel/private.hfa" 24 24 25 25 //----------------------------------------------------------------------------- -
libcfa/src/concurrency/preemption.cfa
ra552a8c r708ae38 31 31 #include "bits/debug.hfa" 32 32 #include "bits/signal.hfa" 33 #include "kernel _private.hfa"33 #include "kernel/private.hfa" 34 34 35 35 -
libcfa/src/concurrency/ready_queue.cfa
ra552a8c r708ae38 24 24 #include "bits/defs.hfa" 25 25 #include "device/cpu.hfa" 26 #include "kernel_private.hfa" 26 #include "kernel/cluster.hfa" 27 #include "kernel/private.hfa" 27 28 28 29 #include "limits.hfa" … … 122 123 __cfadbg_print_safe(ready_queue, "Kernel : pop from %u\n", this); 123 124 124 // Figure out the current cpu and make sure it is valid 125 const int cpu = __kernel_getcpu(); 126 /* paranoid */ verify(cpu >= 0); 127 /* paranoid */ verify(cpu < cpu_info.hthrd_count); 128 unsigned this_cache = cpu_info.llc_map[cpu].cache; 129 130 // Super important: don't write the same value over and over again 131 // We want to maximise our chances that his particular values stays in cache 132 if(caches[this / __shard_factor.readyq].id != this_cache) 133 __atomic_store_n(&caches[this / __shard_factor.readyq].id, this_cache, __ATOMIC_RELAXED); 134 125 // Figure out the current cache is 126 const unsigned this_cache = cache_id(cltr, this / __shard_factor.readyq); 135 127 const unsigned long long ctsc = rdtscl(); 136 128 -
libcfa/src/concurrency/thread.cfa
ra552a8c r708ae38 19 19 #include "thread.hfa" 20 20 21 #include "kernel _private.hfa"21 #include "kernel/private.hfa" 22 22 #include "exception.hfa" 23 23
Note: See TracChangeset
for help on using the changeset viewer.