Fix machine topology pruning.

This patch fixes a bug when eliminating layers in the machine topology (namely
cores, and threads). Before this patch, if a user specifies using only one 
thread per socket, then affinity is not set properly due to bad topology
pruning.

Differential Revision: http://reviews.llvm.org/D11158

llvm-svn: 245966
This commit is contained in:
Jonathan Peyton 2015-08-25 18:44:41 +00:00
parent 8cdb3f90ef
commit 62f3840c9b
1 changed files with 22 additions and 17 deletions

View File

@ -1791,24 +1791,26 @@ __kmp_affinity_create_x2apicid_map(AddrUnsPair **address2os,
new_retval[proc] = AddrUnsPair(addr, retval[proc].second);
}
int new_level = 0;
int newPkgLevel = -1;
int newCoreLevel = -1;
int newThreadLevel = -1;
int i;
for (level = 0; level < depth; level++) {
if ((maxCt[level] == 1) && (level != pkgLevel)) {
if (level == threadLevel) {
threadLevel = -1;
}
else if ((threadLevel >= 0) && (level < threadLevel)) {
threadLevel--;
}
if (level == coreLevel) {
coreLevel = -1;
}
else if ((coreLevel >= 0) && (level < coreLevel)) {
coreLevel--;
}
if (level < pkgLevel) {
pkgLevel--;
}
continue;
if ((maxCt[level] == 1)
&& (level != pkgLevel)) {
//
// Remove this level. Never remove the package level
//
continue;
}
if (level == pkgLevel) {
newPkgLevel = level;
}
if (level == coreLevel) {
newCoreLevel = level;
}
if (level == threadLevel) {
newThreadLevel = level;
}
for (proc = 0; (int)proc < nApics; proc++) {
new_retval[proc].first.labels[new_level]
@ -1820,6 +1822,9 @@ __kmp_affinity_create_x2apicid_map(AddrUnsPair **address2os,
__kmp_free(retval);
retval = new_retval;
depth = new_depth;
pkgLevel = newPkgLevel;
coreLevel = newCoreLevel;
threadLevel = newThreadLevel;
}
if (__kmp_affinity_gran_levels < 0) {