Replies: 2 comments
-
I don't know why exactly the CPU is faster although I have some theories but I can tell you 1. Yes this is a great place for this (even though it's not nearly checked enough) and 2. I actually did quite a bit of research on workgroups for my PR on adding examples. You can find my example for demonstrating and explaining workgroups at https://github.com/JustAnotherCodemonkey/wgpu/tree/JustAnotherCodemonkey/add-examples/examples/hello-workgroups. I hope that helps and if that example isn't very helpful, please tell me what I can improve on before the PR gets merged. |
Beta Was this translation helpful? Give feedback.
-
The total workgroup size (all dimensions of But in general, if you only run a few dozen or hundred invocations of your shader, the performance will not be very impressive. There is a decent amount of driver overhead associated with every dispatch, and even mid-range GPUs have enough cores to run 2000-3000 instances of your shader at once, let alone sequentially. You should also watch out for potential access conflicts to the |
Beta Was this translation helpful? Give feedback.
-
Firstly, please tell me if this isn't the good place to ask this question that is more related to WGSL than wgpu.
I try to simulate ants moving on a graph, and because each ant is independent, I through that it will a good idea to use GPU to simulate those ants in parallel.
But when comparing the execution time between my code on CPU and GPU, I find that until 150 ant simulated, the CPU was faster than the GPU.
One hypothesis I have on what is happening is that, because I write every movement of every ant on the same buffer, the GPU has some difficulty to synchronize the code on each workgroup.
Here is approximately my code :
Also, I don't really understand how workgroup and workgroup_size work, so maybe the issue come from here.
Do you have any idea why the GPU is slower than the GPU, and what can I do to properly use the computing power of the GPU ?
Beta Was this translation helpful? Give feedback.
All reactions