LCOV - code coverage report
Current view: top level - app/shared/commands/configure - hyperthreads.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 45 0.0 %
Date: 2025-03-20 12:08:36 Functions: 0 3 0.0 %

          Line data    Source code
       1             : #include "configure.h"
       2             : 
       3             : #define NAME "hyperthreads"
       4             : 
       5             : #include "../../../../disco/topo/fd_cpu_topo.h"
       6             : 
       7             : ulong
       8             : determine_ht_pair( config_t const *       config,
       9             :                    fd_topo_cpus_t const * cpus,
      10             :                    char const *           kind,
      11           0 :                    ulong                  kind_id ) {
      12           0 :   ulong tile_idx = fd_topo_find_tile( &config->topo, kind, kind_id );
      13           0 :   if( FD_LIKELY( tile_idx!=ULONG_MAX ) ) {
      14           0 :     fd_topo_tile_t const * tile = &config->topo.tiles[ tile_idx ];
      15           0 :     if( FD_LIKELY( tile->cpu_idx!=ULONG_MAX ) ) return cpus->cpu[ tile->cpu_idx ].sibling;
      16           0 :   }
      17           0 :   return ULONG_MAX;
      18           0 : }
      19             : 
      20             : static int
      21             : determine_cpu_used( config_t const * config,
      22           0 :                     ulong            cpu_idx ) {
      23           0 :   if( FD_UNLIKELY( cpu_idx==ULONG_MAX ) ) return 0;
      24             : 
      25           0 :   ulong tile_cnt = config->topo.tile_cnt;
      26           0 :   for( ulong i=0UL; i<tile_cnt; i++ ) {
      27           0 :     fd_topo_tile_t const * tile = &config->topo.tiles[ i ];
      28           0 :     if( tile->cpu_idx==cpu_idx ) return 1;
      29           0 :   }
      30           0 :   return 0;
      31           0 : }
      32             : 
      33             : static configure_result_t
      34           0 : check( config_t const * config ) {
      35           0 :   static int has_warned = 0;
      36             : 
      37           0 :   fd_topo_cpus_t cpus[1];
      38           0 :   fd_topo_cpus_init( cpus );
      39             : 
      40           0 :   ulong pack_tile_idx = fd_topo_find_tile( &config->topo, "pack", 0UL );
      41           0 :   ulong poh_tile_idx  = fd_topo_find_tile( &config->topo, "poh", 0UL );
      42             : 
      43           0 :   ulong pack_pair = determine_ht_pair( config, cpus, "pack", 0UL );
      44           0 :   ulong poh_pair  = determine_ht_pair( config, cpus, "poh",  0UL );
      45             : 
      46           0 :   int pack_pair_used = determine_cpu_used( config, pack_pair );
      47           0 :   int poh_pair_used  = determine_cpu_used( config, poh_pair );
      48             : 
      49           0 :   int pack_pair_online      = 0;
      50           0 :   int poh_pair_online       = 0;
      51           0 :   for( ulong i=0UL; i<cpus->cpu_cnt; i++ ) {
      52           0 :     if( i==pack_pair && !pack_pair_used ) {
      53           0 :       if( FD_UNLIKELY( cpus->cpu[ i ].online ) ) pack_pair_online = 1;
      54           0 :     } else if( i==poh_pair && !poh_pair_used ) {
      55           0 :       if( FD_UNLIKELY( cpus->cpu[ i ].online ) ) poh_pair_online = 1;
      56           0 :     }
      57           0 :   }
      58             : 
      59           0 :   if( FD_LIKELY( !has_warned ) ) {
      60           0 :     if( FD_UNLIKELY( pack_pair_used ) )        FD_LOG_WARNING(( "pack cpu %lu has hyperthread pair cpu %lu which is used by another tile. Proceeding but performance may be reduced.", config->topo.tiles[ pack_tile_idx ].cpu_idx, pack_pair ));
      61           0 :     else if( FD_UNLIKELY( pack_pair_online ) ) FD_LOG_WARNING(( "pack cpu %lu has hyperthread pair cpu %lu which should be offline. Proceeding but performance may be reduced.", config->topo.tiles[ pack_tile_idx ].cpu_idx, pack_pair ));
      62           0 :     if( FD_UNLIKELY( poh_pair_used  ) )        FD_LOG_WARNING(( "poh cpu %lu has hyperthread pair cpu %lu which is used by another tile. Proceeding but performance may be reduced.", config->topo.tiles[ poh_tile_idx ].cpu_idx, poh_pair ));
      63           0 :     else if( FD_UNLIKELY( poh_pair_online ) )  FD_LOG_WARNING(( "poh cpu %lu has hyperthread pair cpu %lu which should be offline. Proceeding but performance may be reduced.", config->topo.tiles[ poh_tile_idx ].cpu_idx, poh_pair ));
      64           0 :   }
      65             : 
      66           0 :   has_warned = 1;
      67             : 
      68           0 :   CONFIGURE_OK();
      69           0 : }
      70             : 
      71             : configure_stage_t fd_cfg_stage_hyperthreads = {
      72             :   .name            = NAME,
      73             :   .always_recreate = 0,
      74             :   .enabled         = NULL,
      75             :   .init_perm       = NULL,
      76             :   .fini_perm       = NULL,
      77             :   .init            = NULL,
      78             :   .fini            = NULL,
      79             :   .check           = check,
      80             : };
      81             : 
      82             : #undef NAME

Generated by: LCOV version 1.14