Programming of Cellular Automata in C and C++
Patrik Christen

TL;DR
This paper evaluates various programming techniques and data structures for cellular automata in C and C++, finding minimal impact on performance and recommending best practices for implementation.
Contribution
It provides an empirical comparison of programming methods, data structures, and compilers for cellular automata, offering practical guidance for efficient implementation.
Findings
Using arrays instead of vectors has negligible effect on performance.
Choice of compiler (gcc vs clang) has minor impact, with clang sometimes better for simple functions.
Structures and objects do not significantly affect performance, supporting their use for multi-state automata.
Abstract
This study explores running times of different ways to program cellular automata in C and C++, i.e. looping through arrays by different means, the effect of structures and objects, and the choice of data structure (array versus vector in C++) and compiler (GNU gcc versus Apple clang). Using arrays instead of vectors, using pointers instead of array indices, using C instead of C++, and using structures and objects instead of primitive data types has little to negligible effects on the running time. Also, the choice of compiler has only a minor effect, except for simple update functions, in which case clang seems to find better ways to optimise it, especially for index-based access. If one is interested in multi-state cellular automata, structures and objects can be used without loss of performance in C and C++, respectively. The study supports the recommendation from practice to use…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsCellular Automata and Applications
