https://gcc.gnu.org/g:614471826dbfcd64a04cce4c14cde61a6dcc4f86

commit 614471826dbfcd64a04cce4c14cde61a6dcc4f86
Author: Tobias Burnus <tbur...@baylibre.com>
Date:   Tue Dec 10 16:16:04 2024 +0100

    plugin/plugin-gcn.c: Fix error handling of 
GOMP_OFFLOAD_openacc_async_construct
    
    Follow up to r15-5392-g884637b6362391. As the name implies,
    GOMP_OFFLOAD_openacc_async_construct is also externally called.
    Hence, partially revert previous commit to permit unlocking handling
    in oacc-async.c's lookup_goacc_asyncqueue by not failing fatally.
    
    Hence, also the other (indirect) callers had to be updated:
    GOMP_OFFLOAD_dev2dev fails now with 'false' and
    GOMP_OFFLOAD_async_run fatally.
    
    libgomp/ChangeLog:
    
            * plugin/plugin-gcn.c (GOMP_OFFLOAD_dev2dev, 
GOMP_OFFLOAD_async_run):
            Handle omp_async_queue == NULL after call to maybe_init_omp_async.
            (GOMP_OFFLOAD_openacc_async_construct): Use error not fatal error,
            partially reverting r15-5392.
    
    (cherry picked from commit 7a12dc695b1ae70f9fc99baf95b7188af6515ed3)

Diff:
---
 libgomp/ChangeLog.omp       |  8 ++++++++
 libgomp/plugin/plugin-gcn.c | 14 ++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 21c83c403264..b3db799956fe 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,5 +1,13 @@
 2024-12-18  Thomas Schwinge  <tschwi...@baylibre.com>
 
+       Backported from trunk:
+       2024-12-10  Tobias Burnus  <tbur...@baylibre.com>
+
+       * plugin/plugin-gcn.c (GOMP_OFFLOAD_dev2dev, GOMP_OFFLOAD_async_run):
+       Handle omp_async_queue == NULL after call to maybe_init_omp_async.
+       (GOMP_OFFLOAD_openacc_async_construct): Use error not fatal error,
+       partially reverting r15-5392.
+
        Backported from trunk:
        2024-11-18  Tobias Burnus  <tbur...@baylibre.com>
 
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index 271a7fc05bda..37b047a66ce2 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -3981,6 +3981,8 @@ GOMP_OFFLOAD_dev2dev (int device, void *dst, const void 
*src, size_t n)
     {
       struct agent_info *agent = get_agent_info (device);
       maybe_init_omp_async (agent);
+      if (!agent->omp_async_queue)
+       return false;
       queue_push_copy (agent->omp_async_queue, dst, src, n);
       return true;
     }
@@ -4392,6 +4394,8 @@ GOMP_OFFLOAD_async_run (int device, void *tgt_fn, void 
*tgt_vars,
     }
 
   maybe_init_omp_async (agent);
+  if (!agent->omp_async_queue)
+    GOMP_PLUGIN_fatal ("Asynchronous queue initialization failed");
   queue_push_launch (agent->omp_async_queue, kernel, tgt_vars, kla);
   queue_push_callback (agent->omp_async_queue,
                       GOMP_PLUGIN_target_task_completion, async_data);
@@ -4490,9 +4494,7 @@ GOMP_OFFLOAD_openacc_async_exec (void (*fn_ptr) (void *),
   gcn_exec (kernel, devaddrs, dims, targ_mem_desc, true, aq);
 }
 
-/* Create a new asynchronous thread and queue for running future kernels;
-   issues a fatal error if the queue cannot be created as all callers expect
-   that the queue exists.  */
+/* Create a new asynchronous thread and queue for running future kernels.  */
 
 void
 GOMP_OFFLOAD_openacc_async_exec_params (void (*fn) (void *), size_t mapnum,
@@ -4529,17 +4531,17 @@ GOMP_OFFLOAD_openacc_async_construct (int device)
 
   if (pthread_mutex_init (&aq->mutex, NULL))
     {
-      GOMP_PLUGIN_fatal ("Failed to initialize a GCN agent queue mutex");
+      GOMP_PLUGIN_error ("Failed to initialize a GCN agent queue mutex");
       return NULL;
     }
   if (pthread_cond_init (&aq->queue_cond_in, NULL))
     {
-      GOMP_PLUGIN_fatal ("Failed to initialize a GCN agent queue cond");
+      GOMP_PLUGIN_error ("Failed to initialize a GCN agent queue cond");
       return NULL;
     }
   if (pthread_cond_init (&aq->queue_cond_out, NULL))
     {
-      GOMP_PLUGIN_fatal ("Failed to initialize a GCN agent queue cond");
+      GOMP_PLUGIN_error ("Failed to initialize a GCN agent queue cond");
       return NULL;
     }

Reply via email to