]> 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)
committerAndrew Stubbs <ams@codesourcery.com>
Wed, 4 Aug 2021 14:26:52 +0000 (15:26 +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/config/gcn/bar.h
libgomp/config/gcn/team.c

index bbd3141837f75c70ad3f68cb98511c11a8346bf9..63e803bd72b02849b6d0c1a2d440be3f397ed33a 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 627210ea4071cf66bf75f9c3b47281831dd775bd..6aa74744315f01bdfffb66cb21a066f28c95b415 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)
     {