diff options
author | Andrew Stubbs <ams@codesourcery.com> | 2022-04-13 16:55:47 +0100 |
---|---|---|
committer | Andrew Stubbs <ams@codesourcery.com> | 2022-04-20 14:28:17 +0100 |
commit | f0bde8aba15fcec3f6c07c7f05de56a3995fe9bf (patch) | |
tree | 6a318bf81f40295b80523f95b0cc5fb67fbd01ab | |
parent | a82e01cd8ab7088dd68cd65b3e47e2162296cff5 (diff) | |
download | gcc-f0bde8aba15fcec3f6c07c7f05de56a3995fe9bf.zip gcc-f0bde8aba15fcec3f6c07c7f05de56a3995fe9bf.tar.gz gcc-f0bde8aba15fcec3f6c07c7f05de56a3995fe9bf.tar.bz2 |
openmp: unified_address support
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.
-rw-r--r-- | gcc/ChangeLog.omp | 4 | ||||
-rw-r--r-- | gcc/c/ChangeLog.omp | 5 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 31 | ||||
-rw-r--r-- | gcc/cp/ChangeLog.omp | 5 | ||||
-rw-r--r-- | gcc/cp/parser.c | 31 | ||||
-rw-r--r-- | gcc/fortran/ChangeLog.omp | 5 | ||||
-rw-r--r-- | gcc/fortran/openmp.c | 6 | ||||
-rw-r--r-- | gcc/omp-low.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog.omp | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/usm-4.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/usm-4.f90 | 6 |
11 files changed, 82 insertions, 23 deletions
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index 1141e72..e260341 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -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 diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp index 7109823..502bd7f 100644 --- a/gcc/c/ChangeLog.omp +++ b/gcc/c/ChangeLog.omp @@ -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 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 1240877..9a3d0cb 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -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")) diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp index 58ebce0..e95124f 100644 --- a/gcc/cp/ChangeLog.omp +++ b/gcc/cp/ChangeLog.omp @@ -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 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index fd9f62f..3a9ea27 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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")) diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index bbf6c8e..cd390aa 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -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 diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index ac4126b..ece04c0 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -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) { diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 4653370..ce30f53 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -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 *) { diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 66349b3..9021abb 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -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 index 0000000..b19664e --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/usm-4.c @@ -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 index 0000000..725b07f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/usm-4.f90 @@ -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 |