public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Tobias Burnus <tobias@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, fortran <fortran@gcc.gnu.org>
Subject: Re: [Patch] OpenMP: Handle descriptors in target's firstprivate [PR104949]
Date: Thu, 19 May 2022 15:59:13 +0200	[thread overview]
Message-ID: <YoZNMQmofH/+CMDT@tucnak> (raw)
In-Reply-To: <f61da0e4-1298-1808-026f-52a26d1278bd@codesourcery.com>

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


  reply	other threads:[~2022-05-19 13:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11 17:33 Tobias Burnus
2022-05-19 13:59 ` Jakub Jelinek [this message]
2022-05-23  9:00   ` Tobias Burnus
2023-02-28 10:56 ` Thomas Schwinge
2023-03-24 16:18   ` Add caveat/safeguard to OpenMP: Handle descriptors in target's firstprivate [PR104949] (was: [Patch] OpenMP: Handle descriptors in target's firstprivate [PR104949]) Thomas Schwinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YoZNMQmofH/+CMDT@tucnak \
    --to=jakub@redhat.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).