[Openmp-commits] [PATCH] D56804: Fix thread_limits to work properly for teams construct

Terry Wilmarth via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Jan 16 13:12:17 PST 2019

tlwilmar created this revision.
tlwilmar added reviewers: AndreyChurbanov, protze.joachim, hbae.
tlwilmar added a project: OpenMP.

The thread-limit-var and omp_get_thread_limit API was not perfectly handled for teams construct.  Now, when modified by thread_limit clause, omp_get_thread_limit reports the correct value. In addition, the value is restored when leaving the teams construct to what it was in the encountering context.

This is done partly by creating the notion of a Contention Group root (CG root) that keeps track of the thread at the root of each separate CG, the thread-limit-var associated with the CG, and associated counter of active threads within the contention group.

thread-limits are passed from master to worker threads via an entry in the ICV data structure.  When a "contention group switch" occurs, a new CG root record is made and passed from master to worker.  A thread could potentially have several CG root records if it encounters multiple nested teams constructs (but at the moment the spec doesn't allow for nested teams, so the most one could have currently is 2). The master of the teams masters gets the thread-limit clause value stored to its local ICV structure, and the other teams masters copy it from the master. The thread-limit is set from that ICV copy and restored to the ICV copy when entering and leaving the teams construct.

This change also fixes a bug when the top-level teams construct team gets reused, and OMP_DYNAMIC was true, which can cause the expected size of this team to be smaller than what was actually allocated.  The fix updates the size of the team after its threads were reserved.

  rOMP OpenMP



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56804.182129.patch
Type: text/x-patch
Size: 17596 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190116/b46383c9/attachment.bin>

More information about the Openmp-commits mailing list