public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Julian Brown <julian@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <fortran@gcc.gnu.org>, <jakub@redhat.com>, <tobias@codesourcery.com>
Subject: [PATCH 01/14] Revert "Assumed-size arrays with non-lexical data mappings"
Date: Mon, 19 Jun 2023 21:17:25 +0000	[thread overview]
Message-ID: <6d5055a3ff4c70e5d9f312aca7e1c25363ba3d01.1687201315.git.julian@codesourcery.com> (raw)
In-Reply-To: <cover.1687201315.git.julian@codesourcery.com>

This reverts commit 72733f6e6f6ec1bb9884fea8bfbebd3de03d9374.

2023-06-16  Julian Brown  <julian@codesourcery.com>

gcc/
	Revert:
	* gimplify.cc (gimplify_adjust_omp_clauses_1): Raise error for
	assumed-size arrays in map clauses for Fortran/OpenMP.
	* omp-low.cc (lower_omp_target): Set the size of assumed-size Fortran
	arrays to one to allow use of data already mapped on the offload device.

gcc/fortran/
	Revert:
	* trans-openmp.cc (gfc_omp_finish_clause): Change clauses mapping
	assumed-size arrays to use the GOMP_MAP_FORCE_PRESENT map type.
---
 gcc/fortran/trans-openmp.cc | 22 +++++++++-------------
 gcc/gimplify.cc             | 14 --------------
 gcc/omp-low.cc              |  5 -----
 3 files changed, 9 insertions(+), 32 deletions(-)

diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index e8f3b24e5f8..e55c8292d05 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -1588,18 +1588,10 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p, bool openacc)
   tree decl = OMP_CLAUSE_DECL (c);
 
   /* Assumed-size arrays can't be mapped implicitly, they have to be mapped
-     explicitly using array sections.  For OpenACC this restriction is lifted
-     if the array has already been mapped:
-
-       - Using a lexically-enclosing data region: in that case we see the
-         GOMP_MAP_FORCE_PRESENT mapping kind here.
-
-       - Using a non-lexical data mapping ("acc enter data").
-
-     In the latter case we change the mapping type to GOMP_MAP_FORCE_PRESENT.
-     This raises an error for OpenMP in the caller
-     (gimplify.c:gimplify_adjust_omp_clauses_1).  OpenACC will raise a runtime
-     error if the implicitly-referenced assumed-size array is not mapped.  */
+     explicitly using array sections.  An exception is if the array is
+     mapped explicitly in an enclosing data construct for OpenACC, in which
+     case we see GOMP_MAP_FORCE_PRESENT here and do not need to raise an
+     error.  */
   if (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FORCE_PRESENT
       && TREE_CODE (decl) == PARM_DECL
       && GFC_ARRAY_TYPE_P (TREE_TYPE (decl))
@@ -1607,7 +1599,11 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p, bool openacc)
       && GFC_TYPE_ARRAY_UBOUND (TREE_TYPE (decl),
 				GFC_TYPE_ARRAY_RANK (TREE_TYPE (decl)) - 1)
 	 == NULL)
-    OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_FORCE_PRESENT);
+    {
+      error_at (OMP_CLAUSE_LOCATION (c),
+		"implicit mapping of assumed size array %qD", decl);
+      return;
+    }
 
   if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FORCE_DEVICEPTR)
     return;
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 09c596f026e..3729b986801 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -12828,26 +12828,12 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
   *list_p = clause;
   struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp;
   gimplify_omp_ctxp = ctx->outer_context;
-  gomp_map_kind kind = (code == OMP_CLAUSE_MAP) ? OMP_CLAUSE_MAP_KIND (clause)
-						: (gomp_map_kind) GOMP_MAP_LAST;
   /* Don't call omp_finish_clause on implicitly added OMP_CLAUSE_PRIVATE
      in simd.  Those are only added for the local vars inside of simd body
      and they don't need to be e.g. default constructible.  */
   if (code != OMP_CLAUSE_PRIVATE || ctx->region_type != ORT_SIMD) 
     lang_hooks.decls.omp_finish_clause (clause, pre_p,
 					(ctx->region_type & ORT_ACC) != 0);
