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] unify open acc level constants


I've committed this to the gomp4 branch. It cleans up the existing OACC_foo constants defined in omp-low.h, replacing them with the ones I just defined in gomp-constants.h

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

	* omp-low.h (enum oacc_loop_levels): Delete.
	(OACC_LOOP_MASK): Delete.
	* omp-low.c: Change all OACC_x to GOMP_DIM_x
	* config/nvptx/nvptx.c: Change all OACC_x to GOMP_DIM_x
	* builtins.c (expand_oacc_id): Change OACC_HWM to GOMP_DIM_MAX.

Index: gcc/config/nvptx/nvptx.c
===================================================================
--- gcc/config/nvptx/nvptx.c	(revision 226314)
+++ gcc/config/nvptx/nvptx.c	(working copy)
@@ -1075,7 +1075,7 @@ void
 nvptx_expand_oacc_fork (rtx mode)
 {
   /* Emit fork for worker level.  */
-  if (UINTVAL (mode) == OACC_worker)
+  if (UINTVAL (mode) == GOMP_DIM_WORKER)
     emit_insn (gen_nvptx_fork (mode));
 }
 
@@ -2169,8 +2169,6 @@ nvptx_reorg_subreg ()
    a NULL loop.  We should be able to extend this to represent
    superblocks.  */
 
