Implementation of Conway's game of life in C++ and CUDA.
- Any live cell with two or three live neighbours survives.
- Any dead cell with three live neighbours becomes a live cell.
- All other live cells die in the next generation. Similarly, all other dead cells stay dead.
-
To compile use the use:
- nvcc -c conway_gpu.cu conway.cpp
- nvcc conway_gpu.o conway.o simulate.cu -o simulate
-
To generate the data run:
- ./simulate cpu random
- ./simulate cpu spaceship
- ./simulate gpu random
- ./simulate gpu spaceship
-
To plot the results run:
- ipython plotting random
- ipython plotting spaceship
Simulatuion with grid initiated with 30P5H2V0 spaceship
To run the benchmark first compile with:
- nvcc -c conway_gpu.cu conway.cpp
- nvcc conway_gpu.o conway.o benchmark.cu -o benchmark
And then run the bash script ./run_benchmark.sh. Bellow is the output for 100000 iterations.
grid | t_cpu [s] | t_gpu [s] | err |
---|---|---|---|
400 | 3.27869 | 0.381443 | 0 |
900 | 6.03539 | 0.367432 | 0 |
1600 | 9.54228 | 0.362275 | 0 |
2500 | 13.9355 | 0.386967 | 0 |
3600 | 18.9013 | 0.392833 | 0 |
4900 | 24.9878 | 0.385277 | 0 |
6400 | 31.363 | 0.40496 | 0 |
8100 | 39.3561 | 0.417143 | 0 |
10000 | 47.1459 | 0.449636 | 0 |
12100 | 56.6858 | 0.426525 | 0 |