From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1461) id 66C5738515E7; Wed, 4 Aug 2021 14:33:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 66C5738515E7 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Andrew Stubbs To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] libgomp amdgcn: Fix issues with dynamic OpenMP thread scaling X-Act-Checkin: gcc X-Git-Author: Andrew Stubbs X-Git-Refname: refs/heads/devel/omp/gcc-11 X-Git-Oldrev: 69b1e8c24d1c84322fb385d40aa930313aca710e X-Git-Newrev: 64855d67f0bef461d11da03380de587cca5850e7 Message-Id: <20210804143357.66C5738515E7@sourceware.org> Date: Wed, 4 Aug 2021 14:33:57 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Aug 2021 14:33:57 -0000 https://gcc.gnu.org/g:64855d67f0bef461d11da03380de587cca5850e7 commit 64855d67f0bef461d11da03380de587cca5850e7 Author: Andrew Stubbs Date: Tue Aug 3 13:45:35 2021 +0100 libgomp amdgcn: Fix issues with dynamic OpenMP thread scaling libgomp/ChangeLog: * config/gcn/bar.h (gomp_barrier_init): Limit thread count to the actual physical number. * config/gcn/team.c (gomp_team_start): Don't attempt to set up threads that do not exist. Diff: --- libgomp/config/gcn/bar.h | 3 +++ libgomp/config/gcn/team.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/libgomp/config/gcn/bar.h b/libgomp/config/gcn/bar.h index bbd3141837f..63e803bd72b 100644 --- a/libgomp/config/gcn/bar.h +++ b/libgomp/config/gcn/bar.h @@ -55,6 +55,9 @@ typedef unsigned int gomp_barrier_state_t; static inline void gomp_barrier_init (gomp_barrier_t *bar, unsigned count) { + unsigned actual_thread_count = __builtin_gcn_dim_size (1); + if (count > actual_thread_count) + count = actual_thread_count; bar->total = count; bar->awaited = count; bar->awaited_final = count; diff --git a/libgomp/config/gcn/team.c b/libgomp/config/gcn/team.c index 627210ea407..6aa74744315 100644 --- a/libgomp/config/gcn/team.c +++ b/libgomp/config/gcn/team.c @@ -187,6 +187,10 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, if (nthreads == 1) return; + unsigned actual_thread_count = __builtin_gcn_dim_size (1); + if (nthreads > actual_thread_count) + nthreads = actual_thread_count; + /* Release existing idle threads. */ for (unsigned i = 1; i < nthreads; ++i) {