]> 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)
committerHafiz Abid Qadeer <abidh@codesourcery.com>
Fri, 11 Mar 2022 23:03:58 +0000 (23:03 +0000)
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.

gcc/c/ChangeLog.omp
gcc/c/c-parser.c
gcc/cp/ChangeLog.omp
gcc/cp/parser.c
gcc/fortran/ChangeLog.omp
gcc/fortran/openmp.c
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 3838d18e5712d80bbb8933d30bb01b2f8993810c..71098232cb3e01707a8520d6fa1cef3a7d3a1248 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.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:
index 1dab35b19ad79c9303b79bae23c5a70ca429173f..1240877019327e6ce0fe629edc1e88c4e32dd310 100644 (file)
@@ -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"))
index 79221b0eece88bca5021c7ea0d88c75a48c9a63b..58ebce0523cce26b23c1a24c0ea35e20890424ff 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.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:
index 15aa72ea6ad46b631157b9db7cad7efdc82223e5..fd9f62f45437f58cd579eef0bdb4502ae02ce8f8 100644 (file)
@@ -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"))
index f1c025799c3e1e51c64c9a6305afe9ff89f59791..bbf6c8efabcf32d4e7d543510f5a9af3ea396a44 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.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
index 7be015f5b3fbd6d15dee61f1c98ecd4bba03ea8c..ac4126bd7ea1ee8e0ccbb46d47c4d59fd3fedb5d 100644 (file)
@@ -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)
        {
index 23b5adca0fe3467d8a772063d15bf6428f299ad6..eefd1cb9e43875343338db0c45d13899118139e3 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