Line data Source code
1 : #include "configure.h" 2 : 3 : #define NAME "hyperthreads" 4 : 5 : #include "../../../../disco/topo/fd_cpu_topo.h" 6 : 7 : static 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 : check( config_t const * config, 35 0 : int check_type ) { 36 0 : if( !( check_type==FD_CONFIGURE_CHECK_TYPE_PRE_INIT || 37 0 : check_type==FD_CONFIGURE_CHECK_TYPE_CHECK || 38 0 : check_type==FD_CONFIGURE_CHECK_TYPE_RUN ) ) CONFIGURE_OK(); 39 : 40 0 : fd_topo_cpus_t cpus[1]; 41 0 : fd_topo_cpus_init( cpus ); 42 : 43 0 : ulong pack_tile_idx = fd_topo_find_tile( &config->topo, "pack", 0UL ); 44 0 : ulong poh_tile_idx = fd_topo_find_tile( &config->topo, "poh", 0UL ); 45 : 46 0 : ulong pack_pair = determine_ht_pair( config, cpus, "pack", 0UL ); 47 0 : ulong poh_pair = determine_ht_pair( config, cpus, "poh", 0UL ); 48 : 49 0 : int pack_pair_used = determine_cpu_used( config, pack_pair ); 50 0 : int poh_pair_used = determine_cpu_used( config, poh_pair ); 51 : 52 0 : int pack_pair_online = 0; 53 0 : int poh_pair_online = 0; 54 0 : for( ulong i=0UL; i<cpus->cpu_cnt; i++ ) { 55 0 : if( i==pack_pair && !pack_pair_used ) { 56 0 : if( FD_UNLIKELY( cpus->cpu[ i ].online ) ) pack_pair_online = 1; 57 0 : } else if( i==poh_pair && !poh_pair_used ) { 58 0 : if( FD_UNLIKELY( cpus->cpu[ i ].online ) ) poh_pair_online = 1; 59 0 : } 60 0 : } 61 : 62 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 )); 63 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 )); 64 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 )); 65 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 )); 66 : 67 0 : CONFIGURE_OK(); 68 0 : } 69 : 70 : configure_stage_t fd_cfg_stage_hyperthreads = { 71 : .name = NAME, 72 : .always_recreate = 0, 73 : .enabled = NULL, 74 : .init_perm = NULL, 75 : .fini_perm = NULL, 76 : .init = NULL, 77 : .fini = NULL, 78 : .check = check, 79 : }; 80 : 81 : #undef NAME