Changeset dd46fd3 for libcfa/src/concurrency
- Timestamp:
- Nov 30, 2022, 10:36:25 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 5657de9, c8238c0
- Parents:
- be1d00c
- Location:
- libcfa/src/concurrency
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
rbe1d00c rdd46fd3 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Nov 21 17:40:24202213 // Update Count : 5 512 // Last Modified On : Tue Nov 29 20:42:21 2022 13 // Update Count : 56 14 14 // 15 15 … … 223 223 struct processor * last_proc; 224 224 225 PRNG_ ARG_T random_state; // fast random numbers225 PRNG_STATE_T random_state; // fast random numbers 226 226 227 227 #if defined( __CFA_WITH_VERIFY__ ) -
libcfa/src/concurrency/kernel.cfa
rbe1d00c rdd46fd3 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 31 07:08:20 202013 // Update Count : 7 112 // Last Modified On : Wed Nov 30 18:14:08 2022 13 // Update Count : 76 14 14 // 15 15 … … 151 151 // Because of a bug, we couldn't initialized the seed on construction 152 152 // Do it here 153 __cfaabi_tls.rand_seed ^= rdtscl();153 PRNG_SET_SEED( __cfaabi_tls.random_state, rdtscl() ); 154 154 __cfaabi_tls.ready_rng.fwd_seed = 25214903917_l64u * (rdtscl() ^ (uintptr_t)&runner); 155 155 __tls_rand_advance_bck(); -
libcfa/src/concurrency/kernel/fwd.hfa
rbe1d00c rdd46fd3 46 46 } preemption_state; 47 47 48 #if defined(__SIZEOF_INT128__) 49 __uint128_t rand_seed; 50 #else 51 uint64_t rand_seed; 52 #endif 48 PRNG_STATE_T random_state; 49 53 50 struct { 54 51 uint64_t fwd_seed; … … 57 54 58 55 struct __stats_t * volatile this_stats; 59 60 56 61 57 #ifdef __CFA_WITH_VERIFY__ … … 76 72 #define publicTLS_get( member ) ((typeof(__cfaabi_tls.member))__cfatls_get( __builtin_offsetof(KernelThreadData, member) )) 77 73 78 static inline uint64_t __tls_rand() { 79 return 80 #if defined(__SIZEOF_INT128__) 81 lehmer64( kernelTLS().rand_seed ); 82 #else 83 xorshift_13_7_17( kernelTLS().rand_seed ); 84 #endif 74 static inline 75 #ifdef __x86_64__ // 64-bit architecture 76 uint64_t 77 #else // 32-bit architecture 78 uint32_t 79 #endif // __x86_64__ 80 __tls_rand() { 81 return PRNG_NAME( kernelTLS().random_state ); 85 82 } 86 83 -
libcfa/src/concurrency/kernel/startup.cfa
rbe1d00c rdd46fd3 108 108 extern void __wake_proc(processor *); 109 109 extern int cfa_main_returned; // from interpose.cfa 110 PRNG_ARG_T__global_random_prime = 4_294_967_291u;110 size_t __global_random_prime = 4_294_967_291u; 111 111 bool __global_random_mask = false; 112 112 … … 135 135 // Global state 136 136 __thread struct KernelThreadData __cfaabi_tls __attribute__ ((tls_model ( "initial-exec" ))) @= { 137 NULL,// cannot use 0p138 NULL,139 false,140 { 1, false,false },141 0,142 { 0,0 },143 NULL,137 .this_thread : NULL, // cannot use 0p 138 .this_processor : NULL, 139 .sched_lock : false, 140 .preemption_state : { .disable_count : 1, .enabled : false, .in_progress : false }, 141 // random_state uninitialized 142 .ready_rng : { .fwd_seed : 0, .bck_seed : 0 }, 143 .this_stats : NULL, 144 144 #ifdef __CFA_WITH_VERIFY__ 145 false,146 0,145 .in_sched_lock : false, 146 .sched_id : 0, 147 147 #endif 148 148 }; … … 521 521 preferred = ready_queue_new_preferred(); 522 522 last_proc = 0p; 523 random_state = __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl();523 PRNG_SET_SEED( random_state, __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl() ); 524 524 #if defined( __CFA_WITH_VERIFY__ ) 525 525 executing = 0p; -
libcfa/src/concurrency/thread.cfa
rbe1d00c rdd46fd3 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 22 22:18:37 202213 // Update Count : 8112 // Last Modified On : Wed Nov 30 18:14:07 2022 13 // Update Count : 95 14 14 // 15 15 … … 26 26 #include "invoke.h" 27 27 28 extern PRNG_ARG_T __global_random_seed, __global_random_prime; 28 extern size_t __global_random_seed; 29 extern size_t __global_random_prime; 29 30 extern bool __global_random_mask; 30 31 … … 53 54 preferred = ready_queue_new_preferred(); 54 55 last_proc = 0p; 55 random_state = __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl();56 PRNG_SET_SEED( random_state, __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl() ); 56 57 #if defined( __CFA_WITH_VERIFY__ ) 57 58 executing = 0p; … … 228 229 229 230 void set_seed( size_t seed ) { 230 PRNG_ARG_T & state = active_thread()->random_state; 231 state = __global_random_seed = seed; 231 PRNG_STATE_T & state = active_thread()->random_state; 232 __global_random_seed = seed; 233 PRNG_SET_SEED( state, seed ); 232 234 (void)PRNG_NAME( state ); // prime PRNG 233 __global_random_prime = s tate;235 __global_random_prime = seed; 234 236 __global_random_mask = true; 235 237 } // set_seed 236 238 237 239 size_t prng( void ) { // [0,UINT_MAX] 238 PRNG_ ARG_T & state= active_thread()->random_state;240 PRNG_STATE_T( & state ) = active_thread()->random_state; 239 241 return PRNG_NAME( state ); 240 242 } // prng
Note: See TracChangeset
for help on using the changeset viewer.