This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][host runtime] Add support for teams affinity
ClosedPublic

Authored by jlpeyton on Sep 16 2021, 1:36 PM.

Details

Summary

This patch implements teams affinity on the host.
The default is spread. A user can specify either spread, close, or
primary using KMP_TEAMS_PROC_BIND environment variable. Unlike
OMP_PROC_BIND, KMP_TEAMS_PROC_BIND is only a single value and is not a
list of values. The values follow the same semantics under the OpenMP
specification for parallel regions except T is the number of teams in
a league instead of the number of threads in a parallel region.

Diff Detail

Event Timeline

jlpeyton created this revision.Sep 16 2021, 1:36 PM
jlpeyton requested review of this revision.Sep 16 2021, 1:36 PM
tlwilmar requested changes to this revision.Oct 13 2021, 10:35 AM

Check potential KMP_AFFINITY_SUPPORTED changes mentioned in comments.

openmp/runtime/src/kmp_runtime.cpp
5075

Can all of the code using do_place_partition go inside KMP_AFFINITY_SUPPORTED?

5263–5264

For example, here. Can KMP_AFFINITY_SUPPORTED wrap the whole if statement?

This revision now requires changes to proceed.Oct 13 2021, 10:35 AM
jlpeyton added inline comments.Oct 14 2021, 8:50 AM
openmp/runtime/src/kmp_runtime.cpp
5075

The variable really controls both doing the place partition and setting the proc bind var.

5263–5264

So for this example, I can't wrap the setting of t_proc_bind under the KMP_AFFINITY_SUPPORTED macro since it needs to be updated even on platforms with no affinity. At least, that's how it is currently setup (t_proc_bind isn't guarded by KMP_AFFINITY_SUPPORTED even before this patch).

tlwilmar accepted this revision.Oct 14 2021, 11:56 AM

Okay, that makes sense. THanks! LGTM

This revision is now accepted and ready to land.Oct 14 2021, 11:56 AM
This revision was landed with ongoing or failed builds.Oct 14 2021, 2:32 PM
This revision was automatically updated to reflect the committed changes.