This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 3/3] [og9] Wait on queue-full condition in AMD GCN libgomp offloading plugin
- From: Julian Brown <julian at codesourcery dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Cc: Andrew Stubbs <andrew_stubbs at mentor dot com>, Jakub Jelinek <jakub at redhat dot com>
- Date: Tue, 13 Aug 2019 14:37:15 -0700
- Subject: [PATCH 3/3] [og9] Wait on queue-full condition in AMD GCN libgomp offloading plugin
- Ironport-sdr: XTdBh4U6MiPFJ/PrQq5WGgWbE5KRy53KKi08/7n2V2xehYkSyr3Uqb/DQ0Ipmqvo9VWPUgD7OO x+jdPXHYGFE/87kOIyAPz58ovnAb2DHrTLxIOGJT7YaZOQy/W30RCY2K4WWettadtOzCzFTjNt Zszj19hHvz6sZTLsPFKDgc/ZDBs6PhtPzRqqG2k78UkBQNbQavwNVDURFELmDzabLk0AZ87iVt zQawCFEKjcWR4o27XW3e6PLolLGDcq0RlTl4RB7qkRLxTbC5slnniRNe27ZLar1RjvaKF5lLcH UYY=
- Ironport-sdr: Cz8zCuNokM1TIjYY33YiNWeA/Tmr1nJLuU3Q9OcwXkojc6nKXpP7j3Qc5wOQw9k/k2aC83AHA5 QH4eBJW0ul0FeeYTd267JkstRISi7U10R31GltiOE2EvJrFL3aetSMAeIa89OtByfjq1PDFFiA klDcIvG69Jo2fKbyst5omicJdiZolmGy2JztUK+NVU3Outl0ez+gL2E6zcVyHOnMuF+/vP2aMn 75QNpFbj1OfmJb4vqTdw2lbmnu0WHf554aJW/TvJvScMqJzuAoni5Trfw9bZ1yc7Xsqd51aKXS M90=
- References: <cover.1565729221.git.julian@codesourcery.com>
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