public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <burnus@net-b.de>
To: Sandra Loosemore <sandra@codesourcery.com>, gcc-patches@gcc.gnu.org
Cc: kcy@codesourcery.com, tobias@codesourcery.com, jakub@redhat.com
Subject: Re: [PATCH 1/8] OpenMP: metadirective tree data structures and front-end interfaces
Date: Sat, 6 Jan 2024 20:45:42 +0100	[thread overview]
Message-ID: <af36b83e-1aa9-4400-875b-a387f3eb3319@net-b.de> (raw)
In-Reply-To: <20240106185257.126445-2-sandra@codesourcery.com>

Hi Sandra,

given that it is "just" a revised patch of previously posted patch and 
(code wise not file wise) very localized to OpenMP code - and even there 
touching only 'declare ...' code in a simple way:

I would be still fine to have it in GCC 14, but I want to give Jakub a 
chance to shout...


Glancing at the code, it looks okayish, but I have two quick comments.
(I have now an errant to do - and will continue later with the review.)

Sandra Loosemore wrote:
> +static tree
> +omp_dynamic_cond (tree ctx)
> +{
> +  tree expr = NULL_TREE;
> +
> +  tree user = omp_get_context_selector (ctx, OMP_TRAIT_SET_USER,
> +					OMP_TRAIT_USER_CONDITION);
> +  if (user)
> +    {
> +      tree expr_list = OMP_TS_PROPERTIES (user);
> +
> +      gcc_assert (OMP_TP_NAME (expr_list) == NULL_TREE);
> +
> +      /* The user condition is not dynamic if it is constant.  */
> +      if (!tree_fits_shwi_p (TREE_VALUE (expr_list)))
> +	expr = TREE_VALUE (expr_list);
> +    }
> +
> +  tree target_device
> +    = omp_get_context_selector_list (ctx, OMP_TRAIT_SET_TARGET_DEVICE);
> +  if (target_device)
> +    {
> +      tree device_num = null_pointer_node;
> +      tree kind = null_pointer_node;
> +      tree arch = null_pointer_node;
> +      tree isa = null_pointer_node;
> +
> +      tree device_num_sel
> +	= omp_get_context_selector (ctx, OMP_TRAIT_SET_TARGET_DEVICE,
> +				    OMP_TRAIT_DEVICE_NUM);
> +      if (device_num_sel)
> +	device_num = OMP_TP_VALUE (OMP_TS_PROPERTIES (device_num_sel));
> +      else
> +	device_num = build_int_cst (integer_type_node, -1);

I think this won't correctly distinguish 'omp_initial_device' (= -1) 
from unset. OpenMP has 'omp_invalid_device', 'omp_initial_device' and 
then the values 0 to omp_get_num_devices()  [where the latter denotes 
the host, 0 ... < omp_get_num_device() are non-host devices].


>   /* Compute *SCORE for context selector CTX.  Return true if the score
>      would be different depending on whether it is a declare simd clone or
> @@ -2194,12 +2308,21 @@ omp_context_compute_score (tree ctx, score_wide_int *score, bool declare_simd)
>   {
>     tree selectors
>       = omp_get_context_selector_list (ctx, OMP_TRAIT_SET_CONSTRUCT);
> -  bool has_kind = omp_get_context_selector (ctx, OMP_TRAIT_SET_DEVICE,
> -					    OMP_TRAIT_DEVICE_KIND);
> -  bool has_arch = omp_get_context_selector (ctx, OMP_TRAIT_SET_DEVICE,
> -					    OMP_TRAIT_DEVICE_ARCH);
> -  bool has_isa = omp_get_context_selector (ctx, OMP_TRAIT_SET_DEVICE,
> -					   OMP_TRAIT_DEVICE_ISA);
> +  bool has_kind
> +    = (omp_get_context_selector (ctx, OMP_TRAIT_SET_DEVICE,
> +				 OMP_TRAIT_DEVICE_KIND)
> +       || omp_get_context_selector (ctx, OMP_TRAIT_SET_TARGET_DEVICE,
> +				    OMP_TRAIT_DEVICE_KIND));

I do not completely understand how that's used, but I have the feeling 
that having a match that contains both 'device' and 'target_device' is 
not correctly handled here.

>       int *scores
>         = (int *) alloca ((2 * nconstructs + 2) * sizeof (int));

That's not new but I have the feeling it should be '+ 3' and not '+ 2'
for device or target_device + and having both device and target device,
it might even need to be + 6.

I also wonder whether 'alloca' will really work - or only when inlined 
at all call sites. (Currenlty, it is called 6 times - and a 7th time 
with this patch.)

That's how far I came and before having to leave for now. (And having no 
time to think about what I wrote about 'score'.)

Tobias

  reply	other threads:[~2024-01-06 19:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-06 18:52 [PATCH 0/8] OpenMP: Implement metadirective support Sandra Loosemore
2024-01-06 18:52 ` [PATCH 1/8] OpenMP: metadirective tree data structures and front-end interfaces Sandra Loosemore
2024-01-06 19:45   ` Tobias Burnus [this message]
2024-01-07 12:18     ` Tobias Burnus
2024-01-06 18:52 ` [PATCH 2/8] OpenMP: middle-end support for metadirectives Sandra Loosemore
2024-01-06 18:52 ` [PATCH 3/8] libgomp: runtime support for target_device selector Sandra Loosemore
2024-01-06 22:44   ` Tobias Burnus
2024-01-07 11:48     ` Tobias Burnus
2024-01-06 18:52 ` [PATCH 4/8] OpenMP: C front end support for metadirectives Sandra Loosemore
2024-01-06 18:52 ` [PATCH 5/8] OpenMP: C++ front-end " Sandra Loosemore
2024-01-06 18:52 ` [PATCH 6/8] OpenMP: common c/c++ testcases " Sandra Loosemore
2024-01-06 18:52 ` [PATCH 7/8] OpenMP: Fortran front-end support " Sandra Loosemore
2024-01-06 18:52 ` [PATCH 8/8] OpenMP: Update documentation of metadirective implementation status Sandra Loosemore

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=af36b83e-1aa9-4400-875b-a387f3eb3319@net-b.de \
    --to=burnus@net-b.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=kcy@codesourcery.com \
    --cc=sandra@codesourcery.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).