-
Notifications
You must be signed in to change notification settings - Fork 247
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
Support Atomics #442
Comments
I was able to implement these here atomic so it looks like atomics do work on the latest version of the compiler. Is there a particular reason atomics have not been merged? It seems more natural to me to have these be functions as they are here instead of hooking into core::sync::atomic, since that would more or less require that shader inputs be AtomicU32 etc, which makes it hard to be generic over using atomic ops (like for accumulating across workgroups or shader stages) and impls that do not need atomic ops. It's also more consistent with opencl, glsl, cuda, etc which have functions not atomic types. My particular use case involves atomic accumulations of f32 via atomic_compare_exchange, as well as storing 16 and 8 bit values via a similar mechanism (thus more portable than requiring 16 explicit types). |
We haven't had the time to do proper research/design/evaluation of the various possibility spaces, because it's not a priority for us. For example...
I'm assuming rust had good reasons for creating the AtomicU32 etc. types instead of having them be operations on "regular" scalars (e.g. saftey, etc.). We should make sure we understand those reasons before blasting ahead with the status quo - rust-gpu is supposed to strive to "be as safe as regular rust", not blindly follow the (potentially unsafe) status quo. |
it seems to me that atomics/barriers/subgroups haven't made much progress recently due to unanswered design questions. would it make sense to expose these things as intrinsics in spirv-std until rust-gpu gains support for emitting them automagically? |
@dvc94ch Not really - once a path is set down on, it's difficult to re-evaluate and change direction. It takes even more resources to do so, and considering we don't even have enough to do the research in the first place, that's unlikely to happen. |
@khyperia seems like the vulkan memory model differs from the c++ memory model that rust uses, which would mean that rust-gpu should do it like this too.
|
Currently if you try to use an atomic you get the following error.
Code
Playground
Error
The text was updated successfully, but these errors were encountered: