This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gomp4] remove goacc locking


I've committed this to remove the now no longer needed lock and unlock builtins and related infrastructure.

nathan
2015-09-28  Nathan Sidwell  <nathan@codesourcery.com>

	* target.def (GOACC_LOCK): Delete hook.
	* doc/tm.texi.in (TARGET_GOACC_LOCK): Delete.
	* doc/tm.texi: Rebuilt.
	* targhooks.h (default_goacc_lock): Delete.
	* internal-fn.def (GOACC_LOCK,  GOACC_UNLOCK, GOACC_LOCK_INIT): Delete.
	* internal-fn.c (expand_GOACC_LOCK, expand_GOACC_UNLOCK,
	expand_GOACC_LOCK_INIT): Delete.
	* omp-low.c (lower_oacc_reductions): Remove locking.
	(execute_oacc_transform): Remove lock transforming.
	(default_goacc_lock): Delete.
	
	* config/nvptx/nvptx-protos.h (nvptx_expand_oacc_lock): Delete.
	* config/nvptx/nvptx.md (oacc_lock, oacc_unlock, oacc_lock_init):
	Delete.
	(nvptx_spin_lock, nvptx_spin_reset): Delete.
	* config/nvptx/nvptx.c (LOCK_GLOBAL, LOCK_SHARED, LOCK_MAX): Delete.
	(lock_names, lock_space, lock_level, lock_used): Delete.
	(force_global_locks): Delete.
	(nvptx_option_override): Do not initialize lock syms.
	(nvptx_expand_oacc_lock): Delete.
	(nvptx_file_end): Do not finalize locks.
	(TARGET_GOACC_LOCK): Delete.

