From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Vineet Gupta <vineetg@rivosinc.com>
Cc: tech-unprivileged@lists.riscv.org, gcc@gcc.gnu.org,
Uros Bizjak <ubizjak@gmail.com>, Hans Boehm <hboehm@google.com>,
Hongyu Wang <hongyu.wang@intel.com>
Subject: Re: Fences/Barriers when mixing C++ atomics and non-atomics
Date: Thu, 13 Oct 2022 21:15:04 +0100 [thread overview]
Message-ID: <CAH6eHdSnx-V0SmS969pe=H=HfpcVFOnS-gPhJ1xcDyeXd509mQ@mail.gmail.com> (raw)
In-Reply-To: <8c7380d2-2587-78c7-a85a-a4c8afef2284@rivosinc.com>
On Thu, 13 Oct 2022 at 20:31, Vineet Gupta wrote:
>
> Hi,
>
> I have a testcase (from real workloads) involving C++ atomics and trying
> to understand the codegen (gcc 12) for RVWMO and x86.
> It does mix atomics with non-atomics so not obvious what the behavior is
> intended to be hence some explicit CC of subject matter experts
> (apologies for that in advance).
>
> Test has a non-atomic store
And a non-atomic load of 'g'
> followed by an atomic_load(SEQ_CST). I
> assume that unadorned direct access defaults to safest/conservative seq_cst.
Yes, the two functions below are identical.
>
> extern int g;
> std::atomic<int> a;
>
> int bar_noaccessor(int n, int *n2)
> {
> *n2 = g;
> return n + a;
> }
>
> int bar_seqcst(int n, int *n2)
> {
> *n2 = g;
> return n + a.load(std::memory_order_seq_cst);
> }
>
next prev parent reply other threads:[~2022-10-13 20:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 19:31 Vineet Gupta
2022-10-13 20:15 ` Jonathan Wakely [this message]
2022-10-13 20:30 ` Uros Bizjak
2022-10-13 21:14 ` Vineet Gupta
2022-10-13 21:29 ` Uros Bizjak
2022-10-13 20:54 ` Hans Boehm
2022-10-13 21:11 ` Vineet Gupta
2022-10-13 21:43 ` Hans Boehm
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='CAH6eHdSnx-V0SmS969pe=H=HfpcVFOnS-gPhJ1xcDyeXd509mQ@mail.gmail.com' \
--to=jwakely.gcc@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=hboehm@google.com \
--cc=hongyu.wang@intel.com \
--cc=tech-unprivileged@lists.riscv.org \
--cc=ubizjak@gmail.com \
--cc=vineetg@rivosinc.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).