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 pohh_tile_idx = fd_topo_find_tile( &config->topo, "pohh", 0UL ); 45 0 : ulong poh_tile_idx = fd_topo_find_tile( &config->topo, "poh", 0UL ); 46 : 47 0 : ulong pack_pair = determine_ht_pair( config, cpus, "pack", 0UL ); 48 0 : ulong pohh_pair = determine_ht_pair( config, cpus, "pohh", 0UL ); 49 0 : ulong poh_pair = determine_ht_pair( config, cpus, "poh", 0UL ); 50 : 51 0 : int pack_pair_used = determine_cpu_used( config, pack_pair ); 52 0 : int pohh_pair_used = determine_cpu_used( config, pohh_pair ); 53 0 : int poh_pair_used = determine_cpu_used( config, poh_pair ); 54 : 55 0 : int pack_pair_online = 0; 56 0 : int pohh_pair_online = 0; 57 0 : int poh_pair_online = 0; 58 0 : for( ulong i=0UL; i<cpus->cpu_cnt; i++ ) { 59 0 : if( i==pack_pair && !pack_pair_used ) { 60 0 : if( FD_UNLIKELY( cpus->cpu[ i ].online ) ) pack_pair_online = 1; 61 0 : } else if( i==pohh_pair && !pohh_pair_used ) { 62 0 : if( FD_UNLIKELY( cpus->cpu[ i ].online ) ) pohh_pair_online = 1; 63 0 : } else if( i==poh_pair && !poh_pair_used ) { 64 0 : if( FD_UNLIKELY( cpus->cpu[ i ].online ) ) poh_pair_online = 1; 65 0 : } 66 0 : } 67 : 68 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 )); 69 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 )); 70 0 : if( FD_UNLIKELY( pohh_pair_used ) ) FD_LOG_WARNING(( "pohh cpu %lu has hyperthread pair cpu %lu which is used by another tile. Proceeding but performance may be reduced.", config->topo.tiles[ pohh_tile_idx ].cpu_idx, pohh_pair )); 71 0 : else if( FD_UNLIKELY( pohh_pair_online ) ) FD_LOG_WARNING(( "pohh cpu %lu has hyperthread pair cpu %lu which should be offline. Proceeding but performance may be reduced.", config->topo.tiles[ pohh_tile_idx ].cpu_idx, pohh_pair )); 72 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 )); 73 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 )); 74 : 75 0 : CONFIGURE_OK(); 76 0 : } 77 : 78 : configure_stage_t fd_cfg_stage_hyperthreads = { 79 : .name = NAME, 80 : .always_recreate = 0, 81 : .enabled = NULL, 82 : .init_perm = NULL, 83 : .fini_perm = NULL, 84 : .init = NULL, 85 : .fini = NULL, 86 : .check = check, 87 : }; 88 : 89 : #undef NAME