]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[og9] Wait on queue-full condition in AMD GCN libgomp offloading plugin
authorJulian Brown <julian@codesourcery.com>
Tue, 13 Aug 2019 20:13:30 +0000 (13:13 -0700)
committerThomas Schwinge <thomas@codesourcery.com>
Tue, 3 Mar 2020 11:50:41 +0000 (12:50 +0100)
libgomp/
* plugin/plugin-gcn.c (queue_push_callback): Wait on queue-full
condition.

(cherry picked from openacc-gcc-9-branch commit
b4bc0ff301aae3b6a6359f007b3c773419c3163b)

libgomp/ChangeLog.omp
libgomp/plugin/plugin-gcn.c

index 2a9a7f18ca2e2127acd1735ec983b0a4ce272f0f..f9d8e6ecd39740eac2550f65b74986a843889c40 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-13  Julian Brown  <julian@codesourcery.com>
+
+       * plugin/plugin-gcn.c (queue_push_callback): Wait on queue-full
+       condition.
+
 2019-08-13  Julian Brown  <julian@codesourcery.com>
 
        * plugin/plugin-gcn.c (struct copy_data): Add using_src_copy field.
index 65690e643ede9d5dfd27d267bb9eeabde1667bbc..099f70b647cf23e4c829d3d6749a198d9a2140b8 100644 (file)
@@ -1416,8 +1416,15 @@ queue_push_callback (struct goacc_asyncqueue *aq, void (*fn)(void *),
                     void *data)
 {
   if (aq->queue_n == ASYNC_QUEUE_SIZE)
-    GOMP_PLUGIN_fatal ("Async thread %d:%d: error: queue overflowed",
-                      aq->agent->device_id, aq->id);
+    {
+      pthread_mutex_lock (&aq->mutex);
+
+      /* Queue is full.  Wait for it to not be full.  */
+      while (aq->queue_n == ASYNC_QUEUE_SIZE)
+       pthread_cond_wait (&aq->queue_cond_out, &aq->mutex);
+
+      pthread_mutex_unlock (&aq->mutex);
+    }
 
   pthread_mutex_lock (&aq->mutex);