public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/pgo-reproducibility-test)] Check array contiguity for OpenACC/Fortran Date: Thu, 30 Jan 2020 08:53:00 -0000 [thread overview] Message-ID: <20200130085138.53407.qmail@sourceware.org> (raw) https://gcc.gnu.org/g:a5ed4958a2c1b563e933b25ca3b481761cc40b07 commit a5ed4958a2c1b563e933b25ca3b481761cc40b07 Author: Julian Brown <julian@codesourcery.com> Date: Fri Jan 3 17:39:56 2020 -0800 Check array contiguity for OpenACC/Fortran PR fortran/93025 gcc/fortran/ * openmp.c (resolve_omp_clauses): Check array references for contiguity. gcc/testsuite/ * gfortran.dg/goacc/mapping-tests-2.f90: New test. * gfortran.dg/goacc/subarrays.f95: Expect rejection of non-contiguous array. Diff: --- gcc/fortran/ChangeLog | 5 ++++ gcc/fortran/openmp.c | 29 +++++++++++++++----- gcc/testsuite/ChangeLog | 7 +++++ .../gfortran.dg/goacc/mapping-tests-2.f90 | 32 ++++++++++++++++++++++ gcc/testsuite/gfortran.dg/goacc/subarrays.f95 | 2 +- 5 files changed, 67 insertions(+), 8 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c51dab2..c7e2b31 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,10 @@ 2020-01-28 Julian Brown <julian@codesourcery.com> + PR fortran/93025 + * openmp.c (resolve_omp_clauses): Check array references for contiguity. + +2020-01-28 Julian Brown <julian@codesourcery.com> + * gfortran.h (gfc_symbol): Add comp_mark bitfield. * openmp.c (resolve_omp_clauses): Disallow mixed component and full-derived-type accesses to the same variable within a single diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 444fdcc..0accb18 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -4536,13 +4536,28 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, /* Look through component refs to find last array reference. */ if (openacc && resolved) - while (array_ref - && (array_ref->type == REF_COMPONENT - || (array_ref->type == REF_ARRAY - && array_ref->next - && (array_ref->next->type - == REF_COMPONENT)))) - array_ref = array_ref->next; + { + /* The "!$acc cache" directive allows rectangular + subarrays to be specified, with some restrictions + on the form of bounds (not implemented). + Only raise an error here if we're really sure the + array isn't contiguous. An expression such as + arr(-n:n,-n:n) could be contiguous even if it looks + like it may not be. */ + if (list != OMP_LIST_CACHE + && !gfc_is_simply_contiguous (n->expr, false, true) + && gfc_is_not_contiguous (n->expr)) + gfc_error ("Array is not contiguous at %L", + &n->where); + + while (array_ref + && (array_ref->type == REF_COMPONENT + || (array_ref->type == REF_ARRAY + && array_ref->next + && (array_ref->next->type + == REF_COMPONENT)))) + array_ref = array_ref->next; + } } if (array_ref || (n->expr diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a362367..9e1af091 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2020-01-28 Tobias Burnus <tobias@codesourcery.com> + Julian Brown <julian@codesourcery.com> + + * gfortran.dg/goacc/mapping-tests-2.f90: New test. + * gfortran.dg/goacc/subarrays.f95: Expect rejection of non-contiguous + array. + 2020-01-28 Julian Brown <julian@codesourcery.com> * gfortran.dg/goacc/deep-copy-2.f90: Move test here (from libgomp diff --git a/gcc/testsuite/gfortran.dg/goacc/mapping-tests-2.f90 b/gcc/testsuite/gfortran.dg/goacc/mapping-tests-2.f90 new file mode 100644 index 0000000..1372f6a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/mapping-tests-2.f90 @@ -0,0 +1,32 @@ +subroutine foo + type t + integer :: i, j + end type t + + type t2 + type(t) :: cc(3) + end type t2 + + type(t) x, y(3) + type(t2) :: z(3) + + ! OK - map whole aggregated variable +!$acc enter data copyin(x) + ! map(to:x [len: 8]) + + ! OK - map two components of the aggregated variable +!$acc enter data copyin(x%j, x%i) + + ! Bad - we cannot mix full-object and component accesses +!$acc enter data copyin(x, x%i) +! { dg-error "Symbol .x. has mixed component and non-component accesses" "" { target "*-*-*" } 21 } + + ! Bad - we cannot do a strided access of 'x' + ! No C/C++ equivalent +!$acc enter data copyin(y(:)%i) +! { dg-error "Array is not contiguous" "" { target "*-*-*" } 26 } + + ! Bad - again, a strided access +!$acc enter data copyin(z(1)%cc(:)%i) +! { dg-error "Array is not contiguous" "" { target "*-*-*" } 30 } +end diff --git a/gcc/testsuite/gfortran.dg/goacc/subarrays.f95 b/gcc/testsuite/gfortran.dg/goacc/subarrays.f95 index f6adde4..fa03785 100644 --- a/gcc/testsuite/gfortran.dg/goacc/subarrays.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/subarrays.f95 @@ -27,7 +27,7 @@ program test ! { dg-error "'a' in MAP clause" "" { target *-*-* } .-2 } !$acc end parallel - !$acc parallel copy (b(1:3,2:4)) + !$acc parallel copy (b(1:3,2:4)) ! { dg-error "Array is not contiguous" } !$acc end parallel !$acc parallel copy (b(2:3)) ! { dg-error "Rank mismatch" "" { target *-*-* } .-1 }
reply other threads:[~2020-01-30 8:51 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=20200130085138.53407.qmail@sourceware.org \ --to=marxin@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).