Code Monkey home page Code Monkey logo

cgol-pthread-parallelization's Introduction

CGOL-Pthread-Parallelization

Using pthreads to parallelize Conway's Game Of Life

Note: Usage of many global variables was required for parallelization.

Usage

compile: make

execute:

Data parallelization: ./dat_gol numThreads gridSize numIterations (-d)

Task parallelization: ./task_gol gridSize numIterations (-d)

Where:

  • numThreads is the number of threads used for the data parallel program
  • gridSize is the size of the grid (i.e 10 = 10x10)
  • numIterations is the number of iterations of the board to be computed
  • if "id" is present, the output of each board is outputted to stdout

Data Vs Task parallelization

Data approach: Assign n pthreads with an approximately equal number of board squares to compute and update.

Task approach: 3 threads.

  1. computes whether a square will be alive or dead in the next board iteration. Add the index of this square to either the alive queue or dead queue.
  2. Reads from the alive queue and updates the square for the next iteration
  3. Reads from the dead queue and updates the square for the next iteration

This approach is less effective than a serial verison. I just thought it would be interesting to create a task parallelized approach to this problem!

Some Other information

The board: The board is created with the odds of a dead cell being spawned: 66.66%, live cell 33.33%.

Due to the restraints of stdout terminal...printing boards too large (i.e 100 x 100) will look distored. Boards up to ~60x60 appear nicely.

Maximum number of iterations = 10000

cgol-pthread-parallelization's People

Contributors

luke-fischer avatar parzival-05 avatar

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.