From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123228 invoked by alias); 17 Jun 2016 03:22:45 -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 123204 invoked by uid 89); 17 Jun 2016 03:22:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=distracted, parenthesis, Unexpected X-Spam-User: qpsmtpd, 2 recipients 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 17 Jun 2016 03:22:34 +0000 Received: from svr-orw-fem-03.mgc.mentorg.com ([147.34.97.39]) by relay1.mentorg.com with esmtp id 1bDkMY-00053I-GL from Cesar_Philippidis@mentor.com ; Thu, 16 Jun 2016 20:22:30 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.3.224.2; Thu, 16 Jun 2016 20:22:30 -0700 Subject: Re: OpenACC wait clause To: Jakub Jelinek References: <20160607111307.GQ7387@tucnak.redhat.com> <5756E1B6.605@codesourcery.com> <20160607150252.GS7387@tucnak.redhat.com> CC: , Fortran List From: Cesar Philippidis Message-ID: <57636CF5.40400@codesourcery.com> Date: Fri, 17 Jun 2016 03:22:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <20160607150252.GS7387@tucnak.redhat.com> Content-Type: multipart/mixed; boundary="------------090500010403050802040909" X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg00040.txt.bz2 --------------090500010403050802040909 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Content-length: 1564 On 06/07/2016 08:02 AM, Jakub Jelinek wrote: > On Tue, Jun 07, 2016 at 08:01:10AM -0700, Cesar Philippidis wrote: >> On 06/07/2016 04:13 AM, Jakub Jelinek wrote: >> >>> I've noticed >>> if ((mask & OMP_CLAUSE_WAIT) >>> && !c->wait >>> && gfc_match ("wait") == MATCH_YES) >>> { >>> c->wait = true; >>> match_oacc_expr_list (" (", &c->wait_list, false); >>> continue; >>> } >>> which looks just weird and confusing. Why isn't this instead: >>> if ((mask & OMP_CLAUSE_WAIT) >>> && !c->wait >>> && (match_oacc_expr_list ("wait (", &c->wait_list, false) >>> == MATCH_YES)) >>> { >>> c->wait = true; >>> continue; >>> } >>> ? Otherwise you happily accept wait without following (, perhaps even >>> combined with another clause without any space in between etc. >> >> Both acc wait and async accept optional parenthesis arguments. E.g., >> >> #pragma acc wait >> >> blocks for all of the async streams to complete before proceeding, whereas >> >> #pragma acc wait (1, 5) >> >> only blocks for async streams 1 and 5. > > But then you need to set need_space = true; if it doesn't have the ( after > it. I was distracted with acc routine stuff, so this took me a little longer to get around to this. In addition to that problem with the wait clause, I discovered a similar problem with the async clause and the wait directive. It this patch ok for trunk and gcc-6? Cesar --------------090500010403050802040909 Content-Type: text/x-patch; name="fortran-wait-async.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fortran-wait-async.diff" Content-length: 3287 2016-06-16 Cesar Philippidis gcc/fortran/ * openmp.c (gfc_match_omp_clauses): Update use a needs_space for the OpenACC wait and async clauses. (gfc_match_oacc_wait): Ensure that there is a space when the optional parenthesis is missing. gcc/testsuite/ * gfortran.dg/goacc/asyncwait-2.f95: Add additional test coverage. * gfortran.dg/goacc/asyncwait-4.f95: Likewise. diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 2c92794..435c709 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -677,7 +677,6 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask, && gfc_match ("async") == MATCH_YES) { c->async = true; - needs_space = false; if (gfc_match (" ( %e )", &c->async_expr) != MATCH_YES) { c->async_expr @@ -685,6 +684,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask, gfc_default_integer_kind, &gfc_current_locus); mpz_set_si (c->async_expr->value.integer, GOMP_ASYNC_NOVAL); + needs_space = true; } continue; } @@ -1328,7 +1328,8 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask, && gfc_match ("wait") == MATCH_YES) { c->wait = true; - match_oacc_expr_list (" (", &c->wait_list, false); + if (match_oacc_expr_list (" (", &c->wait_list, false) == MATCH_NO) + needs_space = true; continue; } if ((mask & OMP_CLAUSE_WORKER) @@ -1649,7 +1650,7 @@ gfc_match_oacc_wait (void) gfc_expr_list *wait_list = NULL, *el; match_oacc_expr_list (" (", &wait_list, true); - gfc_match_omp_clauses (&c, OACC_WAIT_CLAUSES, false, false, true); + gfc_match_omp_clauses (&c, OACC_WAIT_CLAUSES, false, true, true); if (gfc_match_omp_eos () != MATCH_YES) { diff --git a/gcc/testsuite/gfortran.dg/goacc/asyncwait-2.f95 b/gcc/testsuite/gfortran.dg/goacc/asyncwait-2.f95 index db0ce1f..7b2ae07 100644 --- a/gcc/testsuite/gfortran.dg/goacc/asyncwait-2.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/asyncwait-2.f95 @@ -83,6 +83,18 @@ program asyncwait end do !$acc end parallel ! { dg-error "Unexpected \\\!\\\$ACC END PARALLEL" } + !$acc parallel copyin (a(1:N)) copy (b(1:N)) waitasync ! { dg-error "Unclassifiable OpenACC directive" } + do i = 1, N + b(i) = a(i) + end do + !$acc end parallel ! { dg-error "Unexpected \\\!\\\$ACC END PARALLEL" } + + !$acc parallel copyin (a(1:N)) copy (b(1:N)) asyncwait ! { dg-error "Unclassifiable OpenACC directive" } + do i = 1, N + b(i) = a(i) + end do + !$acc end parallel ! { dg-error "Unexpected \\\!\\\$ACC END PARALLEL" } + !$acc parallel copyin (a(1:N)) copy (b(1:N)) wait do i = 1, N b(i) = a(i) diff --git a/gcc/testsuite/gfortran.dg/goacc/asyncwait-4.f95 b/gcc/testsuite/gfortran.dg/goacc/asyncwait-4.f95 index cd64ef3..01349b0 100644 --- a/gcc/testsuite/gfortran.dg/goacc/asyncwait-4.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/asyncwait-4.f95 @@ -34,4 +34,6 @@ program asyncwait !$acc wait async (1.0) ! { dg-error "ASYNC clause at \\\(1\\\) requires a scalar INTEGER expression" } !$acc wait async 1 ! { dg-error "Unexpected junk in \\\!\\\$ACC WAIT at" } + + !$acc waitasync ! { dg-error "Unexpected junk in \\\!\\\$ACC WAIT at" } end program asyncwait --------------090500010403050802040909--