public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, libgomp] PR 67141, uninitialized acc_device_lock mutex
@ 2015-09-18  7:52 Chung-Lin Tang
  2015-09-18  8:05 ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Chung-Lin Tang @ 2015-09-18  7:52 UTC (permalink / raw)
  To: gcc-patches
  Cc: Nathan Sidwell, Thomas Schwinge, Richard Henderson, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

Hi,
this patch fixes the uninitialized acc_device_lock mutex situation
reported in PR 67141. The patch attached on the bugzilla page
tries to solve it by constructor priorities, which we think will
probably be less manageable in general.

This patch changes goacc_host_init() to be called from
goacc_runtime_initialize() instead, thereby ensuring the init order.
libgomp testsuite was re-run without regressions, okay for trunk?

Thanks,
Chung-Lin

2015-09-18  Chung-Lin Tang  <cltang@codesourcery.com>

	PR libgomp/67141

	* oacc-int.h (goacc_host_init): Add declaration.
	* oacc-host.c (goacc_host_init): Remove static and
	constructor attribute
	* oacc-init.c (goacc_runtime_initialize): Call goacc_host_init()
	at end.

[-- Attachment #2: libgomp-acc-mutex.patch --]
[-- Type: text/x-patch, Size: 1204 bytes --]

Index: oacc-host.c
===================================================================
--- oacc-host.c	(revision 227895)
+++ oacc-host.c	(working copy)
@@ -256,7 +256,7 @@ static struct gomp_device_descr host_dispatch =
   };
 
 /* Initialize and register this device type.  */
-static __attribute__ ((constructor)) void
+void
 goacc_host_init (void)
 {
   gomp_mutex_init (&host_dispatch.lock);
Index: oacc-int.h
===================================================================
--- oacc-int.h	(revision 227895)
+++ oacc-int.h	(working copy)
@@ -97,6 +97,7 @@ void goacc_runtime_initialize (void);
 void goacc_save_and_set_bind (acc_device_t);
 void goacc_restore_bind (void);
 void goacc_lazy_initialize (void);
+void goacc_host_init (void);
 
 #ifdef HAVE_ATTRIBUTE_VISIBILITY
 # pragma GCC visibility pop
Index: oacc-init.c
===================================================================
--- oacc-init.c	(revision 227895)
+++ oacc-init.c	(working copy)
@@ -644,6 +644,9 @@ goacc_runtime_initialize (void)
 
   goacc_threads = NULL;
   gomp_mutex_init (&goacc_thread_lock);
+
+  /* Initialize and register the 'host' device type.  */
+  goacc_host_init ();
 }
 
 /* Compiler helper functions */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, libgomp] PR 67141, uninitialized acc_device_lock mutex
  2015-09-18  7:52 [PATCH, libgomp] PR 67141, uninitialized acc_device_lock mutex Chung-Lin Tang
@ 2015-09-18  8:05 ` Jakub Jelinek
  2015-09-22  6:58   ` Chung-Lin Tang
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2015-09-18  8:05 UTC (permalink / raw)
  To: Chung-Lin Tang
  Cc: gcc-patches, Nathan Sidwell, Thomas Schwinge, Richard Henderson

On Fri, Sep 18, 2015 at 03:41:30PM +0800, Chung-Lin Tang wrote:
> this patch fixes the uninitialized acc_device_lock mutex situation
> reported in PR 67141. The patch attached on the bugzilla page
> tries to solve it by constructor priorities, which we think will
> probably be less manageable in general.
> 
> This patch changes goacc_host_init() to be called from
> goacc_runtime_initialize() instead, thereby ensuring the init order.
> libgomp testsuite was re-run without regressions, okay for trunk?
> 
> Thanks,
> Chung-Lin
> 
> 2015-09-18  Chung-Lin Tang  <cltang@codesourcery.com>
> 
> 	PR libgomp/67141
> 

No vertical space in between PR line and subsequent entries.

> 	* oacc-int.h (goacc_host_init): Add declaration.
> 	* oacc-host.c (goacc_host_init): Remove static and
> 	constructor attribute

