-
Notifications
You must be signed in to change notification settings - Fork 242
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
shared memory + atomic addition? #5894
Comments
I wonder if it is a driver issue. I have this simple code:
which generates:
Looking at this spirv, I am not able to identify anything suspicious. Can you update your driver etc. and try again? Which platform/hardware are you using? |
I recommend using Slang's Atomic type for more explicit control on atomic load and store. Can you try:
|
@csyonghe Thank you very much for answering and I am really sorry that I didn't provide you the minimum code that reproduces the bug. Your code works. Although, I think I found the correct combination of factors to catch it. This is it:
It seems like writing into global memory is messing around with my shared memory. This global memory is large enough to allocate hundreds of 32bit registers thus I don't think I am writing out of bounds or something like that. By the way, this is the spirv code:
I'll attach the whole spirv output in case you need it: I hope this sheds some light on the issue. Edit: I am on Vulkan Instance Version: 1.3.280, Win11, RTX4090, Nvidia driver v.566.36 Jaime. |
I feel you may be running into a driver bug. |
I would also try changing the barrier to AllMemoryBarrierWithGroupSync() and see if it changes anything. |
I did use AllMemoryBarrierWithGroupSync as suggested but nothing changed. I will try to find someone who can test the code too because I have no other GPU available right now. I'll keep you updated. Jaime. |
Hi again @csyonghe, I coded a simple project for Daxa API about this topic using GLSL & Slang: The GLSL version works, the Slang one doesn't. Best regards, |
Let me verify this on my machine and get back to you. |
I created this test:
The result of
which suggests that the code is working properly. There could be other factors in your application that are causing this issue. I inspected the SPIRV and unable to find anything wrong about it. I am on RTX4090 with NVIDIA driver 561.09. |
I am seeing that you are using unoptimized code. Can you pass -O1 to slang and let spirv opt process the SPIRV first? I've seen bugs within the driver when dealing with unoptimized spirv. Update: I tried running unoptimized spirv for this test as well, and it still produces correct result. |
So you ran the same test in PR #6107 and you see 0s? |
I have run your test and it works on my machine! Do you think that bindless descriptors could be messing with shared memory somehow? I was looking into the compilation flags that Daxa uses: |
I could now also replicate the issue jaisero showed.
It prints 0, but it should print 1. Config:
I also tried barriers and removing all the compile flags but nothing helped. I suspect that vulkan validation layers could cause a difference in results. |
Update: using the latest slang i can not reproduce. It seems to work now. |
Confirmed: the newest Slang version solved the issue for me. |
@Jaisiero Glad to know that this issue is resolved! Closing this now, and please let us know if you run into other problems. |
Thank you for helping! Much appreciate it. |
Hi there! I'm using shared memory and trying to increment it with an atomic operation in a compute shader but it's not working.
I have tried to simplify the code as much as possible. Could you guys take a look?
Expected value: It should return at least one (more than zero for sure, printf is performed when regular increment is used).
Value return: When I use atomics, value returned is always zero (not printf performed at all).
Thank you!
Jaime.
The text was updated successfully, but these errors were encountered: