]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: unified_address support
authorAndrew Stubbs <ams@codesourcery.com>
Wed, 13 Apr 2022 15:55:47 +0000 (16:55 +0100)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 28 Jun 2022 20:55:25 +0000 (13:55 -0700)
This makes "requires unified_address" work by making it eqivalent to
"requires unified_shared_memory".  This is more than is strictly necessary,
but should be standard compliant.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_requires): Check requires unified_address
for conflict with -foffload-memory=shared.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_requires): Check requires unified_address
for conflict with -foffload-memory=shared.

gcc/fortran/ChangeLog:

* openmp.cc (gfc_match_omp_requires): Check requires unified_address
for conflict with -foffload-memory=shared.

gcc/ChangeLog:

* omp-low.cc: Do USM transformations for "unified_address".

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/usm-4.c: New test.
* gfortran.dg/gomp/usm-4.f90: New test.

gcc/ChangeLog.omp
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/omp-low.cc
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/gomp/usm-4.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/usm-4.f90 [new file with mode: 0644]

index a98d8b3cfedebb47176c3cbc4a8fef0553d2f205..a971ba0acf1318cf4eebb7a76aac7342c0787d95 100644 (file)
@@ -1,3 +1,7 @@
+2022-04-20  Andrew Stubbs  <ams@codesourcery.com>
+
+       * omp-low.cc: Do USM transformations for "unified_address".
+
 2022-04-02  Andrew Stubbs  <ams@codesourcery.com>
 
        * omp-low.cc (usm_transform): Transform omp_target_alloc and
index a918af2a22f97f2a634bceddc204212431196db7..a2284db471f929726cbcb3d41944a873babb2b96 100644 (file)
@@ -1,3 +1,8 @@
+2022-04-20  Andrew Stubbs  <ams@codesourcery.com>
+
+       * c-parser.cc (c_parser_omp_requires): Check requires unified_address
+       for conflict with -foffload-memory=shared.
+
 2022-03-10  Andrew Stubbs <ams@codesourcery.com>
 
        Backport of the patch posted at
index cd04c6902cbe5960647e37e5aa7a3d7ee2b95e84..b234d0b388047dc64e094934f14ec0a96d08ea0f 100644 (file)
@@ -22625,18 +22625,27 @@ c_parser_omp_requires (c_parser *parser)
          enum omp_requires this_req = (enum omp_requires) 0;
 
          if (!strcmp (p, "unified_address"))
-           this_req = OMP_REQUIRES_UNIFIED_ADDRESS;
+           {
+             this_req = OMP_REQUIRES_UNIFIED_ADDRESS;
+
+             if (flag_offload_memory != OFFLOAD_MEMORY_UNIFIED
+                 && flag_offload_memory != OFFLOAD_MEMORY_NONE)
+               error_at (cloc,
+                         "unified_address is incompatible with the "
+                         "selected -foffload-memory option");
+             flag_offload_memory = OFFLOAD_MEMORY_UNIFIED;
+           }
          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;
