Sujet : Re: Memory ordering
De : aph (at) *nospam* littlepinkcloud.invalid
Groupes : comp.archDate : 17. Dec 2024, 21:38:18
Autres entêtes
Message-ID : <LDSdnRp-r7KnfPz6nZ2dnZfqnPudnZ2d@supernews.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : tin/1.9.2-20070201 ("Dalaruan") (UNIX) (Linux/4.18.0-553.27.1.el8_10.x86_64 (x86_64))
jseigh <
jseigh_es00@xemaps.com> wrote:
C++ doesn't use #LoadStore, etc... memory ordering terminology. They
use acquire, release, cst, relaxed, ... While in some cases it's
straightforward as to what that means, in others it's less obvious.
Indeed you don't know the exact mapping to instructions, but that's
the idea: you ask for the ordering model you want, and the compiler
chooses the instructions.
Non-obvious isn't exactly what you want when writing multi-threaded
code. There's enough subtlety as it is.
There are efficiency advantages to be had from getting away from
explicit barriers, though. AArch64 has seq-cst load and store
instructions which don't need the sledgehammer of of a full StoreLoad
between a store and a load.
Andrew.