From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 26E8A3858D1E for ; Wed, 17 Aug 2022 13:09:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 26E8A3858D1E Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-ft5wgfT0PuK_RXDdn3eOZA-1; Wed, 17 Aug 2022 09:09:54 -0400 X-MC-Unique: ft5wgfT0PuK_RXDdn3eOZA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3A180801231; Wed, 17 Aug 2022 13:09:54 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA47214583C2; Wed, 17 Aug 2022 13:09:53 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 27HD9oKD3133566 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Aug 2022 15:09:51 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 27HD9n9f3133565; Wed, 17 Aug 2022 15:09:49 +0200 Date: Wed, 17 Aug 2022 15:09:49 +0200 From: Jakub Jelinek To: Tobias Burnus Cc: gcc-patches , fortran Subject: Re: [Patch] Fortran: OpenMP fix declare simd inside modules and absent linear step [PR106566] Message-ID: Reply-To: Jakub Jelinek References: <9dde1b4a-03cb-214c-8eb7-8f75978754c7@codesourcery.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=WINDOWS-1252 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Wed, 17 Aug 2022 13:10:00 -0000 On Tue, Aug 16, 2022 at 04:45:07PM +0200, Tobias Burnus wrote: > Fixed subject line: "absent linear" should be "absent linear step" in the subject line; > i.e. with "step" added: "Fortran: OpenMP fix declare simd inside modules and absent linear step [PR106566]" > > I have also decided to move the 'step = 1' to openmp.cc, which also set it before with > the old pre-OpenMP 5.2 syntax. > > I also added a pre-OpenMP-5.2-syntax example. > > * * * > > For GCC 12 (and GCC 11), only the '%s' fix and the third, now added example apply; > for the 5.1 syntax, 'step' was already set. > > OK? And thoughts regarding the backports (none? Only 12? Or 11+12?)? > > Tobias > ----------------- > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 > Fortran: OpenMP fix declare simd inside modules and absent linear step [PR106566] > > gcc/fortran/ChangeLog: > > PR fortran/106566 > * openmp.cc (gfc_match_omp_clauses): Fix setting linear-step value > to 1 when not specified. > (gfc_match_omp_declare_simd): Accept module procedures. > > gcc/testsuite/ChangeLog: > > PR fortran/106566 > * gfortran.dg/gomp/declare-simd-4.f90: New test. > * gfortran.dg/gomp/declare-simd-5.f90: New test. > * gfortran.dg/gomp/declare-simd-6.f90: New test. > > gcc/fortran/openmp.cc | 10 +++-- > gcc/testsuite/gfortran.dg/gomp/declare-simd-4.f90 | 42 +++++++++++++++++++ > gcc/testsuite/gfortran.dg/gomp/declare-simd-5.f90 | 49 +++++++++++++++++++++++ > gcc/testsuite/gfortran.dg/gomp/declare-simd-6.f90 | 42 +++++++++++++++++++ > 4 files changed, 140 insertions(+), 3 deletions(-) > > diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc > index a7eb6c3e8f4..594907714ff 100644 > --- a/gcc/fortran/openmp.cc > +++ b/gcc/fortran/openmp.cc > @@ -2480,7 +2480,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, > goto error; > } > } > - else > + if (step == NULL) > { > step = gfc_get_constant_expr (BT_INTEGER, > gfc_default_integer_kind, Ah, didn't know that gfc_match ("%e ) ", &step) will free and clear step if it successfully matched it first and then doesn't match ) after it. So ok. > @@ -4213,9 +4213,13 @@ gfc_match_omp_declare_simd (void) > gfc_omp_declare_simd *ods; > bool needs_space = false; > > - switch (gfc_match (" ( %s ) ", &proc_name)) > + switch (gfc_match (" ( ")) > { > - case MATCH_YES: break; > + case MATCH_YES: > + if (gfc_match_symbol (&proc_name, /* host assoc = */ true) != MATCH_YES > + || gfc_match (" ) ") != MATCH_YES) > + return MATCH_ERROR; > + break; > case MATCH_NO: proc_name = NULL; needs_space = true; break; > case MATCH_ERROR: return MATCH_ERROR; > } LGTM. > diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-simd-4.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-simd-4.f90 > new file mode 100644 > index 00000000000..44132525963 > --- /dev/null > +++ b/gcc/testsuite/gfortran.dg/gomp/declare-simd-4.f90 > @@ -0,0 +1,42 @@ > +! { dg-do compile } > +! { dg-additional-options "-fdump-tree-gimple" } > +! > +! PR fortran/106566 > +! > +! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare simd \\(linear\\(0:ref,step\\(4\\)\\) simdlen\\(8\\)\\)\\)\\)" 2 "gimple" } } > +! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare simd \\(linear\\(0:ref,step\\(8\\)\\) simdlen\\(8\\)\\)\\)\\)" 2 "gimple" } } > + > +subroutine add_one2(p) > + implicit none > + !$omp declare simd(add_one2) linear(p: ref) simdlen(8) > + integer :: p Wonder if it wouldn't be better to use integer(kind=4) explicitly when you try to match the size of that multiplied by 1 or 2 in dg-final, as say with -fdefault-integer-8 this will fail miserably otherwise. Ditto in other spots in this as well as other tests. Ok with/without that change. As for backports, I'd wait some time with just trunk and then backport wherever you are willing to test it. Jakub