These past weeks, I’ve been working a lot on my side project and I’ve made a new release of it. First of all, the project has been renamed “Foundry” (instead of “rlife”). I wanted to find a better name for this project and as this project is now actually based on Vulkan (that was my primary objective when I started it), I thought it would be a good idea to give a name related to it. Plus, there was no crates already named “Foundry”.
So the biggest change is that the computations for passing from a generation of a grid to the next one are not done with the CPU anymore but with the GPU via the Vulkan API. To add the Vulkan support, I’ve used vulkano. The grid is represented as a
Vec where each cell is a
u8. So instead of computing and writing sequentially the new states of the cells in another new grid, we have now two grids (one for the current generation and the other for the next one) contained inside images stored on the Vulkan device’s memory (ideally the graphic card’s memory when there is one on the machine) and the device will launch parallel computations for determining and writing the next states of the cells.
So what are the results in term of performances? It turned out that there are huge gains regarding the time which is taken to compute the next generations of grids. Especially for computing a lot of generations at once and/or for large grids. Here are the results I’ve got with my machine that have an Intel Core i7-6700 as a CPU and an AMD Radeon RX 480 as a GPU (I’ve first generated a grid filled randomly and with a certain requested size and then run the computations):
- calculating 1000 generations of a toroidal grid with a width of 1024 cells and a height of 1024 cells with the CPU: 74.040 seconds
- doing the same with the GPU: 0.754 seconds
- calculating 1000 generations of a resizable grid with a width of 1024 cells and a height of 1024 cells with the CPU: 100.603 seconds
- doing the same with the GPU: 1.968 seconds
- calculating 1 generation of a toroidal grid with a width of 16384 cells and a height of 16384 cells with the CPU: 18.917 seconds
- doing the same with the GPU: 0.083 seconds
- calculating 1 generation of a resizable grid with a width of 16384 cells and a height of 16384 cells with the CPU: 25.903 seconds
- doing the same with the GPU: 0.243 seconds
I will soon write proper benchmarks for Foundry for better measurements.
Obviously, this is the very first implementation of the Vulkan API support so there are a lot of optimizations left to do.
See the PR that brings the Vulkan support for more details.
The next goal is to find a way for rendering the grid using Vulkan, so that Foundry can be used within GUI applications.