Giter VIP home page Giter VIP logo

gerzin / parallel-cellular-automata Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 0.0 1.16 MB

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.

Home Page: https://gerzin.github.io/parallel-cellular-automata/namespaces.html

License: MIT License

CMake 0.71% C++ 99.08% Shell 0.20%
cpp cellular-automata cellular-automaton framework fastflow openmp openmp-parallelization cpp17 cpp-library multithreading

parallel-cellular-automata's Introduction

parallel-cellular-automata

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 namespace ca 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 to std::thread::hardware_concurrency.

Note on fastflow

fastflow needs to be optimized for the machine it's running on. To optimize it run the script mapping_string.sh under include/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 build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make

this will create a static library in the build directory. To use the framework include the files under include and link with the generated library (libparallelcellularautomata.a on linux).

All the documentation is written using doxygen comments. Call doxygen in the main dir to generate it (this will create a doc folder).

Example

#include<cellular_automata.hpp>

int main() {
    ca::Grid<int> grid(100,100);

    // init the grid
    for(...){
        grid(i,j) = something;
    }

    // define update function with this signature
    auto 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 found here.

โœ๏ธ TODO

  • port it to C++20 once modules are available.
  • add support to CUDA.
  • improve the various CMakeLists.txt.

Contributions are very welcome.

parallel-cellular-automata's People

Contributors

gerzin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

parallel-cellular-automata's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.