From patchwork Thu Feb 14 13:54:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1042189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-496129-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="OavMSoW6"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 440dF06Csfz9sML for ; Fri, 15 Feb 2019 00:55:00 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=FLsmSW+INeIi8RGp KV8qRzo/DuzE9/OhhcRYGALqT79lGDGIypKkln81978+ckSzaByBA8CS94EE9IwK +p6Gyb23az2U9x+zvvQal4WV5bWIkrGOsAqEnSwWyXe9k5xki1gtg7fuRfXYjNrg HRZ0RPcu+heI7YcFtAdh5oZf8pI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=m6cTqqvtzGWBFeMMAz6Gw8 TErFo=; b=OavMSoW64qQj1gesNCjmFCXvIWtHrAKrCNR4Jrj2N+ZQ5CWEbFzbq0 EIsRtwP8sjwxwSSQORS15bO5//t1biGGvZKsSCn+57PnTYdozNXXYruYRDvwNBGz F2wCxe3sQlJry4Nkd1pCDyMzdeeNdUx2WqUotbtPflXDemfv+Q5GI= Received: (qmail 125378 invoked by alias); 14 Feb 2019 13:54:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 125364 invoked by uid 89); 14 Feb 2019 13:54:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:U*burnus, sk:thomas, 88649, prs 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, 14 Feb 2019 13:54:46 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-03.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1guHTP-0004DG-2N from Thomas_Schwinge@mentor.com ; Thu, 14 Feb 2019 05:54:43 -0800 Received: from hertz.schwinge.homeip.net (137.202.0.90) by SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Thu, 14 Feb 2019 13:54:39 +0000 From: Thomas Schwinge To: , CC: Jakub Jelinek , Tobias Burnus , Subject: Fix PR72715 "ICE in gfc_trans_omp_do, at fortran/trans-openmp.c:3164" In-Reply-To: <61baf31c-0ba2-16c9-f222-059da4a22060@codesourcery.com> References: <61baf31c-0ba2-16c9-f222-059da4a22060@codesourcery.com> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/25.2.2 (x86_64-pc-linux-gnu) Date: Thu, 14 Feb 2019 14:54:32 +0100 Message-ID: MIME-Version: 1.0 Hi! PR72715 "ICE in gfc_trans_omp_do, at fortran/trans-openmp.c:3164" is the OpenACC variant of the OpenMP PR60127 "ICE with OpenMP and DO CONCURRENT" (trunk r210331) changes. On Mon, 29 Aug 2016 14:33:07 -0700, Cesar Philippidis wrote: > It looks like the fortran FE has some preliminary support for do > concurrent loops, however it was not well tested, nor is do concurrent > supported by the OpenACC spec. (Tobias Burnus has written up in some further PRs and emails what the issues are.) > This patch teaches the fortran FE to > error when an acc loop directive is applied to a do concurrent loop. > > The reason why the existing do concurrent wasn't detected earlier is > because the only tests that utilized do concurrent loops contained other > expected failures, therefore the FE never successfully left the resolver > stage. And this ICE occurred as the loop was being translated into gimple. > > There's one other questionably use of EXEC_DO_CONCURRENT that involves > the OpenACC cache directive. I've decided to leave gfc_exec_oacc_cache > alone for the time being because the OpenACC spec does not explicitly > define what it means by 'loop'. Then again, the user isn't required to > explicitly mark acc loops inside acc kernels regions, so perhaps it > would be better to leave the end user with more flexibility. On the > other hand, it's debatable whether do concurrent loops should even be > permitted inside acc offloaded regions. > > I've applied this patch to gomp-4_0-branch. Is this OK for trunk, gcc-6 > and gcc-5? Thanks. As attached committed to trunk in r268875, and will backport to release branches later. Grüße Thomas From dac1fbf62c5293c4b6b2788a6d9677c73088df5d Mon Sep 17 00:00:00 2001 From: tschwinge Date: Thu, 14 Feb 2019 13:44:19 +0000 Subject: [PATCH] Fix PR72715 "ICE in gfc_trans_omp_do, at fortran/trans-openmp.c:3164" The OpenACC 'resolve_oacc_nested_loops' function duplicates most code of the OpenMP 'resolve_omp_do', but didn't include the PR60127 "ICE with OpenMP and DO CONCURRENT" (trunk r210331) changes. (Probably the two functions should be unified?) The Fortran DO CONCURRENT construct is a way to tell the compiler that loop iterations don't have any interdependencies -- which is information that would very well be suitable for OpenACC/OpenMP loops. There are some "details" however, see the discussion/references in PR60127, so for the time being, make this a compile-time error instead of an ICE. gcc/fortran/ * openmp.c (resolve_oacc_nested_loops): Error on do concurrent loops. gcc/testsuite/ * gfortran.dg/goacc/loop-3-2.f95: Error on do concurrent loops. * gfortran.dg/goacc/loop-3.f95: Likewise. * gfortran.dg/goacc/pr72715.f90: New test. Reviewed-by: Thomas Schwinge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268875 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/openmp.c | 8 +++++++- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95 | 4 ++-- gcc/testsuite/gfortran.dg/goacc/loop-3.f95 | 4 ++-- gcc/testsuite/gfortran.dg/goacc/pr72715.f90 | 6 ++++++ 6 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/pr72715.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c573f77410c..71cef4f1884 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-02-14 Cesar Philippidis + + PR fortran/72715 + * openmp.c (resolve_oacc_nested_loops): Error on do concurrent + loops. + 2019-02-13 Martin Liska PR fortran/88649 diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 15c5842dea4..8651afaee4f 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -5760,7 +5760,13 @@ resolve_oacc_nested_loops (gfc_code *code, gfc_code* do_code, int collapse, "at %L", &do_code->loc); break; } - gcc_assert (do_code->op == EXEC_DO || do_code->op == EXEC_DO_CONCURRENT); + if (do_code->op == EXEC_DO_CONCURRENT) + { + gfc_error ("!$ACC LOOP cannot be a DO CONCURRENT loop at %L", + &do_code->loc); + break; + } + gcc_assert (do_code->op == EXEC_DO); if (do_code->ext.iterator->var->ts.type != BT_INTEGER) gfc_error ("!$ACC LOOP iteration variable must be of type integer at %L", &do_code->loc); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index def998a14ee..6a649831c94 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-02-14 Cesar Philippidis + + PR fortran/72715 + * gfortran.dg/goacc/loop-3-2.f95: Error on do concurrent loops. + * gfortran.dg/goacc/loop-3.f95: Likewise. + * gfortran.dg/goacc/pr72715.f90: New test. + 2019-02-14 Martin Liska PR rtl-optimization/89242 diff --git a/gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95 b/gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95 index 9be74a85919..c091084a4f5 100644 --- a/gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95 @@ -27,9 +27,9 @@ subroutine test1 !$acc end parallel !$acc end loop ! { dg-error "Unexpected" } - ! OpenACC supports Fortran 2008 do concurrent statement + ! OpenACC does not support Fortran 2008 do concurrent statement !$acc loop - do concurrent (i = 1:5) + do concurrent (i = 1:5) ! { dg-error "ACC LOOP cannot be a DO CONCURRENT loop" } end do !$acc loop diff --git a/gcc/testsuite/gfortran.dg/goacc/loop-3.f95 b/gcc/testsuite/gfortran.dg/goacc/loop-3.f95 index 30930f404f3..ed3e8d50a76 100644 --- a/gcc/testsuite/gfortran.dg/goacc/loop-3.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/loop-3.f95 @@ -24,9 +24,9 @@ subroutine test1 !$acc end parallel !$acc end loop ! { dg-error "Unexpected" } - ! OpenACC supports Fortran 2008 do concurrent statement + ! OpenACC does not support Fortran 2008 do concurrent statement !$acc loop - do concurrent (i = 1:5) + do concurrent (i = 1:5) ! { dg-error "ACC LOOP cannot be a DO CONCURRENT loop" } end do !$acc loop diff --git a/gcc/testsuite/gfortran.dg/goacc/pr72715.f90 b/gcc/testsuite/gfortran.dg/goacc/pr72715.f90 new file mode 100644 index 00000000000..68580f9f7de --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr72715.f90 @@ -0,0 +1,6 @@ +program p + integer :: i + !$acc loop + do concurrent (i=1:3) ! { dg-error "ACC LOOP cannot be a DO CONCURRENT loop" } + end do +end program p -- 2.17.1