This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][libomp] Add core attributes to KMP_HW_SUBSET
ClosedPublic

Authored by jlpeyton on Dec 1 2021, 12:28 PM.

Details

Summary

Add filtering of hardware resources based on core attributes to the environment variable KMP_HW_SUBSET. There are two new attributes added:

  1. Core Type (intel_atom, intel_core)
  2. Core Efficiency (integer) where the higher the efficiency, the more performant the core

On hybrid architectures , e.g., Alder Lake, users can specify
KMP_HW_SUBSET=4c:intel_atom,4c:intel_core to select the first four Atom
and first four Big cores. The can also use the efficiency syntax. e.g.,
KMP_HW_SUBSET=2c:eff0,2c:eff1

Diff Detail

Event Timeline

jlpeyton created this revision.Dec 1 2021, 12:28 PM
jlpeyton requested review of this revision.Dec 1 2021, 12:28 PM
AndreyChurbanov accepted this revision.Dec 8 2021, 8:07 AM

LGTM

Please rebase before the commit (message catalog has been changed).

This revision is now accepted and ready to land.Dec 8 2021, 8:07 AM
This revision was automatically updated to reflect the committed changes.
kaz7 added a subscriber: kaz7.Dec 13 2021, 10:45 AM

I've just noticed this is causing compile errors on not X86 machine.

openmp/runtime/src/kmp_settings.cpp
4998–5000

These lines causes undeclared KMP_HW_CORE_TYPE_ATOM and KMP_HW_CORE_TYPE_CORE errors. Both are defined iff KMP_ARCH_X86 || KMP_ARCH_X86_64.

kaz7 added a comment.Dec 13 2021, 10:49 AM

In addition, these lines also cause compiler errors.

openmp/runtime/src/kmp_affinity.cpp
1107–1110

These lines causes undeclared KMP_HW_CORE_TYPE_ATOM and KMP_HW_CORE_TYPE_CORE errors. Similar to previous comment.

In addition, these lines also cause compiler errors.

Thanks for this report. I've just submitted https://reviews.llvm.org/D115664 with you as a reviewer. Is it possible for you to test that this fixes the compiler errors?

kaz7 added a comment.Dec 13 2021, 10:18 PM

In addition, these lines also cause compiler errors.

Thanks for this report. I've just submitted https://reviews.llvm.org/D115664 with you as a reviewer. Is it possible for you to test that this fixes the compiler errors?

Yes. That patch fixes our compiler errors. I've also responsed in https://reviews.llvm.org/D115664 too. Thank you for quick patch.

hans added a subscriber: hans.Feb 9 2022, 4:40 AM
hans added inline comments.
openmp/runtime/src/kmp_affinity.cpp
951

hw_subset_depth isn't a constant expression, causing an error with MSVC: https://github.com/llvm/llvm-project/issues/53672