public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Marcel Vollweiler <marcel@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] Fortran/OpenMP: Add support for 'close' in map clause Date: Fri, 21 May 2021 13:04:09 +0000 (GMT) [thread overview] Message-ID: <20210521130409.738253848039@sourceware.org> (raw) https://gcc.gnu.org/g:a41b3c2af85737f9fe041a264c805bd96f978bfa commit a41b3c2af85737f9fe041a264c805bd96f978bfa Author: Marcel Vollweiler <marcel@codesourcery.com> Date: Fri May 21 05:32:46 2021 -0700 Fortran/OpenMP: Add support for 'close' in map clause gcc/fortran/ChangeLog: * openmp.c (gfc_match_omp_clauses): Support map-type-modifier 'close'. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/map-6.f90: New test. * gfortran.dg/gomp/map-7.f90: New test. * gfortran.dg/gomp/map-8.f90: New test. (cherry picked from commit cdcec2f8505ea12c2236cf0184d77dd2f5de4832) Diff: --- gcc/fortran/ChangeLog.omp | 6 ++++ gcc/fortran/openmp.c | 55 ++++++++++++++++++++++++++------ gcc/testsuite/ChangeLog.omp | 8 +++++ gcc/testsuite/gfortran.dg/gomp/map-6.f90 | 50 +++++++++++++++++++++++++++++ gcc/testsuite/gfortran.dg/gomp/map-7.f90 | 26 +++++++++++++++ gcc/testsuite/gfortran.dg/gomp/map-8.f90 | 34 ++++++++++++++++++++ 6 files changed, 169 insertions(+), 10 deletions(-) diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index f59fea039c0..9810cecc01f 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,9 @@ +2021-05-21 Marcel Vollweiler <marcel@codesourcery.com> + + Fortran/OpenMP: Add support for 'close' in map clause + + * openmp.c (gfc_match_omp_clauses): Support map-type-modifier 'close'. + 2021-05-18 Tobias Burnus <tobias@codesourcery.com> Backported from master: diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index eaddca5212b..6c1fe468a0e 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -1712,27 +1712,62 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, && gfc_match ("map ( ") == MATCH_YES) { locus old_loc2 = gfc_current_locus; - bool always = false; + int always_modifier = 0; + int close_modifier = 0; + locus second_always_locus = old_loc2; + locus second_close_locus = old_loc2; + + for (;;) + { + locus current_locus = gfc_current_locus; + if (gfc_match ("always ") == MATCH_YES) + { + if (always_modifier++ == 1) + second_always_locus = current_locus; + } + else if (gfc_match ("close ") == MATCH_YES) + { + if (close_modifier++ == 1) + second_close_locus = current_locus; + } + else + break; + gfc_match (", "); + } + gfc_omp_map_op map_op = OMP_MAP_TOFROM; - if (gfc_match ("always , ") == MATCH_YES) - always = true; if (gfc_match ("alloc : ") == MATCH_YES) map_op = OMP_MAP_ALLOC; else if (gfc_match ("tofrom : ") == MATCH_YES) - map_op = always ? OMP_MAP_ALWAYS_TOFROM : OMP_MAP_TOFROM; + map_op = always_modifier ? OMP_MAP_ALWAYS_TOFROM : OMP_MAP_TOFROM; else if (gfc_match ("to : ") == MATCH_YES) - map_op = always ? OMP_MAP_ALWAYS_TO : OMP_MAP_TO; + map_op = always_modifier ? OMP_MAP_ALWAYS_TO : OMP_MAP_TO; else if (gfc_match ("from : ") == MATCH_YES) - map_op = always ? OMP_MAP_ALWAYS_FROM : OMP_MAP_FROM; + map_op = always_modifier ? OMP_MAP_ALWAYS_FROM : OMP_MAP_FROM; else if (gfc_match ("release : ") == MATCH_YES) map_op = OMP_MAP_RELEASE; else if (gfc_match ("delete : ") == MATCH_YES) map_op = OMP_MAP_DELETE; - else if (always) + else { gfc_current_locus = old_loc2; - always = false; + always_modifier = 0; + close_modifier = 0; } + + if (always_modifier > 1) + { + gfc_error ("too many %<always%> modifiers at %L", + &second_always_locus); + break; + } + if (close_modifier > 1) + { + gfc_error ("too many %<close%> modifiers at %L", + &second_close_locus); + break; + } + head = NULL; if (gfc_match_omp_variable_list ("", &c->lists[OMP_LIST_MAP], false, NULL, &head, @@ -1743,8 +1778,8 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, n->u.map_op = map_op; continue; } - else - gfc_current_locus = old_loc; + gfc_current_locus = old_loc; + break; } if ((mask & OMP_CLAUSE_MERGEABLE) && !c->mergeable && gfc_match ("mergeable") == MATCH_YES) diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index afc5c93c3fc..5ab58ec30ba 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,11 @@ +2021-05-21 Marcel Vollweiler <marcel@codesourcery.com> + + Fortran/OpenMP: Add support for 'close' in map clause + + * gfortran.dg/gomp/map-6.f90: New test. + * gfortran.dg/gomp/map-7.f90: New test. + * gfortran.dg/gomp/map-8.f90: New test. + 2021-05-20 Tobias Burnus <tobias@codesourcery.com> Backported from master: diff --git a/gcc/testsuite/gfortran.dg/gomp/map-6.f90 b/gcc/testsuite/gfortran.dg/gomp/map-6.f90 new file mode 100644 index 00000000000..309f8454333 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/map-6.f90 @@ -0,0 +1,50 @@ +! { dg-additional-options "-fdump-tree-original" } + +implicit none + +integer :: a, b, b1, b2, b3, b4, b5, b6 + +!$omp target map(a) +!$omp end target + +!$omp target map(to : a) +!$omp end target + +!$omp target map(always to: a) +!$omp end target +!$omp target map(always, to: a) +!$omp end target +!$omp target map(close to: a) +!$omp end target +!$omp target map(close, to: a) +!$omp end target + +!$omp target map(close always to:b1) +!$omp end target +!$omp target map(close, always to:b2) +!$omp end target +!$omp target map(close, always, to:b3) +!$omp end target +!$omp target map(always close to:b4) +!$omp end target +!$omp target map(always, close to:b5) +!$omp end target +!$omp target map(always, close, to:b6) +!$omp end target + + +!$omp target map (always to : a) map (close to : b) +!$omp end target + +end + +! { dg-final { scan-tree-dump-not "map\\(\[^\n\r)]*close\[^\n\r)]*to:" "original" } } + +! { dg-final { scan-tree-dump-times "#pragma omp target map\\(always,to:" 9 "original" } } + +! { dg-final { scan-tree-dump "#pragma omp target map\\(always,to:b1\\)" "original" } } +! { dg-final { scan-tree-dump "#pragma omp target map\\(always,to:b2\\)" "original" } } +! { dg-final { scan-tree-dump "#pragma omp target map\\(always,to:b3\\)" "original" } } +! { dg-final { scan-tree-dump "#pragma omp target map\\(always,to:b4\\)" "original" } } +! { dg-final { scan-tree-dump "#pragma omp target map\\(always,to:b5\\)" "original" } } +! { dg-final { scan-tree-dump "#pragma omp target map\\(always,to:b6\\)" "original" } } diff --git a/gcc/testsuite/gfortran.dg/gomp/map-7.f90 b/gcc/testsuite/gfortran.dg/gomp/map-7.f90 new file mode 100644 index 00000000000..009c6d49547 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/map-7.f90 @@ -0,0 +1,26 @@ +! { dg-additional-options "-fdump-tree-original" } + +implicit none + +integer :: a, b, close, always, to + +!$omp target map(close) +!$omp end target + +!$omp target map(always) +!$omp end target + +!$omp target map(always, close) +!$omp end target + +!$omp target map(always, close, to : always, close, a) +!$omp end target + +!$omp target map(to, always, close) +!$omp end target + +end + +! { dg-final { scan-tree-dump-not "map\\(\[^\n\r)]*close\[^\n\r)]*to:" "original" } } +! { dg-final { scan-tree-dump "#pragma omp target map\\(always,to:always\\) map\\(always,to:close\\) map\\(always,to:a\\)" "original" } } +! { dg-final { scan-tree-dump-not "map\\(\[^\n\r)]*close\[^\n\r)]*to:" "original" } } diff --git a/gcc/testsuite/gfortran.dg/gomp/map-8.f90 b/gcc/testsuite/gfortran.dg/gomp/map-8.f90 new file mode 100644 index 00000000000..92b802c67ed --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/map-8.f90 @@ -0,0 +1,34 @@ +implicit none + +integer :: a + +!$omp target map(close, delete: a) ! { dg-error "TARGET with map-type other than TO, FROM, TOFROM, or ALLOC on MAP clause at \\(1\\)" } +!$omp end target + +!$omp target map(close) ! { dg-error "Symbol 'close' at \\(1\\) has no IMPLICIT type" } +!$omp end target + +!$omp target map(always) ! { dg-error "Symbol 'always' at \\(1\\) has no IMPLICIT type" } +!$omp end target + +!$omp target map(always, always, to : a) ! { dg-error "too many 'always' modifiers" } +! !$omp end target +!$omp target map(always always, to : a) ! { dg-error "too many 'always' modifiers" } +! !$omp end target +!$omp target map(always, always to : a) ! { dg-error "too many 'always' modifiers" } +! !$omp end target +!$omp target map(always always to : a) ! { dg-error "too many 'always' modifiers" } +! !$omp end target +!$omp target map(close, close, to : a) ! { dg-error "too many 'close' modifiers" } +! !$omp end target +!$omp target map(close close, to : a) ! { dg-error "too many 'close' modifiers" } +! !$omp end target +!$omp target map(close, close to : a) ! { dg-error "too many 'close' modifiers" } +! !$omp end target +!$omp target map(close close to : a) ! { dg-error "too many 'close' modifiers" } +! !$omp end target + +!$omp target map(close close always always to : a) ! { dg-error "too many 'always' modifiers" } +! !$omp end target + +end
reply other threads:[~2021-05-21 13:04 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=20210521130409.738253848039@sourceware.org \ --to=marcel@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).