Ignore:
Timestamp:
Jun 25, 2020, 2:30:46 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
566fde0
Parents:
8e27ac45
Message:

Clusters/Processors? can now select which stats to print.
Instead of all or nothing.

Location:
libcfa/src/concurrency
Files:
4 edited

Legend:

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

    r8e27ac45 r69fbc61  
    241241
    242242        #if !defined(__CFA_NO_STATISTICS__)
    243                 print_stats = false;
     243                print_stats = 0;
    244244                print_halts = false;
    245245        #endif
     
    281281
    282282        #if !defined(__CFA_NO_STATISTICS__)
    283                 print_stats = false;
     283                print_stats = 0;
    284284                stats = alloc();
    285285                __init_stats( stats );
     
    297297
    298298        #if !defined(__CFA_NO_STATISTICS__)
    299                 if(this.print_stats) {
    300                         __print_stats( this.stats, true, this.name, (void*)&this );
     299                if( 0 != this.print_stats ) {
     300                        __print_stats( this.stats, this.print_stats, true, this.name, (void*)&this );
    301301                }
    302302                free( this.stats );
     
    568568        #if !defined(__CFA_NO_STATISTICS__)
    569569                __tally_stats(proc->cltr->stats, &local_stats);
    570                 if(proc->print_stats) {
    571                         __print_stats( &local_stats, true, proc->name, (void*)proc );
     570                if( 0 != proc->print_stats ) {
     571                        __print_stats( &local_stats, proc->print_stats, true, proc->name, (void*)proc );
    572572                }
    573573        #endif
  • libcfa/src/concurrency/kernel.hfa

    r8e27ac45 r69fbc61  
    106106
    107107        #if !defined(__CFA_NO_STATISTICS__)
    108                 bool print_stats;
     108                int print_stats;
    109109                bool print_halts;
    110110        #endif
     
    207207
    208208        #if !defined(__CFA_NO_STATISTICS__)
    209                 bool print_stats;
    210209                struct __stats_t * stats;
     210                int print_stats;
    211211        #endif
    212212};
     
    229229
    230230#if !defined(__CFA_NO_STATISTICS__)
    231         static inline void print_stats_at_exit( cluster & this ) {
    232                 this.print_stats = true;
     231        static inline void print_stats_at_exit( cluster & this, int flags ) {
     232                this.print_stats |= flags;
    233233        }
    234234
    235         static inline void print_stats_at_exit( processor & this ) {
    236                 this.print_stats = true;
     235        static inline void print_stats_at_exit( processor & this, int flags ) {
     236                this.print_stats |= flags;
    237237        }
    238238
  • libcfa/src/concurrency/stats.cfa

    r8e27ac45 r69fbc61  
    7373        }
    7474
    75         void __print_stats( struct __stats_t * stats, bool cluster, const char * name, void * id ) with( *stats ) {
     75        void __print_stats( struct __stats_t * stats, int flags, bool cluster, const char * name, void * id ) with( *stats ) {
    7676
    77                 double push_sur = (100.0 * ((double)ready.pick.push.success) / ready.pick.push.attempt);
    78                 double pop_sur  = (100.0 * ((double)ready.pick.pop .success) / ready.pick.pop .attempt);
     77                if( flags & CFA_STATS_READY_Q ) {
     78                        double push_sur = (100.0 * ((double)ready.pick.push.success) / ready.pick.push.attempt);
     79                        double pop_sur  = (100.0 * ((double)ready.pick.pop .success) / ready.pick.pop .attempt);
    7980
    80                 double push_len = ((double)ready.pick.push.attempt) / ready.pick.push.success;
    81                 double pop_len  = ((double)ready.pick.pop .attempt) / ready.pick.pop .success;
     81                        double push_len = ((double)ready.pick.push.attempt) / ready.pick.push.success;
     82                        double pop_len  = ((double)ready.pick.pop .attempt) / ready.pick.pop .success;
    8283
    83                 double lpush_sur = (100.0 * ((double)ready.pick.push.lsuccess) / ready.pick.push.local);
    84                 double lpop_sur  = (100.0 * ((double)ready.pick.pop .lsuccess) / ready.pick.pop .local);
     84                        double lpush_sur = (100.0 * ((double)ready.pick.push.lsuccess) / ready.pick.push.local);
     85                        double lpop_sur  = (100.0 * ((double)ready.pick.pop .lsuccess) / ready.pick.pop .local);
    8586
    86                 double lpush_len = ((double)ready.pick.push.local) / ready.pick.push.lsuccess;
    87                 double lpop_len  = ((double)ready.pick.pop .local) / ready.pick.pop .lsuccess;
     87                        double lpush_len = ((double)ready.pick.push.local) / ready.pick.push.lsuccess;
     88                        double lpop_len  = ((double)ready.pick.pop .local) / ready.pick.pop .lsuccess;
     89
     90                        __cfaabi_bits_print_safe( STDOUT_FILENO,
     91                                "----- %s \"%s\" (%p) - Ready Q Stats -----\n"
     92                                "- total threads run      : %'15lu\n"
     93                                "- total threads scheduled: %'15lu\n"
     94                                "- push average probe len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n"
     95                                "- pop  average probe len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n"
     96                                "- local push avg prb len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n"
     97                                "- local pop  avg prb len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n"
     98                                "- thread migrations      : %'15lu\n"
     99                                "- Idle Sleep -\n"
     100                                "-- halts                 : %'15lu\n"
     101                                "-- cancelled halts       : %'15lu\n"
     102                                "-- schedule wake         : %'15lu\n"
     103                                "-- wake on exit          : %'15lu\n"
     104                                "\n"
     105                                , cluster ? "Cluster" : "Processor",  name, id
     106                                , ready.pick.pop.success
     107                                , ready.pick.push.success
     108                                , push_len, push_sur, ready.pick.push.attempt
     109                                , pop_len , pop_sur , ready.pick.pop .attempt
     110                                , lpush_len, lpush_sur, ready.pick.push.local
     111                                , lpop_len , lpop_sur , ready.pick.pop .local
     112                                , ready.threads.migration
     113                                , ready.sleep.halts, ready.sleep.cancels, ready.sleep.wakes, ready.sleep.exits
     114                        );
     115                }
    88116
    89117                #if defined(HAVE_LINUX_IO_URING_H)
    90                         double avgrdy = ((double)io.submit_q.submit_avg.rdy) / io.submit_q.submit_avg.cnt;
    91                         double avgcsm = ((double)io.submit_q.submit_avg.csm) / io.submit_q.submit_avg.cnt;
    92                         double avgavl = ((double)io.submit_q.submit_avg.avl) / io.submit_q.submit_avg.cnt;
     118                        if( flags & CFA_STATS_IO ) {
     119                                double avgrdy = ((double)io.submit_q.submit_avg.rdy) / io.submit_q.submit_avg.cnt;
     120                                double avgcsm = ((double)io.submit_q.submit_avg.csm) / io.submit_q.submit_avg.cnt;
     121                                double avgavl = ((double)io.submit_q.submit_avg.avl) / io.submit_q.submit_avg.cnt;
    93122
    94                         double lavgv = 0;
    95                         double lavgb = 0;
    96                         if(io.submit_q.look_avg.cnt != 0) {
    97                                 lavgv = ((double)io.submit_q.look_avg.val  ) / io.submit_q.look_avg.cnt;
    98                                 lavgb = ((double)io.submit_q.look_avg.block) / io.submit_q.look_avg.cnt;
     123                                double lavgv = 0;
     124                                double lavgb = 0;
     125                                if(io.submit_q.look_avg.cnt != 0) {
     126                                        lavgv = ((double)io.submit_q.look_avg.val  ) / io.submit_q.look_avg.cnt;
     127                                        lavgb = ((double)io.submit_q.look_avg.block) / io.submit_q.look_avg.cnt;
     128                                }
     129
     130                                double aavgv = 0;
     131                                double aavgb = 0;
     132                                if(io.submit_q.alloc_avg.cnt != 0) {
     133                                        aavgv = ((double)io.submit_q.alloc_avg.val  ) / io.submit_q.alloc_avg.cnt;
     134                                        aavgb = ((double)io.submit_q.alloc_avg.block) / io.submit_q.alloc_avg.cnt;
     135                                }
     136
     137                                __cfaabi_bits_print_safe( STDOUT_FILENO,
     138                                        "----- %s \"%s\" (%p) - I/O Stats -----\n"
     139                                        "- total submit calls     : %'15lu\n"
     140                                        "- avg ready entries      : %'18.2lf\n"
     141                                        "- avg submitted entries  : %'18.2lf\n"
     142                                        "- avg available entries  : %'18.2lf\n"
     143                                        "- total ready search     : %'15lu\n"
     144                                        "- avg ready search len   : %'18.2lf\n"
     145                                        "- avg ready search block : %'18.2lf\n"
     146                                        "- total alloc search     : %'15lu\n"
     147                                        "- avg alloc search len   : %'18.2lf\n"
     148                                        "- avg alloc search block : %'18.2lf\n"
     149                                        "- total wait calls       : %'15lu   (%'lu slow, %'lu fast)\n"
     150                                        "- avg completion/wait    : %'18.2lf\n"
     151                                        "\n"
     152                                        , cluster ? "Cluster" : "Processor",  name, id
     153                                        , io.submit_q.submit_avg.cnt
     154                                        , avgrdy, avgcsm, avgavl
     155                                        , io.submit_q.look_avg.cnt
     156                                        , lavgv, lavgb
     157                                        , io.submit_q.alloc_avg.cnt
     158                                        , aavgv, aavgb
     159                                        , io.complete_q.completed_avg.slow_cnt + io.complete_q.completed_avg.fast_cnt
     160                                        , io.complete_q.completed_avg.slow_cnt,  io.complete_q.completed_avg.fast_cnt
     161                                        , ((double)io.complete_q.completed_avg.val) / (io.complete_q.completed_avg.slow_cnt + io.complete_q.completed_avg.fast_cnt)
     162                                );
    99163                        }
    100 
    101                         double aavgv = 0;
    102                         double aavgb = 0;
    103                         if(io.submit_q.alloc_avg.cnt != 0) {
    104                                 aavgv = ((double)io.submit_q.alloc_avg.val  ) / io.submit_q.alloc_avg.cnt;
    105                                 aavgb = ((double)io.submit_q.alloc_avg.block) / io.submit_q.alloc_avg.cnt;
    106                         }
    107                 #endif
    108 
    109                 __cfaabi_bits_print_safe( STDOUT_FILENO,
    110                         "----- %s \"%s\" (%p) - Ready Q Stats -----\n"
    111                         "- total threads run      : %'15lu\n"
    112                         "- total threads scheduled: %'15lu\n"
    113                         "- push average probe len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n"
    114                         "- pop  average probe len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n"
    115                         "- local push avg prb len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n"
    116                         "- local pop  avg prb len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n"
    117                         "- thread migrations      : %'15lu\n"
    118                         "- Idle Sleep -\n"
    119                         "-- halts                 : %'15lu\n"
    120                         "-- cancelled halts       : %'15lu\n"
    121                         "-- schedule wake         : %'15lu\n"
    122                         "-- wake on exit          : %'15lu\n"
    123                         "\n"
    124                         , cluster ? "Cluster" : "Processor",  name, id
    125                         , ready.pick.pop.success
    126                         , ready.pick.push.success
    127                         , push_len, push_sur, ready.pick.push.attempt
    128                         , pop_len , pop_sur , ready.pick.pop .attempt
    129                         , lpush_len, lpush_sur, ready.pick.push.local
    130                         , lpop_len , lpop_sur , ready.pick.pop .local
    131                         , ready.threads.migration
    132                         , ready.sleep.halts, ready.sleep.cancels, ready.sleep.wakes, ready.sleep.exits
    133                 );
    134                 #if defined(HAVE_LINUX_IO_URING_H)
    135                         __cfaabi_bits_print_safe( STDOUT_FILENO,
    136                                 "----- %s \"%s\" (%p) - I/O Stats -----\n"
    137                                 "- total submit calls     : %'15lu\n"
    138                                 "- avg ready entries      : %'18.2lf\n"
    139                                 "- avg submitted entries  : %'18.2lf\n"
    140                                 "- avg available entries  : %'18.2lf\n"
    141                                 "- total ready search     : %'15lu\n"
    142                                 "- avg ready search len   : %'18.2lf\n"
    143                                 "- avg ready search block : %'18.2lf\n"
    144                                 "- total alloc search     : %'15lu\n"
    145                                 "- avg alloc search len   : %'18.2lf\n"
    146                                 "- avg alloc search block : %'18.2lf\n"
    147                                 "- total wait calls       : %'15lu   (%'lu slow, %'lu fast)\n"
    148                                 "- avg completion/wait    : %'18.2lf\n"
    149                                 "\n"
    150                                 , cluster ? "Cluster" : "Processor",  name, id
    151                                 , io.submit_q.submit_avg.cnt
    152                                 , avgrdy, avgcsm, avgavl
    153                                 , io.submit_q.look_avg.cnt
    154                                 , lavgv, lavgb
    155                                 , io.submit_q.alloc_avg.cnt
    156                                 , aavgv, aavgb
    157                                 , io.complete_q.completed_avg.slow_cnt + io.complete_q.completed_avg.fast_cnt
    158                                 , io.complete_q.completed_avg.slow_cnt,  io.complete_q.completed_avg.fast_cnt
    159                                 , ((double)io.complete_q.completed_avg.val) / (io.complete_q.completed_avg.slow_cnt + io.complete_q.completed_avg.fast_cnt)
    160                         );
    161164                #endif
    162165        }
  • libcfa/src/concurrency/stats.hfa

    r8e27ac45 r69fbc61  
    77        static inline void __init_stats( struct __stats_t * ) {}
    88        static inline void __tally_stats( struct __stats_t *, struct __stats_t * ) {}
    9         static inline void __print_stats( struct __stats_t *, bool, const char *, void * ) {}
     9        static inline void __print_stats( struct __stats_t *, int, bool, const char *, void * ) {}
    1010#else
     11        enum {
     12                CFA_STATS_READY_Q  = 0x01,
     13                #if defined(HAVE_LINUX_IO_URING_H)
     14                        CFA_STATS_IO = 0x02,
     15                #endif
     16        };
     17
    1118        struct __attribute__((aligned(64))) __stats_readQ_t {
    1219                struct {
     
    96103        void __init_stats ( struct __stats_t * );
    97104        void __tally_stats( struct __stats_t *, struct __stats_t * );
    98         void __print_stats( struct __stats_t *, bool, const char *, void * );
     105        void __print_stats( struct __stats_t *, int, bool, const char *, void * );
    99106#endif
    100107
Note: See TracChangeset for help on using the changeset viewer.