public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-13] OpenMP: Handle 'all' as category in defaultmap
@ 2023-09-19 12:47 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2023-09-19 12:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5e2f61d5e2bf595bf0ce353666b386140bb385f0

commit 5e2f61d5e2bf595bf0ce353666b386140bb385f0
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Tue Sep 19 11:17:31 2023 +0200

    OpenMP: Handle 'all' as category in defaultmap
    
    Both, specifying no category and specifying 'all', implies
    that the implicit-behavior applies to all categories.
    
    gcc/c/ChangeLog:
    
            * c-parser.cc (c_parser_omp_clause_defaultmap): Parse
            'all' as category.
    
    gcc/cp/ChangeLog:
    
            * parser.cc (cp_parser_omp_clause_defaultmap): Parse
            'all' as category.
    
    gcc/fortran/ChangeLog:
    
            * gfortran.h (enum gfc_omp_defaultmap_category):
            Add OMP_DEFAULTMAP_CAT_ALL.
            * openmp.cc (gfc_match_omp_clauses): Parse
            'all' as category.
            * trans-openmp.cc (gfc_trans_omp_clauses): Handle it.
    
    gcc/ChangeLog:
    
            * tree-core.h (enum omp_clause_defaultmap_kind): Add
            OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL.
            * gimplify.cc (gimplify_scan_omp_clauses): Handle it.
            * tree-pretty-print.cc (dump_omp_clause): Likewise.
    
    libgomp/ChangeLog:
    
            * libgomp.texi (OpenMP 5.2 status): Add depobj with
            destroy-var argument as 'N'. Mark defaultmap with
            'all' category as 'Y'.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/gomp/defaultmap-1.f90: Update dg-error.
            * c-c++-common/gomp/defaultmap-5.c: New test.
            * c-c++-common/gomp/defaultmap-6.c: New test.
            * gfortran.dg/gomp/defaultmap-10.f90: New test.
            * gfortran.dg/gomp/defaultmap-9.f90: New test.
    
    (cherry picked from commit 0698c9fddfc5a41dd7f233928b7a486cb044fea3)

Diff:
---
 gcc/ChangeLog.omp                                |  10 ++
 gcc/c/ChangeLog.omp                              |   8 ++
 gcc/c/c-parser.cc                                |  19 +++-
 gcc/cp/ChangeLog.omp                             |   8 ++
 gcc/cp/parser.cc                                 |  19 +++-
 gcc/fortran/ChangeLog.omp                        |  11 +++
 gcc/fortran/gfortran.h                           |   1 +
 gcc/fortran/openmp.cc                            |  12 ++-
 gcc/fortran/trans-openmp.cc                      |   3 +
 gcc/gimplify.cc                                  |   1 +
 gcc/testsuite/ChangeLog.omp                      |  10 ++
 gcc/testsuite/c-c++-common/gomp/defaultmap-5.c   |  47 +++++++++
 gcc/testsuite/c-c++-common/gomp/defaultmap-6.c   |  48 ++++++++++
 gcc/testsuite/gfortran.dg/gomp/defaultmap-1.f90  |   2 +-
 gcc/testsuite/gfortran.dg/gomp/defaultmap-10.f90 | 116 +++++++++++++++++++++++
 gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90  |  71 ++++++++++++++
 gcc/tree-core.h                                  |   1 +
 gcc/tree-pretty-print.cc                         |   3 +
 libgomp/ChangeLog.omp                            |   9 ++
 libgomp/libgomp.texi                             |   4 +-
 20 files changed, 390 insertions(+), 13 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index e41f04a6a51..5589dfe2e3d 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,13 @@
+2023-09-19  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2023-08-22  Tobias Burnus  <tobias@codesourcery.com>
+
+	* tree-core.h (enum omp_clause_defaultmap_kind): Add
+	OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL.
+	* gimplify.cc (gimplify_scan_omp_clauses): Handle it.
+	* tree-pretty-print.cc (dump_omp_clause): Likewise.
+
 2023-09-12  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp
