Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

NotificationsYou must be signed in to change notification settings

gerzin/parallel-cellular-automata

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.

Note on fastflow

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.

🛠️ Compilation

to compile the library you must use CMake.

mkdir buildcd buildcmake -DCMAKE_BUILD_TYPE=Release ..make

this 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).

Example

#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;}

📝 Report

The project report with the framework's results can be foundhere.

✏️ TODO

  • 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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp