Message ID | 344cae01-4b4d-1e6c-afb6-c8e869b140a2@codesourcery.com |
---|---|
State | New |
Headers | show |
Series | Fortran: With OpenACC, ignore OpenMP's cond comp sentinels | expand |
On Fri, Nov 27, 2020 at 06:18:46PM +0100, Tobias Burnus wrote: > '!' starts in Fortran a comment (+ fixed-form variants) > OpenACC defines as sentinel "!$acc" (likewise) > But OpenMP has two: Besides "!$omp" there is additionally > "!$ " (with space) to permit conditional compilation. > > Currently, -fopenacc also executes the '!$ ' code, which I > think does not make sense. > > Hence, this patch ignores it. > Comments? If not, I intent to commit it in the next days Depends on what does the OpenACC standard say. If it has similar wording to OpenMP that '!$ ' stands for OpenACC conditional compilation, then the patch is incorrect, if it is silent on that, then the patch is correct. What about fixed-form parsing? Does it also recognize the conditional compilation in OpenACC or not? Tests should cover that too, I guess including -fopenmp -fopenacc goacc-gomp test that would test that it still works (both free form and fixed form). Jakub
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ße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
... and now committed as r11-5572-g1d6f6ac693a8601bef9fe4ba72eb6fbf7b60b5cd. Thanks again for the suggestions! Tobias On 27.11.20 23:14, Tobias Burnus wrote: > 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ße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
Fortran: With OpenACC, ignore OpenMP's cond comp sentinels gcc/fortran/ChangeLog: PR fortran/98011 * scanner.c (skip_free_comments): If only -fopenacc but not -fopenmp is used, ignore OpenMP's conditional compilation sentinels. gcc/testsuite/ChangeLog: PR fortran/98011 * gfortran.dg/goacc/sentinel-free-form.f95: Update as OpenMP's "!$ " conditional compilation sentinels are now ignored. gcc/fortran/scanner.c | 23 ++++++++-------------- .../gfortran.dg/goacc/sentinel-free-form.f95 | 7 +++++-- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index fd11f5a244a..b70728d6bd1 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; } 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