From patchwork Fri Oct 10 11:27:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 398521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 9FC801400D2 for ; Fri, 10 Oct 2014 22:27:28 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=kiqFs3mmE2GkrwJ0lOPi6w2D9+ugeGS6EYQ+dUqf8aL +stTKB75N6vFBOpj5VLjyDmgi8eJFK1q0aSQ3rN5U9amgvX8flJX+iWGmsGk3jPq UqWBknhi/DpAUJs06f1bjnPDvrfbWFEVNqOrhADdh7rfqwGXW/n77rdXiFg/mnEc = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=i+srXuVuzbrb0nEjR5wcXCzd118=; b=o6Xa80ioA1189BT48 oKkiujkyNlzNFLyK9d6Z+twVVRosaZxsh2FbKzG82nRDsSjNjHbRsR7kq4Nn9bjE c1Y3jQkFr9Hayv/UmudgRRLEE/5XjvAuXbQUOL7TQ+pvKp0GbMiDcQM0kf1qb7b9 xB702LtCn/x3yTU889W4q7zEBQ= Received: (qmail 12908 invoked by alias); 10 Oct 2014 11:27:17 -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 12888 invoked by uid 89); 10 Oct 2014 11:27:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 10 Oct 2014 11:27:11 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9ABRACX004543 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 10 Oct 2014 07:27:10 -0400 Received: from tucnak.zalov.cz (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9ABR8qP004143 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Fri, 10 Oct 2014 07:27:10 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.9/8.14.9) with ESMTP id s9ABR7Y4019483; Fri, 10 Oct 2014 13:27:07 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.9/8.14.9/Submit) id s9ABR67i019482; Fri, 10 Oct 2014 13:27:06 +0200 Date: Fri, 10 Oct 2014 13:27:06 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH] Fix default(none) with array parameters (PR fortran/59488) Message-ID: <20141010112706.GI10376@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi! This patch makes Fortran array/derived parameters as well as vtables predetermined shared. For the standard proper those aren't really variables at all, and as they are global vars, shared is the best predetermination for them. 2014-10-10 Jakub Jelinek PR fortran/59488 * trans-openmp.c (gfc_omp_predetermined_sharing): Return OMP_CLAUSE_DEFAULT_SHARED for parameters or vtables. * gfortran.dg/gomp/pr59488-1.f90: New test. * gfortran.dg/gomp/pr59488-2.f90: New test. Jakub --- gcc/fortran/trans-openmp.c.jj 2014-09-01 09:43:40.000000000 +0200 +++ gcc/fortran/trans-openmp.c 2014-10-10 10:15:00.426035513 +0200 @@ -135,6 +135,16 @@ gfc_omp_predetermined_sharing (tree decl if (GFC_DECL_RESULT (decl) && ! DECL_HAS_VALUE_EXPR_P (decl)) return OMP_CLAUSE_DEFAULT_SHARED; + /* These are either array or derived parameters, or vtables. + In the former cases, the OpenMP standard doesn't consider them to be + variables at all (they can't be redefined), but they can nevertheless appear + in parallel/task regions and for default(none) purposes treat them as shared. + For vtables likely the same handling is desirable. */ + if (TREE_CODE (decl) == VAR_DECL + && TREE_READONLY (decl) + && TREE_STATIC (decl)) + return OMP_CLAUSE_DEFAULT_SHARED; + return OMP_CLAUSE_DEFAULT_UNSPECIFIED; } --- gcc/testsuite/gfortran.dg/gomp/pr59488-1.f90.jj 2014-10-10 10:06:38.231365699 +0200 +++ gcc/testsuite/gfortran.dg/gomp/pr59488-1.f90 2014-10-10 10:06:56.054036548 +0200 @@ -0,0 +1,13 @@ +! PR fortran/59488 +! { dg-do compile } +! { dg-options "-fopenmp" } + + implicit none + integer, parameter :: p(2) = (/ 11, 12 /) + integer :: r + + !$omp parallel do default(none) + do r = 1, 2 + print *, p(r) + end do +end --- gcc/testsuite/gfortran.dg/gomp/pr59488-2.f90.jj 2014-10-10 10:06:41.331308441 +0200 +++ gcc/testsuite/gfortran.dg/gomp/pr59488-2.f90 2014-10-10 10:08:07.000000000 +0200 @@ -0,0 +1,16 @@ +! PR fortran/59488 +! { dg-do compile } +! { dg-options "-fopenmp" } + + implicit none + type t + integer :: s1, s2, s3 + end type + integer :: r + type(t), parameter :: u = t(1, 2, 3) + + !$omp parallel do default(none) + do r = 1, 2 + print *, u + end do +end