Full stop at the end of entry.

> 	* oacc-init.c (goacc_runtime_initialize): Call goacc_host_init()
> 	at end.

The patch is ok.  Though, perhaps as a follow-up, I think I'd prefer getting
rid of pthread_key_create (&goacc_cleanup_key, goacc_destroy_thread);,
it is wasteful if we do the same thing in initialize_team.  As the
goacc_tls_data pointer is __thread anyway, I think just putting it into
struct gomp_thread, arranging for init_team to be called from the env.c
ctor and from the team TLS destructor call also some oacc freeing if
the goacc_tls_data pointer is non-NULL (perhaps with __builtin_expect
unlikely).

	Jakub

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, libgomp] PR 67141, uninitialized acc_device_lock mutex
  2015-09-18  8:05 ` Jakub Jelinek
@ 2015-09-22  6:58   ` Chung-Lin Tang
  2015-09-22  7:19     ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Chung-Lin Tang @ 2015-09-22  6:58 UTC (permalink / raw)
  To: Jakub Jelinek, Chung-Lin Tang
  Cc: gcc-patches, Nathan Sidwell, Thomas Schwinge, Richard Henderson

On 2015/9/18 04:02 PM, Jakub Jelinek wrote:
> On Fri, Sep 18, 2015 at 03:41:30PM +0800, Chung-Lin Tang wrote:
>> this patch fixes the uninitialized acc_device_lock mutex situation
>> reported in PR 67141. The patch attached on the bugzilla page
>> tries to solve it by constructor priorities, which we think will
>> probably be less manageable in general.
>>
>> This patch changes goacc_host_init() to be called from
>> goacc_runtime_initialize() instead, thereby ensuring the init order.
>> libgomp testsuite was re-run without regressions, okay for trunk?
>>
>> Thanks,
>> Chung-Lin
>>
>> 2015-09-18  Chung-Lin Tang  <cltang@codesourcery.com>
>>
>> 	PR libgomp/67141
>>
> 
> No vertical space in between PR line and subsequent entries.
> 
>> 	* oacc-int.h (goacc_host_init): Add declaration.
>> 	* oacc-host.c (goacc_host_init): Remove static and
>> 	constructor attribute
> 
> Full stop at the end of entry.
> 
>> 	* oacc-init.c (goacc_runtime_initialize): Call goacc_host_init()
>> 	at end.
> 
> The patch is ok.  Though, perhaps as a follow-up, I think I'd prefer getting
> rid of pthread_key_create (&goacc_cleanup_key, goacc_destroy_thread);,
> it is wasteful if we do the same thing in initialize_team.  As the
> goacc_tls_data pointer is __thread anyway, I think just putting it into
> struct gomp_thread, arranging for init_team to be called from the env.c
> ctor and from the team TLS destructor call also some oacc freeing if
> the goacc_tls_data pointer is non-NULL (perhaps with __builtin_expect
> unlikely).
> 
> 	Jakub

Committed, thanks for the review.
I believe this patch is also needed for 5.x, okay for that branch as well?

Thanks,
Chung-Lin


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, libgomp] PR 67141, uninitialized acc_device_lock mutex
  2015-09-22  6:58   ` Chung-Lin Tang
@ 2015-09-22  7:19     ` Jakub Jelinek
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2015-09-22  7:19 UTC (permalink / raw)
  To: Chung-Lin Tang
  Cc: Chung-Lin Tang, gcc-patches, Nathan Sidwell, Thomas Schwinge,
	Richard Henderson

On Tue, Sep 22, 2015 at 02:49:04PM +0800, Chung-Lin Tang wrote:
> Committed, thanks for the review.
> I believe this patch is also needed for 5.x, okay for that branch as well?

Ok.
	Jakub

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-22  6:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-18  7:52 [PATCH, libgomp] PR 67141, uninitialized acc_device_lock mutex Chung-Lin Tang
2015-09-18  8:05 ` Jakub Jelinek
2015-09-22  6:58   ` Chung-Lin Tang
2015-09-22  7:19     ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).