[OpenMP] Fix for smaller team sizes inside teams construct.
authorTerry Wilmarth <terry.l.wilmarth@intel.com>
Tue, 13 Dec 2022 18:54:24 +0000 (12:54 -0600)
committerTerry Wilmarth <terry.l.wilmarth@intel.com>
Wed, 11 Jan 2023 17:24:21 +0000 (11:24 -0600)
commit9830a5d0c19b8d5165735e39343b7174addd94a0
treeb0b014f19c58ae32d08f0c58a01197b49ab20656
parent2fb74eec97d5862eb32db8749e140455babb5c02
[OpenMP] Fix for smaller team sizes inside teams construct.

When a team nested inside a teams construct is allocated, it is
allocated to a size specified by the teams thread_limit.  In the case
where any mechanism that might not grant the full thread_limit is in
use, we may get a smaller team.  This possibility was not reflected in
the code when using the th_teams_size.nth value stored on the master
thread for the team. This value was never updated even when t_nproc on
the team itself was different.  I added a line to update it shortly
before the team is forked.

Added a simple teams test that uses KMP_DYNAMIC_MODE=random to mimic
allocating teams with sizes <= thread_limit. Eventually, this
will segfault without the fix in this commit.

Differential Revision: https://reviews.llvm.org/D139960
openmp/runtime/src/kmp_runtime.cpp
openmp/runtime/test/teams/teams_resize.c [new file with mode: 0644]