-         }
+           {
+             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 0e90645e09454422b6123a64a53bfe6454e18a38..316b5730ca25b117fd8de7b7e0105e8874f93ba2 100644 (file)
@@ -1,3 +1,8 @@
+2022-04-20  Andrew Stubbs  <ams@codesourcery.com>
+
+       * parser.cc (cp_parser_omp_requires): Check requires unified_address
+       for conflict with -foffload-memory=shared.
+
 2022-03-10  Andrew Stubbs <ams@codesourcery.com>
 
        Backport of the patch posted at
index 8b76ea740b83af094f8af45c2dd4dbfd4e7c22ce..f4f655f6cc3274e825f69b9ec96307ebb72acc19 100644 (file)
@@ -46919,18 +46919,27 @@ cp_parser_omp_requires (cp_parser *parser, cp_token *pragma_tok)
          enum omp_requires this_req = (enum omp_requires) 0;
 
          if (!strcmp (p, "unified_address"))
-           this_req = OMP_REQUIRES_UNIFIED_ADDRESS;
+           {
+             this_req = OMP_REQUIRES_UNIFIED_ADDRESS;
+
+             if (flag_offload_memory != OFFLOAD_MEMORY_UNIFIED
+                 && flag_offload_memory != OFFLOAD_MEMORY_NONE)
+               error_at (cloc,
+                         "unified_address is incompatible with the "
+                         "selected -foffload-memory option");
+             flag_offload_memory = OFFLOAD_MEMORY_UNIFIED;
+           }
          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;
-         }
+           {
+             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 d172be951234c6bdac26d9e3723a433bb9d9d695..791dba879c08f8d6bba5ca5ceb74827ef54a3992 100644 (file)
@@ -1,3 +1,8 @@
+2022-04-20  Andrew Stubbs  <ams@codesourcery.com>
+
+       * openmp.cc (gfc_match_omp_requires): Check requires unified_address
+       for conflict with -foffload-memory=shared.
+
 2022-03-10  Andrew Stubbs <ams@codesourcery.com>
 
        Backport of the patch posted at
index 0067415e48905287525559822b0206d91bb72d25..61a5e0410ba3fcb67190d281d21d3aee97faeac5 100644 (file)
@@ -5557,6 +5557,12 @@ gfc_match_omp_requires (void)
          requires_clause = OMP_REQ_UNIFIED_ADDRESS;
          if (requires_clauses & OMP_REQ_UNIFIED_ADDRESS)
            goto duplicate_clause;
+
+         if (flag_offload_memory != OFFLOAD_MEMORY_UNIFIED
+             && flag_offload_memory != OFFLOAD_MEMORY_NONE)
+           gfc_error_now ("unified_address at %C is incompatible with "
+                          "the selected -foffload-memory option");
+         flag_offload_memory = OFFLOAD_MEMORY_UNIFIED;
        }
       else if (gfc_match (clauses[2]) == MATCH_YES)
        {
index 0734a4e9743623cc4311165e0e16b2b780d3046b..dc450c62ef4faeee3a9928f07fba6089bf51ba8a 100644 (file)
@@ -16267,7 +16267,8 @@ public:
   {
     return (flag_openmp || flag_openmp_simd)
            && (flag_offload_memory == OFFLOAD_MEMORY_UNIFIED
-               || omp_requires_mask & OMP_REQUIRES_UNIFIED_SHARED_MEMORY);
+               || omp_requires_mask & OMP_REQUIRES_UNIFIED_SHARED_MEMORY
+               || omp_requires_mask & OMP_REQUIRES_UNIFIED_ADDRESS);
   }
   virtual unsigned int execute (function *)
   {
index 9d8026e00065d90d5bb5e7cde3553c236f705e24..8ebaa141543d8bd78bb608027299b07a532d9748 100644 (file)
@@ -1,3 +1,8 @@
+2022-04-20  Andrew Stubbs  <ams@codesourcery.com>
+
+       * c-c++-common/gomp/usm-4.c: New test.
+       * gfortran.dg/gomp/usm-4.f90: New test.
+
 2022-04-02  Andrew Stubbs  <ams@codesourcery.com>
 
        * c-c++-common/gomp/usm-2.c: Add omp_target_alloc.
diff --git a/gcc/testsuite/c-c++-common/gomp/usm-4.c b/gcc/testsuite/c-c++-common/gomp/usm-4.c
new file mode 100644 (file)
index 0000000..b19664e
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-foffload-memory=pinned" } */
+
+#pragma omp requires unified_address        /* { dg-error "unified_address is incompatible with the selected -foffload-memory option" } */
diff --git a/gcc/testsuite/gfortran.dg/gomp/usm-4.f90 b/gcc/testsuite/gfortran.dg/gomp/usm-4.f90
new file mode 100644 (file)
index 0000000..725b07f
--- /dev/null
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! { dg-additional-options "-foffload-memory=pinned" }
+
+!$omp requires unified_address  ! { dg-error "unified_address at .* is incompatible with the selected -foffload-memory option" }
+
+end