Ignore:
Timestamp:
Jan 13, 2022, 10:53:25 AM (4 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
3eaa689
Parents:
3bb12921 (diff), 00f5fde (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:
7 edited

Legend:

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

    r3bb12921 r42daeb4  
    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/io.cfa

    r3bb12921 r42daeb4  
    548548                        /* paranoid */ verify( proc == __cfaabi_tls.this_processor );
    549549                        /* paranoid */ verify( ! __preemption_enabled() );
     550
     551                        return true;
    550552                }
    551553        #endif
  • libcfa/src/concurrency/kernel.cfa

    r3bb12921 r42daeb4  
    554554        /* paranoid */ verify( 0x0D15EA5E0D15EA5Ep == thrd->canary );
    555555
    556         const bool local = thrd->state != Start;
    557556        if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready;
    558557
     
    737736
    738737        // Check if there is a sleeping processor
    739         int fd = __atomic_load_n(&this->procs.fd, __ATOMIC_SEQ_CST);
     738        // int fd = __atomic_load_n(&this->procs.fd, __ATOMIC_SEQ_CST);
     739        int fd = 0;
     740        if( __atomic_load_n(&this->procs.fd, __ATOMIC_SEQ_CST) != 0 ) {
     741                fd = __atomic_exchange_n(&this->procs.fd, 0, __ATOMIC_RELAXED);
     742        }
    740743
    741744        // If no one is sleeping, we are done
  • libcfa/src/concurrency/kernel/fwd.hfa

    r3bb12921 r42daeb4  
    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/kernel/startup.cfa

    r3bb12921 r42daeb4  
    101101extern void __wake_proc(processor *);
    102102extern int cfa_main_returned;                                                   // from interpose.cfa
     103extern uint32_t __global_random_seed;
    103104
    104105//-----------------------------------------------------------------------------
     
    489490        preferred = ready_queue_new_preferred();
    490491        last_proc = 0p;
     492        random_state = __global_random_seed;
    491493        #if defined( __CFA_WITH_VERIFY__ )
    492494                canary = 0x0D15EA5E0D15EA5Ep;
  • libcfa/src/concurrency/ready_queue.cfa

    r3bb12921 r42daeb4  
    681681        // Actually pop the list
    682682        struct thread$ * thrd;
    683         unsigned long long tsc_before = ts(lane);
     683        #if defined(USE_WORK_STEALING) || defined(USE_CPU_WORK_STEALING)
     684                unsigned long long tsc_before = ts(lane);
     685        #endif
    684686        unsigned long long tsv;
    685687        [thrd, tsv] = pop(lane);
  • libcfa/src/concurrency/thread.cfa

    r3bb12921 r42daeb4  
    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 : Wed Jan 12 18:46:48 2022
     13// Update Count     : 36
    1414//
    1515
     
    2727uint64_t thread_rand();
    2828
     29extern uint32_t __global_random_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 };
     
    4547        preferred = ready_queue_new_preferred();
    4648        last_proc = 0p;
     49        random_state = __global_random_seed;
    4750        #if defined( __CFA_WITH_VERIFY__ )
    4851                canary = 0x0D15EA5E0D15EA5Ep;
     
    177180        return ret;
    178181}
     182 
     183#define GENERATOR LCG
     184
     185static inline uint32_t MarsagliaXor( uint32_t & state ) {
     186        uint32_t ret = state;
     187        state ^= state << 6;
     188        state ^= state >> 21;
     189        state ^= state << 7;
     190        return ret;
     191} // MarsagliaXor
     192
     193static 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;
     197} // LCG
     198
     199void set_seed( uint32_t seed ) {
     200        active_thread()->random_state = __global_random_seed = seed;
     201        GENERATOR( active_thread()->random_state );
     202} // set_seed
     203uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX]
    179204
    180205// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.