]> 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)
committerAndrew Stubbs <ams@codesourcery.com>
Wed, 20 Apr 2022 13:28:17 +0000 (14:28 +0100)
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.c (c_parser_omp_requires): Check requires unified_address
for conflict with -foffload-memory=shared.

gcc/cp/ChangeLog:

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

gcc/fortran/ChangeLog:

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

gcc/ChangeLog:

* omp-low.c: 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.c
gcc/cp/ChangeLog.omp
gcc/cp/parser.c
gcc/fortran/ChangeLog.omp
gcc/fortran/openmp.c
gcc/omp-low.c
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 1141e72ebc58ed1866beefc8911e1cd5e46017aa..e260341d53aaa45888c277878cdad7b28543f40a 100644 (file)
@@ -1,3 +1,7 @@
+2022-04-20  Andrew Stubbs  <ams@codesourcery.com>
+
+       * omp-low.c: Do USM transformations for "unified_address".
+
 2022-04-02  Andrew Stubbs  <ams@codesourcery.com>
 
        * omp-low.c (usm_transform): Transform omp_target_alloc and
index 71098232cb3e01707a8520d6fa1cef3a7d3a1248..502bd7f14eb487728ece5f4f7d8e4fdc2146af12 100644 (file)
@@ -1,3 +1,8 @@
+2022-04-20  Andrew Stubbs  <ams@codesourcery.com>
+
+       * c-parser.c (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 1240877019327e6ce0fe629edc1e88c4e32dd310..9a3d0cb8cead83698077af5e0804bd882eb8ac23 100644 (file)
@@ -22531,18 +22531,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 58ebce0523cce26b23c1a24c0ea35e20890424ff..e95124f119553b1429a632bf2155a2efdcbd40d8 100644 (file)
@@ -1,3 +1,8 @@
+2022-04-20  Andrew Stubbs  <ams@codesourcery.com>
+
+       * parser.c (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 fd9f62f45437f58cd579eef0bdb4502ae02ce8f8..3a9ea272f107c00f51be2f5d72734bd46ed9905d 100644 (file)
@@ -46406,18 +46406,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 bbf6c8efabcf32d4e7d543510f5a9af3ea396a44..cd390aa194c020dba81baaf959f8132a0da4eb32 100644 (file)
@@ -1,3 +1,8 @@
+2022-04-20  Andrew Stubbs  <ams@codesourcery.com>
+
+       * openmp.c (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 ac4126bd7ea1ee8e0ccbb46d47c4d59fd3fedb5d..ece04c03a681e376f49576cc926cdcb9d9ece72f 100644 (file)
@@ -5546,6 +5546,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 4653370aa41857017fa6835fb5e8b8adce0263f4..ce30f53dbb59c97f725b2dcc5149d63774ff5dc5 100644 (file)
@@ -16008,7 +16008,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 66349b3ceda0a1f3fca73bebaf8154c2a948d42a..9021abbea511fc1ffa7eda63f6b3ed877f47dbd9 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