]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Really fix og9 "Fix hang when running oacc exec with CUDA 9.0 nvprof" devel/omp/gcc-9
authorThomas Schwinge <thomas@codesourcery.com>
Thu, 26 Mar 2020 16:34:01 +0000 (17:34 +0100)
committerThomas Schwinge <thomas@codesourcery.com>
Thu, 26 Mar 2020 16:34:01 +0000 (17:34 +0100)
In my yesterday's commit 9ae129017c7fc1fa638d6beedd3802b515ca692b 'Fix og9 "Fix
hang when running oacc exec with CUDA 9.0 nvprof"', I wrongly blamed the og9
"Fix hang when running oacc exec with CUDA 9.0 nvprof" to be responsible for
the hang being back, when in fact it's only the later og9 "OpenACC Profiling
Interface (incomplete)" backport from trunk that introduced the problem.

The confusing thing was that the og9 "Fix hang when running oacc exec with CUDA
9.0 nvprof" commit appears *before* the og9 "OpenACC Profiling Interface
(incomplete)" backport that it relates to.

And, in addition to that, I pushed the wrong (incomplete) version of my fix.

libgomp/
* oacc-init.c (acc_init_1): Move other 'acc_init_state' logic to
where it belongs.

libgomp/ChangeLog.omp
libgomp/oacc-init.c

index 75c459179981502c4c346fa91aea153c5e54df4e..922e00fbff5b5e3fac28e7343b02fec4fb9a4cb0 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-26  Thomas Schwinge <thomas@codesourcery.com>
+
+       * oacc-init.c (acc_init_1): Move other 'acc_init_state' logic to
+       where it belongs.
+
 2020-03-25  Thomas Schwinge <thomas@codesourcery.com>
 
        * oacc-init.c (acc_init_1): Move 'acc_init_state' logic to where
index 765fa2f3b9521acbd602da9f00a82160ef320c41..40c14fa9bf2b3c54b3c47d50fe5c6892f5595a1f 100644 (file)
@@ -317,10 +317,6 @@ acc_init_1 (acc_device_t d, acc_construct_t parent_construct, int implicit)
   gomp_init_device (acc_dev);
   gomp_mutex_unlock (&acc_dev->lock);
 
-  gomp_mutex_lock (&acc_init_state_lock);
-  acc_init_state = initialized;
-  gomp_mutex_unlock (&acc_init_state_lock);
-
   if (profiling_p)
     {
       prof_info.event_type = acc_ev_device_init_end;
@@ -329,6 +325,14 @@ acc_init_1 (acc_device_t d, acc_construct_t parent_construct, int implicit)
                                &api_info);
     }
 
+  /* We're setting 'initialized' *after* 'goacc_profiling_dispatch', so that a
+     nested 'acc_get_device_type' called from a profiling callback still sees
+     'initializing', so that we don't deadlock when it then again tries to lock
+     'goacc_prof_lock'.  See also the discussion in 'acc_get_device_type'.  */
+  gomp_mutex_lock (&acc_init_state_lock);
+  acc_init_state = initialized;
+  gomp_mutex_unlock (&acc_init_state_lock);
+
   return base_dev;
 }