public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Stubbs <ams@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] openmp: unified_address support Date: Wed, 20 Apr 2022 13:28:42 +0000 (GMT) [thread overview] Message-ID: <20220420132842.BA9A83858C53@sourceware.org> (raw) https://gcc.gnu.org/g:f0bde8aba15fcec3f6c07c7f05de56a3995fe9bf commit f0bde8aba15fcec3f6c07c7f05de56a3995fe9bf Author: Andrew Stubbs <ams@codesourcery.com> Date: Wed Apr 13 16:55:47 2022 +0100 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. Diff: --- gcc/ChangeLog.omp | 4 ++++ gcc/c/ChangeLog.omp | 5 +++++ gcc/c/c-parser.c | 31 ++++++++++++++++++++----------- gcc/cp/ChangeLog.omp | 5 +++++ gcc/cp/parser.c | 31 ++++++++++++++++++++----------- gcc/fortran/ChangeLog.omp | 5 +++++ gcc/fortran/openmp.c | 6 ++++++ gcc/omp-low.c | 3 ++- gcc/testsuite/ChangeLog.omp | 5 +++++ gcc/testsuite/c-c++-common/gomp/usm-4.c | 4 ++++ 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 1141e72ebc5..e260341d53a 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 71098232cb3..502bd7f14eb 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 12408770193..9a3d0cb8cea 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 58ebce0523c..e95124f1195 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 fd9f62f4543..3a9ea272f10 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 bbf6c8efabc..cd390aa194c 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 ac4126bd7ea..ece04c03a68 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 4653370aa41..ce30f53dbb5 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 66349b3ceda..9021abbea51 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 00000000000..b19664e9b66 --- /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 00000000000..725b07f2f88 --- /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
reply other threads:[~2022-04-20 13:28 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220420132842.BA9A83858C53@sourceware.org \ --to=ams@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).