Changes in libcfa/src/stdlib.cfa [5d1ebb9:2210cfc]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.cfa
r5d1ebb9 r2210cfc 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 13 21:38:30202213 // Update Count : 5 9312 // Last Modified On : Mon Jan 10 17:07:21 2022 13 // Update Count : 572 14 14 // 15 15 16 16 #include "stdlib.hfa" 17 #include "bits/random.hfa"17 //#include "concurrency/kernel/fwd.hfa" 18 18 #include "concurrency/invoke.h" // random_state 19 19 … … 225 225 #define GENERATOR LCG 226 226 227 uint32_t __global_random_seed; // sequential/concurrent 228 uint32_t __global_random_state; // sequential only 229 230 void set_seed( PRNG & prng, uint32_t seed_ ) with( prng ) { state = seed = seed_; GENERATOR( state ); } // set seed 227 inline uint32_t MarsagliaXor( uint32_t & state ) { 228 state ^= state << 6; 229 state ^= state >> 21; 230 state ^= state << 7; 231 return state; 232 } // MarsagliaXor 233 234 inline uint32_t LCG( uint32_t & state ) { // linear congruential generator 235 return state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime! 236 } // LCG 237 238 uint32_t __thread_seed = rdtscl(); // global thread seed 239 240 void set_seed( uint32_t seed ) { __thread_seed = seed; } 241 uint32_t get_seed() { return __thread_seed; } 231 242 uint32_t prng( PRNG & prng ) with( prng ) { callcnt += 1; return GENERATOR( state ); } 232 243 233 void set_seed( uint32_t seed ) { __global_random_seed = seed; GENERATOR( __global_random_state ); } 234 uint32_t get_seed() { return __global_random_seed; } 235 uint32_t prng( void ) { return GENERATOR( __global_random_state ); } // [0,UINT_MAX] 244 uint32_t prng( void ) { return GENERATOR( __thread_seed ); } // [0,UINT_MAX] 236 245 237 246 //---------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.