top of page

Parallel Programming

parallel1.png

For this project, I learned the concepts of parallel programming and applied my knowledge into developing a program to have optimised performance, followed by an analysis of my results in a report. This is achieved with C++, using OpenMP and MPI for parallelisation.

Overview

"This assignment asks you to implement serial and parallel versions of a prey/predator simulation using cellular automata and provide performance and behaviour analysis."

Parallel programming, in short, is a way to make code execute faster by taking advantage of modern hardware. This makes programs run faster and could, for example, make it so that more instructions can fit into the same sized program, more results can be generated in a set time, etc.

The idea is to 'parallelise' code- this must be done with careful consideration. I have to write/identify blocks of code which can be made to run in parallel and benefit from the methods. I analyse results throughout to ensure I am correctly applying these methods.

Preview

Skills Developed

  • C++

  • OpenMP and MPI libraries (knowledge and application)

  • Parallel programming concepts and practical use

  • Efficiently debug and troubleshoot code

  • Determine code performance, through monitoring and measuring

  • Improve code performance, through low and high level optimisation

  • Documentation

  • Research

  • Working to develop on external code

  • Fulfilling requirements from a brief using problem solving

Concepts Simply Explained

fox.png
fox.png
fox.png
fox.png
froggie.png
fox.png
fox.png
fox.png
fox.png

The program is based on a cellular automaton, defined as:

"A cellular automaton is a collection of "colored" cells on a grid of specified shape that evolves through a number of discrete time steps according to a set of rules based on the states of neighboring cells. The rules are then applied iteratively for as many time steps as desired." (source)

In a grid, we have cells. Each cell is represented by an organism.

The grid acts like an ecosystem. The cells are animals whose survival is determined by rules of the ecosystem- by those neighbouring them.

In this grid, the frog is fully surrounded by foxes. This means that:

1. The frog cannot find a mating partner and therefore cannot produce any offspring in the next generation.

2. The frog is likely to be predated on as it is surrounded by its predators.

These are examples of 'game rules', which are also implemented into this simulation.

fox.png
fox.png
fox.png
fox.png
froggie.png
fox.png
fox.png
fox.png
fox.png
fox.png
fox.png
fox.png
fox.png
fox.png
fox.png
fox.png
fox.png

In the next generation, the frog is no longer present as it has died. This change is represented in the grid. In a future generation, this cell may be filled with another animal. The foxes may one day also die, for example, by starvation and old age- these are also rules I implemented into this simulation.

Internally, the code works throughout the grid, analysing each cell to determine if the cell should change in the next iteration- this means that each animal in the ecosystem is analysed to determine their survival status. In large sized ecosystems (grids) this can become a heavy workload which can take a long time for a computer to process. This is where parallelisation comes in.

fox.png
fox.png
fox.png
fox.png
froggie.png
fox.png
fox.png
fox.png
fox.png

Each modern processor has multiple cores. To simplify, let's say each computer has multiple employees who it splits tasks with. In this sense, a computer with 2 workers can split the task of analysing this grid between both workers. Theoretically, this should result in the task being complete in half the time (but not exactly because of communication time, for example).

This is what is meant be 'parallel processing', or 'multi-threading tasks'.

Why Cellular Automaton?

The purpose of this project is to demonstrate proficiency at code optimisation using parallelisation models OpenMP and MPI with C++. The reason why there is a cellular automaton focus is because this provides an environment from which there are plenty of operations to execute- this creates a program which would benefit from parallelisation in the first place and allow for these proficiencies to be demonstrated and for these analyses to be carried out. 

bottom of page