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.133.124]) by sourceware.org (Postfix) with ESMTPS id B4C313857433 for ; Mon, 4 Jul 2022 17:20:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B4C313857433 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-588-fwLEoh4dPjWJHrBIXMNOZw-1; Mon, 04 Jul 2022 13:20:31 -0400 X-MC-Unique: fwLEoh4dPjWJHrBIXMNOZw-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 087F58339A4; Mon, 4 Jul 2022 17:20:31 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCCE51415309; Mon, 4 Jul 2022 17:20:30 +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 264HKRjt1678403 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 4 Jul 2022 19:20:28 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 264HKRFV1678402; Mon, 4 Jul 2022 19:20:27 +0200 Date: Mon, 4 Jul 2022 19:20:26 +0200 From: Jakub Jelinek To: Tobias Burnus Cc: gcc-patches , fortran Subject: Re: [Patch] OpenMP/Fortran: Add support for OpenMP 5.2 linear clause syntax Message-ID: Reply-To: Jakub Jelinek References: <00106b18-d0f4-d449-73de-17831af2006a@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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: Mon, 04 Jul 2022 17:20:34 -0000 On Mon, Jul 04, 2022 at 06:09:31PM +0200, Tobias Burnus wrote: > thanks for the comment & spec referral. I have now updated the patch – > and included the new C/Fortran testcase. Thanks. > + while (true) > + { > + old_loc = gfc_current_locus; > + if (gfc_match ("val )") == MATCH_YES) > + { > + if (linear_op != OMP_LINEAR_DEFAULT) > + { > + duplicate_mod = true; > + break; > + } > + linear_op = OMP_LINEAR_VAL; > + has_modifiers = true; > + break; > + } > + else if (gfc_match ("val , ") == MATCH_YES) > + { > + if (linear_op != OMP_LINEAR_DEFAULT) > + { > + duplicate_mod = true; > + break; > + } > + linear_op = OMP_LINEAR_VAL; > + has_modifiers = true; > + continue; > + } Perhaps you could avoid some code duplication by doing it like: bool close_paren = gfc_match ("val )") == MATCH_YES; if (close_paren || gfc_match ("val , ") == MATCH_YES) { if (linear_op != OMP_LINEAR_DEFAULT) { duplicate_mod = true; break; } linear_op = OMP_LINEAR_VAL; has_modifiers = true; if (close_paren) break; else continue; } and similarly for uval and ref. > + else if (!has_modifiers > + && gfc_match ("%e )", &step) == MATCH_YES) > + { > + if ((step->expr_type == EXPR_FUNCTION > + || step->expr_type == EXPR_VARIABLE) > + && strcmp (step->symtree->name, "step") == 0) > + { > + gfc_current_locus = old_loc; > + gfc_match ("step ("); > + has_error = true; > + } I think the above should accept even linear (v : step (1) + 0) or linear (v : step (1, 2, 3) * 1) which is desirable, because step then will be some other operation (hope folding isn't performed yet). > --- /dev/null > +++ b/gcc/testsuite/gfortran.dg/gomp/linear-4.f90 > @@ -0,0 +1,102 @@ > +! { dg-do compile } > +! { dg-options "-fopenmp" } > + > +module m > +implicit none > + > +integer :: i > + > +interface > + integer function bar (x, y, z) > + integer :: x, y > + integer, value :: z > + !!$omp declare simd linear (x : ref, step (1)) linear (y : step (2), uval) Are all these !! intentional? The test then doesn't test much. Or is that a FIXME? Jakub