public inbox for gcc-patches@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] Fortran: Update use_device_ptr for OpenMP 5.1 [PR105318]
Date: Fri, 30 Sep 2022 13:04:53 +0200	[thread overview]
Message-ID: <YzbNVZ/Iu4OAptHA@tucnak> (raw)
In-Reply-To: <6005cea4-c89e-0c31-1c61-d322dcf072e7@codesourcery.com>

On Fri, Sep 30, 2022 at 12:41:19PM +0200, Tobias Burnus wrote:
> While has_device_addr has been implemented (in GCC 12), updating
> use_device_ptr for Fortran was missed.
> 
> This patch fixes it: Removing the restrictions and mapping to
> has_device_addr where applicable.
> 
> For use_device_ptr something similar was done, albeit I think
> this has no semantic effect.
> 
> And 'device(omp_initial_device)' printed a warning in Fortran.
> (BTW: C/C++ silently accepts any negative value.)

I think that is what the standard wants.
E.g. in 5.2 device Clause chapter, there is just
"If the device_num device-modifier is specified and target-offload-var is not mandatory,
device-description must evaluate to a conforming device number."
restriction, which is something that can't be checked at compile time,
you don't know if target-offload-var is mandatory or not.
>    if (omp_clauses->device)
> -    resolve_nonnegative_int_expr (omp_clauses->device, "DEVICE");
> +    {
> +      resolve_scalar_int_expr (omp_clauses->device, "DEVICE");
> +      /* omp_initial_device == 1, omp_invalid_device = -4 (in GCC).  */
> +      if (omp_clauses->device->expr_type == EXPR_CONSTANT
> +	  && omp_clauses->device->ts.type == BT_INTEGER
> +	  && mpz_cmp_si (omp_clauses->device->value.integer, -1) < 0
> +	  && mpz_cmp_si (omp_clauses->device->value.integer, -4) != 0)
> +	gfc_warning (0,
> +		     "INTEGER expression of DEVICE clause at %L must be non-"
> +		     "negative or omp_initial_device or omp_invalid_device",
> +		     &omp_clauses->device->where);
> +    }

So I think we should just resolve_scalar_int_expr and be done with that.

Otherwise LGTM.

	Jakub


  parent reply	other threads:[~2022-09-30 11:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30 10:41 Tobias Burnus
2022-09-30 10:57 ` Tobias Burnus
2022-09-30 11:04 ` Jakub Jelinek [this message]
2022-09-30 11:40   ` Tobias Burnus

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=YzbNVZ/Iu4OAptHA@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).