]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgomp amdgcn: Fix issues with dynamic OpenMP thread scaling
authorAndrew Stubbs <ams@codesourcery.com>
Tue, 3 Aug 2021 12:45:35 +0000 (13:45 +0100)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 21 Jun 2022 13:11:40 +0000 (14:11 +0100)
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.

libgomp/ChangeLog.omp
libgomp/config/gcn/bar.h
libgomp/config/gcn/team.c

index aed8dc03211f9f87cdc81bb97eb810f74cb4ff92..5a8a4687ade5a77f03aa7173f2bfc86765afefcc 100644 (file)
@@ -1,3 +1,10 @@
+2021-08-03  Andrew Stubbs  <ams@codesourcery.com>
+
+       * 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.
+
 2021-06-02  Julian Brown  <julian@codesourcery.com>
 
        * testsuite/libgomp.oacc-c-c++-common/deep-copy-15.c: New test.
index 19d3a6204bc133e3a08e52d631a1045ebcf71edf..b4b2286af412647752a4703178efec722eea8fda 100644 (file)
@@ -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;
index 254dd4da23498fc54f196dbe9cbb70236f1d63a2..70fbf6f482278c9c956e193ceb3b99e7696454c3 100644 (file)
@@ -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)
     {