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
Should use C11 atomics #17
Comments
Hi @clausecker, while probably migrating to C11 atomics is a good idea for portability, I do not yet understand why volatile is a problem. The reason I use volatile here is to force the compiler to emit a read operation instead of optimizing the read away. Why can't I do this using volatile under C11 semantics, if I were to migrate to C11 atomics? |
The
The
You are also using |
With the |
@trolando I don't see how For example, on an architecture with a less strict addressing mode, So Note also that both C11 threads and pthreads provide barrier types, so I don't really see why you felt the need to implement your own. |
@clausecker The whole Since using normal writes/reads on I don't see barrier types provided by C11 threads, please clarify. I could try to first fix Lace to ditch POSIX and rely only on C11 provided primitives, hopefully without deteriorating performance... if this works for Lace and the benchmarks are stable, I could then just copy the new Lace header/source files to Oink. |
So far I can partially modify Lace to use atomics instead of volatile variables, but I find that the generated code is less optimized. For example, Lace has a |
Might be possible to use a union here. |
It already is a union, it's just that for some reason the compiler now decides to compute the result via the stack instead of pure registers :( |
The project currently uses haphazardly hand-crafted atomics using
volatile
variables. This is not guaranteed to work correctly and is unportable. Consider migrating to C11 atomics if possible.The text was updated successfully, but these errors were encountered: