Changes in / [42daeb4:3bb12921]


Ignore:
Files:
1 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/locks.hfa

    r42daeb4 r3bb12921  
    3131                // previous thread to acquire the lock
    3232                void* prev_thrd;
    33                 // keep track of number of times we had to spin, just in case the number is unexpectedly huge
    34                 size_t spin_count;
    3533        #endif
    3634};
     
    5048        static inline void ?{}( __spinlock_t & this ) {
    5149                this.lock = 0;
    52                 #ifdef __CFA_DEBUG__
    53                         this.spin_count = 0;
    54                 #endif
    5550        }
    5651
     
    7772                for ( unsigned int i = 1;; i += 1 ) {
    7873                        if ( (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0) ) break;
    79                         #ifdef __CFA_DEBUG__
    80                                 this.spin_count++;
    81                         #endif
    8274                        #ifndef NOEXPBACK
    8375                                // exponential spin
  • libcfa/src/concurrency/invoke.h

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

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

    r42daeb4 r3bb12921  
    554554        /* paranoid */ verify( 0x0D15EA5E0D15EA5Ep == thrd->canary );
    555555
     556        const bool local = thrd->state != Start;
    556557        if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready;
    557558
     
    736737
    737738        // Check if there is a sleeping processor
    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         }
     739        int fd = __atomic_load_n(&this->procs.fd, __ATOMIC_SEQ_CST);
    743740
    744741        // If no one is sleeping, we are done
  • libcfa/src/concurrency/kernel/fwd.hfa

    r42daeb4 r3bb12921  
    7777
    7878                static inline uint64_t __tls_rand() {
    79                         return
    8079                        #if defined(__SIZEOF_INT128__)
    81                                 __lehmer64( kernelTLS().rand_seed );
     80                                return __lehmer64( kernelTLS().rand_seed );
    8281                        #else
    83                                 __xorshift64( kernelTLS().rand_seed );
     82                                return __xorshift64( kernelTLS().rand_seed );
    8483                        #endif
    8584                }
     
    9291
    9392                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
    114116
    115117        extern void disable_interrupts();
  • libcfa/src/concurrency/kernel/startup.cfa

    r42daeb4 r3bb12921  
    101101extern void __wake_proc(processor *);
    102102extern int cfa_main_returned;                                                   // from interpose.cfa
    103 extern uint32_t __global_random_seed;
    104103
    105104//-----------------------------------------------------------------------------
     
    490489        preferred = ready_queue_new_preferred();
    491490        last_proc = 0p;
    492         random_state = __global_random_seed;
    493491        #if defined( __CFA_WITH_VERIFY__ )
    494492                canary = 0x0D15EA5E0D15EA5Ep;
  • libcfa/src/concurrency/ready_queue.cfa

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

    r42daeb4 r3bb12921  
    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:46:48 2022
    13 // Update Count     : 36
     12// Last Modified On : Wed Dec  4 09:17:49 2019
     13// Update Count     : 9
    1414//
    1515
     
    2727uint64_t thread_rand();
    2828
    29 extern uint32_t __global_random_seed;
    30 
    3129//-----------------------------------------------------------------------------
    3230// Thread ctors and dtors
    33 void ?{}( thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
     31void ?{}(thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
    3432        context{ 0p, 0p };
    3533        self_cor{ name, storage, storageSize };
     
    4745        preferred = ready_queue_new_preferred();
    4846        last_proc = 0p;
    49         random_state = __global_random_seed;
    5047        #if defined( __CFA_WITH_VERIFY__ )
    5148                canary = 0x0D15EA5E0D15EA5Ep;
     
    180177        return ret;
    181178}
    182  
    183 #define GENERATOR LCG
    184 
    185 static 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 
    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;
    197 } // LCG
    198 
    199 void set_seed( uint32_t seed ) {
    200         active_thread()->random_state = __global_random_seed = seed;
    201         GENERATOR( active_thread()->random_state );
    202 } // set_seed
    203 uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX]
    204179
    205180// Local Variables: //
  • libcfa/src/device/cpu.cfa

    r42daeb4 r3bb12921  
    427427                        unsigned c = pairings[i].cpu;
    428428                        unsigned llc_id = pairings[i].id;
     429                        unsigned width = maps[llc_id].raw->width;
    429430                        unsigned start = maps[llc_id].start;
    430                         entries[c].count = maps[llc_id].raw->width;
     431                        unsigned self  = start + (maps[llc_id].count++);
     432                        entries[c].count = width;
    431433                        entries[c].start = start;
    432                         entries[c].self  = start + (maps[llc_id].count++);
    433                         entries[c].cache = llc_id;
     434                        entries[c].self  = self;
    434435                }
    435436
  • libcfa/src/device/cpu.hfa

    r42daeb4 r3bb12921  
    1616#include <stddef.h>
    1717
    18 // Map from cpu entry to a structure detailling cpus with common topologies
    19 // Note that the cpu-groups are contiguous so the indexing is different from
    20 // the cpu indexing
    2118struct cpu_map_entry_t {
    22         // Where this particular cpu is in the group
    2319        unsigned self;
    24 
    25         // Starting index of the cpus with the same topology
    2620        unsigned start;
    27 
    28         // Number of cpus with the same topology
    2921        unsigned count;
    30 
    31         // Index of the cache this entry describes
    32         unsigned cache;
    3322};
    3423
  • libcfa/src/fstream.cfa

    r42daeb4 r3bb12921  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 10 08:45:05 2022
    13 // Update Count     : 513
     12// Last Modified On : Sun Oct 10 11:23:05 2021
     13// Update Count     : 512
    1414//
    1515
     
    5252inline void setPrt$( ofstream & os, bool state ) { os.prt$ = state; }
    5353
    54 inline void lock( ofstream & os ) with( os ) { lock( os.lock$ ); }
     54inline void lock( ofstream & os ) with( os ) {  lock( os.lock$ ); }
    5555inline void unlock( ofstream & os ) { unlock( os.lock$ ); }
    5656
  • libcfa/src/startup.cfa

    r42daeb4 r3bb12921  
    1010// Created On       : Tue Jul 24 16:21:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 12 18:51:24 2022
    13 // Update Count     : 51
     12// Last Modified On : Sat Jan  9 23:18:23 2021
     13// Update Count     : 34
    1414//
    1515
     
    1818#include <stdlib.h>                                                                             // getenv
    1919#include "startup.hfa"
    20 #include "bits/defs.hfa"
    21 
    22 extern uint32_t __global_random_seed, __global_random_state;
    2320
    2421extern "C" {
     
    5148        void __cfaabi_core_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_CORE ) ));
    5249        void __cfaabi_core_startup( void ) {
    53                 __global_random_state = __global_random_seed = rdtscl();
    5450                __cfaabi_interpose_startup();
    5551                __cfaabi_device_startup();
  • libcfa/src/stdlib.cfa

    r42daeb4 r3bb12921  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 12 18:52:41 2022
    13 // Update Count     : 582
     12// Last Modified On : Mon Jan  3 09:36:27 2022
     13// Update Count     : 519
    1414//
    1515
    1616#include "stdlib.hfa"
    17 //#include "concurrency/kernel/fwd.hfa"
    18 #include "concurrency/invoke.h"                                                 // random_state
    1917
    2018//---------------------------------------
     
    223221//---------------------------------------
    224222
    225 // Pipelined to allow OoO overlap with reduced dependencies. Critically, return the current value, and compute and store
    226 // the next value.
     223static uint32_t seed = 0;                                                               // current seed
     224static thread_local uint32_t state;                                             // random state
     225
     226void set_seed( uint32_t seed_ ) { state = seed = seed_; }
     227uint32_t get_seed() { return seed; }
    227228
    228229#define GENERATOR LCG
    229230
    230 static inline uint32_t MarsagliaXor( uint32_t & state ) {
    231         uint32_t ret = state;
     231inline uint32_t MarsagliaXor( uint32_t & state ) {
     232        if ( unlikely( seed == 0 ) ) set_seed( rdtscl() );
     233        else if ( unlikely( state == 0 ) ) state = seed;
    232234        state ^= state << 6;
    233235        state ^= state >> 21;
    234236        state ^= state << 7;
    235         return ret;
     237        return state;
    236238} // MarsagliaXor
    237239
    238 static inline uint32_t LCG( uint32_t & state ) {                // linear congruential generator
    239         uint32_t ret = state;
    240         state = 36969 * (state & 65535) + (state >> 16);        // 36969 is NOT prime! No not change it!
    241         return ret;
     240inline uint32_t LCG( uint32_t & state ) {                               // linear congruential generator
     241        if ( unlikely( seed == 0 ) ) set_seed( rdtscl() );
     242        else if ( unlikely( state == 0 ) ) state = seed;
     243        return state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime!
    242244} // LCG
    243245
    244 uint32_t __global_random_seed;                                                  // sequential/concurrent
    245 uint32_t __global_random_state;                                                 // sequential only
    246 
    247 void set_seed( PRNG & prng, uint32_t seed_ ) with( prng ) { state = seed = seed_; GENERATOR( state ); } // set seed
    248246uint32_t prng( PRNG & prng ) with( prng ) { callcnt += 1; return GENERATOR( state ); }
    249247
    250 void set_seed( uint32_t seed ) { __global_random_seed = seed; GENERATOR( __global_random_state ); }
    251 uint32_t get_seed() { return __global_random_seed; }
    252 uint32_t prng( void ) { return GENERATOR( __global_random_state ); } // [0,UINT_MAX]
     248uint32_t prng( void ) { return GENERATOR( state ); }
    253249
    254250//---------------------------------------
  • libcfa/src/stdlib.hfa

    r42daeb4 r3bb12921  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 12 18:56:13 2022
    13 // Update Count     : 621
     12// Last Modified On : Sun Jan  2 22:53:57 2022
     13// Update Count     : 594
    1414//
    1515
     
    2121#include <stdlib.h>                                                                             // *alloc, strto*, ato*
    2222#include <heap.hfa>
    23 
    2423
    2524// Reduce includes by explicitly defining these routines.
     
    386385//---------------------------------------
    387386
    388 // Sequential Pseudo Random-Number Generator : generate repeatable sequence of values that appear random.
    389 //
    390 // Declaration :
    391 //   PRNG sprng = { 1009 } - set starting seed versus random seed
    392 //   
    393 // Interface :
    394 //   set_seed( sprng, 1009 ) - set starting seed for ALL kernel threads versus random seed
    395 //   get_seed( sprng ) - read seed
    396 //   prng( sprng ) - generate random value in range [0,UINT_MAX]
    397 //   prng( sprng, u ) - generate random value in range [0,u)
    398 //   prng( sprng, l, u ) - generate random value in range [l,u]
    399 //   calls( sprng ) - number of generated random value so far
    400 //
    401 // Examples : generate random number between 5-21
    402 //   prng( sprng ) % 17 + 5;    values 0-16 + 5 = 5-21
    403 //   prng( sprng, 16 + 1 ) + 5;
    404 //   prng( sprng, 5, 21 );
    405 //   calls( sprng );
    406 
    407387struct PRNG {
    408388        uint32_t callcnt;                                                                       // call count
     
    411391}; // PRNG
    412392
    413 void set_seed( PRNG & prng, uint32_t seed_ );
    414 uint32_t prng( PRNG & prng ) __attribute__(( warn_unused_result )); // [0,UINT_MAX]
     393extern uint32_t prng( PRNG & prng ) __attribute__(( warn_unused_result )); // [0,UINT_MAX]
    415394static inline {
     395        void set_seed( PRNG & prng, uint32_t seed_ ) with( prng ) { state = seed = seed_; } // set seed
    416396        void ?{}( PRNG & prng ) { set_seed( prng, rdtscl() ); } // random seed
    417397        void ?{}( PRNG & prng, uint32_t seed ) { set_seed( prng, seed ); } // fixed seed
     
    422402} // distribution
    423403
    424 // Concurrent Pseudo Random-Number Generator : generate repeatable sequence of values that appear random.
    425 //
    426 // Interface :
    427 //   set_seed( 1009 ) - fixed seed for all kernel threads versus random seed
    428 //   get_seed() - read seed
    429 //   prng() - generate random value in range [0,UINT_MAX]
    430 //   prng( u ) - generate random value in range [0,u)
    431 //   prng( l, u ) - generate random value in range [l,u]
    432 //
    433 // Examples : generate random number between 5-21
    434 //   prng() % 17 + 5;   values 0-16 + 5 = 5-21
    435 //   prng( 16 + 1 ) + 5;
    436 //   prng( 5, 21 );
    437 
    438 void set_seed( uint32_t seed_ ) OPTIONAL_THREAD;
    439 uint32_t get_seed() __attribute__(( warn_unused_result ));
    440 uint32_t prng( void ) __attribute__(( warn_unused_result )) OPTIONAL_THREAD; // [0,UINT_MAX]
     404extern void set_seed( uint32_t seed );                                  // set per thread seed
     405extern uint32_t get_seed();                                                             // get seed
     406extern uint32_t prng( void ) __attribute__(( warn_unused_result )); // [0,UINT_MAX]
    441407static inline {
    442         uint32_t prng( uint32_t u ) __attribute__(( warn_unused_result )) { return prng() % u; } // [0,u)
    443         uint32_t prng( uint32_t l, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( u - l + 1 ) + l; } // [l,u]
     408        uint32_t prng( uint32_t u ) __attribute__(( warn_unused_result ));
     409        uint32_t prng( uint32_t u ) { return prng() % u; }      // [0,u)
     410        uint32_t prng( uint32_t l, uint32_t u ) __attribute__(( warn_unused_result ));
     411        uint32_t prng( uint32_t l, uint32_t u ) { return prng( u - l + 1 ) + l; } // [l,u]
    444412} // distribution
    445413
  • tests/io/io-acquire.cfa

    r42daeb4 r3bb12921  
    1010// Created On       : Mon Mar  1 18:40:09 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 10 07:57:12 2022
    13 // Update Count     : 73
     12// Last Modified On : Wed Oct  6 18:04:58 2021
     13// Update Count     : 72
    1414//
    1515
     
    2323
    2424        for ( 100 ) {                                                                           // expression protection
    25                 mutex( sout ) sout | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
     25                mutex(sout) sout | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
    2626        }
    2727        mutex( sout ) {                                                                         // statement protection
     
    5151        int a, b, c, d, e, f, g, h, i;
    5252        for ( 100 ) {                                                                           // expression protection
    53                 mutex( sin ) sin | a | b | c | d | e | f | g | h | i;
     53                mutex(sin) sin | a | b | c | d | e | f | g | h | i;
    5454        }
    5555        mutex( sin ) {                                                                          // statement protection
  • tools/jenkins/setup.sh.in

    r42daeb4 r3bb12921  
    4848                regex1='/([[:alpha:][:digit:]@/_.-]+)'
    4949                regex2='(libcfa[[:alpha:][:digit:].]+) => not found'
    50                 regex3='linux-vdso.so.1|linux-gate.so.1'
     50                regex3='linux-vdso.so.1'
    5151                if [[ $line =~ $regex1 ]]; then
    5252                        retsysdeps+=(${BASH_REMATCH[1]})
Note: See TracChangeset for help on using the changeset viewer.