From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 43AFA385800F; Fri, 27 Nov 2020 22:14:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 43AFA385800F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: QTVQlvUQG7Fq3FlobOOrFsJLauqQCg2DHkXgdEi335/RW8VUSFqYC0NQw6qVNAEf54Cw3h9Y4M xv4Y+DiXZWLvMwbov/+1LwOGfXeu/BPqPVh4WcJv3GoniCzgTD6gYWFAoiSrf7kviG9KWDxf9H hPSIaqmQMOStFORxoIlskGNAgzM5yYnc/O4rl4d9J0BH5/LsJ3ahhpcc5P5fKDBX2ySzSXDY7L Ul4AfzOow++2+cCdrK/jTGnc3/cnvPihDIfGp0KfGDLDaZqrkTPUjhrwOS8CMaFQR/AOdFChMp +UM= X-IronPort-AV: E=Sophos;i="5.78,375,1599552000"; d="diff'?scan'208";a="55544761" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 27 Nov 2020 14:14:08 -0800 IronPort-SDR: kQNyO+lfqBfPkOsBtldpzmaLWPfZJ6OBAb/ok/8ykE/5fzt1UlWYJ4a4+6KxViCYW+Du5QG6/6 0M75KCNjqSzN+D91z5zZD8FVaNPj9PqAndIqaCWnJbQBgDzjUeAHtEHmNsBRMkxQ2UyQZRJT+f TSbtqOO95zUOb86pJKmUeL7NJLhCC6yXjWkNqWppnxs+HGHZQfy7MLKZ3ahFDycfA+EqMgyWgw UQmMBdDCI476DAm7Nam00eUNVP2WOla6+4MEAZ88gS3D1j5apZiQ5rR9VAIWtVVbUSNaT79RKl 1Qw= Subject: Re: Fortran: With OpenACC, ignore OpenMP's cond comp sentinels [PR98011] To: Jakub Jelinek , gcc-patches CC: Thomas Schwinge , fortran References: <344cae01-4b4d-1e6c-afb6-c8e869b140a2@codesourcery.com> <20201127173122.GI3788@tucnak> From: Tobias Burnus Message-ID: <8daa25d7-64af-bafd-368d-7746b5697cb8@codesourcery.com> Date: Fri, 27 Nov 2020 23:14:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201127173122.GI3788@tucnak> Content-Type: multipart/mixed; boundary="------------DE3B3DCA7A7510EFE5686794" Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Nov 2020 22:14:12 -0000 --------------DE3B3DCA7A7510EFE5686794 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable On 27.11.20 18:31, Jakub Jelinek via Fortran wrote: > Depends on what does the OpenACC standard say. > If it has similar wording to OpenMP that '!$ ' stands ... It only has '!$acc' (free) and !$acc + c$acc + *$acc (fixed). cf. https://www.openacc.org/sites/default/files/inline-images/Specification= /OpenACC-3.1-final.pdf (2.1 Directive Form) > .. if it is silent on that, then the patch is correct. > > What about fixed-form parsing? Missed that somehow. I have now added two fixed-form testcases (goacc + goacc-gomp) and a free one (goacc-gomp). Thanks, Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstra=C3=9Fe 201, 80634 M=C3=BCnch= en / Germany Registergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas = Heurung, Alexander Walter --------------DE3B3DCA7A7510EFE5686794 Content-Type: text/x-patch; charset="UTF-8"; name="oacc-scanner-v2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="oacc-scanner-v2.diff" Fortran: With OpenACC, ignore OpenMP's cond comp sentinels gcc/fortran/ChangeLog: PR fortran/98011 * scanner.c (skip_free_comments, skip_fixed_comments): If only -fopenacc but not -fopenmp is used, ignore OpenMP's conditional compilation sentinels. Fix indentation, use 'else if' for readability. gcc/testsuite/ChangeLog: PR fortran/98011 * gfortran.dg/goacc/sentinel-free-form.f95: * gfortran.dg/goacc-gomp/fixed-1.f: New test. * gfortran.dg/goacc-gomp/free-1.f: New test. * gfortran.dg/goacc/fixed-5.f: New test. gcc/fortran/scanner.c | 32 +++------ gcc/testsuite/gfortran.dg/goacc-gomp/fixed-1.f | 81 ++++++++++++++++++++++ gcc/testsuite/gfortran.dg/goacc-gomp/free-1.f90 | 34 +++++++++ gcc/testsuite/gfortran.dg/goacc/fixed-5.f | 30 ++++++++ .../gfortran.dg/goacc/sentinel-free-form.f95 | 7 +- 5 files changed, 161 insertions(+), 23 deletions(-) diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index fd11f5a244a..304ae2d8d6a 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -899,21 +899,14 @@ skip_free_comments (void) if (next_char () == '$') { c = next_char (); - if (c == 'a' || c == 'A') - { - if (skip_free_oacc_sentinel (start, old_loc)) - return false; - gfc_current_locus = old_loc; - next_char(); - c = next_char(); - } - if (continue_flag || c == ' ' || c == '\t') - { - gfc_current_locus = old_loc; - next_char(); - openacc_flag = 0; - return true; - } + if (c == 'a' || c == 'A') + { + if (skip_free_oacc_sentinel (start, old_loc)) + return false; + gfc_current_locus = old_loc; + next_char(); + c = next_char(); + } } gfc_current_locus = old_loc; } @@ -1076,8 +1069,7 @@ skip_fixed_comments (void) } gfc_current_locus = start; } - - if (flag_openacc && !(flag_openmp || flag_openmp_simd)) + else if (flag_openacc && !(flag_openmp || flag_openmp_simd)) { if (next_char () == '$') { @@ -1087,13 +1079,10 @@ skip_fixed_comments (void) if (skip_fixed_oacc_sentinel (&start)) return; } - else - goto check_for_digits; } gfc_current_locus = start; } - - if (flag_openacc || flag_openmp || flag_openmp_simd) + else if (flag_openacc || flag_openmp || flag_openmp_simd) { if (next_char () == '$') { @@ -1120,6 +1109,7 @@ skip_fixed_comments (void) gcc_unreachable (); check_for_digits: { + /* Required for OpenMP's conditional compilation sentinel. */ int digit_seen = 0; for (col = 3; col < 6; col++, c = next_char ()) diff --git a/gcc/testsuite/gfortran.dg/goacc-gomp/fixed-1.f b/gcc/testsuite/gfortran.dg/goacc-gomp/fixed-1.f new file mode 100644 index 00000000000..b6bab4ce902 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc-gomp/fixed-1.f @@ -0,0 +1,81 @@ +! { dg-additional-options "-fdump-tree-original -Wunused-variable" } + implicit none + integer :: a,b,c,d,e,f,g,h,i,j,k,ll + +c$bogus +!$bogus +*$bogus + +c$ bogus +!$ bogus +*$ bogus + +c$a23 bogus +!$ a bogus +*$12a bogus + +! The following should be parsed as OpenMP conditional sentinel +! If not, expect a unused-variable warning + +c$ a = 1 +!$ b = 2 +*$ c = 3 + +c$ 1 d = 4 +!$ 22 e = 5 +*$34 f = 6 + +c$ g = +c$ *7 +!$ 2 h = +*$ & 8 +*$ 3 i +!$ & = 9 + +c$ j +*$ &= +c$ *10 +!$ 5 k +*$ * = +c$ & 1 +*$ & 1 +*$9 9 ll +!$ & = +!$ * 12 + +c$ bogus +!$ bogus +*$ bogus + +c$bogus +!$bogus +*$bogus + +c$ acc bogus +!$ acc bogus +*$ acc bogus + +c$ omp bogus +!$ omp bogus +*$ omp bogus + end + +!{ dg-final { scan-tree-dump-times "a = 1;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "b = 2;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "c = 3;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "d = 4;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "e = 5;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "f = 6;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "g = 7;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "h = 8;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "i = 9;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "j = 10;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "k = 11;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "ll = 12;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "__label_000001:;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "__label_000022:;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "__label_000034:;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "__label_000002:;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "__label_000003:;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "__label_000005:;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "__label_000099:;" 1 "original" } } diff --git a/gcc/testsuite/gfortran.dg/goacc-gomp/free-1.f90 b/gcc/testsuite/gfortran.dg/goacc-gomp/free-1.f90 new file mode 100644 index 00000000000..0d6f2b2e3a6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc-gomp/free-1.f90 @@ -0,0 +1,34 @@ +! { dg-additional-options "-fdump-tree-original -Wunused-variable" } +implicit none +integer :: a,b,c,d,e,f,g,h + +!$bogus + + !$bogus +!$& bogus + !$& bogus + +!$ a = 1 +!$ b = 2 +!$ c = & +!$3 + +!$ d = & +!$&4 + + !$ e = 5 + !$ f = 6 + !$ g = & + !$7 + + !$ h = & +!$&8 + end + +!{ dg-final { scan-tree-dump-times "a = 1;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "b = 2;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "c = 3;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "d = 4;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "e = 5;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "f = 6;" 1 "original" } } +!{ dg-final { scan-tree-dump-times "g = 7;" 1 "original" } } diff --git a/gcc/testsuite/gfortran.dg/goacc/fixed-5.f b/gcc/testsuite/gfortran.dg/goacc/fixed-5.f new file mode 100644 index 00000000000..ab51b218d80 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/fixed-5.f @@ -0,0 +1,30 @@ +! Check that OpenMP conditional compilations sentinels ('!$ ') are ignored + +c$ bogus +!$ bogus +*$ bogus +c$ bogus +!$ bogus +*$ bogus + +c$a23 bogus +!$ a bogus +*$12a bogus + +c$ 1 bogus +!$ 22 bogus +*$34 bogus + +c$bogus +!$bogus +*$bogus + +c$ acc bogus +!$ acc bogus +*$ acc bogus + +c$ acc bogus +!$ acc bogus +*$ acc bogus + + end diff --git a/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95 b/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95 index 1a3189cb34e..00dac667ef1 100644 --- a/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95 @@ -10,7 +10,10 @@ program test x = 0.0 !$acc parallel ! comment ! sentinel must appear as a single word ! $acc parallel ! comment - !$ acc parallel ! { dg-error "Unclassifiable statement" } + + ! note that '!$ ' is OpenMP's conditional compilation sentinel + !$ acc ignored_due_to_space ! comment + ! directive lines must have space after sentinel !$accparallel ! { dg-warning "followed by a space" } do i = 1,10 @@ -18,4 +21,4 @@ program test enddo !$acc end parallel ! { dg-error "Unexpected" } print *, x -end \ No newline at end of file +end --------------DE3B3DCA7A7510EFE5686794--