index 31ca350a3af..aa035e5de8f 100644
--- a/gcc/c/ChangeLog.omp
+++ b/gcc/c/ChangeLog.omp
@@ -1,3 +1,11 @@
+2023-09-19  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2023-08-22  Tobias Burnus  <tobias@codesourcery.com>
+
+	* c-parser.cc (c_parser_omp_clause_defaultmap): Parse
+	'all' as category.
+
 2023-09-12  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 734eb495ea5..2f4e47fa8ec 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -15566,8 +15566,8 @@ c_parser_omp_clause_defaultmap (c_parser *parser, tree list)
       if (!c_parser_next_token_is (parser, CPP_NAME))
 	{
 	invalid_category:
-	  c_parser_error (parser, "expected %<scalar%>, %<aggregate%> or "
-				  "%<pointer%>");
+	  c_parser_error (parser, "expected %<scalar%>, %<aggregate%>, "
+				  "%<pointer%> or %<all%>");
 	  goto out_err;
 	}
       p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
@@ -15576,6 +15576,8 @@ c_parser_omp_clause_defaultmap (c_parser *parser, tree list)
 	case 'a':
 	  if (strcmp ("aggregate", p) == 0)
 	    category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE;
+	  else if (strcmp ("all", p) == 0)
+	    category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL;
 	  else
 	    goto invalid_category;
 	  break;
