DEPARTMENT OF COMPUTING

CS 3005: Programming in C++

Faster Calculations

Introduction

We want to be able to calculate our grid numbers more quickly. One way to accomplish this is to use more cores of the CPU. We’ll use threads of execution to accomplish this task.

Assignment

In this assignment you will create a class ThreadedGrid, that inherits from the NumberGrid class and becomes the parent of the ComplexFractal class. The main purpose of the ThreadedGrid class is to override the calculateAllNumbers method so that it will use threads to calculate numbers simultaneously.

The ppm_menu program needs to adjust its commands.

The menu will now provide two options for calculation:

fractal-calculate-single-thread will call a new function to do the non-threaded version of calculation.

Programming Requirements

The following files must be updated or created and stored in the src directory of your repository.

Create ThreadedGrid.{h,cpp}

This class inherits from the NumberGrid class, and becomes the parent of ComplexFractal.

Data Members:

Methods:

Update ComplexFractal.{h,cpp}

ComplexFractal should now inherit from ThreadedGrid. This will require minor changes to the class declaration in the header file and in the constructor chaining in the implementation file.

Update image_menu.h and image_drawing.cpp

Add this function:

Note that calculateFractal() will not change. However, because of ThreadedGrid’s override of calculateAllNumbers(), calculateFractal() will automatically use the threaded version.

Update Functions in controllers.cpp

Table of New Commands

Command Name Function Name Description
fractal-calculate calculateFractal Calculate the escape values for the fractal.
fractal-calculate-single-thread calculateFractalSingleThread Calculate the escape values for the fractal, single-thread.

Update Makefile

The following commands should work correctly.

Additional Documentation

Show Off Your Work

To receive credit for this assignment, you must

Additionally, the program must build, run and give correct output.

Extra Challenges (Not Required)

Last Updated 09/11/2023