Ignore:
Timestamp:
Jan 10, 2022, 7:11:34 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
07a1e7a
Parents:
5b7a3662 (diff), a10f6b4 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa/src/concurrency
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/invoke.h

    r5b7a3662 r9b33337  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan  6 16:37:40 2022
    13 // Update Count     : 47
     12// Last Modified On : Sun Jan  9 19:06:45 2022
     13// Update Count     : 48
    1414//
    1515
     
    211211                struct processor * last_proc;
    212212
     213                uint32_t random_state;                                                  // fast random numbers
     214
    213215                #if defined( __CFA_WITH_VERIFY__ )
    214216                        void * canary;
  • libcfa/src/concurrency/kernel/fwd.hfa

    r5b7a3662 r9b33337  
    7777
    7878                static inline uint64_t __tls_rand() {
     79                        return
    7980                        #if defined(__SIZEOF_INT128__)
    80                                 return __lehmer64( kernelTLS().rand_seed );
     81                                __lehmer64( kernelTLS().rand_seed );
    8182                        #else
    82                                 return __xorshift64( kernelTLS().rand_seed );
     83                                __xorshift64( kernelTLS().rand_seed );
    8384                        #endif
    8485                }
     
    9192
    9293                static inline unsigned __tls_rand_fwd() {
    93 
    9494                        kernelTLS().ready_rng.fwd_seed = (A * kernelTLS().ready_rng.fwd_seed + C) & (M - 1);
    9595                        return kernelTLS().ready_rng.fwd_seed >> D;
     
    112112                }
    113113        }
    114 
    115 
    116114
    117115        extern void disable_interrupts();
  • libcfa/src/concurrency/thread.cfa

    r5b7a3662 r9b33337  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 09:17:49 2019
    13 // Update Count     : 9
     12// Last Modified On : Mon Jan 10 17:05:35 2022
     13// Update Count     : 28
    1414//
    1515
     
    2727uint64_t thread_rand();
    2828
     29extern uint32_t __thread_seed;                                                  // global thread seed
     30
    2931//-----------------------------------------------------------------------------
    3032// Thread ctors and dtors
    31 void ?{}(thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
     33void ?{}( thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
    3234        context{ 0p, 0p };
    3335        self_cor{ name, storage, storageSize };
     
    3941        self_mon.owner = &this;
    4042        self_mon.recursion = 1;
     43        random_state = __thread_seed;
    4144        self_mon_p = &self_mon;
    4245        curr_cluster = &cl;
     
    178181}
    179182
     183#define GENERATOR LCG
     184
     185inline uint32_t MarsagliaXor( uint32_t & state ) {
     186        state ^= state << 6;
     187        state ^= state >> 21;
     188        state ^= state << 7;
     189        return state;
     190} // MarsagliaXor
     191
     192inline uint32_t LCG( uint32_t & state ) {                               // linear congruential generator
     193        return state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime!
     194} // LCG
     195
     196void set_seed( uint32_t seed ) { active_thread()->random_state = seed; __thread_seed = seed; }
     197uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX]
     198
    180199// Local Variables: //
    181200// mode: c //
Note: See TracChangeset for help on using the changeset viewer.