SFML community forums

Help => Graphics => Topic started by: jimmyrickson on June 27, 2019, 09:03:02 am

Title: Particle cloud with sfml!!
Post by: jimmyrickson on June 27, 2019, 09:03:02 am
I've created a simple program that draws a "particle cloud" in the sfml window. With threads i can simulate about 100k particles that moves after the mouse, anything bigger makes it laggy. So my question is if there is anyway to use the gpu with the sfml library. I want to use the GPU to update the particle locations( this is what takes the most of the time to do). Have anyone of you guys tried anything similar? Thanks for reading, all the best

Title: Re: Particle cloud with sfml!!
Post by: Nexus on July 03, 2019, 09:56:22 pm
Generally, it's possible to do computing on GPUs -- some keywords to look for more might be CUDA, OpenCL, OpenACC.

The question is if it's worth it. In order to outperform the CPU, you need to exploit a GPUs massive-parallelized and vector-optimized architecture (which depends on the update pattern of your particles). Also keep in mind that both video memory and bandwidth to upload/download data to the graphics card can be limiting factors depending on your application.

Since GPU programming comes with quite some complexity, I would first try to maximize the performance on the GPU. Did you use a profiler to find the bottleneck? If the computation is stuck on one core, could you try multi-threading? Are you sure you use optimal data structures, algorithms, avoid cache misses and bad branch predictions, etc?