-  /* Allow OpenACC to have implicit assumed-size arrays via FORCE_PRESENT,
-     which should work as long as the array has previously been mapped
-     explicitly on the target (e.g. by "enter data").  Raise an error for
-     OpenMP.  */
-  if (lang_GNU_Fortran ()
-      && code == OMP_CLAUSE_MAP
-      && (ctx->region_type & ORT_ACC) == 0
-      && kind == GOMP_MAP_TOFROM
-      && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_FORCE_PRESENT)
-    error_at (OMP_CLAUSE_LOCATION (clause),
-	      "implicit mapping of assumed size array %qD",
-	      OMP_CLAUSE_DECL (clause));
   if (gimplify_omp_ctxp)
     for (; clause != chain; clause = OMP_CLAUSE_CHAIN (clause))
       if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index 3424eba2217..59143d8efe5 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -14353,11 +14353,6 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 	      s = OMP_CLAUSE_SIZE (c);
 	    if (s == NULL_TREE)
 	      s = TYPE_SIZE_UNIT (TREE_TYPE (ovar));
-	    /* Fortran assumed-size arrays have zero size because the type is
-	       incomplete.  Set the size to one to allow the runtime to remap
-	       any existing data that is already present on the accelerator.  */
-	    if (s == NULL_TREE && is_gimple_omp_oacc (ctx->stmt))
-	      s = integer_one_node;
 	    s = fold_convert (size_type_node, s);
 	    purpose = size_int (map_idx++);
 	    CONSTRUCTOR_APPEND_ELT (vsize, purpose, s);
-- 
2.31.1


  reply	other threads:[~2023-06-19 21:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 21:17 [PATCH 00/14] [og13] OpenMP/OpenACC: map clause and OMP gimplify rework Julian Brown
2023-06-19 21:17 ` Julian Brown [this message]
2023-06-19 21:17 ` [PATCH 02/14] Revert "Fix references declared in lexically-enclosing OpenACC data region" Julian Brown
2023-06-19 21:17 ` [PATCH 03/14] Revert "Fix implicit mapping for array slices on lexically-enclosing data constructs (PR70828)" Julian Brown
2023-06-19 21:17 ` [PATCH 04/14] Revert "openmp: Handle C/C++ array reference base-pointers in array sections" Julian Brown
2023-06-19 21:17 ` [PATCH 05/14] OpenMP/OpenACC: Reindent TO/FROM/_CACHE_ stanza in {c_}finish_omp_clause Julian Brown
2023-06-19 21:17 ` [PATCH 06/14] OpenMP/OpenACC: Rework clause expansion and nested struct handling Julian Brown
2023-06-19 21:17 ` [PATCH 07/14] OpenMP: implicitly map base pointer for array-section pointer components Julian Brown
2023-06-19 21:17 ` [PATCH 08/14] OpenMP: Pointers and member mappings Julian Brown
2023-06-19 21:17 ` [PATCH 09/14] OpenMP/OpenACC: Unordered/non-constant component offset runtime diagnostic Julian Brown
2023-06-19 21:17 ` [PATCH 10/14] OpenMP/OpenACC: Reorganise OMP map clause handling in gimplify.cc Julian Brown
2023-06-19 21:17 ` [PATCH 11/14] OpenACC: Reimplement "inheritance" for lexically-nested offload regions Julian Brown
2023-06-19 21:17 ` [PATCH 12/14] OpenACC: "declare create" fixes wrt. "allocatable" variables Julian Brown
2023-06-19 21:17 ` [PATCH 13/14] OpenACC: Allow implicit uses of assumed-size arrays in offload regions Julian Brown
2023-06-19 21:17 ` [PATCH 14/14] OpenACC: Improve implicit mapping for non-lexically nested " Julian Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6d5055a3ff4c70e5d9f312aca7e1c25363ba3d01.1687201315.git.julian@codesourcery.com \
    --to=julian@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).