]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: allow requires unified_shared_memory
authorAndrew Stubbs <ams@codesourcery.com>
Thu, 10 Mar 2022 21:38:54 +0000 (21:38 +0000)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 28 Jun 2022 20:55:23 +0000 (13:55 -0700)
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.cc (c_parser_omp_requires): Check compatibility of
-foffload-memory option with requires directive.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_requires): Check compatibility of
-foffload-memory option with requires directive.

gcc/fortran/ChangeLog:

* openmp.cc (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.

gcc/c/ChangeLog.omp
gcc/c/c-parser.cc
gcc/cp/ChangeLog.omp
gcc/cp/parser.cc
gcc/fortran/ChangeLog.omp
gcc/fortran/openmp.cc
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/gomp/usm-1.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/usm-1.f90 [new file with mode: 0644]

index 11d0bbe781813a54d33f8adf630a71f57948d97a..a918af2a22f97f2a634bceddc204212431196db7 100644 (file)
@@ -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.cc (c_parser_omp_requires): Check compatibility of
+       -foffload-memory option with requires directive.
+
 2022-02-24  Chung-Lin Tang  <cltang@codesourcery.com>
 
        * c-typeck.cc (handle_omp_array_sections): Add handling for
index 60734268f7eeb1a211f75f190b514968636db4ac..cd04c6902cbe5960647e37e5aa7a3d7ee2b95e84 100644 (file)
@@ -22627,7 +22627,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"))
index b0f96782d48e7eecea7e3bae251b9f7807d2785d..0e90645e09454422b6123a64a53bfe6454e18a38 100644 (file)
@@ -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.cc (cp_parser_omp_requires): Check compatibility of
+       -foffload-memory option with requires directive.
+
 2022-02-24  Chung-Lin Tang  <cltang@codesourcery.com>
 
        * semantics.cc (handle_omp_array_sections): Add handling for
index 7377849105d7591e3efbc839e6cce7b7609324fb..8b76ea740b83af094f8af45c2dd4dbfd4e7c22ce 100644 (file)
@@ -46921,7 +46921,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"))
index 9e2b67850dff95dc18c7fd74854daa9503d552ad..d172be951234c6bdac26d9e3723a433bb9d9d695 100644 (file)
@@ -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.cc (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
index 42423585395f09840faf178b4724befeb7a3673e..0067415e48905287525559822b0206d91bb72d25 100644 (file)
@@ -5564,6 +5564,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)
        {
index 8367e4995f3dbc11e7c7856ca9fb0cbf0dbb199c..552124bda1351bab31a12e326e5f22f5b9096cb0 100644 (file)
@@ -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 (file)
index 0000000..619c21a
--- /dev/null
@@ -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 (file)
index 0000000..340f6bb
--- /dev/null
@@ -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