Index: internal-fn.def
===================================================================
--- internal-fn.def	(revision 228200)
+++ internal-fn.def	(working copy)
@@ -81,13 +81,6 @@ DEF_INTERNAL_FN (UNIQUE, ECF_NOTHROW | E
 DEF_INTERNAL_FN (GOACC_DIM_SIZE, ECF_CONST | ECF_NOTHROW | ECF_LEAF, ".")
 DEF_INTERNAL_FN (GOACC_DIM_POS, ECF_PURE | ECF_NOTHROW | ECF_LEAF, ".")
 
-/* LOCK, UNLOCK & LOCK_INIT operate a mutex used for reductions.  The first
-   argument is the compute dimension of the reduction and the second
-   argument is a loop identifer.  */
-DEF_INTERNAL_FN (GOACC_LOCK, ECF_NOTHROW | ECF_LEAF, "..")
-DEF_INTERNAL_FN (GOACC_UNLOCK, ECF_NOTHROW | ECF_LEAF, "..")
-DEF_INTERNAL_FN (GOACC_LOCK_INIT, ECF_NOTHROW | ECF_LEAF, "..")
-
 /* REDUCTION_SETUP, REDUCTION_INIT, REDUCTION_FINI and REDUCTION_TEARDOWN
    together define a generic interface to support gang, worker and vector
    reductions. All of the functions take the following form
Index: config/nvptx/nvptx-protos.h
===================================================================
--- config/nvptx/nvptx-protos.h	(revision 228200)
+++ config/nvptx/nvptx-protos.h	(working copy)
@@ -34,7 +34,6 @@ extern const char *nvptx_section_for_dec
 #ifdef RTX_CODE
 extern void nvptx_expand_oacc_fork (unsigned);
 extern void nvptx_expand_oacc_join (unsigned);
-extern void nvptx_expand_oacc_lock (rtx, int);
 extern void nvptx_expand_call (rtx, rtx);
 extern rtx nvptx_expand_compare (rtx);
 extern const char *nvptx_ptx_type_from_mode (machine_mode, bool);
Index: config/nvptx/nvptx.md
===================================================================
--- config/nvptx/nvptx.md	(revision 228200)
+++ config/nvptx/nvptx.md	(working copy)
@@ -1371,36 +1371,6 @@
   return asms[INTVAL (operands[1])];
 })
 
-(define_expand "oacc_lock"
-  [(unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "")
-		        (match_operand:SI 1 "const_int_operand" "")]
-		       UNSPECV_LOCK)]
-  ""
-{
-  nvptx_expand_oacc_lock (operands[0], 0);
-  DONE;
-})
-
-(define_expand "oacc_unlock"
-  [(unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "")
-		        (match_operand:SI 1 "const_int_operand" "")]
-		       UNSPECV_LOCK)]
-  ""
-{
-  nvptx_expand_oacc_lock (operands[0], +1);
-  DONE;
-})
-
-(define_expand "oacc_lock_init"
-  [(unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "")
-		        (match_operand:SI 1 "const_int_operand" "")]
-		       UNSPECV_LOCK)]
-  ""
-{
-  nvptx_expand_oacc_lock (operands[0], -1);
-  DONE;
-})
-
 (define_insn "nvptx_fork"
   [(unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "")]
 		       UNSPECV_FORK)]
@@ -1588,23 +1558,3 @@
 		    UNSPECV_MEMBAR)]
   ""
   "%.\\tmembar%B0;")
-
-;; spin lock and reset
-(define_insn "nvptx_spin_lock"
-   [(parallel
-     [(set (match_operand:SI 2 "register_operand" "=R")
-	   (unspec_volatile:SI [(match_operand:SI 0 "memory_operand" "m")
-			        (match_operand:SI 1 "const_int_operand" "i")]
-			       UNSPECV_LOCK))
-      (set (match_operand:BI 3 "register_operand" "=R") (const_int 0))
-      (label_ref (match_operand 4 "" ""))])]
-   ""
-   "%4:\\tatom%R1.cas.b32\\t%2, %0, 0, 1;\\n\\t\\tsetp.ne.u32\\t%3, %2, 0;\\n\\t@%3\\tbra.uni\\t%4;")
-
-(define_insn "nvptx_spin_reset"
-   [(set (match_operand:SI 2 "register_operand" "=R")
-	    (unspec_volatile:SI [(match_operand:SI 0 "memory_operand" "m")
-				 (match_operand:SI 1 "const_int_operand" "i")]
-				UNSPECV_LOCK))]
-   ""
-   "%.\\tatom%R1.exch.b32\\t%2, %0, 0;")
Index: config/nvptx/nvptx.c
===================================================================
--- config/nvptx/nvptx.c	(revision 228200)
+++ config/nvptx/nvptx.c	(working copy)
@@ -122,21 +122,6 @@ static unsigned worker_bcast_align;
 #define worker_bcast_name "__worker_bcast"
 static GTY(()) rtx worker_bcast_sym;
 
-/* Global and shared lock variables.  Allocated at end of compilation,
-   if used.  Again, PTX lacks common blocks, so we can't share across
-   compilations.  */
-#define LOCK_GLOBAL 0
-#define LOCK_SHARED 1
-#define LOCK_MAX    2
-static const char *const lock_names[] = {"__global_lock", "__shared_lock"};
-static const unsigned lock_space[] = {ADDR_SPACE_GLOBAL, ADDR_SPACE_SHARED};
-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.  */
@@ -208,9 +193,6 @@ nvptx_option_override (void)
 
   worker_red_sym = gen_rtx_SYMBOL_REF (Pmode, worker_red_name);
   worker_red_align = GET_MODE_ALIGNMENT (SImode) / BITS_PER_UNIT;
-
-  for (unsigned ix = LOCK_MAX; ix--;)
-    lock_syms[ix] = gen_rtx_SYMBOL_REF (Pmode, lock_names[ix]);
 }
 
 /* Return the mode to be used when declaring a ptx object for OBJ.
@@ -1271,44 +1253,6 @@ nvptx_expand_oacc_join (unsigned mode)
   nvptx_emit_joining (GOMP_DIM_MASK (mode), false);
 }
 
-/* Expander for reduction locking and unlocking.  We expect SRC to be
-   gang or worker level.  */
-
-void
-nvptx_expand_oacc_lock (rtx src, int direction)
-{
-  unsigned HOST_WIDE_INT kind;
-  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]);
-  rtx space = GEN_INT (lock_space[kind]);
-  rtx barrier = NULL_RTX;
-  rtx tmp = gen_reg_rtx (SImode);
-
-  if (direction >= 0)
-    barrier = gen_nvptx_membar (GEN_INT (lock_level[kind]));
-
-  if (direction > 0)
-    emit_insn (barrier);
-  if (!direction)
-    {
-      rtx_code_label *label = gen_label_rtx ();
-
-      LABEL_NUSES (label)++;
-      pat = gen_nvptx_spin_lock (mem, space, tmp, gen_reg_rtx (BImode), label);
-    }
-  else
-    /* We can use reset for both unlock and initialization.  */
-    pat = gen_nvptx_spin_reset (mem, space, tmp);
-  emit_insn (pat);
-  if (!direction)
-    emit_insn (barrier);
-}
-
 /* Generate instruction(s) to unpack a 64 bit object into 2 32 bit
    objects.  */
 
@@ -4103,16 +4047,6 @@ nvptx_file_end (void)
 	       worker_red_align,
 	       worker_red_name, worker_red_hwm);
     }
