public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <tobias@codesourcery.com>
To: Jakub Jelinek <jakub@redhat.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: Mon, 23 May 2022 11:00:54 +0200	[thread overview]
Message-ID: <f56b563c-0067-e0b9-e678-f076c242e240@codesourcery.com> (raw)
In-Reply-To: <YoZNMQmofH/+CMDT@tucnak>

Hi Jakub,

On 19.05.22 15:59, Jakub Jelinek wrote:
> 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.

I concur – although, the question is how to to it best – i.e. what is statically
known vs. only known at run time. The current patch requires some in-depth
knowledge both of the internal structure (array size) and also the handling of
what is passed to libgomp. But it can be done statically.

Thus, I think it is okay to handle this case of firstprivate differently from:

For the Fortran patch regarding deep-copying of derived types, it is different:
it is a complicated deeply nested structure and with polymorphic types or
recursive types – or array derived types with allocatable derived components.

In this case, omp-low.cc only calls a three lang hooks and defers most to the
language hooks. Namely: Has deep copying, how many (run-time determined) - do
a malloc - and last hook: fill the three arrays (data, sizes, kinds).

I think that patch can be extended to handle deep firstprivate as well. As the
FE lang hook code controls the data/sizes/kinds array handling, it can also
handle the firstprivate bits.

(I need at some point to cleanup the patch and submit it piecewise, starting
with some generic Fortran patches.)

(Cross ref: See omp-low.cc changes at
https://gcc.gnu.org/pipermail/gcc-patches/2022-April/593562.html)

> 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...

Yes – we also need something for map as OpenMP 5.x (x=1 or 2, I forgot; to be
extended in 6.0) permits more with regards to dynamic types and calling virtual
functions. (Likewise, but not relevant to mapping: Also dereferencing function
pointers.)

The submitted patch was now committed as
https://gcc.gnu.org/r13-706-g49d1a2f91325fa8cc011149e27e5093a988b3a49.

Thanks for the comments!

Tobias

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

  reply	other threads:[~2022-05-23  9:01 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
2022-05-23  9:00   ` Tobias Burnus [this message]
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=f56b563c-0067-e0b9-e678-f076c242e240@codesourcery.com \
    --to=tobias@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.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).