Create two new arrays to hold the results of calculations


Assessment Task:

This coursework will allow you to investigate some of the issues involved in writing threaded programs.

You are to write a series of simple programs in C/C++ that will run under Linux, to illustrate how multithreading may be used to partition a processing task. Designs should be presented and all code must be fully commented and handed in as part of the deliverable.

Consider a 2 D data array whose contents need to be processed.

The array consists of values representing the height of a terrain at that point.

Create two new arrays to hold the results of calculations.

Result array one is to hold the Euclidean distance between each point and the next point in the row.

Result array two is to hold the angle of the slope between the point and its neighbour in the row calculated using arcsin.

1. Set up the first array and write a sequential program that accesses the data array and populates the result arrays. Provide evidence that the calculations used are correct.

2. Create a second program that it is still sequential but accesses the data array by a series of calls to a single function. Each call to that function will process a number of rows of the array as defined by a parameter passed to the function.

3. Write a third version of the program that will allow the processing to be carried out in one or more threads. Each thread should access a different set of rows of the array as in 2. above so that locking etc. is not an issue. Your program must be able to run with different numbers of threads.

4. Investigate how you might obtain run time information for the implementations and report on run times of each of your implementations.

Experiment with your implementations on machines with different numbers of processors/cores and explain all results.

5. Write a conclusion to your investigations. This should include

• an overview of threads and processes
• expected gains in threading in a typical application
• expected link between numbers of cores/processes and performance
• narrative regarding your results and development include short discussion on how code would need to change if locking were required

6. You may need to do a short demonstration of your code in a lab session or at some mutually agreed time. This is a mandatory part of the assessment.

Submission Instructions

The report should be a single document, word processed in Word format, and it should present your findings clearly and concisely. Take care that code is neatly laid out in the report - correctly formatted and with all code in Courier New font.

You must submit only an electronic version of the coursework (via Blackboard) which may be submitted to a plagiarism detection system.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Create two new arrays to hold the results of calculations
Reference No:- TGS01720564

Expected delivery within 24 Hours