-
Notifications
You must be signed in to change notification settings - Fork 1.6k
atomic_flag_test, lock free type aliases #684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I want to stress that there's a design decision on There are 3 sensible options:
First option will make good counters that are unlikely to wrap around, which makes some algorithm more reliable. Also it makes good interprocess types, since they can be shared between 32-bit and 64-bit processes. Standard mentions that "lock-free types should also be address-free for interprocess shared memory". Though it violates what standard tells that "operations should be most effective". 64-bit type on x86 is not most effective, though #651 could make the situation way better. Second option looks natural, but it is not different bitness interprocess friendly Third option is good for efficiency, for interprocess, in line with Linux, but does not make effort to make the best of x64: prone to wrap around, and cannot even fit pointer or size on x64. |
|
I think |
|
Can you add smoke tests for these? |
# Conflicts: # stl/inc/yvals_core.h # tests/std/tests/VSO_0157762_feature_test_macros/test.cpp
|
Marking as @cbezault says that on ARM32, 64-bit atomic operations aren't super efficient, so we are essentially deciding whether to special-case x86 or not. |
|
I vote to not special case x86. The only thing that was changed recently was load and store, exchange / cas / arithmetic etc. are still relatively slow. |
Are they way slower? Specifically, is Sure, |
# Conflicts: # stl/inc/yvals_core.h
|
Anyway, is there end of 32-bit x86 era in sight? What about 32-bit ARM? |
Still a full fence but one needs a loop and the other does not. And
I haven't bothered to benchmark but the loop case alone I think makes it worth not special casing in absence of data indicating that such a special case would be useful for anything. Being able to stuff a pointer in here is important. Being able to stuff more than a pointer has limited utility when still interpreting the result as an integral type. |
Co-Authored-By: Casey Carter <cartec69@gmail.com>
Co-Authored-By: Casey Carter <cartec69@gmail.com>
I was thinking about having 64-bit value that is less likely to wrap around is useful for patterns similar to SeqLock. But I missed registers clobbering and that loop overhead is present even if there's just one iteration, so I agree now that having 64-bit atomic lock free type on x86 contradicts the Standard requirement of "most efficient operations". |
This reverts commit 3ae2c0a. # Conflicts: # tests/tr1/tests/atomic/test.cpp
…into atomic_flag_test # Conflicts: # tests/tr1/tests/atomic/test.cpp
|
Now new test pass. |
StephanTLavavej
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! I have very minor suggestions, so I'll just go ahead and push changes.
CaseyCarter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - just a couple of style nitpicks that probably aren't worth resetting testing.
StephanTLavavej
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub testing is so fast, resetting it isn't a big deal. 😸 I just pushed changes to address your comments. I also added a reserve() call because @AlexGuteniev had already computed total and it seemed reasonable.
|
Thanks for yet another contribution, @AlexGuteniev! |
Keep wait for review #593 , easy parts can be made available separately earlier