gpt4 book ai didi

Why release sequence can only contain read-modify-write but not pure write(为什么发布序列只能包含读-修改-写而不能包含纯写)

转载 作者:bug小助手 更新时间:2023-10-25 17:22:35 25 4
gpt4 key购买 nike




After a release operation A is performed on an atomic object M, the
longest continuous subsequence of the modification order of M that
consists of:



  1. Writes performed by the same thread that performed A. (until C++20)

  2. Atomic read-modify-write operations made to M by any thread. Is
    known as release sequence headed by A.




  • Q1: Why do we need the concept of release sequence?

    问1:为什么我们需要发布顺序的概念?


    A1: See What does "release sequence" mean?

    A1:看看“发布顺序”是什么意思?



  • Q2: Is the first item removed in C++20?

    Q2:在C++20中删除了第一项吗?



  • Q3: Why read-modify-write operations qualify in a release sequence but pure write operations don't?

    问题3:为什么读-修改-写操作在发布序列中符合条件,而纯写操作不符合条件?


    What's special about relaxed RMWs that lets them form a chain without being an acquire load and release store? Either in computer-architecture terms, or in C++ language formalism? Or to put it another way, how can hardware support release-sequence semantics for atomic RMWs but have pure stores that break connections?

    放松的RMW有什么特别之处,让他们形成了一个连锁店,而不是一个收购、装载和释放商店?无论是在计算机体系结构方面,还是在C++语言形式主义方面?或者换一种说法,硬件如何支持原子RMW的发布顺序语义,但拥有中断连接的纯存储?




更多回答

We need the concept of a release-sequence because some hardware is weak enough that an acquire load might not sync-with all previous release-stores in the modification-order for that object, not just the one who's value headed this release-sequence. My answer on What does "release sequence" mean? explains that most hardware is stronger, and provides the guarantees of older C++ standards from before they came up with the release-sequence rule at all.

我们需要释放序列的概念,因为一些硬件足够弱,以至于获取加载可能不会与该对象的所有先前的发布存储按修改顺序同步,而不仅仅是值领导该发布序列的那个对象。我的答案是“发布顺序”是什么意思?解释说,大多数硬件都更强大,并提供了旧C++标准在提出发布顺序规则之前的保证。

@PeterCordes Proposal and discussion is in open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0982r1.html.

@PeterCordes提案和讨论在open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0982r1.html。

@PeterCordes (Q3) I was wondering why RMWs can be included a release sequence but pure stores cannot. The "read" part of RMWs doesn't look important here. It should be some special characteristics of RMWs that qualify them in a release sequence.

@PeterCordes(Q3)我想知道为什么RMW可以包括在发布序列中,而纯商店不能。在这里,RMW的“阅读”部分看起来并不重要。应该是RMW的一些特殊特性使它们在发布序列中具有资格。

If you had a middle-man thread that, instead of relaxed RMW, did an acquire load and then a release store back to the same object, IIRC the resulting happens-before is strong enough to be transitive; an acquire load of that new value would see values from before the original release store as well. But IDK about consume load / release store as a replacement for a relaxed RMW.

如果您有一个中间人线程,而不是松弛的RMW,它执行一个获取加载,然后一个释放存储返回到同一个对象,IIRC产生的发生-之前足够强,可以传递;这个新值的获取加载也将看到原始发布存储之前的值。但IDK认为可以使用加载/释放存储来替代宽松的RMW。

Re: your title: reads don't disturb a release-sequence; any number of other threads can observe values if they want to. But x.store(x.load(relaxed), relaxed) would on paper, if that's what you mean. Reads aren't part of the modification order, they just observe a point in it.

Re:你的标题:阅读不会扰乱释放顺序;如果愿意,任何数量的其他线程都可以观察值。但是如果你是这个意思的话,那么x.store(x.Load(轻松的),轻松的)在纸面上是可以的。阅读不是修改命令的一部分,他们只是观察其中的一个点。

优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com