This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/3] [og9] Wait on queue-full condition in AMD GCN libgomp offloading plugin


This patch lets the AMD GCN libgomp plugin wait for asynchronous queues
to have some space to push new operations when they are full, rather
than just erroring out immediately on that condition. This fixes the
libgomp.oacc-c-c++-common/da-4.c test.

Julian

ChangeLog

	libgomp/
	* plugin/plugin-gcn.c (queue_push_callback): Wait on queue-full
	condition.
---
 libgomp/ChangeLog.openacc   |  5 +++++
 libgomp/plugin/plugin-gcn.c | 11 +++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/libgomp/ChangeLog.openacc b/libgomp/ChangeLog.openacc
index 2a9a7f18ca2..f9d8e6ecd39 100644
--- a/libgomp/ChangeLog.openacc
+++ b/libgomp/ChangeLog.openacc
@@ -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.
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index 65690e643ed..099f70b647c 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -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);
 
-- 
2.22.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]