Changeset c34ebf2 for libcfa/src


Ignore:
Timestamp:
Jun 25, 2020, 1:34:34 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:
8e27ac45
Parents:
c953163
Message:

Processors now have their own print stats flag

Location:
libcfa/src/concurrency
Files:
4 edited

Legend:

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

    rc953163 rc34ebf2  
    240240        runner.proc = &this;
    241241
     242        #if !defined(__CFA_NO_STATISTICS__)
     243                print_stats = false;
     244                print_halts = false;
     245        #endif
     246
    242247        idle{};
    243248
     
    293298        #if !defined(__CFA_NO_STATISTICS__)
    294299                if(this.print_stats) {
    295                         __print_stats( this.stats );
     300                        __print_stats( this.stats, true, this.name, (void*)&this );
    296301                }
    297302                free( this.stats );
     
    563568        #if !defined(__CFA_NO_STATISTICS__)
    564569                __tally_stats(proc->cltr->stats, &local_stats);
     570                if(proc->print_stats) {
     571                        __print_stats( &local_stats, true, proc->name, (void*)proc );
     572                }
    565573        #endif
    566574
     
    853861                id = -1u;
    854862
     863                #if !defined(__CFA_NO_STATISTICS__)
     864                        print_stats = false;
     865                        print_halts = false;
     866                #endif
     867
    855868                runner{ &this };
    856869                __cfadbg_print_safe(runtime_core, "Kernel : constructed main processor context %p\n", &runner);
     
    10041017        }
    10051018
     1019        #if !defined(__CFA_NO_STATISTICS__)
     1020                if(this->print_halts) {
     1021                        printf("%d - %lld 0\n", this->id, rdtscl());
     1022                }
     1023        #endif
     1024
    10061025        wait( idle );
     1026
     1027        #if !defined(__CFA_NO_STATISTICS__)
     1028                if(this->print_halts) {
     1029                        printf("%d - %lld 1\n", this->id, rdtscl());
     1030                }
     1031        #endif
    10071032}
    10081033
     
    11901215        return true;
    11911216}
     1217
     1218//-----------------------------------------------------------------------------
     1219// Statistics
     1220#if !defined(__CFA_NO_STATISTICS__)
     1221        void print_halts( processor & this ) {
     1222                this.print_halts = true;
     1223                printf("Processor : %d - %s (%p)\n", this.id, this.name, (void*)&this);
     1224        }
     1225#endif
    11921226// Local Variables: //
    11931227// mode: c //
  • libcfa/src/concurrency/kernel.hfa

    rc953163 rc34ebf2  
    104104        // Link lists fields
    105105        Link(processor) link;
     106
     107        #if !defined(__CFA_NO_STATISTICS__)
     108                bool print_stats;
     109                bool print_halts;
     110        #endif
    106111
    107112#ifdef __CFA_DEBUG__
     
    227232                this.print_stats = true;
    228233        }
     234
     235        static inline void print_stats_at_exit( processor & this ) {
     236                this.print_stats = true;
     237        }
     238
     239        void print_halts( processor & this );
    229240#endif
    230241
  • libcfa/src/concurrency/stats.cfa

    rc953163 rc34ebf2  
    7373        }
    7474
    75         void __print_stats( struct __stats_t * stats ) with( *stats ) {
     75        void __print_stats( struct __stats_t * stats, bool cluster, const char * name, void * id ) with( *stats ) {
    7676
    7777                double push_sur = (100.0 * ((double)ready.pick.push.success) / ready.pick.push.attempt);
     
    108108
    109109                __cfaabi_bits_print_safe( STDOUT_FILENO,
    110                         "----- Ready Q Stats -----\n"
     110                        "----- %s \"%s\" (%p) - Ready Q Stats -----\n"
    111111                        "- total threads run      : %'15lu\n"
    112112                        "- total threads scheduled: %'15lu\n"
     
    121121                        "-- schedule wake         : %'15lu\n"
    122122                        "-- wake on exit          : %'15lu\n"
    123                         #if defined(HAVE_LINUX_IO_URING_H)
    124                                 "\n"
    125                                 "----- I/O Stats -----\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"
    126137                                "- total submit calls     : %'15lu\n"
    127138                                "- avg ready entries      : %'18.2lf\n"
     
    136147                                "- total wait calls       : %'15lu   (%'lu slow, %'lu fast)\n"
    137148                                "- avg completion/wait    : %'18.2lf\n"
    138                         #endif
    139                         , ready.pick.pop.success
    140                         , ready.pick.push.success
    141                         , push_len, push_sur, ready.pick.push.attempt
    142                         , pop_len , pop_sur , ready.pick.pop .attempt
    143                         , lpush_len, lpush_sur, ready.pick.push.local
    144                         , lpop_len , lpop_sur , ready.pick.pop .local
    145                         , ready.threads.migration
    146                         , ready.sleep.halts, ready.sleep.cancels, ready.sleep.wakes, ready.sleep.exits
    147                         #if defined(HAVE_LINUX_IO_URING_H)
     149                                "\n"
     150                                , cluster ? "Cluster" : "Processor",  name, id
    148151                                , io.submit_q.submit_avg.cnt
    149                                 , avgrdy
    150                                 , avgcsm
    151                                 , avgavl
     152                                , avgrdy, avgcsm, avgavl
    152153                                , io.submit_q.look_avg.cnt
    153                                 , lavgv
    154                                 , lavgb
     154                                , lavgv, lavgb
    155155                                , io.submit_q.alloc_avg.cnt
    156                                 , aavgv
    157                                 , aavgb
     156                                , aavgv, aavgb
    158157                                , io.complete_q.completed_avg.slow_cnt + io.complete_q.completed_avg.fast_cnt
    159158                                , io.complete_q.completed_avg.slow_cnt,  io.complete_q.completed_avg.fast_cnt
    160159                                , ((double)io.complete_q.completed_avg.val) / (io.complete_q.completed_avg.slow_cnt + io.complete_q.completed_avg.fast_cnt)
    161                         #endif
    162                 );
     160                        );
     161                #endif
    163162        }
    164163#endif
  • libcfa/src/concurrency/stats.hfa

    rc953163 rc34ebf2  
    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 * ) {}
     9        static inline void __print_stats( struct __stats_t *, bool, const char *, void * ) {}
    1010#else
    1111        struct __attribute__((aligned(64))) __stats_readQ_t {
     
    9696        void __init_stats ( struct __stats_t * );
    9797        void __tally_stats( struct __stats_t *, struct __stats_t * );
    98         void __print_stats( struct __stats_t * );
     98        void __print_stats( struct __stats_t *, bool, const char *, void * );
    9999#endif
    100100
Note: See TracChangeset for help on using the changeset viewer.