[RFC] Offloading Support in libgomp

Jakub Jelinek jakub@redhat.com
Fri Sep 13 15:34:00 GMT 2013


On Fri, Sep 13, 2013 at 02:36:14PM +0200, Jakub Jelinek wrote:
> FYI, I'm attaching a WIP patch with the splay tree stuff, debugging
> target-1.c with OMP_DEFAULT_DEVICE=257 right now (with all tgtv related
> stuff removed), but hitting some error regarding OMP_CLAUSE_MAP_POINTER
> reallocation, supposedly a bug on the compiler side.  But e.g. fn2 and fn3
> already seem to pass with that, only fn4 is problematic.

Ok, found the bug, this should fix fn4 and the whole test passes
now with OMP_DEFAULT_DEVICE=257.

Will commit once the http://gcc.gnu.org/ml/gcc-patches/2013-09/msg01044.html
issue is resolved.

2013-09-13  Jakub Jelinek  <jakub@redhat.com>

	* omp-low.c (install_var_field): Use (mask & 4) to request double
	indirection.
	(scan_sharing_clauses): For OMP_CLAUSE_MAP_POINTER arrays pass
	7 instead of 3 to install_var_field.
	(lower_omp_target): For OMP_CLAUSE_MAP_POINTER arrays add extra
	indirection.

--- gcc/omp-low.c.jj	2013-09-12 13:55:34.000000000 +0200
+++ gcc/omp-low.c	2013-09-13 15:57:58.425272908 +0200
@@ -1017,7 +1017,12 @@ install_var_field (tree var, bool by_ref
 	      || !splay_tree_lookup (ctx->sfield_map, (splay_tree_key) var));
 
   type = TREE_TYPE (var);
-  if (by_ref)
+  if (mask & 4)
+    {
+      gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
+      type = build_pointer_type (build_pointer_type (type));
+    }
+  else if (by_ref)
     type = build_pointer_type (type);
   else if ((mask & 3) == 1 && is_reference (var))
     type = TREE_TYPE (type);
@@ -1587,7 +1592,13 @@ scan_sharing_clauses (tree clauses, omp_
 		}
 	      else
 		{
-		  install_var_field (decl, true, 3, ctx);
+		  if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
+		      && OMP_CLAUSE_MAP_KIND (c) == OMP_CLAUSE_MAP_POINTER
+		      && !OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION (c)
+		      && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+		    install_var_field (decl, true, 7, ctx);
+		  else
+		    install_var_field (decl, true, 3, ctx);
 		  if (gimple_omp_target_kind (ctx->stmt)
 		      == GF_OMP_TARGET_KIND_REGION)
 		    install_var_local (decl, ctx);
@@ -9331,6 +9342,11 @@ lower_omp_target (gimple_stmt_iterator *
 	  {
 	    x = build_receiver_ref (var, true, ctx);
 	    tree new_var = lookup_decl (var, ctx);
+	    if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
+		&& OMP_CLAUSE_MAP_KIND (c) == OMP_CLAUSE_MAP_POINTER
+		&& !OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION (c)
+		&& TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE)
+	      x = build_simple_mem_ref (x);
 	    SET_DECL_VALUE_EXPR (new_var, x);
 	    DECL_HAS_VALUE_EXPR_P (new_var) = 1;
 	  }
@@ -9435,7 +9451,20 @@ lower_omp_target (gimple_stmt_iterator *
 	      {
 		tree var = lookup_decl_in_outer_ctx (ovar, ctx);
 		tree x = build_sender_ref (ovar, ctx);
-		if (is_gimple_reg (var))
+		if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
+		    && OMP_CLAUSE_MAP_KIND (c) == OMP_CLAUSE_MAP_POINTER
+		    && !OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION (c)
+		    && TREE_CODE (TREE_TYPE (ovar)) == ARRAY_TYPE)
+		  {
+		    gcc_assert (kind == GF_OMP_TARGET_KIND_REGION);
+		    tree avar
+		      = create_tmp_var (TREE_TYPE (TREE_TYPE (x)), NULL);
+		    mark_addressable (avar);
+		    gimplify_assign (avar, build_fold_addr_expr (var), &ilist);
+		    avar = build_fold_addr_expr (avar);
+		    gimplify_assign (x, avar, &ilist);
+		  }
+		else if (is_gimple_reg (var))
 		  {
 		    gcc_assert (kind == GF_OMP_TARGET_KIND_REGION);
 		    tree avar = create_tmp_var (TREE_TYPE (var), NULL);


	Jakub



More information about the Gcc mailing list