Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/thread.cfa

    r1959528 r2210cfc  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 12 18:28:18 2022
    13 // Update Count     : 35
     12// Last Modified On : Mon Jan 10 17:05:35 2022
     13// Update Count     : 28
    1414//
    1515
     
    2727uint64_t thread_rand();
    2828
    29 extern uint32_t __global_random_seed;
     29extern uint32_t __thread_seed;                                                  // global thread seed
    3030
    3131//-----------------------------------------------------------------------------
     
    4141        self_mon.owner = &this;
    4242        self_mon.recursion = 1;
     43        random_state = __thread_seed;
    4344        self_mon_p = &self_mon;
    4445        curr_cluster = &cl;
     
    4748        preferred = ready_queue_new_preferred();
    4849        last_proc = 0p;
    49         random_state = __global_random_seed;
    5050        #if defined( __CFA_WITH_VERIFY__ )
    5151                canary = 0x0D15EA5E0D15EA5Ep;
     
    180180        return ret;
    181181}
    182  
     182
    183183#define GENERATOR LCG
    184184
    185 static inline uint32_t MarsagliaXor( uint32_t & state ) {
    186         uint32_t ret = state;
     185inline uint32_t MarsagliaXor( uint32_t & state ) {
    187186        state ^= state << 6;
    188187        state ^= state >> 21;
    189188        state ^= state << 7;
    190         return ret;
     189        return state;
    191190} // MarsagliaXor
    192191
    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;
     192inline uint32_t LCG( uint32_t & state ) {                               // linear congruential generator
     193        return state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime!
    197194} // LCG
    198195
    199 void set_seed( uint32_t seed ) { active_thread()->random_state = seed; __global_random_seed = seed; }
     196void set_seed( uint32_t seed ) { active_thread()->random_state = seed; __thread_seed = seed; }
    200197uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX]
    201198
Note: See TracChangeset for help on using the changeset viewer.