-#define OACC_null OACC_HWM
-
 struct parallel
 {
   /* Parent parallel.  */
@@ -2369,7 +2367,7 @@ typedef auto_vec<bb_par_t> bb_par_vec_t;
 static parallel *
 nvptx_discover_pars (bb_insn_map_t *map)
 {
-  parallel *outer_par = new parallel (0, OACC_null);
+  parallel *outer_par = new parallel (0, GOMP_DIM_MAX);
   bb_par_vec_t worklist;
   basic_block block;
 
@@ -2413,7 +2411,7 @@ nvptx_discover_pars (bb_insn_map_t *map)
 		l = new parallel (l, mode);
 		l->forked_block = block;
 		l->forked_insn = end;
-		if (mode == OACC_worker)
+		if (mode == GOMP_DIM_WORKER)
 		  l->fork_insn
 		    = nvptx_discover_pre (block, CODE_FOR_nvptx_fork);
 	      }
@@ -2428,7 +2426,7 @@ nvptx_discover_pars (bb_insn_map_t *map)
 		gcc_assert (l->mode == mode);
 		l->join_block = block;
 		l->join_insn = end;
-		if (mode == OACC_worker)
+		if (mode == GOMP_DIM_WORKER)
 		  l->joining_insn
 		    = nvptx_discover_pre (block, CODE_FOR_nvptx_joining);
 		l = l->parent;
@@ -2706,7 +2704,7 @@ nvptx_single (unsigned mask, basic_block
 	{
 	  /* If we're only doing vector single, there's no need to
 	     emit skip code because we'll not insert anything.  */
-	  if (!(mask & OACC_LOOP_MASK (OACC_vector)))
+	  if (!(mask & GOMP_DIM_MASK (GOMP_DIM_VECTOR)))
 	    skip_mask = 0;
 	}
       else if (tail_branch)
@@ -2717,8 +2715,8 @@ nvptx_single (unsigned mask, basic_block
   /* Insert the vector test inside the worker test.  */
   unsigned mode;
   rtx_insn *before = tail;
-  for (mode = OACC_worker; mode <= OACC_vector; mode++)
-    if (OACC_LOOP_MASK (mode) & skip_mask)
+  for (mode = GOMP_DIM_WORKER; mode <= GOMP_DIM_VECTOR; mode++)
+    if (GOMP_DIM_MASK (mode) & skip_mask)
       {
 	rtx id = gen_reg_rtx (SImode);
 	rtx pred = gen_reg_rtx (BImode);
@@ -2728,7 +2726,7 @@ nvptx_single (unsigned mask, basic_block
 	rtx cond = gen_rtx_SET (pred, gen_rtx_NE (BImode, id, const0_rtx));
 	emit_insn_before (cond, head);
 	rtx br;
-	if (mode == OACC_vector)
+	if (mode == GOMP_DIM_VECTOR)
 	  br = gen_br_true (pred, label);
 	else
 	  br = gen_br_true_uni (pred, label);
@@ -2746,7 +2744,7 @@ nvptx_single (unsigned mask, basic_block
     {
       rtx pvar = XEXP (XEXP (cond_branch, 0), 0);
 
-      if (OACC_LOOP_MASK (OACC_vector) == mask)
+      if (GOMP_DIM_MASK (GOMP_DIM_VECTOR) == mask)
 	{
 	  /* Vector mode only, do a shuffle.  */
 	  emit_insn_before (nvptx_gen_vcast (pvar), tail);
@@ -2806,7 +2804,7 @@ nvptx_skip_par (unsigned mask, parallel
 static unsigned
 nvptx_process_pars (parallel *par)
 {
-  unsigned inner_mask = OACC_LOOP_MASK (par->mode);
+  unsigned inner_mask = GOMP_DIM_MASK (par->mode);
   
   /* Do the inner parallels first.  */
   if (par->inner)
@@ -2817,15 +2815,15 @@ nvptx_process_pars (parallel *par)
   
   switch (par->mode)
     {
-    case OACC_null:
+    case GOMP_DIM_MAX:
       /* Dummy parallel.  */
       break;
 
-    case OACC_vector:
+    case GOMP_DIM_VECTOR:
       nvptx_vpropagate (par->forked_block, par->forked_insn);
       break;
       
-    case OACC_worker:
+    case GOMP_DIM_WORKER:
       {
 	nvptx_wpropagate (false, par->forked_block,
 			  par->forked_insn);
@@ -2836,7 +2834,7 @@ nvptx_process_pars (parallel *par)
       }
       break;
 
-    case OACC_gang:
+    case GOMP_DIM_GANG:
       break;
 
     default:gcc_unreachable ();
@@ -2855,30 +2853,30 @@ nvptx_process_pars (parallel *par)
 static void
 nvptx_neuter_pars (parallel *par, unsigned modes, unsigned outer)
 {
-  unsigned me = (OACC_LOOP_MASK (par->mode)
-		 & (OACC_LOOP_MASK (OACC_worker)
-		    | OACC_LOOP_MASK (OACC_vector)));
+  unsigned me = (GOMP_DIM_MASK (par->mode)
+		 & (GOMP_DIM_MASK (GOMP_DIM_WORKER)
+		    | GOMP_DIM_MASK (GOMP_DIM_VECTOR)));
   unsigned  skip_mask = 0, neuter_mask = 0;
   
   if (par->inner)
     nvptx_neuter_pars (par->inner, modes, outer | me);
 
-  for (unsigned mode = OACC_worker; mode <= OACC_vector; mode++)
+  for (unsigned mode = GOMP_DIM_WORKER; mode <= GOMP_DIM_VECTOR; mode++)
     {
-      if ((outer | me) & OACC_LOOP_MASK (mode))
+      if ((outer | me) & GOMP_DIM_MASK (mode))
 	{ /* Mode is partitioned: no neutering.  */ }
-      else if (!(modes & OACC_LOOP_MASK (mode)))
+      else if (!(modes & GOMP_DIM_MASK (mode)))
 	{ /* Mode  is not used: nothing to do.  */ }
-      else if (par->inner_mask & OACC_LOOP_MASK (mode)
+      else if (par->inner_mask & GOMP_DIM_MASK (mode)
 	       || !par->forked_insn)
 	/* Partitioned in inner parallels, or we're not a partitioned
 	   at all: neuter individual blocks.  */
-	neuter_mask |= OACC_LOOP_MASK (mode);
+	neuter_mask |= GOMP_DIM_MASK (mode);
       else if (!par->parent || !par->parent->forked_insn
-	       || par->parent->inner_mask & OACC_LOOP_MASK (mode))
+	       || par->parent->inner_mask & GOMP_DIM_MASK (mode))
 	/* Parent isn't a parallel or contains this paralleling: skip
 	   parallel at this level.  */
-	skip_mask |= OACC_LOOP_MASK (mode);
+	skip_mask |= GOMP_DIM_MASK (mode);
       else
 	{ /* Parent will skip this parallel itself.  */ }
     }
@@ -2936,8 +2934,8 @@ nvptx_reorg (void)
   parallel *pars = nvptx_discover_pars (&bb_insn_map);
 
   nvptx_process_pars (pars);
-  nvptx_neuter_pars (pars, (OACC_LOOP_MASK (OACC_vector)
-			    | OACC_LOOP_MASK (OACC_worker)), 0);
+  nvptx_neuter_pars (pars, (GOMP_DIM_MASK (GOMP_DIM_VECTOR)
+			    | GOMP_DIM_MASK (GOMP_DIM_WORKER)), 0);
 
   delete pars;
 
Index: gcc/omp-low.c
===================================================================
--- gcc/omp-low.c	(revision 226314)
+++ gcc/omp-low.c	(working copy)
@@ -2678,17 +2678,17 @@ scan_omp_for (gomp_for *stmt, omp_contex
 	  int val;
 	  if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_GANG)
 	    {
-	      val = OACC_LOOP_MASK (OACC_gang);
+	      val = GOMP_DIM_MASK (GOMP_DIM_GANG);
 	      gwv_clause = true;
 	    }
 	  else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_WORKER)
 	    {
-	      val = OACC_LOOP_MASK (OACC_worker);
+	      val = GOMP_DIM_MASK (GOMP_DIM_WORKER);
 	      gwv_clause = true;
 	    }
 	  else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_VECTOR)
 	    {
-	      val = OACC_LOOP_MASK (OACC_vector);
+	      val = GOMP_DIM_MASK (GOMP_DIM_VECTOR);
 	      gwv_clause = true;
 	    }
 	  else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SEQ)
@@ -2833,11 +2833,11 @@ scan_omp_target (gomp_target *stmt, omp_
       for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
 	{
 	  if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_GANGS)
-	    ctx->gwv_this |= OACC_LOOP_MASK (OACC_gang);
+	    ctx->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_GANG);
 	  else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_WORKERS)
-	    ctx->gwv_this |= OACC_LOOP_MASK (OACC_worker);
+	    ctx->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_WORKER);
 	  else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_VECTOR_LENGTH)
-	    ctx->gwv_this |= OACC_LOOP_MASK (OACC_vector);
+	    ctx->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_VECTOR);
 	}
     }
 
@@ -3472,8 +3472,8 @@ gen_oacc_fork (gimple_seq *seq, unsigned
 {
   unsigned level;
 
-  for (level = OACC_gang; level != OACC_HWM; level++)
-    if (mask & OACC_LOOP_MASK (level))
+  for (level = GOMP_DIM_GANG; level != GOMP_DIM_MAX; level++)
+    if (mask & GOMP_DIM_MASK (level))
       {
 	tree arg = build_int_cst (unsigned_type_node, level);
 	gcall *call = gimple_build_call_internal (IFN_GOACC_FORK, 1, arg);
@@ -3488,8 +3488,8 @@ gen_oacc_join (gimple_seq *seq, unsigned
 {
   unsigned level;
 
-  for (level = OACC_HWM; level-- != OACC_gang; )
-    if (mask & OACC_LOOP_MASK (level))
+  for (level = GOMP_DIM_MAX; level-- != GOMP_DIM_GANG; )
+    if (mask & GOMP_DIM_MASK (level))
       {
 	tree arg = build_int_cst (unsigned_type_node, level);
 	gcall *call = gimple_build_call_internal (IFN_GOACC_JOIN, 1, arg);
@@ -4681,8 +4681,8 @@ expand_oacc_get_num_threads (gimple_seq
   tree  decl = builtin_decl_explicit (BUILT_IN_GOACC_NID);
   unsigned ix;
 
-  for (ix = OACC_gang; ix != OACC_HWM; ix++)
-    if (OACC_LOOP_MASK(ix) & gwv_bits)
+  for (ix = GOMP_DIM_GANG; ix != GOMP_DIM_MAX; ix++)
+    if (GOMP_DIM_MASK(ix) & gwv_bits)
       {
 	tree arg = build_int_cst (unsigned_type_node, ix);
 	tree count = create_tmp_var (unsigned_type_node);
@@ -4709,8 +4709,8 @@ expand_oacc_get_thread_num (gimple_seq *
   unsigned ix;
 
   /* Start at gang level, and examine relevant dimension indices.  */
-  for (ix = OACC_gang; ix != OACC_HWM; ix++)
-    if (OACC_LOOP_MASK (ix) & gwv_bits)
+  for (ix = GOMP_DIM_GANG; ix != GOMP_DIM_MAX; ix++)
+    if (GOMP_DIM_MASK (ix) & gwv_bits)
       {
 	tree arg = build_int_cst (unsigned_type_node, ix);
 
@@ -10047,11 +10047,11 @@ find_omp_for_region_gwv (gimple stmt)
 
   tree clauses = gimple_omp_for_clauses (stmt);
   if (find_omp_clause (clauses, OMP_CLAUSE_GANG))
-    tmp |= OACC_LOOP_MASK (OACC_gang);
+    tmp |= GOMP_DIM_MASK (GOMP_DIM_GANG);
   if (find_omp_clause (clauses, OMP_CLAUSE_WORKER))
-    tmp |= OACC_LOOP_MASK (OACC_worker);
+    tmp |= GOMP_DIM_MASK (GOMP_DIM_WORKER);
   if (find_omp_clause (clauses, OMP_CLAUSE_VECTOR))
-    tmp |= OACC_LOOP_MASK (OACC_vector);
+    tmp |= GOMP_DIM_MASK (GOMP_DIM_VECTOR);
 
   return tmp;
 }
@@ -10096,11 +10096,11 @@ find_omp_target_region_data (struct omp_
 
   tree clauses = gimple_omp_target_clauses (stmt);
   if (find_omp_clause (clauses, OMP_CLAUSE_NUM_GANGS))
-    region->gwv_this |= OACC_LOOP_MASK (OACC_gang);
+    region->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_GANG);
   if (find_omp_clause (clauses, OMP_CLAUSE_NUM_WORKERS))
-    region->gwv_this |= OACC_LOOP_MASK (OACC_worker);
+    region->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_WORKER);
   if (find_omp_clause (clauses, OMP_CLAUSE_VECTOR_LENGTH))
-    region->gwv_this |= OACC_LOOP_MASK (OACC_vector);
+    region->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_VECTOR);
   region->kind = gimple_omp_target_kind (stmt);
 }
 
@@ -11665,9 +11665,9 @@ oacc_init_count_vars (omp_context *ctx,
   tree getnid = builtin_decl_explicit (BUILT_IN_GOACC_NID);
   tree worker_var, worker_count;
   
-  if (ctx->gwv_this & OACC_LOOP_MASK (OACC_worker))
+  if (ctx->gwv_this & GOMP_DIM_MASK (GOMP_DIM_WORKER))
     {
-      tree arg = build_int_cst (unsigned_type_node, OACC_worker);
+      tree arg = build_int_cst (unsigned_type_node, GOMP_DIM_WORKER);
       
       worker_var = create_tmp_var (unsigned_type_node, ".worker");
       worker_count = create_tmp_var (unsigned_type_node, ".workercount");
Index: gcc/omp-low.h
===================================================================
--- gcc/omp-low.h	(revision 226314)
+++ gcc/omp-low.h	(working copy)
@@ -20,17 +20,6 @@ along with GCC; see the file COPYING3.
 #ifndef GCC_OMP_LOW_H
 #define GCC_OMP_LOW_H
 
-/* Levels of parallelism as defined by OpenACC.  Increasing numbers
-   correspond to deeper loop nesting levels.  */
-enum oacc_loop_levels
-  {
-    OACC_gang,
-    OACC_worker,
-    OACC_vector,
-    OACC_HWM
-  };
-#define OACC_LOOP_MASK(X) (1 << (X))
-
 struct omp_region;
 
 extern tree find_omp_clause (tree, enum omp_clause_code);
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 226314)
+++ gcc/builtins.c	(working copy)
@@ -5929,10 +5929,11 @@ expand_oacc_id (enum built_in_function f
   rtx arg;
 
   arg = expand_normal (arg0);
-  if (GET_CODE (arg) != CONST_INT || UINTVAL (arg) >= OACC_HWM)
+
+  if (GET_CODE (arg) != CONST_INT || UINTVAL (arg) >= GOMP_DIM_MAX)
     {
       error ("argument to %D must be constant in range 0 to %d",
-	     get_callee_fndecl (exp), OACC_HWM - 1);
+	     get_callee_fndecl (exp), GOMP_DIM_MAX - 1);
       return result;
     }
 

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