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 DD229383E81F for ; Thu, 19 May 2022 13:59:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DD229383E81F 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-90-YnNaKlb4O5S7-oOE-kWZRw-1; Thu, 19 May 2022 09:59:19 -0400 X-MC-Unique: YnNaKlb4O5S7-oOE-kWZRw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0F2CF1E02E39; Thu, 19 May 2022 13:59:19 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ABF29492C14; Thu, 19 May 2022 13:59:18 +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 24JDxEWr075191 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 19 May 2022 15:59:15 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 24JDxDUs075190; Thu, 19 May 2022 15:59:13 +0200 Date: Thu, 19 May 2022 15:59:13 +0200 From: Jakub Jelinek To: Tobias Burnus Cc: gcc-patches , fortran Subject: Re: [Patch] OpenMP: Handle descriptors in target's firstprivate [PR104949] Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Thu, 19 May 2022 13:59:24 -0000 On Wed, May 11, 2022 at 07:33:00PM +0200, Tobias Burnus wrote: > gcc/fortran/ChangeLog: > > PR fortran/104949 > * f95-lang.cc (LANG_HOOKS_OMP_ARRAY_SIZE): Redefine. > * trans-openmp.cc (gfc_omp_array_size): New. > (gfc_trans_omp_variable_list): Never turn has_device_addr > to firstprivate. > * trans.h (gfc_omp_array_size): New. > > gcc/ChangeLog: > > PR fortran/104949 > * langhooks-def.h (lhd_omp_array_size): New. > (LANG_HOOKS_OMP_ARRAY_SIZE): Define Missing full stop above. > (LANG_HOOKS_DECLS): Add it. > * langhooks.cc (lhd_omp_array_size): New. > * langhooks.h (struct lang_hooks_for_decls): Add hook. > * omp-low.cc (scan_sharing_clauses, lower_omp_target): > Handle GOMP_MAP_FIRSTPRIVATE for array descriptors. > > libgomp/ChangeLog: > > PR fortran/104949 > * target.c (gomp_map_vars_internal, copy_firstprivate_data): > Support attach for GOMP_MAP_FIRSTPRIVATE. > * testsuite/libgomp.fortran/target-firstprivate-1.f90: New test. > * testsuite/libgomp.fortran/target-firstprivate-2.f90: New test. > * testsuite/libgomp.fortran/target-firstprivate-3.f90: New test. I guess ok like this for now, but handling the further deep copy cases (allocatable members of derived types) wouldn't be very nice, I think generally we need a target hook to handle the stuff that is target specific and express it say in further clauses or their modified copies (perhaps some flags on them, or new clause types) which will allow the pointer attachments to be done. Generally, for firstprivate on constructs other than target we invoke a copy constructor or its language equivalent (memcpy for C, perhaps some deep copying for Fortran), which takes care of stuff like in C++ embedded reference type members etc. But for target we don't have such a luxury, we don't have copy ctors between different devices and so we need to do something different, for now it has been mainly just bitwise copying the aggregate between devices. But eventually it would be nice to have a target hook that emulates the cross-device copy construction. And we probably need also something to emulate destruction... Jakub