public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] openmp: allow requires unified_shared_memory
@ 2022-03-14 10:26 Hafiz Abid Qadeer
0 siblings, 0 replies; only message in thread
From: Hafiz Abid Qadeer @ 2022-03-14 10:26 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8126f3f00f8037b366569301ed354f0e495d8a6a
commit 8126f3f00f8037b366569301ed354f0e495d8a6a
Author: Andrew Stubbs <ams@codesourcery.com>
Date: Thu Mar 10 21:38:54 2022 +0000
openmp: allow requires unified_shared_memory
This is the front-end portion of the Unified Shared Memory implementation.
It checks that -foffload-memory isn't set to an incompatible mode.
Backport of the patch posted at
https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591351.html
gcc/c/ChangeLog:
* c-parser.c (c_parser_omp_requires): Check compatibility of
-foffload-memory option with requires directive.
gcc/cp/ChangeLog:
* parser.c (cp_parser_omp_requires): Check compatibility of
-foffload-memory option with requires directive.
gcc/fortran/ChangeLog:
* openmp.c (gfc_match_omp_requires): Check compatibility of
-foffload-memory option with requires directive.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/usm-1.c: New test.
* gfortran.dg/gomp/usm-1.f90: New test.
Diff:
---
gcc/c/ChangeLog.omp | 8 ++++++++
gcc/c/c-parser.c | 9 +++++++++
gcc/cp/ChangeLog.omp | 8 ++++++++
gcc/cp/parser.c | 9 +++++++++
gcc/fortran/ChangeLog.omp | 8 ++++++++
gcc/fortran/openmp.c | 7 +++++++
gcc/testsuite/ChangeLog.omp | 8 ++++++++
gcc/testsuite/c-c++-common/gomp/usm-1.c | 4 ++++
gcc/testsuite/gfortran.dg/gomp/usm-1.f90 | 6 ++++++
9 files changed, 67 insertions(+)
diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp
index 3838d18e571..71098232cb3 100644
--- a/gcc/c/ChangeLog.omp
+++ b/gcc/c/ChangeLog.omp
@@ -1,3 +1,11 @@
+2022-03-10 Andrew Stubbs <ams@codesourcery.com>
+
+ Backport of the patch posted at
+ https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591351.html
+
+ * c-parser.c (c_parser_omp_requires): Check compatibility of
+ -foffload-memory option with requires directive.
+
2022-02-27 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 1dab35b19ad..12408770193 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -22533,7 +22533,16 @@ c_parser_omp_requires (c_parser *parser)
if (!strcmp (p, "unified_address"))
this_req = OMP_REQUIRES_UNIFIED_ADDRESS;
else if (!strcmp (p, "unified_shared_memory"))
+ {
this_req = OMP_REQUIRES_UNIFIED_SHARED_MEMORY;
+
+ if (flag_offload_memory != OFFLOAD_MEMORY_UNIFIED
+ && flag_offload_memory != OFFLOAD_MEMORY_NONE)
+ error_at (cloc,
+ "unified_shared_memory is incompatible with the "
+ "selected -foffload-memory option");
+ flag_offload_memory = OFFLOAD_MEMORY_UNIFIED;
+ }
else if (!strcmp (p, "dynamic_allocators"))
this_req = OMP_REQUIRES_DYNAMIC_ALLOCATORS;
else if (!strcmp (p, "reverse_offload"))
diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp
index 79221b0eece..58ebce0523c 100644
--- a/gcc/cp/ChangeLog.omp
+++ b/gcc/cp/ChangeLog.omp
@@ -1,3 +1,11 @@
+2022-03-10 Andrew Stubbs <ams@codesourcery.com>
+
+ Backport of the patch posted at
+ https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591351.html
+
+ * parser.c (cp_parser_omp_requires): Check compatibility of
+ -foffload-memory option with requires directive.
+
2022-02-27 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 15aa72ea6ad..fd9f62f4543 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -46408,7 +46408,16 @@ cp_parser_omp_requires (cp_parser *parser, cp_token *pragma_tok)
if (!strcmp (p, "unified_address"))
this_req = OMP_REQUIRES_UNIFIED_ADDRESS;
else if (!strcmp (p, "unified_shared_memory"))
+ {
this_req = OMP_REQUIRES_UNIFIED_SHARED_MEMORY;
+
+ if (flag_offload_memory != OFFLOAD_MEMORY_UNIFIED
+ && flag_offload_memory != OFFLOAD_MEMORY_NONE)
+ error_at (cloc,
+ "unified_shared_memory is incompatible with the "
+ "selected -foffload-memory option");
+ flag_offload_memory = OFFLOAD_MEMORY_UNIFIED;
+ }
else if (!strcmp (p, "dynamic_allocators"))
this_req = OMP_REQUIRES_DYNAMIC_ALLOCATORS;
else if (!strcmp (p, "reverse_offload"))
diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index f1c025799c3..bbf6c8efabc 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,11 @@
+2022-03-10 Andrew Stubbs <ams@codesourcery.com>
+
+ Backport of the patch posted at
+ https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591351.html
+
+ * openmp.c (gfc_match_omp_requires): Check compatibility of
+ -foffload-memory option with requires directive.
+
2022-03-09 Abid Qadeer <abidh@codesourcery.com>
Backport of a patch posted at
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 7be015f5b3f..ac4126bd7ea 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "gomp-constants.h"
#include "options.h"
#include "target-memory.h" /* For gfc_encode_character. */
+#include "options.h"
/* Match an end of OpenMP directive. End of OpenMP directive is optional
whitespace, followed by '\n' or comment '!'. In the special case where a
@@ -5552,6 +5553,12 @@ gfc_match_omp_requires (void)
requires_clause = OMP_REQ_UNIFIED_SHARED_MEMORY;
if (requires_clauses & OMP_REQ_UNIFIED_SHARED_MEMORY)
goto duplicate_clause;
+
+ if (flag_offload_memory != OFFLOAD_MEMORY_UNIFIED
+ && flag_offload_memory != OFFLOAD_MEMORY_NONE)
+ gfc_error_now ("unified_shared_memory at %C is incompatible with "
+ "the selected -foffload-memory option");
+ flag_offload_memory = OFFLOAD_MEMORY_UNIFIED;
}
else if (gfc_match (clauses[3]) == MATCH_YES)
{
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 23b5adca0fe..eefd1cb9e43 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,11 @@
+2022-03-10 Andrew Stubbs <ams@codesourcery.com>
+
+ Backport of the patch posted at
+ https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591351.html
+
+ * c-c++-common/gomp/usm-1.c: New test.
+ * gfortran.dg/gomp/usm-1.f90: New test.
+
2022-03-09 Abid Qadeer <abidh@codesourcery.com>
Backport of a patch posted at
diff --git a/gcc/testsuite/c-c++-common/gomp/usm-1.c b/gcc/testsuite/c-c++-common/gomp/usm-1.c
new file mode 100644
index 00000000000..619c21a83f4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/usm-1.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-foffload-memory=pinned" } */
+
+#pragma omp requires unified_shared_memory /* { dg-error "unified_shared_memory is incompatible with the selected -foffload-memory option" } */
diff --git a/gcc/testsuite/gfortran.dg/gomp/usm-1.f90 b/gcc/testsuite/gfortran.dg/gomp/usm-1.f90
new file mode 100644
index 00000000000..340f6bb50a5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/usm-1.f90
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! { dg-additional-options "-foffload-memory=pinned" }
+
+!$omp requires unified_shared_memory ! { dg-error "unified_shared_memory at .* is incompatible with the selected -foffload-memory option" }
+
+end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-14 10:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 10:26 [gcc/devel/omp/gcc-11] openmp: allow requires unified_shared_memory Hafiz Abid Qadeer
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).