Skip to content

Parallel Implementation

This guide is for the Rust version of the coursework, which is offered as an optional extension.

In this stage, you are required to write code to evolve Game of Life using multithreading on a single machine.

The following pages are some suggested steps to help you get started, you are not required to follow them.

Your implementation will be marked against the success criteria outlined here.

Step 2

Step 2

Parallelise your Game of Life so that it uses worker threads to calculate the new state of the board.

You should implement a distributor that tasks different worker threads to operate on different parts of the image in parallel.

The number of worker threads you should create is specified in struct Params.

We recommend using threads or rayon (a data parallelism library), to parallelise the Game of Life computation.

We do NOT recommend tokio as it is designed for handling IO-bound tasks, it is not the best choice for the compute-bound tasks for this coursework.

If you use rayon, you can use rayon::ThreadPoolBuilder::new().num_threads().build() to manually generate a fix-sized thread pool, allowing you to specify how many threads rayon should use.

Test

To test your implementation, type the following in the terminal.

bash
cargo test --release --test gol