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 BFD793858D3C for ; Fri, 18 Mar 2022 16:38:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BFD793858D3C Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-135-86uAW2ufPFGo0_bRAz63eQ-1; Fri, 18 Mar 2022 12:38:16 -0400 X-MC-Unique: 86uAW2ufPFGo0_bRAz63eQ-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 F02831C068D5; Fri, 18 Mar 2022 16:38:15 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B19361457F3D; Fri, 18 Mar 2022 16:38:15 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 22IGcCYp1822013 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 18 Mar 2022 17:38:13 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 22IGcCB81822012; Fri, 18 Mar 2022 17:38:12 +0100 Date: Fri, 18 Mar 2022 17:38:11 +0100 From: Jakub Jelinek To: Tobias Burnus Cc: gcc-patches , fortran Subject: Re: [Patch] Fortran/OpenMP: Improve associate-name diagnostic [PR103039] Message-ID: Reply-To: Jakub Jelinek References: <6e5a585d-9876-cc66-413d-3cad381ddbdf@codesourcery.com> MIME-Version: 1.0 In-Reply-To: <6e5a585d-9876-cc66-413d-3cad381ddbdf@codesourcery.com> 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=-4.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 18 Mar 2022 16:38:19 -0000 On Fri, Mar 18, 2022 at 05:27:02PM +0100, Tobias Burnus wrote: > SELECT TYPE, SELECT RANK and ASSOCIATE have > associate-name => selector > and create a pointer to the selector. > > GCC was fixed to handle CLASS properly in > class(t) :: var > !$omp ... firstprivate(var) > As a side effect, firstprivate(assoc_name) now also gets > handled that way, effectively trying to firstprivate(selector) > which should be shared... > > While firstprivate(var) does not appear explicitly, it gets > added via gfc_omp_predetermined_sharing. > > I went for the simple solution and handle it only > in gfortran's ctor/dtor. > > An alternative would be to set OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE, > which is currently only set for C++'s __for_end / __for_range > and then later process it in ctor/dtor. I am not sure whether that's > really best and what's the best way to propagate it. One way would > be to create and use OMP_CLAUSE_DEFAULT_FIRSTPRIVATE_NO_REFERENCE. > > OK as is (simple version) – or is a fuller version better. If so, > suggestion how to do this best? LGTM. > Fortran/OpenMP: Fix privatization of associated names > > gfc_omp_predetermined_sharing cases the associate-name pointer variable > to be OMP_CLAUSE_DEFAULT_FIRSTPRIVATE, which is fine. However, the associated > selector is shared. Thus, the target of associate-name pointer should not get > copied. (It was before but because of gfc_omp_privatize_by_reference returning > false, the selector was not only wrongly copied but this was also not done > properly.) > > gcc/fortran/ChangeLog: > > PR fortran/103039 > * trans-openmp.cc (gfc_omp_clause_copy_ctor, gfc_omp_clause_dtor): > Only privatize pointer for associate names. > > libgomp/ChangeLog: > > PR fortran/103039 > * testsuite/libgomp.fortran/associate4.f90: New test. > > gcc/fortran/trans-openmp.cc | 10 +++ > libgomp/testsuite/libgomp.fortran/associate4.f90 | 92 ++++++++++++++++++++++++ > 2 files changed, 102 insertions(+) > Jakub