- Notifications
You must be signed in to change notification settings - Fork0
Framework for building parallel cellular automata in C++. In it you can also find a work-stealing threadpool and a reusable barrier that you can use in other projects.
License
gerzin/parallel-cellular-automata
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Framework for building Cellular Automata initially developed as a project for the exam of Parallel and Distrituted Systems.It offers four types of automata:
- A sequential one
- Three parallel ones, parallelized using:
- standard c++ library and pthread
- OpenMp
- FastFlow framework
the framework is inside the namespaceca and each automaton is located in its respective nested namespace (ca::seq ,ca::par,ca::par::bw,ca::ffl,ca::omp).
The interfaces of the automata are the same, so you can try different ones by simply replacing the namespace.The sequential automaton is missing the parameter to set the number of threads. If the other automata are called without passing that parameter, it will be set by default tostd::thread::hardware_concurrency.
fastflow needs to be optimized for the machine it's running on. To optimize it run the scriptmapping_string.sh underinclude/ff (you need to have hwloc installed).
This will be done automatically by cmake when you build the library.
to compile the library you must use CMake.
mkdir buildcd buildcmake -DCMAKE_BUILD_TYPE=Release ..makethis will create a static library in the build directory. To use the framework include the files underinclude and link with the generated library (libparallelcellularautomata.a on linux).
All the documentation is written using doxygen comments. Calldoxygen in the main dir to generate it (this will create adoc folder).
#include<cellular_automata.hpp>intmain() { ca::Grid<int>grid(100,100);// init the gridfor(...){grid(i,j) = something; }// define update function with this signatureauto update_fn = [](int c,int tl,int t,int tr,int l,int r,int bl,int b,int br) { do_something; };// if the namespace is the one of a parallel implementation you can pass// the number of workers too.ca::(seq,par,par::bw,omp,ffl)::CellularAutomaton<int>aut(grid, update_fn);// run 10 simulation steps aut.simulate(10); std::cout << grid;}
The project report with the framework's results can be foundhere.
- port it to C++20 once modules are available.
- add support to CUDA.
- improve the various CMakeLists.txt.
Contributions arevery welcome.
About
Framework for building parallel cellular automata in C++. In it you can also find a work-stealing threadpool and a reusable barrier that you can use in other projects.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.