GPU Support in Grasshopper

There is a thing called shared memory, but it’s tricky to implement and limited in size.
You can also access global memory, but it’s slow because then you have to copy data between GPU and CPU.

Even if you managed to do so, you will have racing issue to deal with, where some threads might finished calculation while others are still working.

The safest way to manage other thread’s memory in my understanding is to use synchronization which you wait until all threads are completed and collect data from GPU to CPU, you then post process data in CPU and input the updated data into GPU again for next iteration or “frame”. But I am not sure how you can do all those directly in GPU without passing through CPU.

That said, it might be possible depending on the algorithm and how you implement your buffer.

But again, I might be entirely wrong🥲…

You are right, it is absolutely possible to use the data from a previous iteration. Normally you would use double-buffering, where you keep a copy of the GPU buffer of the previous frame and therefore don’t need to write any memory back to RAM, which would be super slow.

We have used it to code a GPU-based wave simulation in 2D and 3D or a GPU-based damper for example.