From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7845) id 738253848039; Fri, 21 May 2021 13:04:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 738253848039 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Marcel Vollweiler To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] Fortran/OpenMP: Add support for 'close' in map clause X-Act-Checkin: gcc X-Git-Author: Marcel Vollweiler X-Git-Refname: refs/heads/devel/omp/gcc-11 X-Git-Oldrev: 41a85e38f14c1230e1ab21770f7ec2960f138b1e X-Git-Newrev: a41b3c2af85737f9fe041a264c805bd96f978bfa Message-Id: <20210521130409.738253848039@sourceware.org> Date: Fri, 21 May 2021 13:04:09 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 13:04:09 -0000 https://gcc.gnu.org/g:a41b3c2af85737f9fe041a264c805bd96f978bfa commit a41b3c2af85737f9fe041a264c805bd96f978bfa Author: Marcel Vollweiler 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 + + 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 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 % modifiers at %L", + &second_always_locus); + break; + } + if (close_modifier > 1) + { + gfc_error ("too many % 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 + + 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 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