-
-  /* Emit lock variables.  */
-  for (unsigned ix = LOCK_MAX; ix--;)
-    if (lock_used[ix])
-      {
-	fprintf (asm_out_file, "// BEGIN VAR DEF: %s\n", lock_names[ix]);
-	fprintf (asm_out_file, "%s .u32 %s;\n",
-		 nvptx_section_from_addr_space (lock_space[ix]),
-		 lock_names[ix]);
-      }
 }
 
 /* Expander for the shuffle builtins.  */
@@ -4930,9 +4864,6 @@ nvptx_use_anchors_for_symbol (const_rtx
 #undef TARGET_GOACC_FORK_JOIN
 #define TARGET_GOACC_FORK_JOIN nvptx_xform_fork_join
 
-#undef TARGET_GOACC_LOCK
-#define TARGET_GOACC_LOCK nvptx_xform_lock
-
 #undef TARGET_GOACC_REDUCTION
 #define TARGET_GOACC_REDUCTION nvptx_goacc_reduction
 
Index: internal-fn.c
===================================================================
--- internal-fn.c	(revision 228200)
+++ internal-fn.c	(working copy)
@@ -2026,45 +2026,6 @@ expand_GOACC_DIM_POS (gcall *ARG_UNUSED
 #endif
 }
 
-static void
-expand_GOACC_LOCK (gcall *ARG_UNUSED (stmt))
-{
-#ifdef HAVE_oacc_lock
-  rtx dim = expand_normal (gimple_call_arg (stmt, 0));
-  rtx id = expand_normal (gimple_call_arg (stmt, 1));
-  
-  emit_insn (gen_oacc_lock (dim, id));
-#else
-  gcc_unreachable ();
-#endif
-}
-
-static void
-expand_GOACC_UNLOCK (gcall *ARG_UNUSED (stmt))
-{
-#ifdef HAVE_oacc_unlock
-  rtx dim = expand_normal (gimple_call_arg (stmt, 0));
-  rtx id = expand_normal (gimple_call_arg (stmt, 1));
-  
-  emit_insn (gen_oacc_unlock (dim, id));
-#else
-  gcc_unreachable ();
-#endif
-}
-
-static void
-expand_GOACC_LOCK_INIT (gcall *ARG_UNUSED (stmt))
-{
-#ifdef HAVE_oacc_lock_init
-  rtx dim = expand_normal (gimple_call_arg (stmt, 0));
-  rtx id = expand_normal (gimple_call_arg (stmt, 1));
-  
-  emit_insn (gen_oacc_lock_init (dim, id));
-#else
-  gcc_unreachable ();
-#endif
-}
-
 /* This should get expanded in oacc_transform.  */
 
 static void
Index: omp-low.c
===================================================================
--- omp-low.c	(revision 228200)
+++ omp-low.c	(working copy)
@@ -4718,14 +4718,11 @@ expand_oacc_get_thread_num (gimple_seq *
    before-loop forking sequence in FORK_SEQ and the after-loop joining
    sequence to JOIN_SEQ.  The general form of these sequences is
 
-     GOACC_LOCK_INIT
      GOACC_REDUCTION_SETUP
      GOACC_FORK
      GOACC_REDUCTION_INIT
      ...
-     GOACC_LOCK
      GOACC_REDUCTION_FINI
-     GOACC_UNLOCK
      GOACC_JOIN
      GOACC_REDUCTION_TEARDOWN.  */
 
@@ -4833,30 +4830,12 @@ lower_oacc_reductions (location_t loc, t
       }
 
   /* Now stitch things together.  */
-  if (count)
-    {
-      gcall *init = gimple_build_call_internal
-	(IFN_GOACC_LOCK_INIT, 2, level, lid);
-      gimple_seq_add_stmt (fork_seq, init);
-    }
   gimple_seq_add_seq (fork_seq, before_fork);
   if (fork)
     gimple_seq_add_stmt (fork_seq, fork);
   gimple_seq_add_seq (fork_seq, after_fork);
 
-  if (count)
-    {
-      gcall *init = gimple_build_call_internal
-	(IFN_GOACC_LOCK, 2, level, lid);
-      gimple_seq_add_stmt (join_seq, init);
-    }
   gimple_seq_add_seq (join_seq, before_join);
-  if (count)
-    {
-      gcall *init = gimple_build_call_internal
-	(IFN_GOACC_UNLOCK, 2, level, lid);
-      gimple_seq_add_stmt (join_seq, init);
-    }
   if (join)
     gimple_seq_add_stmt (join_seq, join);
   gimple_seq_add_seq (join_seq, after_join);
@@ -14914,13 +14893,6 @@ execute_oacc_transform ()
 		rescan = 0;
 		break;
 
-	      case IFN_GOACC_LOCK:
-	      case IFN_GOACC_UNLOCK:
-	      case IFN_GOACC_LOCK_INIT:
-		if (targetm.goacc.lock (call, dims, ifn_code))
-		  rescan = -1;
-		break;
-
 	      case IFN_GOACC_REDUCTION_SETUP:
 	      case IFN_GOACC_REDUCTION_INIT:
 	      case IFN_GOACC_REDUCTION_FINI:
@@ -15026,37 +14998,6 @@ default_goacc_fork_join (gcall *ARG_UNUS
     }
 
   return false;
-}
-
-/* Default lock/unlock early expander.  Delete the function calls if
-   there is no RTL expander.  */
-
-bool
-default_goacc_lock (gcall *ARG_UNUSED (call), const int*ARG_UNUSED (dims),
-		    unsigned ifn_code)
-{
-  switch (ifn_code)
-    {
-    case IFN_GOACC_LOCK:
-#ifndef HAVE_oacc_lock
-      return true;
-#endif
-      break;
-    case IFN_GOACC_UNLOCK:
-#ifndef HAVE_oacc_unlock
-      return true;
-#endif
-      break;
-    case IFN_GOACC_LOCK_INIT:
-#ifndef HAVE_oacc_lock_init
-      return true;
-#endif
-      break;
-    default:
-      gcc_unreachable ();
-    }
-
-  return false;
 }
 
 /* Default goacc.reduction early expander.
Index: target.def
===================================================================
--- target.def	(revision 228200)
+++ target.def	(working copy)
@@ -1671,16 +1671,6 @@ bool, (gcall *call, const int dims[], bo
 default_goacc_fork_join)
 
 DEFHOOK
-(lock,
-"This hook should convert IFN_GOACC_LOCK, IFN_GOACC_UNLOCK,\n\
-IFN_GOACC_LOCK_INIT function calls to target-specific gimple.  It is\n\
-executed during the oacc_xform pass.  It should return true, if the\n\
-functions should be deleted.  The default hook returns true, if there\n\
-are no RTL expanders for them.",
-bool, (gcall *call, const int dims[], unsigned ifn_code),
-default_goacc_lock)
-
-DEFHOOK
 (reduction,
 "This hook is used by the oacc_transform pass to expand calls to the\n\
 internal functions @var{GOACC_REDUCTION_SETUP},\n\
Index: doc/tm.texi
===================================================================
--- doc/tm.texi	(revision 228200)
+++ doc/tm.texi	(working copy)
@@ -5768,14 +5768,6 @@ pass.  It should return true, if the fun
 default hook returns true, if there are no RTL expanders for them.
 @end deftypefn
 
-@deftypefn {Target Hook} bool TARGET_GOACC_LOCK (gcall *@var{call}, const int @var{dims[]}, unsigned @var{ifn_code})
-This hook should convert IFN_GOACC_LOCK, IFN_GOACC_UNLOCK,
-IFN_GOACC_LOCK_INIT function calls to target-specific gimple.  It is
-executed during the oacc_xform pass.  It should return true, if the
-functions should be deleted.  The default hook returns true, if there
-are no RTL expanders for them.
-@end deftypefn
-
 @deftypefn {Target Hook} bool TARGET_GOACC_REDUCTION (gcall *@var{call})
 This hook is used by the oacc_transform pass to expand calls to the
 internal functions @var{GOACC_REDUCTION_SETUP},
Index: doc/tm.texi.in
===================================================================
--- doc/tm.texi.in	(revision 228200)
+++ doc/tm.texi.in	(working copy)
@@ -4253,8 +4253,6 @@ address;  but often a machine-dependent
 
 @hook TARGET_GOACC_FORK_JOIN
 
-@hook TARGET_GOACC_LOCK
-
 @hook TARGET_GOACC_REDUCTION
 
 @node Anchored Addresses
Index: targhooks.h
===================================================================
--- targhooks.h	(revision 228200)
+++ targhooks.h	(working copy)
@@ -111,7 +111,6 @@ extern bool default_goacc_reduction (gca
 extern bool default_goacc_validate_dims (tree, int [], int);
 extern unsigned default_goacc_dim_limit (unsigned);
 extern bool default_goacc_fork_join (gcall *, const int [], bool);
-extern bool default_goacc_lock (gcall *, const int [], unsigned);
 
 /* These are here, and not in hooks.[ch], because not all users of
    hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]