Changeset 29702ad for libcfa/src/concurrency
- Timestamp:
- Nov 22, 2022, 10:18:04 AM (19 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 20cf96d
- Parents:
- 1553a55 (diff), d41735a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- libcfa/src/concurrency
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
r1553a55 r29702ad 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 9 19:06:45202213 // Update Count : 4812 // Last Modified On : Mon Nov 21 17:40:24 2022 13 // Update Count : 55 14 14 // 15 15 … … 17 17 #include "bits/defs.hfa" 18 18 #include "bits/locks.hfa" 19 #include "bits/random.hfa" 19 20 #include "kernel/fwd.hfa" 20 21 … … 222 223 struct processor * last_proc; 223 224 224 uint32_t random_state;// fast random numbers225 PRNG_ARG_T random_state; // fast random numbers 225 226 226 227 #if defined( __CFA_WITH_VERIFY__ ) -
libcfa/src/concurrency/kernel/fwd.hfa
r1553a55 r29702ad 120 120 121 121 // Yield: yield N times 122 static inline void yield( unsignedtimes ) {122 static inline void yield( size_t times ) { 123 123 for( times ) { 124 124 yield(); -
libcfa/src/concurrency/kernel/startup.cfa
r1553a55 r29702ad 39 39 #include "limits.hfa" 40 40 #include "math.hfa" 41 #include "bits/random.hfa" // prng 41 42 42 43 #define CFA_PROCESSOR_USE_MMAP 0 … … 107 108 extern void __wake_proc(processor *); 108 109 extern int cfa_main_returned; // from interpose.cfa 109 uint32_t __global_random_prime = 4_294_967_291u, __global_random_mask = false; 110 PRNG_ARG_T __global_random_prime = 4_294_967_291u; 111 bool __global_random_mask = false; 110 112 111 113 //----------------------------------------------------------------------------- -
libcfa/src/concurrency/thread.cfa
r1553a55 r29702ad 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Feb 12 15:24:18202213 // Update Count : 6612 // Last Modified On : Sun Nov 20 17:17:50 2022 13 // Update Count : 80 14 14 // 15 15 … … 26 26 #include "invoke.h" 27 27 28 extern uint32_t __global_random_seed, __global_random_prime, __global_random_mask; 28 extern PRNG_ARG_T __global_random_seed, __global_random_prime; 29 extern bool __global_random_mask; 29 30 30 31 #pragma GCC visibility push(default) … … 225 226 226 227 //----------------------------------------------------------------------------- 227 #define GENERATOR LCG 228 229 void set_seed( uint32_t seed ) { 230 uint32_t & state = active_thread()->random_state; 228 229 void set_seed( uint64_t seed ) { 230 PRNG_ARG_T & state = active_thread()->random_state; 231 231 state = __global_random_seed = seed; 232 GENERATOR( state );232 (void)PRNG_NAME( state ); // prime PRNG 233 233 __global_random_prime = state; 234 234 __global_random_mask = true; 235 235 } // set_seed 236 236 237 uint 32_t prng( void ) { // [0,UINT_MAX]238 uint32_t& state = active_thread()->random_state;239 return GENERATOR( state );237 uint64_t prng( void ) { // [0,UINT_MAX] 238 PRNG_ARG_T & state = active_thread()->random_state; 239 return PRNG_NAME( state ); 240 240 } // prng 241 241 -
libcfa/src/concurrency/thread.hfa
r1553a55 r29702ad 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 11 16:34:07 202213 // Update Count : 2012 // Last Modified On : Sat Nov 19 16:41:27 2022 13 // Update Count : 30 14 14 // 15 15 … … 23 23 #include "monitor.hfa" 24 24 #include "exception.hfa" 25 #include "bits/random.hfa" 25 26 26 27 //----------------------------------------------------------------------------- … … 142 143 // prng 143 144 static inline { 144 uint 32_t prng( thread$ & th ) __attribute__(( warn_unused_result )) { return LCG( th.random_state ); } // [0,UINT_MAX]145 uint 32_t prng( thread$ & th, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( th ) % u; } // [0,u)146 uint 32_t prng( thread$ & th, uint32_t l, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( th, u - l + 1 ) + l; } // [l,u]145 uint64_t prng( thread$ & th ) __attribute__(( warn_unused_result )) { return PRNG_NAME( th.random_state ); } // [0,UINT_MAX] 146 uint64_t prng( thread$ & th, uint64_t u ) __attribute__(( warn_unused_result )) { return prng( th ) % u; } // [0,u) 147 uint64_t prng( thread$ & th, uint64_t l, uint64_t u ) __attribute__(( warn_unused_result )) { return prng( th, u - l + 1 ) + l; } // [l,u] 147 148 forall( T & | is_thread(T) ) { 148 uint 32_t prng( T & th ) __attribute__(( warn_unused_result )) { return prng( (thread &)th ); } // [0,UINT_MAX]149 uint 32_t prng( T & th, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( th ) % u; } // [0,u)150 uint 32_t prng( T & th, uint32_t l, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( th, u - l + 1 ) + l; } // [l,u]149 uint64_t prng( T & th ) __attribute__(( warn_unused_result )) { return prng( (thread &)th ); } // [0,UINT_MAX] 150 uint64_t prng( T & th, uint64_t u ) __attribute__(( warn_unused_result )) { return prng( th ) % u; } // [0,u) 151 uint64_t prng( T & th, uint64_t l, uint64_t u ) __attribute__(( warn_unused_result )) { return prng( th, u - l + 1 ) + l; } // [l,u] 151 152 } // distribution 152 153 } // distribution
Note: See TracChangeset
for help on using the changeset viewer.