Skip to content

Commit

Permalink
[OpenMP] Ensure socket layer is not first in CPUID topology detection
Browse files Browse the repository at this point in the history
* Return 0 length topology if socket layer is detected first
* Fix DEBUG ASSERT
  • Loading branch information
jpeyton52 committed Jul 6, 2023
1 parent b7d36a1 commit 05e2bc2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion openmp/runtime/src/kmp_affinity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,10 @@ __kmp_x2apicid_get_levels(int leaf,
level++;
} while (level_type != INTEL_LEVEL_TYPE_INVALID);

// Ensure the INTEL_LEVEL_TYPE_INVALID (Socket) layer isn't first
if (levels_index == 0 || levels[0].level_type == INTEL_LEVEL_TYPE_INVALID)
return 0;

// Set the masks to & with apicid
for (unsigned i = 0; i < levels_index; ++i) {
if (levels[i].level_type != INTEL_LEVEL_TYPE_INVALID) {
Expand All @@ -2517,7 +2521,7 @@ __kmp_x2apicid_get_levels(int leaf,
for (unsigned j = 0; j < i; ++j)
levels[i].mask ^= levels[j].mask;
} else {
KMP_DEBUG_ASSERT(levels_index > 0);
KMP_DEBUG_ASSERT(i > 0);
levels[i].mask = (-1) << levels[i - 1].mask_width;
levels[i].cache_mask = 0;
}
Expand Down

0 comments on commit 05e2bc2

Please sign in to comment.