public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gomp4] force global locks for nvptx targets
@ 2015-09-08 20:09 Cesar Philippidis
  2015-09-09  8:08 ` Chung-Lin Tang
  0 siblings, 1 reply; 2+ messages in thread
From: Cesar Philippidis @ 2015-09-08 20:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: Nathan Sidwell

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

This patch forces GOACC_LOCK to use locks in global memory regardless if
the lock us for a worker or a gang. We were using a shared memory for
worker locks, but we ran into an issue with that would sporadically
involve deadlocks in worker reductions. We're still investigating that
issue, but for the time being, global locks appear to work albeit with a
lock contention penalty.

I've applied this patch to gomp-4_0-branch.

Cesar

[-- Attachment #2: global-locks.diff --]
[-- Type: text/x-patch, Size: 1415 bytes --]

2015-09-08  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/
	* config/nvptx/nvptx.c (force_global_lock): New global variable.
	(nvptx_expand_oacc_lock): Use it to workaround a shared memory lock
	problem.
	(nvptx_xform_lock): Likewise.

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 51f2893..c8f6f5c 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -134,6 +134,9 @@ static const unsigned lock_level[] = {BARRIER_GLOBAL, BARRIER_SHARED};
 static GTY(()) rtx lock_syms[LOCK_MAX];
 static bool lock_used[LOCK_MAX];
 
+/* FIXME: Temporary workaround for worker locks.  */
+static bool force_global_locks = true;
+
 /* Size of buffer needed for worker reductions.  This has to be
    disjoing from the worker broadcast array, as both may be live
    concurrently.  */
@@ -1245,6 +1248,7 @@ nvptx_expand_oacc_lock (rtx src, int direction)
   rtx pat;
   
   kind = INTVAL (src) == GOMP_DIM_GANG ? LOCK_GLOBAL : LOCK_SHARED;
+  kind = force_global_locks ? LOCK_GLOBAL : kind;
   lock_used[kind] = true;
 
   rtx mem = gen_rtx_MEM (SImode, lock_syms[kind]);
@@ -3740,7 +3744,7 @@ nvptx_xform_lock (gimple stmt, const int *ARG_UNUSED (dims), unsigned ifn_code)
       return mode > GOMP_DIM_WORKER;
 
     case IFN_GOACC_LOCK_INIT:
-      return mode != GOMP_DIM_WORKER;
+      return force_global_lock || mode != GOMP_DIM_WORKER;
 
     default: gcc_unreachable();
     }

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

* Re: [gomp4] force global locks for nvptx targets
  2015-09-08 20:09 [gomp4] force global locks for nvptx targets Cesar Philippidis
@ 2015-09-09  8:08 ` Chung-Lin Tang
  0 siblings, 0 replies; 2+ messages in thread
From: Chung-Lin Tang @ 2015-09-09  8:08 UTC (permalink / raw)
  To: Cesar Philippidis, gcc-patches; +Cc: Nathan Sidwell

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

On 2015/9/9 04:02 AM, Cesar Philippidis wrote:
> This patch forces GOACC_LOCK to use locks in global memory regardless if
> the lock us for a worker or a gang. We were using a shared memory for
> worker locks, but we ran into an issue with that would sporadically
> involve deadlocks in worker reductions. We're still investigating that
> issue, but for the time being, global locks appear to work albeit with a
> lock contention penalty.
> 
> I've applied this patch to gomp-4_0-branch.
> 
> Cesar
> 

Fixed typo, committed as obvious.

Chung-Lin

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

        * config/nvptx/nvptx.c (nvptx_xform_lock): Correct typo
        of variable 'force_global_locks'.


[-- Attachment #2: a.diff --]
[-- Type: text/plain, Size: 486 bytes --]

Index: config/nvptx/nvptx.c
===================================================================
--- config/nvptx/nvptx.c	(revision 227582)
+++ config/nvptx/nvptx.c	(working copy)
@@ -3744,7 +3744,7 @@ nvptx_xform_lock (gimple stmt, const int *ARG_UNUS
       return mode > GOMP_DIM_WORKER;
 
     case IFN_GOACC_LOCK_INIT:
-      return force_global_lock || mode != GOMP_DIM_WORKER;
+      return force_global_locks || mode != GOMP_DIM_WORKER;
 
     default: gcc_unreachable();
     }

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

end of thread, other threads:[~2015-09-09  8:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-08 20:09 [gomp4] force global locks for nvptx targets Cesar Philippidis
2015-09-09  8:08 ` Chung-Lin Tang

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).