GPGPU Programming example: spiral animation

Feb 13, 2022 1 min read

After having come close to General Purpose GPU programming and having studied “CUDA by example”, I decided to take the time to write a simple CUDA example.

Many of the small projects I had in my mind were not suitable for CUDA, since they were using Tensorflow that lie above the cuDNN. Therefore, I decided to create a useless graphic animation to prove some techniques learnt in the book.

The problem exposed in this post is an animation based on a spiral. The spiral computed in this project is the Archimedean Spiral:

Figure 1) Formulas related to the Archimedean Spiral.

Figure 2) Graphical representation of the spiral formulas.

The figure is built starting from multiple spiral spinning at the same distance. Every pixel in the image has a tone in the grey scale that depends on the distance to the nearest spiral.

After the paralleled algorithm was written, I passed to CUDA implementation of a 512×512 animated image. The video here below shows well the dynamic behaviour.