public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Chung-Lin Tang <cltang@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	Catherine Moore <clm@codesourcery.com>,
	Tobias Burnus <tobias@codesourcery.com>,
	Thomas Schwinge <thomas@codesourcery.com>
Subject: Re: [PATCH, v2, OpenMP 5.0] Implement relaxation of implicit map vs. existing device mappings (for mainline trunk)
Date: Tue, 9 Nov 2021 16:18:17 +0100	[thread overview]
Message-ID: <20211109151817.GU2710@tucnak> (raw)
In-Reply-To: <ea104896-ffc4-c534-f45d-ac55fecafb4e@codesourcery.com>

On Sat, Nov 06, 2021 at 12:51:59AM +0800, Chung-Lin Tang wrote:
>  static int
>  get_kind (bool short_mapkind, void *kinds, int idx)
>  {
> -  return short_mapkind ? ((unsigned short *) kinds)[idx]
> -		       : ((unsigned char *) kinds)[idx];
> +  int val = (short_mapkind
> +	     ? ((unsigned short *) kinds)[idx]
> +	     : ((unsigned char *) kinds)[idx]);
> +
> +  if (short_mapkind && GOMP_MAP_IMPLICIT_P (val))
> +    val &= ~GOMP_MAP_IMPLICIT;
> +  return val;
> +}

It doesn't make sense to test it twice.  I'd do:
  if (!short_mapkind)
    return ((unsigned char *) kinds)[idx];
  int val = ((unsigned short *) kinds)[idx];
  if (GOMP_MAP_IMPLICIT_P (val))
    val &= ~GOMP_MAP_IMPLICIT;
  return val;

> +
> +
> +static bool
> +get_implicit (bool short_mapkind, void *kinds, int idx)
> +{
> +  int val = (short_mapkind
> +	     ? ((unsigned short *) kinds)[idx]
> +	     : ((unsigned char *) kinds)[idx]);
> +
> +  return short_mapkind && GOMP_MAP_IMPLICIT_P (val);
>  }

and here even simpler, no need to read kinds at all:
  if (!short_mapkind)
    return false;
  int val = ((unsigned short *) kinds)[idx];
  return GOMP_MAP_IMPLICIT_P (val);
?

Otherwise LGTM.

	Jakub


  reply	other threads:[~2021-11-09 15:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 15:17 [PATCH, OG10, OpenMP 5.0, committed] Implement relaxation of implicit map vs. existing device mappings Chung-Lin Tang
2021-05-07 12:35 ` Thomas Schwinge
2021-05-10  9:35   ` Chung-Lin Tang
2021-05-14 13:20   ` [PATCH, OpenMP 5.0] Implement relaxation of implicit map vs. existing device mappings (for mainline trunk) Chung-Lin Tang
2021-06-07 11:28     ` Thomas Schwinge
2021-06-24 15:55     ` Jakub Jelinek
2021-11-05 16:51       ` [PATCH, v2, " Chung-Lin Tang
2021-11-09 15:18         ` Jakub Jelinek [this message]
2021-11-24 11:22         ` 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=20211109151817.GU2710@tucnak \
    --to=jakub@redhat.com \
    --cc=clm@codesourcery.com \
    --cc=cltang@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=thomas@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).