Changes in / [665edf40:c8a0210]


Ignore:
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • benchmark/benchcltr.hfa

    r665edf40 rc8a0210  
    114114        for() {
    115115                sleep(100`ms);
    116                 end = timeHiRes();
     116                end = timeNsec();
    117117                Duration delta = end - start;
    118118                /*if(is_tty)*/ {
     
    126126}
    127127#else
    128 uint64_t timeHiRes() {
     128uint64_t timeNsec() {
    129129        timespec curr;
    130130        clock_gettime( CLOCK_REALTIME, &curr );
     
    140140        for(;;) {
    141141                usleep(100000);
    142                 end = timeHiRes();
     142                end = timeNsec();
    143143                uint64_t delta = end - start;
    144144                /*if(is_tty)*/ {
  • benchmark/io/http/protocol.cfa

    r665edf40 rc8a0210  
    249249
    250250                char buff[100];
    251                 Time now = timeHiRes();
     251                Time now = timeNsec();
    252252                strftime( buff, 100, "%a, %d %b %Y %H:%M:%S %Z", now );
    253253                sout | "Updated date to '" | buff | "'";
  • benchmark/io/readv-posix.c

    r665edf40 rc8a0210  
    111111                                printf("Starting\n");
    112112                                bool is_tty = isatty(STDOUT_FILENO);
    113                                 start = timeHiRes();
     113                                start = timeNsec();
    114114                                run = true;
    115115
     
    118118
    119119                                run = false;
    120                                 end = timeHiRes();
     120                                end = timeNsec();
    121121                                printf("\nDone\n");
    122122
  • benchmark/io/readv.cfa

    r665edf40 rc8a0210  
    147147                                printf("Starting\n");
    148148                                bool is_tty = isatty(STDOUT_FILENO);
    149                                 start = timeHiRes();
     149                                start = timeNsec();
    150150                                run = true;
    151151
     
    156156
    157157                                run = false;
    158                                 end = timeHiRes();
     158                                end = timeNsec();
    159159                                printf("\nDone\n");
    160160                        }
  • benchmark/readyQ/cycle.cc

    r665edf40 rc8a0210  
    8989
    9090                        bool is_tty = isatty(STDOUT_FILENO);
    91                         start = timeHiRes();
     91                        start = timeNsec();
    9292
    9393                        for(int i = 0; i < nthreads; i++) {
     
    9797
    9898                        stop = true;
    99                         end = timeHiRes();
     99                        end = timeNsec();
    100100                        printf("\nDone\n");
    101101
  • benchmark/readyQ/cycle.cfa

    r665edf40 rc8a0210  
    6565
    6666                        bool is_tty = isatty(STDOUT_FILENO);
    67                         start = timeHiRes();
     67                        start = timeNsec();
    6868
    6969                        for(i; nthreads) {
     
    7373
    7474                        stop = true;
    75                         end = timeHiRes();
     75                        end = timeNsec();
    7676                        printf("\nDone\n");
    7777
  • benchmark/readyQ/cycle.cpp

    r665edf40 rc8a0210  
    9393
    9494                        bool is_tty = isatty(STDOUT_FILENO);
    95                         start = timeHiRes();
     95                        start = timeNsec();
    9696
    9797                        for(int i = 0; i < nthreads; i++) {
     
    101101
    102102                        stop = true;
    103                         end = timeHiRes();
     103                        end = timeNsec();
    104104                        printf("\nDone\n");
    105105
  • benchmark/readyQ/locality.cc

    r665edf40 rc8a0210  
    281281
    282282                        bool is_tty = isatty(STDOUT_FILENO);
    283                         start = timeHiRes();
     283                        start = timeNsec();
    284284
    285285                        for(size_t i = 0; i < nthreads; i++) {
     
    289289
    290290                        stop = true;
    291                         end = timeHiRes();
     291                        end = timeNsec();
    292292                        printf("\nDone\n");
    293293
  • benchmark/readyQ/locality.cfa

    r665edf40 rc8a0210  
    232232
    233233                        bool is_tty = isatty(STDOUT_FILENO);
    234                         start = timeHiRes();
     234                        start = timeNsec();
    235235
    236236                        for(i; nthreads) {
     
    240240
    241241                        stop = true;
    242                         end = timeHiRes();
     242                        end = timeNsec();
    243243                        printf("\nDone\n");
    244244
  • benchmark/readyQ/locality.cpp

    r665edf40 rc8a0210  
    287287
    288288                        bool is_tty = isatty(STDOUT_FILENO);
    289                         start = timeHiRes();
     289                        start = timeNsec();
    290290
    291291                        for(size_t i = 0; i < nthreads; i++) {
     
    295295
    296296                        stop = true;
    297                         end = timeHiRes();
     297                        end = timeNsec();
    298298                        printf("\nDone\n");
    299299
  • benchmark/readyQ/rq_bench.hfa

    r665edf40 rc8a0210  
    7373        for() {
    7474                sleep(100`ms);
    75                 Time end = timeHiRes();
     75                Time end = timeNsec();
    7676                Duration delta = end - start;
    7777                if(is_tty) {
  • benchmark/readyQ/rq_bench.hpp

    r665edf40 rc8a0210  
    4646        }
    4747
    48 uint64_t timeHiRes() {
     48uint64_t timeNsec() {
    4949        timespec curr;
    5050        clock_gettime( CLOCK_REALTIME, &curr );
     
    6060        for(;;) {
    6161                Sleeper::usleep(100000);
    62                 uint64_t end = timeHiRes();
     62                uint64_t end = timeNsec();
    6363                uint64_t delta = end - start;
    6464                if(is_tty) {
  • benchmark/readyQ/yield.cfa

    r665edf40 rc8a0210  
    6666
    6767                                bool is_tty = isatty(STDOUT_FILENO);
    68                                 start = timeHiRes();
     68                                start = timeNsec();
    6969                                run = true;
    7070
     
    7575
    7676                                run = false;
    77                                 end = timeHiRes();
     77                                end = timeNsec();
    7878                                printf("\nDone\n");
    7979                        }
  • example/io/batch-readv.c

    r665edf40 rc8a0210  
    6666}
    6767
    68 uint64_t timeHiRes() {
     68uint64_t getTimeNsec() {
    6969        timespec curr;
    7070        clock_gettime( CLOCK_REALTIME, &curr );
     
    163163
    164164        printf("Running for %f second, reading %d bytes in batches of %d\n", duration, buflen, batch);
    165         uint64_t start = timeHiRes();
    166         uint64_t end   = timeHiRes();
    167         uint64_t prev  = timeHiRes();
     165        uint64_t start = getTimeNsec();
     166        uint64_t end   = getTimeNsec();
     167        uint64_t prev  = getTimeNsec();
    168168        for(;;) {
    169169                submit_and_drain(&iov, batch);
    170                 end = timeHiRes();
     170                end = getTimeNsec();
    171171                uint64_t delta = end - start;
    172172                if( to_fseconds(end - prev) > 0.1 ) {
  • libcfa/src/clock.hfa

    r665edf40 rc8a0210  
    1010// Created On       : Thu Apr 12 14:36:06 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Apr 18 08:12:16 2021
    13 // Update Count     : 28
     12// Last Modified On : Wed Apr 14 17:48:25 2021
     13// Update Count     : 20
    1414//
    1515
     
    2727//######################### Clock #########################
    2828
    29 struct Clock {                                                                                  // virtual clock
    30         // private
    31         Duration offset;                                                                        // offset from computer real-time
     29struct Clock {                                                                                  // private
     30        Duration offset;                                                                        // for virtual clock: contains offset from real-time
    3231};
    3332
    3433static inline {
    35         void reset( Clock & clk, Duration adj ) with( clk ) { // change offset
     34        void reset( Clock & clk, Duration adj ) with( clk ) {
    3635                offset = adj + __timezone`s;                                    // timezone (global) is (UTC - local time) in seconds
    3736        } // reset
    3837
    39         void ?{}( Clock & clk ) { reset( clk, (Duration){ 0 } ); } // create no offset
    40         void ?{}( Clock & clk, Duration adj ) { reset( clk, adj ); } // create with offset
     38        void ?{}( Clock & clk ) { reset( clk, (Duration){ 0 } ); }
     39        void ?{}( Clock & clk, Duration adj ) { reset( clk, adj ); }
    4140
    4241        // System-wide clock that measures real, i.e., wall-clock) time. This clock is affected by discontinuous jumps in
    4342        // the system time. For example, manual changes of the clock, and incremental adjustments performed by adjtime(3)
    4443        // and NTP (daylight saving (Fall back).
    45         Duration resolutionHi() {                                                       // clock resolution in nanoseconds (fine)
     44        Duration resolutionNsec() {
    4645                struct timespec res;
    4746                clock_getres( CLOCK_REALTIME, &res );
    4847                return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;
    49         } // resolutionHi
     48        } // resolutionNsec
    5049
    51         Duration resolution() {                                                         // clock resolution without nanoseconds (coarse)
     50        Duration resolution() {
    5251                struct timespec res;
    5352                clock_getres( CLOCK_REALTIME_COARSE, &res );
     
    5554        } // resolution
    5655
    57         Time timeHiRes() {                                                                      // real time with nanoseconds
     56        Time timeNsec() {                                                                       // with nanoseconds
    5857                timespec curr;
    5958                clock_gettime( CLOCK_REALTIME, &curr );
    6059                return (Time){ curr };
    61         } // timeHiRes
     60        } // timeNsec
    6261
    63         Time time() {                                                                           // real time without nanoseconds
     62        Time time() {                                                                           // without nanoseconds
    6463                timespec curr;
    6564                clock_gettime( CLOCK_REALTIME_COARSE, &curr );
     
    6867        } // time
    6968
    70         Time time( Clock & clk ) with( clk ) {                          // real time for given clock
     69        Time time( Clock & clk ) with( clk ) {
    7170                return time() + offset;
    7271        } // time
     
    7675        } // ?()
    7776
    78         timeval time( Clock & clk ) {                                           // convert to C time format
     77        timeval time( Clock & clk ) {
    7978                return (timeval){ clk() };
    8079        } // time
     
    8988        // discontinuous jumps when the OS is not running the kernal thread. A duration is returned because the value is
    9089        // relative and cannot be converted to real-time (wall-clock) time.
    91         Duration processor() {                                                          // non-monotonic duration of kernel thread
     90        Duration processor() {
    9291                timespec ts;
    9392                clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts );
     
    9897        // watch is affected by discontinuous jumps when the OS is not running the kernel threads. A duration is returned
    9998        // because the value is relative and cannot be converted to real-time (wall-clock) time.
    100         Duration program() {                                                            // non-monotonic duration of program CPU
     99        Duration program() {
    101100                timespec ts;
    102101                clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &ts );
     
    104103        } // program
    105104
    106         // Monotonic duration from machine boot and including system suspension. This watch is unaffected by discontinuous
    107         // jumps resulting from manual changes of the clock, and incremental adjustments performed by adjtime(3) and NTP
    108         // (Fall back). A duration is returned because the value is relative and cannot be converted to real-time
    109         // (wall-clock) time.
    110         Duration boot() {                                                                       // monotonic duration since computer boot
     105        // Monotonic stopwatch starting at machine boot and includes system suspension. This watch is unaffected by
     106        // discontinuous jumps resulting from manual changes of the clock, and incremental adjustments performed by
     107        // adjtime(3) and NTP (Fall back). A duration is returned because the value is relative and cannot be converted to
     108        // real-time (wall-clock) time.
     109        Duration boot() {
    111110                timespec ts;
    112111                clock_gettime( CLOCK_BOOTTIME, &ts );
  • libcfa/src/concurrency/ready_queue.cfa

    r665edf40 rc8a0210  
    3535static const size_t cache_line_size = 64;
    3636
    37 #if !defined(__CFA_NO_STATISTICS__)
    38         #define __STATS(...) __VA_ARGS__
    39 #else
    40         #define __STATS(...)
    41 #endif
    42 
    4337// No overriden function, no environment variable, no define
    4438// fall back to a magic number
     
    5852#endif
    5953
    60 static inline struct $thread * try_pop(struct cluster * cltr, unsigned w __STATS(, __stats_readyQ_pop_t & stats));
    61 static inline struct $thread * try_pop(struct cluster * cltr, unsigned i, unsigned j __STATS(, __stats_readyQ_pop_t & stats));
     54static inline [unsigned, bool] idx_from_r(unsigned r, unsigned preferred);
     55static inline struct $thread * try_pop(struct cluster * cltr, unsigned w);
     56static inline struct $thread * try_pop(struct cluster * cltr, unsigned i, unsigned j);
    6257static inline struct $thread * search(struct cluster * cltr);
    63 static inline [unsigned, bool] idx_from_r(unsigned r, unsigned preferred);
    6458
    6559
     
    275269
    276270                        #if !defined(__CFA_NO_STATISTICS__)
    277                                 if(unlikely(external)) __atomic_fetch_add(&cltr->stats->ready.push.extrn.attempt, 1, __ATOMIC_RELAXED);
    278                                 else if(local) __tls_stats()->ready.push.local.attempt++;
    279                                 else __tls_stats()->ready.push.share.attempt++;
     271                                if(external) {
     272                                        if(local) __atomic_fetch_add(&cltr->stats->ready.pick.ext.local, 1, __ATOMIC_RELAXED);
     273                                        __atomic_fetch_add(&cltr->stats->ready.pick.ext.attempt, 1, __ATOMIC_RELAXED);
     274                                }
     275                                else {
     276                                        if(local) __tls_stats()->ready.pick.push.local++;
     277                                        __tls_stats()->ready.pick.push.attempt++;
     278                                }
    280279                        #endif
    281280
     
    303302                // Update statistics
    304303                #if !defined(__CFA_NO_STATISTICS__)
    305                         if(unlikely(external)) __atomic_fetch_add(&cltr->stats->ready.push.extrn.success, 1, __ATOMIC_RELAXED);
    306                         else if(local) __tls_stats()->ready.push.local.success++;
    307                         else __tls_stats()->ready.push.share.success++;
     304                        if(external) {
     305                                if(local) __atomic_fetch_add(&cltr->stats->ready.pick.ext.lsuccess, 1, __ATOMIC_RELAXED);
     306                                __atomic_fetch_add(&cltr->stats->ready.pick.ext.success, 1, __ATOMIC_RELAXED);
     307                        }
     308                        else {
     309                                if(local) __tls_stats()->ready.pick.push.lsuccess++;
     310                                __tls_stats()->ready.pick.push.success++;
     311                        }
    308312                #endif
    309313        }
     
    330334                        [j, localj] = idx_from_r(rj, preferred);
    331335
     336                        #if !defined(__CFA_NO_STATISTICS__)
     337                                if(locali && localj) {
     338                                        __tls_stats()->ready.pick.pop.local++;
     339                                }
     340                        #endif
     341
    332342                        i %= count;
    333343                        j %= count;
    334344
    335345                        // try popping from the 2 picked lists
    336                         struct $thread * thrd = try_pop(cltr, i, j __STATS(, *(locali || localj ? &__tls_stats()->ready.pop.local : &__tls_stats()->ready.pop.help)));
     346                        struct $thread * thrd = try_pop(cltr, i, j);
    337347                        if(thrd) {
     348                                #if !defined(__CFA_NO_STATISTICS__)
     349                                        if( locali || localj ) __tls_stats()->ready.pick.pop.lsuccess++;
     350                                #endif
    338351                                return thrd;
    339352                        }
     
    361374                unsigned i;
    362375                do {
    363                         #if !defined(__CFA_NO_STATISTICS__)
    364                                 if(unlikely(external)) __atomic_fetch_add(&cltr->stats->ready.push.extrn.attempt, 1, __ATOMIC_RELAXED);
    365                                 else __tls_stats()->ready.push.local.attempt++;
    366                         #endif
    367 
    368376                        if(unlikely(external)) {
    369377                                i = __tls_rand() % lanes.count;
     
    390398                        // Unlock and return
    391399                        __atomic_unlock( &lanes.data[i].lock );
    392                 #endif
    393 
    394                 #if !defined(__CFA_NO_STATISTICS__)
    395                         if(unlikely(external)) __atomic_fetch_add(&cltr->stats->ready.push.extrn.success, 1, __ATOMIC_RELAXED);
    396                         else __tls_stats()->ready.push.local.success++;
    397400                #endif
    398401
     
    419422                }
    420423                else if(lanes.tscs[proc->rdq.target].tv < proc->rdq.cutoff) {
    421                         $thread * t = try_pop(cltr, proc->rdq.target __STATS(, __tls_stats()->ready.pop.help));
     424                        $thread * t = try_pop(cltr, proc->rdq.target);
    422425                        proc->rdq.target = -1u;
    423426                        if(t) return t;
     
    426429                for(READYQ_SHARD_FACTOR) {
    427430                        unsigned i = proc->rdq.id + (--proc->rdq.itr % READYQ_SHARD_FACTOR);
    428                         if($thread * t = try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.local))) return t;
     431                        if($thread * t = try_pop(cltr, i)) return t;
    429432                }
    430433                return 0p;
     
    434437                for(25) {
    435438                        unsigned i = __tls_rand() % lanes.count;
    436                         $thread * t = try_pop(cltr, i __STATS(, __tls_stats()->ready.pop.steal));
     439                        $thread * t = try_pop(cltr, i);
    437440                        if(t) return t;
    438441                }
     
    450453//-----------------------------------------------------------------------
    451454// try to pop from a lane given by index w
    452 static inline struct $thread * try_pop(struct cluster * cltr, unsigned w __STATS(, __stats_readyQ_pop_t & stats)) with (cltr->ready_queue) {
    453         __STATS( stats.attempt++; )
    454 
     455static inline struct $thread * try_pop(struct cluster * cltr, unsigned w) with (cltr->ready_queue) {
    455456        // Get relevant elements locally
    456457        __intrusive_lane_t & lane = lanes.data[w];
    457458
    458459        // If list looks empty retry
    459         if( is_empty(lane) ) {
    460                 __STATS( stats.espec++; )
    461                 return 0p;
    462         }
     460        if( is_empty(lane) ) return 0p;
    463461
    464462        // If we can't get the lock retry
    465         if( !__atomic_try_acquire(&lane.lock) ) {
    466                 __STATS( stats.elock++; )
    467                 return 0p;
    468         }
     463        if( !__atomic_try_acquire(&lane.lock) ) return 0p;
    469464
    470465        // If list is empty, unlock and retry
    471466        if( is_empty(lane) ) {
    472467                __atomic_unlock(&lane.lock);
    473                 __STATS( stats.eempty++; )
    474468                return 0p;
    475469        }
     
    486480
    487481        // Update statistics
    488         __STATS( stats.success++; )
     482        #if !defined(__CFA_NO_STATISTICS__)
     483                __tls_stats()->ready.pick.pop.success++;
     484        #endif
    489485
    490486        #if defined(USE_WORK_STEALING)
     
    505501        for(i; count) {
    506502                unsigned idx = (offset + i) % count;
    507                 struct $thread * thrd = try_pop(cltr, idx __STATS(, __tls_stats()->ready.pop.search));
     503                struct $thread * thrd = try_pop(cltr, idx);
    508504                if(thrd) {
    509505                        return thrd;
     
    543539//-----------------------------------------------------------------------
    544540// Given 2 indexes, pick the list with the oldest push an try to pop from it
    545 static inline struct $thread * try_pop(struct cluster * cltr, unsigned i, unsigned j __STATS(, __stats_readyQ_pop_t & stats)) with (cltr->ready_queue) {
     541static inline struct $thread * try_pop(struct cluster * cltr, unsigned i, unsigned j) with (cltr->ready_queue) {
     542        #if !defined(__CFA_NO_STATISTICS__)
     543                __tls_stats()->ready.pick.pop.attempt++;
     544        #endif
     545
    546546        // Pick the bet list
    547547        int w = i;
     
    550550        }
    551551
    552         return try_pop(cltr, w __STATS(, stats));
     552        return try_pop(cltr, w);
    553553}
    554554
  • libcfa/src/concurrency/stats.cfa

    r665edf40 rc8a0210  
    1010#if !defined(__CFA_NO_STATISTICS__)
    1111        void __init_stats( struct __stats_t * stats ) {
    12                 stats->ready.push.local.attempt = 0;
    13                 stats->ready.push.local.success = 0;
    14                 stats->ready.push.share.attempt = 0;
    15                 stats->ready.push.share.success = 0;
    16                 stats->ready.push.extrn.attempt = 0;
    17                 stats->ready.push.extrn.success = 0;
    18                 stats->ready.pop.local .attempt = 0;
    19                 stats->ready.pop.local .success = 0;
    20                 stats->ready.pop.local .elock   = 0;
    21                 stats->ready.pop.local .eempty  = 0;
    22                 stats->ready.pop.local .espec   = 0;
    23                 stats->ready.pop.help  .attempt = 0;
    24                 stats->ready.pop.help  .success = 0;
    25                 stats->ready.pop.help  .elock   = 0;
    26                 stats->ready.pop.help  .eempty  = 0;
    27                 stats->ready.pop.help  .espec   = 0;
    28                 stats->ready.pop.steal .attempt = 0;
    29                 stats->ready.pop.steal .success = 0;
    30                 stats->ready.pop.steal .elock   = 0;
    31                 stats->ready.pop.steal .eempty  = 0;
    32                 stats->ready.pop.steal .espec   = 0;
    33                 stats->ready.pop.search.attempt = 0;
    34                 stats->ready.pop.search.success = 0;
    35                 stats->ready.pop.search.elock   = 0;
    36                 stats->ready.pop.search.eempty  = 0;
    37                 stats->ready.pop.search.espec   = 0;
     12                stats->ready.pick.push.attempt  = 0;
     13                stats->ready.pick.push.success  = 0;
     14                stats->ready.pick.push.local    = 0;
     15                stats->ready.pick.push.lsuccess = 0;
     16                stats->ready.pick.ext.attempt  = 0;
     17                stats->ready.pick.ext.success  = 0;
     18                stats->ready.pick.ext.local    = 0;
     19                stats->ready.pick.ext.lsuccess = 0;
     20                stats->ready.pick.pop .probe    = 0;
     21                stats->ready.pick.pop .attempt  = 0;
     22                stats->ready.pick.pop .success  = 0;
     23                stats->ready.pick.pop .local    = 0;
     24                stats->ready.pick.pop .lsuccess = 0;
    3825                stats->ready.threads.migration = 0;
    3926                stats->ready.threads.threads   = 0;
     
    6754
    6855        void __tally_stats( struct __stats_t * cltr, struct __stats_t * proc ) {
    69                 __atomic_fetch_add( &cltr->ready.push.local.attempt, proc->ready.push.local.attempt, __ATOMIC_SEQ_CST ); proc->ready.push.local.attempt = 0;
    70                 __atomic_fetch_add( &cltr->ready.push.local.success, proc->ready.push.local.success, __ATOMIC_SEQ_CST ); proc->ready.push.local.success = 0;
    71                 __atomic_fetch_add( &cltr->ready.push.share.attempt, proc->ready.push.share.attempt, __ATOMIC_SEQ_CST ); proc->ready.push.share.attempt = 0;
    72                 __atomic_fetch_add( &cltr->ready.push.share.success, proc->ready.push.share.success, __ATOMIC_SEQ_CST ); proc->ready.push.share.success = 0;
    73                 __atomic_fetch_add( &cltr->ready.push.extrn.attempt, proc->ready.push.extrn.attempt, __ATOMIC_SEQ_CST ); proc->ready.push.extrn.attempt = 0;
    74                 __atomic_fetch_add( &cltr->ready.push.extrn.success, proc->ready.push.extrn.success, __ATOMIC_SEQ_CST ); proc->ready.push.extrn.success = 0;
    75                 __atomic_fetch_add( &cltr->ready.pop.local .attempt, proc->ready.pop.local .attempt, __ATOMIC_SEQ_CST ); proc->ready.pop.local .attempt = 0;
    76                 __atomic_fetch_add( &cltr->ready.pop.local .success, proc->ready.pop.local .success, __ATOMIC_SEQ_CST ); proc->ready.pop.local .success = 0;
    77                 __atomic_fetch_add( &cltr->ready.pop.local .elock  , proc->ready.pop.local .elock  , __ATOMIC_SEQ_CST ); proc->ready.pop.local .elock   = 0;
    78                 __atomic_fetch_add( &cltr->ready.pop.local .eempty , proc->ready.pop.local .eempty , __ATOMIC_SEQ_CST ); proc->ready.pop.local .eempty  = 0;
    79                 __atomic_fetch_add( &cltr->ready.pop.local .espec  , proc->ready.pop.local .espec  , __ATOMIC_SEQ_CST ); proc->ready.pop.local .espec   = 0;
    80                 __atomic_fetch_add( &cltr->ready.pop.help  .attempt, proc->ready.pop.help  .attempt, __ATOMIC_SEQ_CST ); proc->ready.pop.help  .attempt = 0;
    81                 __atomic_fetch_add( &cltr->ready.pop.help  .success, proc->ready.pop.help  .success, __ATOMIC_SEQ_CST ); proc->ready.pop.help  .success = 0;
    82                 __atomic_fetch_add( &cltr->ready.pop.help  .elock  , proc->ready.pop.help  .elock  , __ATOMIC_SEQ_CST ); proc->ready.pop.help  .elock   = 0;
    83                 __atomic_fetch_add( &cltr->ready.pop.help  .eempty , proc->ready.pop.help  .eempty , __ATOMIC_SEQ_CST ); proc->ready.pop.help  .eempty  = 0;
    84                 __atomic_fetch_add( &cltr->ready.pop.help  .espec  , proc->ready.pop.help  .espec  , __ATOMIC_SEQ_CST ); proc->ready.pop.help  .espec   = 0;
    85                 __atomic_fetch_add( &cltr->ready.pop.steal .attempt, proc->ready.pop.steal .attempt, __ATOMIC_SEQ_CST ); proc->ready.pop.steal .attempt = 0;
    86                 __atomic_fetch_add( &cltr->ready.pop.steal .success, proc->ready.pop.steal .success, __ATOMIC_SEQ_CST ); proc->ready.pop.steal .success = 0;
    87                 __atomic_fetch_add( &cltr->ready.pop.steal .elock  , proc->ready.pop.steal .elock  , __ATOMIC_SEQ_CST ); proc->ready.pop.steal .elock   = 0;
    88                 __atomic_fetch_add( &cltr->ready.pop.steal .eempty , proc->ready.pop.steal .eempty , __ATOMIC_SEQ_CST ); proc->ready.pop.steal .eempty  = 0;
    89                 __atomic_fetch_add( &cltr->ready.pop.steal .espec  , proc->ready.pop.steal .espec  , __ATOMIC_SEQ_CST ); proc->ready.pop.steal .espec   = 0;
    90                 __atomic_fetch_add( &cltr->ready.pop.search.attempt, proc->ready.pop.search.attempt, __ATOMIC_SEQ_CST ); proc->ready.pop.search.attempt = 0;
    91                 __atomic_fetch_add( &cltr->ready.pop.search.success, proc->ready.pop.search.success, __ATOMIC_SEQ_CST ); proc->ready.pop.search.success = 0;
    92                 __atomic_fetch_add( &cltr->ready.pop.search.elock  , proc->ready.pop.search.elock  , __ATOMIC_SEQ_CST ); proc->ready.pop.search.elock   = 0;
    93                 __atomic_fetch_add( &cltr->ready.pop.search.eempty , proc->ready.pop.search.eempty , __ATOMIC_SEQ_CST ); proc->ready.pop.search.eempty  = 0;
    94                 __atomic_fetch_add( &cltr->ready.pop.search.espec  , proc->ready.pop.search.espec  , __ATOMIC_SEQ_CST ); proc->ready.pop.search.espec   = 0;
     56                __atomic_fetch_add( &cltr->ready.pick.push.attempt , proc->ready.pick.push.attempt , __ATOMIC_SEQ_CST ); proc->ready.pick.push.attempt  = 0;
     57                __atomic_fetch_add( &cltr->ready.pick.push.success , proc->ready.pick.push.success , __ATOMIC_SEQ_CST ); proc->ready.pick.push.success  = 0;
     58                __atomic_fetch_add( &cltr->ready.pick.push.local   , proc->ready.pick.push.local   , __ATOMIC_SEQ_CST ); proc->ready.pick.push.local    = 0;
     59                __atomic_fetch_add( &cltr->ready.pick.push.lsuccess, proc->ready.pick.push.lsuccess, __ATOMIC_SEQ_CST ); proc->ready.pick.push.lsuccess = 0;
     60                __atomic_fetch_add( &cltr->ready.pick.ext.attempt  , proc->ready.pick.ext.attempt  , __ATOMIC_SEQ_CST ); proc->ready.pick.ext.attempt   = 0;
     61                __atomic_fetch_add( &cltr->ready.pick.ext.success  , proc->ready.pick.ext.success  , __ATOMIC_SEQ_CST ); proc->ready.pick.ext.success   = 0;
     62                __atomic_fetch_add( &cltr->ready.pick.ext.local    , proc->ready.pick.ext.local    , __ATOMIC_SEQ_CST ); proc->ready.pick.ext.local     = 0;
     63                __atomic_fetch_add( &cltr->ready.pick.ext.lsuccess , proc->ready.pick.ext.lsuccess , __ATOMIC_SEQ_CST ); proc->ready.pick.ext.lsuccess  = 0;
     64                __atomic_fetch_add( &cltr->ready.pick.pop .probe   , proc->ready.pick.pop .probe   , __ATOMIC_SEQ_CST ); proc->ready.pick.pop .probe    = 0;
     65                __atomic_fetch_add( &cltr->ready.pick.pop .attempt , proc->ready.pick.pop .attempt , __ATOMIC_SEQ_CST ); proc->ready.pick.pop .attempt  = 0;
     66                __atomic_fetch_add( &cltr->ready.pick.pop .success , proc->ready.pick.pop .success , __ATOMIC_SEQ_CST ); proc->ready.pick.pop .success  = 0;
     67                __atomic_fetch_add( &cltr->ready.pick.pop .local   , proc->ready.pick.pop .local   , __ATOMIC_SEQ_CST ); proc->ready.pick.pop .local    = 0;
     68                __atomic_fetch_add( &cltr->ready.pick.pop .lsuccess, proc->ready.pick.pop .lsuccess, __ATOMIC_SEQ_CST ); proc->ready.pick.pop .lsuccess = 0;
    9569                __atomic_fetch_add( &cltr->ready.threads.migration , proc->ready.threads.migration , __ATOMIC_SEQ_CST ); proc->ready.threads.migration  = 0;
    9670                __atomic_fetch_add( &cltr->ready.threads.threads   , proc->ready.threads.threads   , __ATOMIC_SEQ_CST ); proc->ready.threads.threads    = 0;
     
    12195
    12296                if( flags & CFA_STATS_READY_Q ) {
    123                         double push_len = ((double)ready.push.local.attempt + ready.push.share.attempt + ready.push.extrn.attempt) / (ready.push.local.success + ready.push.share.success + ready.push.extrn.success);
    124                         double sLcl_len = ready.push.local.success ? ((double)ready.push.local.attempt) / ready.push.local.success : 0;
    125                         double sOth_len = ready.push.share.success ? ((double)ready.push.share.attempt) / ready.push.share.success : 0;
    126                         double sExt_len = ready.push.extrn.success ? ((double)ready.push.extrn.attempt) / ready.push.extrn.success : 0;
    127 
    128                         double rLcl_len  = ready.pop.local .success ? ((double)ready.pop.local .attempt) / ready.pop.local .success : 0;
    129                         double rHlp_len  = ready.pop.help  .success ? ((double)ready.pop.help  .attempt) / ready.pop.help  .success : 0;
    130                         double rStl_len  = ready.pop.steal .success ? ((double)ready.pop.steal .attempt) / ready.pop.steal .success : 0;
    131                         double rSch_len  = ready.pop.search.success ? ((double)ready.pop.search.attempt) / ready.pop.search.success : 0;
     97                        double push_len = ((double)ready.pick.push.attempt) / ready.pick.push.success;
     98                        double ext_len  = ((double)ready.pick.ext .attempt) / ready.pick.ext .success;
     99                        double pop_len  = ((double)ready.pick.pop .attempt) / ready.pick.pop .success;
     100
     101                        double lpush_len = ((double)ready.pick.push.local) / ready.pick.push.lsuccess;
     102                        double lext_len  = ((double)ready.pick.ext .local) / ready.pick.ext .lsuccess;
     103                        double lpop_len  = ((double)ready.pick.pop .local) / ready.pick.pop .lsuccess;
    132104
    133105                        __cfaabi_bits_print_safe( STDOUT_FILENO,
    134106                                "----- %s \"%s\" (%p) - Ready Q Stats -----\n"
    135                                 "- totals   : %'3" PRIu64 " run, %'3" PRIu64 " schd (%'" PRIu64 "ext, %'" PRIu64 "mig, %'" PRId64 " )\n"
    136                                 "- push avg : %'3.2lf (l: %'3.2lf/%'" PRIu64 ", s: %'3.2lf/%'" PRIu64 ", e: %'3.2lf : %'" PRIu64 "e)\n"
    137                                 "- local    : %'3.2lf (%'3" PRIu64 " try, %'3" PRIu64 " spc, %'3" PRIu64 " lck, %'3" PRIu64 " ept)\n"
    138                                 "- help     : %'3.2lf (%'3" PRIu64 " try, %'3" PRIu64 " spc, %'3" PRIu64 " lck, %'3" PRIu64 " ept)\n"
    139                                 "- steal    : %'3.2lf (%'3" PRIu64 " try, %'3" PRIu64 " spc, %'3" PRIu64 " lck, %'3" PRIu64 " ept)\n"
    140                                 "- search   : %'3.2lf (%'3" PRIu64 " try, %'3" PRIu64 " spc, %'3" PRIu64 " lck, %'3" PRIu64 " ept)\n"
    141                                 "- Idle Slp : %'3" PRIu64 "h, %'3" PRIu64 "c, %'3" PRIu64 "w, %'3" PRIu64 "e\n"
     107                                "- total threads  : %'15" PRIu64 "run, %'15" PRIu64 "schd (%'" PRIu64 "ext, %'" PRIu64 "mig, %'" PRId64 " )\n"
     108                                "- push avg probe : %'3.2lf, %'3.2lfl (%'15" PRIu64 " attempts, %'15" PRIu64 " locals)\n"
     109                                "- ext  avg probe : %'3.2lf, %'3.2lfl (%'15" PRIu64 " attempts, %'15" PRIu64 " locals)\n"
     110                                "- pop  avg probe : %'3.2lf, %'3.2lfl (%'15" PRIu64 " attempts, %'15" PRIu64 " locals)\n"
     111                                "- Idle Sleep     : %'15" PRIu64 "h, %'15" PRIu64 "c, %'15" PRIu64 "w, %'15" PRIu64 "e\n"
    142112                                "\n"
    143113                                , type, name, id
    144                                 , ready.pop.local.success + ready.pop.help.success + ready.pop.steal.success + ready.pop.search.success
    145                                 , ready.push.local.success + ready.push.share.success + ready.push.extrn.success
    146                                 , ready.push.extrn.success, ready.threads.migration, ready.threads.threads
    147                                 , push_len, sLcl_len, ready.push.local.attempt, sOth_len, ready.push.share.attempt, sExt_len, ready.push.extrn.attempt
    148                                 , rLcl_len, ready.pop.local .attempt, ready.pop.local .espec, ready.pop.local .elock, ready.pop.local .eempty
    149                                 , rHlp_len, ready.pop.help  .attempt, ready.pop.help  .espec, ready.pop.help  .elock, ready.pop.help  .eempty
    150                                 , rStl_len, ready.pop.steal .attempt, ready.pop.steal .espec, ready.pop.steal .elock, ready.pop.steal .eempty
    151                                 , rSch_len, ready.pop.search.attempt, ready.pop.search.espec, ready.pop.search.elock, ready.pop.search.eempty
     114                                , ready.pick.pop.success
     115                                , ready.pick.push.success + ready.pick.ext.success
     116                                , ready.pick.ext.success, ready.threads.migration, ready.threads.threads
     117                                , push_len, lpush_len, ready.pick.push.attempt, ready.pick.push.local
     118                                , ext_len , lext_len , ready.pick.ext .attempt, ready.pick.ext .local
     119                                , pop_len , lpop_len , ready.pick.pop .attempt, ready.pick.pop .local
    152120                                , ready.sleep.halts, ready.sleep.cancels, ready.sleep.wakes, ready.sleep.exits
    153121                        );
  • libcfa/src/concurrency/stats.hfa

    r665edf40 rc8a0210  
    1616        static inline void __print_stats( struct __stats_t *, int, const char *, const char *, void * ) {}
    1717#else
    18         struct __stats_readyQ_pop_t {
    19                 // number of attemps at poping something
    20                 volatile uint64_t attempt;
    2118
    22                 // number of successes at poping
    23                 volatile uint64_t success;
    24 
    25                 // number of attempts failed due to the lock being held
    26                 volatile uint64_t elock;
    27 
    28                 // number of attempts failed due to the queue being empty (lock held)
    29                 volatile uint64_t eempty;
    30 
    31                 // number of attempts failed due to the queue looking empty (lock not held)
    32                 volatile uint64_t espec;
    33         };
    34 
    35         struct __attribute__((aligned(64))) __stats_readyQ_t {
    36                 // Push statistic
     19        struct __attribute__((aligned(64))) __stats_readQ_t {
    3720                struct {
     21                        // Push statistic
    3822                        struct {
    39                                 // number of attemps at pushing something to preferred queues
     23                                // number of attemps at pushing something
    4024                                volatile uint64_t attempt;
    4125
     26                                // number of successes at pushing
     27                                volatile uint64_t success;
     28
     29                                // number of attemps at pushing something to preferred queues
     30                                volatile uint64_t local;
     31
    4232                                // number of successes at pushing to preferred queues
     33                                volatile uint64_t lsuccess;
     34                        } push;
     35
     36                        struct {
     37                                // number of attemps at pushing something
     38                                volatile uint64_t attempt;
     39
     40                                // number of successes at pushing
    4341                                volatile uint64_t success;
    44                         }
    45                         // Stats for local queue within cluster
    46                         local,
    4742
    48                         // Stats for non-local queues within cluster
    49                         share,
     43                                // number of attemps at pushing something to preferred queues
     44                                volatile uint64_t local;
    5045
    51                         // Stats from outside cluster
    52                         extrn;
    53                 } push;
     46                                // number of successes at pushing to preferred queues
     47                                volatile uint64_t lsuccess;
     48                        } ext;
    5449
    55                 // Pop statistic
    56                 struct {
    57                         // pop from local queue
    58                         __stats_readyQ_pop_t local;
     50                        // Pop statistic
     51                        struct {
     52                                // number of reads of the mask
     53                                // picking an empty __cfa_readyQ_mask_t counts here
     54                                // but not as an attempt
     55                                volatile uint64_t probe;
    5956
    60                         // pop before looking at local queue
    61                         __stats_readyQ_pop_t help;
     57                                // number of attemps at poping something
     58                                volatile uint64_t attempt;
    6259
    63                         // pop from some other queue
    64                         __stats_readyQ_pop_t steal;
     60                                // number of successes at poping
     61                                volatile uint64_t success;
    6562
    66                         // pop when searching queues sequentially
    67                         __stats_readyQ_pop_t search;
    68                 } pop;
     63                                // number of attemps at poping something to preferred queues
     64                                volatile uint64_t local;
    6965
     66                                // number of successes at poping to preferred queues
     67                                volatile uint64_t lsuccess;
     68                        } pop;
     69                } pick;
    7070                struct {
    7171                        volatile uint64_t migration;
     
    119119
    120120        struct __attribute__((aligned(128))) __stats_t {
    121                 __stats_readyQ_t ready;
     121                __stats_readQ_t ready;
    122122                #if defined(CFA_HAVE_LINUX_IO_URING_H)
    123123                        __stats_io_t    io;
  • tests/time.cfa

    r665edf40 rc8a0210  
    1010// Created On       : Tue Mar 27 17:24:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr 16 14:59:53 2021
    13 // Update Count     : 38
     12// Last Modified On : Thu Jun 18 18:14:49 2020
     13// Update Count     : 37
    1414//
    1515
     
    5353        //       | "Newfoundland" | getTime( Newfoundland )
    5454        //       | "local" | getTime()
    55         //       | "local nsec" | timeHiRes()
     55        //       | "local nsec" | getTimeNsec()
    5656        //       | "PST" | PST();                                                               // getTime short form
    5757        // sout | nl;
Note: See TracChangeset for help on using the changeset viewer.