public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Stubbs <ams@codesourcery.com>
To: Jakub Jelinek <jakub@redhat.com>,
	Chung-Lin Tang <cltang@codesourcery.com>
Cc: Tobias Burnus <tobias@codesourcery.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	Catherine Moore <clm@codesourcery.com>,
	Hafiz Abid Qadeer <abid_qadeer@mentor.com>
Subject: Re: [PATCH, OpenMP, v2] Implement uses_allocators clause for target regions
Date: Thu, 19 May 2022 18:02:43 +0100	[thread overview]
Message-ID: <8334c3f4-32ef-c840-6b32-ec33e4db1654@codesourcery.com> (raw)
In-Reply-To: <YoZphOTS8Cfl/P0J@tucnak>

On 19/05/2022 17:00, Jakub Jelinek wrote:
> Without requires dynamic_allocators, there are various extra restrictions
> imposed:
> 1) omp_init_allocator/omp_destroy_allocator may not be called (except for
>     implicit calls to it from uses_allocators) in a target region

I interpreted that more like "omp_init_allocator/... is not required to 
work", as in the set-up steps provided by 
dynamic_allocators/uses_allocators won't be available. Since we don't 
have any such on/off mode I don't believe we need to worry about this 
(and adding extra logic for this is make-work which will not improve the 
user-experience).

> 2) omp_alloc etc. can't be called with omp_null_allocator and the argument
>     has to be a constant expression for a predefined memory allocator
>     (that is also mentioned on uses_allocators, though that doesn't have to
>     be visible in the source because it could be lexically included in
>     a target construct's body)

Again, does a conforming implementation reject this, or is it merely not 
required to accept it?

> 3) for allocate directive on static vars the above applies plus it has
>     to be mentioned in uses_allocators
> 4) for allocate clause e.g. when privatizing stuff or allocate directive
>     for automatic vars no such restrictions exist
> 
> Now, that means that e.g. the user provided uses_allocators without
> requires dynamic_allocators are only useful for the case 4), it is unclear
> if that was really intended.
> 
> With uses_allocators in particular, it is unclear if
> uses_allocators(omp_null_allocator) is allowed or not, IMHO it shouldn't,
> but I really don't see a restriction disallowing it.
> 
> Then there is the issue that 5.0/5.1 said for C/C++ that traits-array
> should be
> "an identifier of const omp_alloctrait_t * type."
> which is wrong for multiple reasons, because identifiers don't have type,
> expressions or variables do, but more importantly because from the pointer
> to const omp_alloctrait_t it is impossible to find out how many elements
> the traits have.  5.2 fixed that to say that it must be an array
> (so we thankfully know the size), so we certainly should consider that
> change like a defect report against 5.0/5.1 too and require even in the
> old syntax an array.  Note, I'm afraid we need to support even VLAs,
> not just constant size arrays.

We are only implementing 5.0 at this time. If 5.2 is less work and the 
only way to achieve correctness then maybe that's the way to go, but in 
general, one step at a time, please.

> There is also in the spec that when allocator in uses_allocators is
> a variable, it is treated as a private variable that can't be explicitly
> privatized, but nothing said about the traits array, so is say:
> void foo () {
> omp_allocator_handle_t h;
> omp_alloctrait_t t[3] = { ... };
> #pragma omp target uses_allocators(h(t)) firstprivate(t)
> {
> }
> ok or not?  We need to firstprivatize t so that we can call
> h = omp_init_allocator (omp_default_mem_space, 3, t); in the target region
> and it is kind of difficult to privatize the same var multiple times.
> 
> And yet another issue, in omp_alloctrait_t one can point to other allocators
> (with { omp_atk_fallback, some_alloc }).  If some_alloc is a predefined
> allocator, fine, I don't see big deal with that, especially if that
> predefined allocator is also mentioned in uses_allocators clause (before or
> after).  But if it is a user allocator, there is no restriction on that, and
> no way how to map that, say that there should be some specific ordering
> of uses_allocators induced omp_init_allocator calls and that we should
> somehow replace the host value with privatized target replacement.
> 
> More on the actual patch later.

Thank you.

  reply	other threads:[~2022-05-19 17:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06 13:20 [PATCH, OpenMP] " Chung-Lin Tang
2022-05-06 16:40 ` Tobias Burnus
2022-05-10 11:29   ` [PATCH, OpenMP, v2] " Chung-Lin Tang
2022-05-19 16:00     ` Jakub Jelinek
2022-05-19 17:02       ` Andrew Stubbs [this message]
2022-05-19 17:55         ` Jakub Jelinek
2022-05-20  6:59       ` Tobias Burnus
2022-05-19 17:46     ` Jakub Jelinek
2022-05-30 14:43       ` Chung-Lin Tang
2022-05-30 17:23         ` Jakub Jelinek
2022-05-31 10:02           ` Jakub Jelinek
2022-06-06 13:19             ` Chung-Lin Tang
2022-06-06 13:22               ` Jakub Jelinek
2022-06-06 13:38                 ` Chung-Lin Tang
2022-06-06 13:42                   ` Jakub Jelinek
2022-06-09  6:21             ` [PATCH, OpenMP, v4] " Chung-Lin Tang
2022-06-09 12:22               ` Jakub Jelinek
2022-06-13 13:29                 ` Chung-Lin Tang
2022-06-13 14:04                   ` Jakub Jelinek
2023-02-09 11:26 ` [og12] '{c-c++-common,gfortran.dg}/gomp/uses_allocators-*' -> 'libgomp.{c-c++-common,fortran}/uses_allocators-*' (was: [PATCH, OpenMP] Implement uses_allocators clause for target regions) 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=8334c3f4-32ef-c840-6b32-ec33e4db1654@codesourcery.com \
    --to=ams@codesourcery.com \
    --cc=abid_qadeer@mentor.com \
    --cc=clm@codesourcery.com \
    --cc=cltang@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --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).