[OpenMP] Fix hidden helper + affinity
authorPeyton, Jonathan L <jonathan.l.peyton@intel.com>
Mon, 10 May 2021 15:03:23 +0000 (10:03 -0500)
committerPeyton, Jonathan L <jonathan.l.peyton@intel.com>
Tue, 11 May 2021 13:54:22 +0000 (08:54 -0500)
commitc765d140fe45906fb503d843acccf5838e775245
tree783bf7b401cc7b4c8b9bbac12a8cc20aafb4c490
parentfaebc6bf108eccdfd75917636c64137f73a7bda7
[OpenMP] Fix hidden helper + affinity

When KMP_AFFINITY is set, each worker thread's gtid value is used as an
index into the place list to determine the thread's placement. With hidden
helpers enabled, this gtid value is shifted down leading to unexpected
shifted thread placement. This patch restores the previous behavior by
adjusting the mask index to take the number of hidden helper threads
into account.

Hidden helper threads are given the full initial mask and do not
participate in any of the other affinity mechanisms (place partitioning,
balanced affinity). Their affinity is only printed for debug builds.

Differential Revision: https://reviews.llvm.org/D101882
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_affinity.cpp
openmp/runtime/src/kmp_runtime.cpp