Skip to content

Commit

Permalink
Merge pull request #269 from adanalis/2024.10.sysdetect_coreid_gaps
Browse files Browse the repository at this point in the history
sysdetect: accounting for missing core ids.
  • Loading branch information
adanalis authored Oct 30, 2024
2 parents be2ae24 + c376e34 commit 09fee01
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/components/sysdetect/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ fill_cpu_info( _sysdetect_cpu_info_t *info )
}

for (a = 0; a < info->threads * info->cores * info->sockets; ++a) {
CPU_CALL(cpu_get_attribute_at(CPU_ATTR__HWTHREAD_NUMA_AFFINITY, a, &info->numa_affinity[a]),
info->numa_affinity[a] = 0);
int status = cpu_get_attribute_at(CPU_ATTR__HWTHREAD_NUMA_AFFINITY, a, &info->numa_affinity[a]);
if( CPU_SUCCESS != status ){
SUBDBG("Warning: core ids might not be contiguous.\n");
}
}

info->cache_levels = level;
Expand Down
8 changes: 8 additions & 0 deletions src/components/sysdetect/linux_cpu_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,14 @@ get_thread_affinity( int thread, int *val )
return CPU_SUCCESS;
}

// If gaps exist in the core numbering, the caller of this
// fucntion will likely inquire about cpu-ids that do not
// exist in the system (i.e., the gaps).
if( !path_exist(_PATH_SYS_SYSTEM "/cpu/cpu%d", thread) ){
*val = -1;
return CPU_ERROR;
}

int i = 0;
while (!path_exist(_PATH_SYS_SYSTEM "/cpu/cpu%d/node%d", thread, i)) {
++i;
Expand Down
6 changes: 5 additions & 1 deletion src/components/sysdetect/sysdetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,11 @@ get_num_threads_per_numa( _sysdetect_cpu_info_t *cpu_info )

int threads = cpu_info->threads * cpu_info->cores * cpu_info->sockets;
for (k = 0; k < threads; ++k) {
cpu_info->num_threads_per_numa[cpu_info->numa_affinity[k]]++;
int tmp = cpu_info->numa_affinity[k];
// If gaps exist in the core numbering, the numa_affinity entries
// for the skipped core ids will be negative.
if( tmp >= 0 )
cpu_info->num_threads_per_numa[cpu_info->numa_affinity[k]]++;
}

initialized = 1;
Expand Down
3 changes: 2 additions & 1 deletion src/utils/papi_hardware_avail.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ main( int argc, char **argv )
unsigned int numa_threads[MAX_NUMA_NODES][MAX_CPU_THREADS];
for (j = 0; j < threads; ++j) {
PAPI_get_dev_attr(handle, j, PAPI_DEV_ATTR__CPU_UINT_THR_NUMA_AFFINITY, &affinity[j]);
numa_threads[affinity[j]][numa_threads_count[affinity[j]]++] = j;
if( affinity[j] >= 0 )
numa_threads[affinity[j]][numa_threads_count[affinity[j]]++] = j;
}

for ( j = 0; j < numas; ++j ) {
Expand Down

0 comments on commit 09fee01

Please sign in to comment.