public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/102215] [GCN offloading] Missing '__atomic_compare_exchange_1' etc.
Date: Mon, 06 Sep 2021 12:01:28 +0000	[thread overview]
Message-ID: <bug-102215-4-ZQdXvDqtG2@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102215-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102215

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Actually, looking at GCN, it is inline e.g. for both:

int
foo (int *p)
{
  return __sync_val_compare_and_swap_4 (p, 1, 2);
}

int
bar (int *p)
{
  int e = 1;
  __atomic_compare_exchange_4 (p, &e, 2, 0, __ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST);
  return e;
}

but for 1 or 2 byte atomics it is never inline:

int
foo (char *p)
{
  return __sync_val_compare_and_swap_1 (p, 1, 2);
}

int
bar (char *p)
{
  char e = 1;
  __atomic_compare_exchange_1 (p, &e, 2, 0, __ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST);
  return e;
}


The reason why foo in the second testcase works is libgcc/config/gcn/atomic.c
which defines __sync_{val,bool}_compare_and_swap_{1,2}.

So, either it should also define __atomic_compare_exchange_{1,2} perhaps with
calling __sync_val_compare_and_swap_{1,2} under the hood or the other way
around, or the backend somewhere needs to rewrite calls to
__atomic_compare_exchange_{1,2} into calls to __sync_*_compare_and_swap_{1,2}.

The reason why I've changed omp-expand is that by using __atomic_* APIs one can
use the user-requested memory models, and once the 5.1 atomics support is done,
there will be more - weak flag too, and user specified failure memory models.

  parent reply	other threads:[~2021-09-06 12:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06  9:55 [Bug target/102215] New: " tschwinge at gcc dot gnu.org
2021-09-06  9:59 ` [Bug target/102215] " jakub at gcc dot gnu.org
2021-09-06 11:09 ` burnus at gcc dot gnu.org
2021-09-06 12:01 ` jakub at gcc dot gnu.org [this message]
2022-03-09 18:35 ` cvs-commit at gcc dot gnu.org
2022-03-10 12:07 ` burnus at gcc dot gnu.org

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=bug-102215-4-ZQdXvDqtG2@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).