From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130320 invoked by alias); 28 Feb 2019 20:37:37 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 130292 invoked by uid 89); 28 Feb 2019 20:37:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,MISSING_HEADERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=stray X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Feb 2019 20:37:34 +0000 Received: from svr-orw-mbx-05.mgc.mentorg.com ([147.34.90.205]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1gzSQu-0000yJ-Qq from Thomas_Schwinge@mentor.com ; Thu, 28 Feb 2019 12:37:32 -0800 Received: from SVR-ORW-MBX-06.mgc.mentorg.com (147.34.90.206) by SVR-ORW-MBX-05.mgc.mentorg.com (147.34.90.205) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Thu, 28 Feb 2019 12:37:30 -0800 Received: from tftp-cs (147.34.91.1) by SVR-ORW-MBX-06.mgc.mentorg.com (147.34.90.206) with Microsoft SMTP Server id 15.0.1320.4 via Frontend Transport; Thu, 28 Feb 2019 12:37:30 -0800 Received: by tftp-cs (Postfix, from userid 49978) id ECE94C23D1; Thu, 28 Feb 2019 12:37:29 -0800 (PST) From: Thomas Schwinge CC: , Subject: [PR72741, PR89433] Repeated use of the Fortran OpenACC 'routine' directive In-Reply-To: <001e7a79-d2d8-fa63-2b88-20a346f3b4a7@codesourcery.com> References: <579973CB.3070006@codesourcery.com> <579AD9C9.3030804@codesourcery.com> <5776D55A.4030002@codesourcery.com> <878tw35o6k.fsf@kepler.schwinge.homeip.net> <20160811154026.GV14857@tucnak.redhat.com> <871t1vi851.fsf@hertz.schwinge.homeip.net> <001e7a79-d2d8-fa63-2b88-20a346f3b4a7@codesourcery.com> User-Agent: Notmuch/0.9-125-g4686d11 (http://notmuchmail.org) Emacs/25.2.2 (x86_64-pc-linux-gnu) Date: Thu, 28 Feb 2019 20:37:00 -0000 Message-ID: <874l8nodj2.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-SW-Source: 2019-02/txt/msg00245.txt.bz2 --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 3384 Hi! On Mon, 15 Aug 2016 18:54:49 -0700, Cesar Philippidis wrote: > [...] >=20 > Note that besides for checking for multiple acc routine directives, this > patch also handles the case where the optional name argument in 'acc > routine (NAME)' is the name of the current procedure. This was a TODO > item in gomp4. > --- a/gcc/fortran/openmp.c > +++ b/gcc/fortran/openmp.c > @@ -1969,6 +1971,13 @@ gfc_match_oacc_routine (void) > gfc_current_locus =3D old_loc; > return MATCH_ERROR; > } > + > + /* Set sym to NULL if it matches the current procedure's > + name. This will simplify the check for duplicate ACC > + ROUTINE attributes. */ > + if (gfc_current_ns->proc_name > + && !strcmp (buffer, gfc_current_ns->proc_name->name)) > + sym =3D NULL; > } > else > { I re-worked the code a bit, didn't find this necessary. > dims =3D gfc_oacc_routine_dims (c); > if (dims =3D=3D OACC_FUNCTION_NONE) > { > gfc_error ("Multiple loop axes specified in !$ACC ROUTINE at %C"); > - goto cleanup; > + > + /* Don't abort early, because it's important to let the user > + know of any potential duplicate routine directives. */ > + seen_error =3D true; > } Same for this. > + bool needs_entry =3D true; > +=20=20=20=20=20=20 > + /* Scan for any repeated routine directives on 'sym' and report > + an error if necessary. TODO: Extend this function to scan > + for compatible DEVICE_TYPE dims. */ > + for (n =3D gfc_current_ns->oacc_routine_names; n; n =3D n->next) > + if (n->sym =3D=3D sym) > + { > + needs_entry =3D false; > + if (dims !=3D gfc_oacc_routine_dims (n->clauses)) > + { > + gfc_error ("$!ACC ROUTINE already applied at %C"); > + goto cleanup; > + } > + } > + > + if (needs_entry) > + { > + n =3D gfc_get_oacc_routine_name (); This would leave us with a stray non-NULL 'n' in the '!needs_entry' case (which potentially could confuse later processing?). > + n->next =3D NULL; > + > + if (gfc_current_ns->oacc_routine_names !=3D NULL) > + n->next =3D gfc_current_ns->oacc_routine_names; That's just 'n->next =3D gfc_current_ns->oacc_routine_names;'. ;-) > else if (gfc_current_ns->proc_name) > { > + if (gfc_current_ns->proc_name->attr.oacc_function !=3D OACC_FUNCTI= ON_NONE > + && !seen_error) > + { > + gfc_error ("!$ACC ROUTINE already applied at %C"); > + goto cleanup; > + } That need not emit an error if the previous is equal to current clause specifying the level of parallelism. > --- a/gcc/testsuite/gfortran.dg/goacc/pr72741-intrinsic-1.f > +++ b/gcc/testsuite/gfortran.dg/goacc/pr72741-intrinsic-1.f > @@ -1,17 +1,13 @@ > -! Check for valid clauses with intrinsic function specified in !$ACC ROU= TINE ( NAME ). > - > SUBROUTINE sub_1 > IMPLICIT NONE > -!$ACC ROUTINE (ABORT) > -!$ACC ROUTINE (ABORT) SEQ > +!$ACC ROUTINE (ABORT) SEQ VECTOR ! { dg-error "Intrinsic symbol specifie= d in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), with incompatible clauses = specifying the level of parallelism" } That changes what this test cases is supposed to be testing. All that re-worked, and now committed to trunk in r269287 "[PR72741, PR89433] Repeated use of the Fortran OpenACC 'routine' directive", as attached. Gr=C3=BC=C3=9Fe Thomas --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0003-PR72741-PR89433-Repeated-use-of-the-Fortran-OpenACC-.patch Content-Transfer-Encoding: quoted-printable Content-length: 9120 =46rom 35e99d5d3bd98eb2e2cee5d94ba09b6166dbeab2 Mon Sep 17 00:00:00 2001 From: tschwinge Date: Thu, 28 Feb 2019 20:31:36 +0000 Subject: [PATCH 3/3] [PR72741, PR89433] Repeated use of the Fortran OpenACC 'routine' directive gcc/fortran/ PR fortran/72741 PR fortran/89433 * openmp.c (gfc_match_oacc_routine): Handle repeated use of the Fortran OpenACC 'routine' directive. gcc/testsuite/ PR fortran/72741 PR fortran/89433 * gfortran.dg/goacc/routine-multiple-directives-1.f90: New file. * gfortran.dg/goacc/routine-multiple-directives-2.f90: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269287 138bc75d-0d04-0410-9= 61f-82ee72b054a4 --- gcc/fortran/ChangeLog | 5 ++ gcc/fortran/openmp.c | 43 ++++++++-- gcc/testsuite/ChangeLog | 5 ++ .../goacc/routine-multiple-directives-1.f90 | 58 +++++++++++++ .../goacc/routine-multiple-directives-2.f90 | 82 +++++++++++++++++++ 5 files changed, 185 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/routine-multiple-direct= ives-1.f90 create mode 100644 gcc/testsuite/gfortran.dg/goacc/routine-multiple-direct= ives-2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1c8f71252980..6adb90aa4c01 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,6 +1,11 @@ 2019-02-28 Thomas Schwinge Cesar Philippidis =20 + PR fortran/72741 + PR fortran/89433 + * openmp.c (gfc_match_oacc_routine): Handle repeated use of the + Fortran OpenACC 'routine' directive. + PR fortran/72741 * gfortran.h (enum oacc_routine_lop): Add OACC_ROUTINE_LOP_ERROR. * openmp.c (gfc_oacc_routine_lop, gfc_match_oacc_routine): Use it. diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 50b91f2150ab..7a06eb58f5cf 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -2374,17 +2374,44 @@ gfc_match_oacc_routine (void) } else if (sym !=3D NULL) { - n =3D gfc_get_oacc_routine_name (); - n->sym =3D sym; - n->clauses =3D NULL; - n->next =3D NULL; - if (gfc_current_ns->oacc_routine_names !=3D NULL) - n->next =3D gfc_current_ns->oacc_routine_names; - - gfc_current_ns->oacc_routine_names =3D n; + bool add =3D true; + + /* For a repeated OpenACC 'routine' directive, diagnose if it doesn't + match the first one. */ + for (gfc_oacc_routine_name *n_p =3D gfc_current_ns->oacc_routine_nam= es; + n_p; + n_p =3D n_p->next) + if (n_p->sym =3D=3D sym) + { + add =3D false; + if (lop !=3D gfc_oacc_routine_lop (n_p->clauses)) + { + gfc_error ("!$ACC ROUTINE already applied at %C"); + goto cleanup; + } + } + + if (add) + { + n =3D gfc_get_oacc_routine_name (); + n->sym =3D sym; + n->clauses =3D c; + n->next =3D gfc_current_ns->oacc_routine_names; + gfc_current_ns->oacc_routine_names =3D n; + } } else if (gfc_current_ns->proc_name) { + /* For a repeated OpenACC 'routine' directive, diagnose if it doesn't + match the first one. */ + oacc_routine_lop lop_p =3D gfc_current_ns->proc_name->attr.oacc_rout= ine_lop; + if (lop_p !=3D OACC_ROUTINE_LOP_NONE + && lop !=3D lop_p) + { + gfc_error ("!$ACC ROUTINE already applied at %C"); + goto cleanup; + } + if (!gfc_add_omp_declare_target (&gfc_current_ns->proc_name->attr, gfc_current_ns->proc_name->name, &old_loc)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9f4c598951c3..8a36b1f802e1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2019-02-28 Thomas Schwinge Cesar Philippidis =20 + PR fortran/72741 + PR fortran/89433 + * gfortran.dg/goacc/routine-multiple-directives-1.f90: New file. + * gfortran.dg/goacc/routine-multiple-directives-2.f90: Likewise. + PR fortran/72741 * gfortran.dg/goacc/routine-multiple-lop-clauses-1.f90: New file. =20 diff --git a/gcc/testsuite/gfortran.dg/goacc/routine-multiple-directives-1.= f90 b/gcc/testsuite/gfortran.dg/goacc/routine-multiple-directives-1.f90 new file mode 100644 index 000000000000..6e12ee92155c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/routine-multiple-directives-1.f90 @@ -0,0 +1,58 @@ +! Check for valid cases of multiple OpenACC 'routine' directives. + + SUBROUTINE s_1 +!$ACC ROUTINE(s_1) +!$ACC ROUTINE(s_1) SEQ +!$ACC ROUTINE SEQ + END SUBROUTINE s_1 + + SUBROUTINE s_2 +!$ACC ROUTINE +!$ACC ROUTINE SEQ +!$ACC ROUTINE(s_2) + END SUBROUTINE s_2 + + SUBROUTINE v_1 +!$ACC ROUTINE VECTOR +!$ACC ROUTINE VECTOR +!$ACC ROUTINE(v_1) VECTOR +!$ACC ROUTINE VECTOR + END SUBROUTINE v_1 + + SUBROUTINE v_2 +!$ACC ROUTINE(v_2) VECTOR +!$ACC ROUTINE VECTOR +!$ACC ROUTINE(v_2) VECTOR + END SUBROUTINE v_2 + + SUBROUTINE sub_1 + IMPLICIT NONE + EXTERNAL :: g_1 +!$ACC ROUTINE (g_1) GANG +!$ACC ROUTINE (g_1) GANG +!$ACC ROUTINE (g_1) GANG + + CALL s_1 + CALL s_2 + CALL v_1 + CALL v_2 + CALL g_1 + CALL ABORT + END SUBROUTINE sub_1 + + MODULE m_w_1 + IMPLICIT NONE + EXTERNAL :: w_1 +!$ACC ROUTINE (w_1) WORKER +!$ACC ROUTINE (w_1) WORKER + + CONTAINS + SUBROUTINE sub_2 + CALL s_1 + CALL s_2 + CALL v_1 + CALL v_2 + CALL w_1 + CALL ABORT + END SUBROUTINE sub_2 + END MODULE m_w_1 diff --git a/gcc/testsuite/gfortran.dg/goacc/routine-multiple-directives-2.= f90 b/gcc/testsuite/gfortran.dg/goacc/routine-multiple-directives-2.f90 new file mode 100644 index 000000000000..54365ae3f4eb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/routine-multiple-directives-2.f90 @@ -0,0 +1,82 @@ +! Check for invalid (and some valid) cases of multiple OpenACC 'routine' +! directives. + + SUBROUTINE s_1 +!$ACC ROUTINE VECTOR WORKER ! { dg-error "Multiple loop axes specified for= routine" } +!$ACC ROUTINE(s_1) +!$ACC ROUTINE GANG ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE(s_1) SEQ +!$ACC ROUTINE +!$ACC ROUTINE(s_1) WORKER ! { dg-error "\\!\\\$ACC ROUTINE already applied= " } +!$ACC ROUTINE GANG VECTOR ! { dg-error "Multiple loop axes specified for r= outine" } + END SUBROUTINE s_1 + + SUBROUTINE s_2 +!$ACC ROUTINE(s_2) VECTOR WORKER ! { dg-error "Multiple loop axes specifie= d for routine" } +!$ACC ROUTINE +!$ACC ROUTINE(s_2) GANG ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE SEQ +!$ACC ROUTINE(s_2) +!$ACC ROUTINE WORKER ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE(s_2) GANG VECTOR ! { dg-error "Multiple loop axes specified = for routine" } + END SUBROUTINE s_2 + + SUBROUTINE v_1 +!$ACC ROUTINE VECTOR WORKER ! { dg-error "Multiple loop axes specified for= routine" } +!$ACC ROUTINE VECTOR +!$ACC ROUTINE GANG ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE SEQ ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE(v_1) VECTOR +!$ACC ROUTINE WORKER ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE GANG VECTOR ! { dg-error "Multiple loop axes specified for r= outine" } + END SUBROUTINE v_1 + + SUBROUTINE v_2 +!$ACC ROUTINE(v_2) VECTOR +!$ACC ROUTINE(v_2) VECTOR WORKER ! { dg-error "Multiple loop axes specifie= d for routine" } +!$ACC ROUTINE(v_2) ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE VECTOR +!$ACC ROUTINE(v_2) GANG VECTOR ! { dg-error "Multiple loop axes specified = for routine" } + END SUBROUTINE v_2 + + SUBROUTINE sub_1 + IMPLICIT NONE + EXTERNAL :: g_1 +!$ACC ROUTINE (g_1) GANG +!$ACC ROUTINE (g_1) GANG WORKER ! { dg-error "Multiple loop axes specified= for routine" } +!$ACC ROUTINE (g_1) VECTOR ! { dg-error "\\!\\\$ACC ROUTINE already applie= d" } +!$ACC ROUTINE (g_1) SEQ ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE (g_1) ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE (g_1) GANG +!$ACC ROUTINE (g_1) ! { dg-error "\\!\\\$ACC ROUTINE already applied" } + + CALL s_1 + CALL s_2 + CALL v_1 + CALL v_2 + CALL g_1 + CALL ABORT + END SUBROUTINE sub_1 + + MODULE m_w_1 + IMPLICIT NONE + EXTERNAL :: w_1 +!$ACC ROUTINE (w_1) WORKER +!$ACC ROUTINE (w_1) WORKER SEQ ! { dg-error "Multiple loop axes specified = for routine" } +!$ACC ROUTINE (w_1) ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE (w_1) WORKER +!$ACC ROUTINE (w_1) SEQ ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE (w_1) ! { dg-error "\\!\\\$ACC ROUTINE already applied" } +!$ACC ROUTINE (w_1) VECTOR ! { dg-error "\\!\\\$ACC ROUTINE already applie= d" } + + CONTAINS + SUBROUTINE sub_2 + CALL s_1 + CALL s_2 + CALL v_1 + CALL v_2 + CALL w_1 + CALL ABORT + END SUBROUTINE sub_2 + END MODULE m_w_1 --=20 2.17.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" Content-length: 658 -----BEGIN PGP SIGNATURE----- iQGzBAEBCgAdFiEEU9WEfWKGQazCmycCAKI7+41Q4XkFAlx4RoEACgkQAKI7+41Q 4Xkq9gv+LHKhb8Ojotf+SkCJWGfU/FFT8zQQA7R4gtjCfpaKL1w7lqEtk6RkVk5v vzv136DyOmWCyVIRn/JmqrBKqgtvWDk7yGBmNBylrj+OLJFTcrvDd48v9878Ruor HU4fNQvkSEaDSpiQpcR9i+k6a6TD4XAlUrLDycO9MdG0E6mMmabOrjQZSMdpk2WS FzvQM0/rA4OZjlmluZUyLG5VJBuEqThahzFy+BOZ2i3bIphJya4NpTqj6IRymMvX yDQt2vGvg9KlJYO4kbruYQ1iBt4JZPsyFimWlmH8CX9xMIepthEAMrHlWrcP6pW6 F+IMZHfWtDYovwBDgztnint/T3GjxkK+prNbd73jrwRYE97YtVqmY4jmkI69k6Pa dFcduxJ1AAzUvk+KpGKrh4EePynMnxLFR1RXpeJB0ld3TJ9gLm1AaN1JwLXTp/Y8 OPJI58PKxZlxDITM4FiA5TZiww3SGTiuPLZAMYos5wRskhL/VGTaejiTPONzLEWu pqFa4vl8 =/7zM -----END PGP SIGNATURE----- --==-=-=--