@@ -15605,13 +15607,19 @@ c_parser_omp_clause_defaultmap (c_parser *parser, tree list)
   for (c = list; c ; c = OMP_CLAUSE_CHAIN (c))
     if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEFAULTMAP
 	&& (category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
+	    || category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL
 	    || OMP_CLAUSE_DEFAULTMAP_CATEGORY (c) == category
 	    || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
-		== OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)))
+		== OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
+	    || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
+		== OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL)))
       {
 	enum omp_clause_defaultmap_kind cat = category;
 	location_t loc = OMP_CLAUSE_LOCATION (c);
-	if (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
+	if (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
+	    || (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL
+		&& (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
+		    != OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)))
 	  cat = OMP_CLAUSE_DEFAULTMAP_CATEGORY (c);
 	p = NULL;
 	switch (cat)
@@ -15619,6 +15627,9 @@ c_parser_omp_clause_defaultmap (c_parser *parser, tree list)
 	  case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
 	    p = NULL;
 	    break;
+	  case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL:
+	    p = "all";
+	    break;
 	  case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
 	    p = "aggregate";
 	    break;
diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp
index 8289622a016..77d3cfa5a84 100644
--- a/gcc/cp/ChangeLog.omp
+++ b/gcc/cp/ChangeLog.omp
@@ -1,3 +1,11 @@
+2023-09-19  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2023-08-22  Tobias Burnus  <tobias@codesourcery.com>
+
+	* parser.cc (cp_parser_omp_clause_defaultmap): Parse
+	'all' as category.
+
 2023-08-18  Sandra Loosemore  <sandra@codesourcery.com>
 
 	* parser.cc (cp_parser_omp_all_clauses): Allow comma before first
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 1c396ce99f8..dbd1f9a4f49 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -39336,8 +39336,8 @@ cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
       if (!cp_lexer_next_token_is (parser->lexer, CPP_NAME))
 	{
 	invalid_category:
-	  cp_parser_error (parser, "expected %<scalar%>, %<aggregate%> or "
-				   "%<pointer%>");
+	  cp_parser_error (parser, "expected %<scalar%>, %<aggregate%>, "
+				   "%<all%>");
 	  goto out_err;
 	}
       id = cp_lexer_peek_token (parser->lexer)->u.value;
@@ -39348,6 +39348,8 @@ cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
 	case 'a':
 	  if (strcmp ("aggregate", p) == 0)
 	    category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE;
+	  else if (strcmp ("all", p) == 0)
+	    category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL;
 	  else
 	    goto invalid_category;
 	  break;
@@ -39378,13 +39380,19 @@ cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
   for (c = list; c ; c = OMP_CLAUSE_CHAIN (c))
     if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEFAULTMAP
 	&& (category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
+	    || category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL
 	    || OMP_CLAUSE_DEFAULTMAP_CATEGORY (c) == category
 	    || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
-		== OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)))
+		== OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
+	    || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
+		== OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL)))
       {
 	enum omp_clause_defaultmap_kind cat = category;
 	location_t loc = OMP_CLAUSE_LOCATION (c);
-	if (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
+	if (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
+	    || (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL
+		&& (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
+		    != OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)))
 	  cat = OMP_CLAUSE_DEFAULTMAP_CATEGORY (c);
 	p = NULL;
 	switch (cat)
@@ -39392,6 +39400,9 @@ cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
 	  case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
 	    p = NULL;
 	    break;
+	  case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL:
+	    p = "all";
+	    break;
 	  case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
 	    p = "aggregate";
 	    break;
diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 6b29246e605..62a33475ee5 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,14 @@
+2023-09-19  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2023-08-22  Tobias Burnus  <tobias@codesourcery.com>
+
+	* gfortran.h (enum gfc_omp_defaultmap_category):
+	Add OMP_DEFAULTMAP_CAT_ALL.
+	* openmp.cc (gfc_match_omp_clauses): Parse
+	'all' as category.
+	* trans-openmp.cc (gfc_trans_omp_clauses): Handle it.
+
 2023-08-10  Julian Brown  <julian@codesourcery.com>
 
 	* openmp.cc (gfc_match_motion_var_list): Add parsing for mapper
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 3b854e14d47..2cb8257121f 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1344,6 +1344,7 @@ enum gfc_omp_defaultmap
 enum gfc_omp_defaultmap_category
 {
   OMP_DEFAULTMAP_CAT_UNCATEGORIZED,
+  OMP_DEFAULTMAP_CAT_ALL,
   OMP_DEFAULTMAP_CAT_SCALAR,
   OMP_DEFAULTMAP_CAT_AGGREGATE,
   OMP_DEFAULTMAP_CAT_ALLOCATABLE,
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 96e764b90a6..d69607ef288 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -2861,17 +2861,22 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
 		    category = OMP_DEFAULTMAP_CAT_ALLOCATABLE;
 		  else if (gfc_match ("pointer ") == MATCH_YES)
 		    category = OMP_DEFAULTMAP_CAT_POINTER;
+		  else if (gfc_match ("all ") == MATCH_YES)
+		    category = OMP_DEFAULTMAP_CAT_ALL;
 		  else
 		    {
-		      gfc_error ("Expected SCALAR, AGGREGATE, ALLOCATABLE or "
-				 "POINTER at %C");
+		      gfc_error ("Expected SCALAR, AGGREGATE, ALLOCATABLE, "
+				 "POINTER or ALL at %C");
 		      break;
 		    }
 		}
 	      for (int i = 0; i < OMP_DEFAULTMAP_CAT_NUM; ++i)
 		{
 		  if (i != category
-		      && category != OMP_DEFAULTMAP_CAT_UNCATEGORIZED)
+		      && category != OMP_DEFAULTMAP_CAT_UNCATEGORIZED
+		      && category != OMP_DEFAULTMAP_CAT_ALL
+		      && i != OMP_DEFAULTMAP_CAT_UNCATEGORIZED
+		      && i != OMP_DEFAULTMAP_CAT_ALL)
 		    continue;
 		  if (c->defaultmap[i] != OMP_DEFAULTMAP_UNSET)
 		    {
@@ -2879,6 +2884,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
 		      switch (i)
 			{
 			case OMP_DEFAULTMAP_CAT_UNCATEGORIZED: break;
+			case OMP_DEFAULTMAP_CAT_ALL: pcategory = "ALL"; break;
 			case OMP_DEFAULTMAP_CAT_SCALAR: pcategory = "SCALAR"; break;
 			case OMP_DEFAULTMAP_CAT_AGGREGATE:
 			  pcategory = "AGGREGATE";
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 746efb75369..199c7192260 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -7002,6 +7002,9 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 	case OMP_DEFAULTMAP_CAT_UNCATEGORIZED:
 	  category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
 	  break;
+	case OMP_DEFAULTMAP_CAT_ALL:
+	  category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL;
+	  break;
 	case OMP_DEFAULTMAP_CAT_SCALAR:
 	  category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR;
 	  break;
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index df3da9a5906..c63c464b867 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -13369,6 +13369,7 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
 	  switch (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c))
 	    {
 	    case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
+	    case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL:
 	      gdmkmin = GDMK_SCALAR;
 	      gdmkmax = GDMK_POINTER;
 	      break;
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 911425d0fc4..8ee95c9e54c 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,13 @@
+2023-08-18  Sandra Loosemore  <sandra@codesourcery.com>
+
+	* g++.dg/gomp/loop-transforms/attrs-tile-1.C: New file.
+	* g++.dg/gomp/loop-transforms/attrs-tile-2.C: New file.
+	* g++.dg/gomp/loop-transforms/attrs-tile-3.C: New file.
+	* g++.dg/gomp/loop-transforms/attrs-unroll-1.C: New file.
+	* g++.dg/gomp/loop-transforms/attrs-unroll-2.C: New file.
+	* g++.dg/gomp/loop-transforms/attrs-unroll-3.C: New file.
+	* g++.dg/gomp/loop-transforms/attrs-unroll-inner-1.C: New file.
+
 2023-09-12  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/c-c++-common/gomp/defaultmap-5.c b/gcc/testsuite/c-c++-common/gomp/defaultmap-5.c
new file mode 100644
index 00000000000..cc1a77fadb3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/defaultmap-5.c
@@ -0,0 +1,47 @@
+/* { dg-additional-options "-fdump-tree-original -fdump-tree-gimple" } */
+
+void f()
+{
+  struct s {
+    int i;
+  };
+  int scalar1 = 5;
+  int array1[5] = {1,2,3,4,5};
+  int *ptr1 = &scalar1;
+  struct s mystruct1 = {.i = 5};
+
+  /* firstprivate + unspecified modifer. */
+  #pragma omp target defaultmap(firstprivate)
+   {
+     scalar1 = 1;
+     array1[0] = 2;
+     if (ptr1 == 0L)
+       mystruct1.i = 3;
+   }
+
+  /* equivalent: firstprivate + ALL modifer. */
+  #pragma omp target defaultmap(firstprivate : all)
+   {
+     scalar1 = 1;
+     array1[0] = 2;
+     if (ptr1 == 0L)
+       mystruct1.i = 3;
+   }
+
+  /* tofrom + ALL modifer. */
+  #pragma omp target defaultmap(tofrom : all)
+   {
+     scalar1 = 1;
+     array1[0] = 2;
+     if (ptr1 == 0L)
+       mystruct1.i = 3;
+   }
+}
+
+/* { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(firstprivate\\)" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(firstprivate:all\\)" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(tofrom:all\\)" 1 "original" } } */
+
+/* { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate\\) firstprivate\\(mystruct1\\) firstprivate\\(ptr1\\) firstprivate\\(array1\\) firstprivate\\(scalar1\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate:all\\) firstprivate\\(mystruct1\\) firstprivate\\(ptr1\\) firstprivate\\(array1\\) firstprivate\\(scalar1\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(tofrom:all\\) map\\(tofrom:mystruct1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:ptr1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:array1 \\\[len: ..\\\]\\\[implicit\\\]\\) map\\(tofrom:scalar1 \\\[len: .\\\]\\\[implicit\\\]\\)" 1 "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/defaultmap-6.c b/gcc/testsuite/c-c++-common/gomp/defaultmap-6.c
new file mode 100644
index 00000000000..45fce8b66e9
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/defaultmap-6.c
@@ -0,0 +1,48 @@
+void f()
+{
+  struct s {
+    int i;
+  };
+  int scalar1 = 5;
+  int array1[5] = {1,2,3,4,5};
+  int *ptr1 = &scalar1;
+  struct s mystruct1 = {.i = 5};
+
+  #pragma omp target defaultmap(firstprivate ) defaultmap(firstprivate : aggregate)  /* { dg-error "too many 'defaultmap' clauses with 'aggregate' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+
+  #pragma omp target defaultmap(firstprivate : all ) defaultmap(alloc : pointer) /* { dg-error "too many 'defaultmap' clauses with 'pointer' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+
+
+  #pragma omp target defaultmap(firstprivate : aggregate)  defaultmap(firstprivate ) /* { dg-error "too many 'defaultmap' clauses with 'aggregate' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+
+  #pragma omp target defaultmap(alloc : pointer) defaultmap(firstprivate : all )  /* { dg-error "too many 'defaultmap' clauses with 'pointer' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+
+  #pragma omp target defaultmap(firstprivate :all ) defaultmap(firstprivate : all) /* { dg-error "too many 'defaultmap' clauses with 'all' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+  #pragma omp target defaultmap(firstprivate ) defaultmap(firstprivate) /* { dg-error "too many 'defaultmap' clauses with unspecified category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+  #pragma omp target defaultmap(firstprivate ) defaultmap(firstprivate : all) /* { dg-error "too many 'defaultmap' clauses with 'all' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+  #pragma omp target defaultmap(firstprivate : all) defaultmap(firstprivate) /* { dg-error "too many 'defaultmap' clauses with 'all' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+}
diff --git a/gcc/testsuite/gfortran.dg/gomp/defaultmap-1.f90 b/gcc/testsuite/gfortran.dg/gomp/defaultmap-1.f90
index 1f1b8528aef..5123e078e98 100644
--- a/gcc/testsuite/gfortran.dg/gomp/defaultmap-1.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/defaultmap-1.f90
@@ -4,7 +4,7 @@ implicit none
 
 !$omp target defaultmap(bar)  ! { dg-error "25: Expected ALLOC, TO, FROM, TOFROM, FIRSTPRIVATE, PRESENT, NONE or DEFAULT" }
 
-!$omp target defaultmap ( alloc: foo)  ! { dg-error "34: Expected SCALAR, AGGREGATE, ALLOCATABLE or POINTER" }
+!$omp target defaultmap ( alloc: foo)  ! { dg-error "34: Expected SCALAR, AGGREGATE, ALLOCATABLE, POINTER or ALL" }
 
 !$omp target defaultmap(alloc:scalar) defaultmap(none:Scalar)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category SCALAR" }
 
diff --git a/gcc/testsuite/gfortran.dg/gomp/defaultmap-10.f90 b/gcc/testsuite/gfortran.dg/gomp/defaultmap-10.f90
new file mode 100644
index 00000000000..7e230d886f0
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/defaultmap-10.f90
@@ -0,0 +1,116 @@
+subroutine f
+  implicit none
+  type t
+    integer :: i
+  end type t
+  integer, target :: scalar
+  integer, target :: array(5)
+  integer, pointer :: ptr1, ptr2(:)
+  integer, allocatable :: alloc1, alloc2(:)
+  type(t) :: agg1, agg2(2)
+
+  scalar = 1
+  array = [1,2,3,4,5]
+  ptr1 => scalar
+  ptr2 => array
+  alloc1 = 5
+  alloc2 = [1,2]
+  agg1%i = 1
+  agg2(:)%i = [1,2]
+
+  !$omp target defaultmap(firstprivate ) defaultmap(firstprivate : aggregate)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP with unspecified category" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate : all ) defaultmap(alloc : pointer)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category ALL" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate : aggregate)  defaultmap(firstprivate )  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category AGGREGATE" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(alloc : pointer) defaultmap(firstprivate : all )   ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category POINTER" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate :all ) defaultmap(firstprivate : all)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category ALL" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate ) defaultmap(firstprivate)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP with unspecified category" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate ) defaultmap(firstprivate : all)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP with unspecified category" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate : all) defaultmap(firstprivate)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category ALL" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90 b/gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90
new file mode 100644
index 00000000000..b24fc95fc74
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90
@@ -0,0 +1,71 @@
+! { dg-additional-options "-fdump-tree-original -fdump-tree-gimple" }
+
+subroutine f
+  implicit none
+  type t
+    integer :: i
+  end type t
+  integer, target :: scalar
+  integer, target :: array(5)
+  integer, pointer :: ptr1, ptr2(:)
+  integer, allocatable :: alloc1, alloc2(:)
+  type(t) :: agg1, agg2(2)
+
+  scalar = 1
+  array = [1,2,3,4,5]
+  ptr1 => scalar
+  ptr2 => array
+  alloc1 = 5
+  alloc2 = [1,2]
+  agg1%i = 1
+  agg2(:)%i = [1,2]
+
+  ! firstprivate + unspecified modifer.
+  !$omp target defaultmap(firstprivate)
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  ! equivalent: firstprivate + ALL modifer.
+  !$omp target defaultmap(firstprivate : all)
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  ! tofrom + ALL modifer.
+  !$omp target defaultmap(tofrom : all)
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+end subroutine
+
+! { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(firstprivate\\)" 1 "original" } }
+! { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(firstprivate:all\\)" 1 "original" } }
+! { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(tofrom:all\\)" 1 "original" } }
+
+! { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate\\) firstprivate\\(scalar\\) firstprivate\\(ptr2\\) firstprivate\\(ptr1\\) firstprivate\\(array\\) firstprivate\\(alloc2\\) firstprivate\\(alloc1\\) firstprivate\\(agg2\\) firstprivate\\(agg1\\)" 1 "gimple" } }
+
+! { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate:all\\) firstprivate\\(scalar\\) firstprivate\\(ptr2\\) firstprivate\\(ptr1\\) firstprivate\\(array\\) firstprivate\\(alloc2\\) firstprivate\\(alloc1\\) firstprivate\\(agg2\\) firstprivate\\(agg1\\)" 1 "gimple" } }
+
+! { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(tofrom:all\\) map\\(tofrom:scalar \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:.*ptr2.data \\\[len: .*\\\]\\\[implicit\\\]\\) map\\(to:ptr2 \\\[pointer set, len: ..\\\]\\) map\\(always_pointer:.*ptr2.data \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:\\*ptr1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(alloc:ptr1 \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:array \\\[len: ..\\\]\\\[implicit\\\]\\) map\\(tofrom:.*alloc2.data \\\[len: .*\\\]\\\[implicit\\\]\\) map\\(to:alloc2 \\\[pointer set, len: ..\\\]\\) map\\(alloc:.*alloc2.data \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:\\*alloc1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(alloc:alloc1 \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:agg2 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:agg1 \\\[len: .\\\]\\\[implicit\\\]\\)" 1 "gimple" } }
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index fe972c3de54..58cf3c5baf8 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -587,6 +587,7 @@ enum omp_clause_default_kind {
 
 enum omp_clause_defaultmap_kind {
   OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED,
+  OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL,
   OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR,
   OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE,
   OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALLOCATABLE,
diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
index 2bcb9a2cf42..2001a47bf89 100644
--- a/gcc/tree-pretty-print.cc
+++ b/gcc/tree-pretty-print.cc
@@ -1408,6 +1408,9 @@ dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
 	{
 	case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
 	  break;
+	case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL:
+	  pp_string (pp, ":all");
+	  break;
 	case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
 	  pp_string (pp, ":scalar");
 	  break;
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index d79e56bb94b..4b5614e418a 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,12 @@
+2023-09-19  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2023-08-22  Tobias Burnus  <tobias@codesourcery.com>
+
+	* libgomp.texi (OpenMP 5.2 status): Add depobj with
+	destroy-var argument as 'N'. Mark defaultmap with
+	'all' category as 'Y'.
+
 2023-08-10  Julian Brown  <julian@codesourcery.com>
 
 	* testsuite/libgomp.c-c++-common/declare-mapper-18.c: New test.
diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index b0a67151bf4..40fb8bc507b 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -378,6 +378,8 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
       sentinel is warned for with with @code{-Wsurprising} (enabled by
       @code{-Wall}).  Unknown clauses are always rejected with an error.}
 @item Clauses on @code{end} directive can be on directive @tab Y @tab
+@item @code{destroy} clause with destroy-var argument on @code{depobj}
+      @tab N @tab
 @item Deprecation of no-argument @code{destroy} clause on @code{depobj}
       @tab N @tab
 @item @code{linear} clause syntax changes and @code{step} modifier @tab Y @tab
@@ -426,7 +428,7 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
       @code{omp_invalid_device} enum/PARAMETER @tab Y @tab
 @item Initial value of @var{default-device-var} ICV with
       @code{OMP_TARGET_OFFLOAD=mandatory} @tab Y @tab
-@item @code{all} as @emph{implicit-behavior} for @code{defaultmap} @tab N @tab
+@item @code{all} as @emph{implicit-behavior} for @code{defaultmap} @tab Y @tab
 @item @emph{interop_types} in any position of the modifier list for the @code{init} clause
       of the @code{interop} construct @tab N @tab
 @end multitable

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-19 12:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19 12:47 [gcc/devel/omp/gcc-13] OpenMP: Handle 'all' as category in defaultmap Tobias Burnus

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