- File:
-
- 1 edited
-
libcfa/src/concurrency/thread.cfa (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/thread.cfa
r2210cfc r1959528 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 10 17:05:35202213 // Update Count : 2812 // Last Modified On : Wed Jan 12 18:28:18 2022 13 // Update Count : 35 14 14 // 15 15 … … 27 27 uint64_t thread_rand(); 28 28 29 extern uint32_t __ thread_seed; // global thread seed29 extern uint32_t __global_random_seed; 30 30 31 31 //----------------------------------------------------------------------------- … … 41 41 self_mon.owner = &this; 42 42 self_mon.recursion = 1; 43 random_state = __thread_seed;44 43 self_mon_p = &self_mon; 45 44 curr_cluster = &cl; … … 48 47 preferred = ready_queue_new_preferred(); 49 48 last_proc = 0p; 49 random_state = __global_random_seed; 50 50 #if defined( __CFA_WITH_VERIFY__ ) 51 51 canary = 0x0D15EA5E0D15EA5Ep; … … 180 180 return ret; 181 181 } 182 182 183 183 #define GENERATOR LCG 184 184 185 inline uint32_t MarsagliaXor( uint32_t & state ) { 185 static inline uint32_t MarsagliaXor( uint32_t & state ) { 186 uint32_t ret = state; 186 187 state ^= state << 6; 187 188 state ^= state >> 21; 188 189 state ^= state << 7; 189 return state;190 return ret; 190 191 } // MarsagliaXor 191 192 192 inline uint32_t LCG( uint32_t & state ) { // linear congruential generator 193 return state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime! 193 static inline uint32_t LCG( uint32_t & state ) { // linear congruential generator 194 uint32_t ret = state; 195 state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime! No not change it! 196 return ret; 194 197 } // LCG 195 198 196 void set_seed( uint32_t seed ) { active_thread()->random_state = seed; __ thread_seed = seed; }199 void set_seed( uint32_t seed ) { active_thread()->random_state = seed; __global_random_seed = seed; } 197 200 uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX] 198 201
Note:
See TracChangeset
for help on using the changeset viewer.