Quantcast
Channel: What is the right std::atomic memory order for dynamic scheduling? - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by HolyBlackCat for What is the right std::atomic memory order for...

relaxed is ok, because regardless of memory order, each separate atomic variable is always consistent across all threads.Memory orders are only necessary when you have more than one variable (atomic or...

View Article



Answer by Peter Cordes for What is the right std::atomic memory order for...

relaxed is sufficient.Every counter.fetch_add(1, relaxed) will return a different value, and every value from 0 upwards will be returned once. Atomicity alone guarantees this since all operations are...

View Article

Answer by xryl669 for What is the right std::atomic memory order for dynamic...

I think you're confusing with a CAS (compare and swap) operation here.fetch_add is not a CAS, it's defined as a Read Modify Write atomic operation. It's not equivalent to atomic_var.compare_exchange(i,...

View Article

What is the right std::atomic memory order for dynamic scheduling?

I am wondering what the correct memory order is for the classic "atomic counter dynamic scheduling" idiom. That is:use fetch-add to get the index i of the next element to processif i is past the end of...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>