Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ASSIGNMENT 1

CSC3021 Concurrent Programming 2022-2023

Question 1: Process Interleaving: Straight-Line Code [15 marks]

Consider the following program:

Analyse the above code and answer following questions:

· Consider whether all statements are atomic and transform the program to load/store architecture if needed.

· Identify the conflicting pairs of atomic instructions.

· State an upper bound on the possible number of outcomes for this program based on the number of processes and atomic instructions in this program.

· State an upper bound on the possible number of outcomes for this program based on the number of conflicting pairs found.

· What are the possible final values of ‘n’ and ‘k’? Justify your answer.

 Question 2: Process Interleaving with Control Flow [10 marks]

Consider the following program:

Answer following questions:

(i) Consider whether all statements are atomic and transform the program to load/store architecture if needed.

(ii) Identify all conflicting pairs of atomic instructions.

(iii) Construct an interleaving of instructions of the processes ‘P’ and ‘Q’ for which the program terminates.

(iv) What are the possible values of ‘n’ when the program terminates? Can you argue that other values than those you have listed for ‘n’ are impossible?

(v) Does the program terminate for all ways to interleave instructions assuming a fair scheduler? Does the program also terminate for execution scenarios that are unique to an unfair scheduler? Justify your answers. (Reminder: with a fair scheduler no process is deferred forever).

 Question 3: Graph Processing - Introduction [15 marks]

This question lays the foundation for the remaining assessments on the implementation of concurrent graph processing operations. In this assignment you will complete the implementation of a graph processing program. A skeleton program is available in a git repository. 1 You will extend the code by completing the implementation of key data structures to represent graphs.

The code models graph analytics applications as a repeated graph traversal. Each traversal operates like a higher-order map method: all edges of the graph are visited and a user-supplied method is called for each edge. This method performs a function specific to the graph analytics. For instance, in PageRank it consists of a floating-point addition, while the label propagation algorithm performs a ‘minimum’ operation on integers. The actual operation performed is not of immediate interest to us. We will focus our attention on completing the graph data structures. An accompanying document, available on canvas, gives additional information on the PageRank problem. It is useful to familiarise yourself with the PageRank problem for debugging and validation purposes.

The code may operate using one of three graph data structures (CSR, CSC or COO, defined in the slides). Implement the omitted code for calculating out- degrees (an auxiliary method required by PageRank) and for the edgemap method for each of the COO, CSR, and CSC sparse matrix formats. You only need to modify the files SparseMatrix{COO|CSR|CSC}.java. Keep the

command-line interface of the Driver.java program as is and keep the damping factor at 0.85. Test your code thoroughly as you will extend it in the next question. Confirm that all three versions calculate the same PageRank values, up to an error tolerance of 10-7.

Perform following experiments using your implementation and the orkut_undir2

graph and briefly answer these questions:

(i) Record the residual error (printed to the console by the PageRank operation) at the end of each iteration of the power method for each of the three matrix formats. Plot these values in a chart (consider log-scale). Summarise your observations.

(ii) Record the execution time taken by the PageRank algorithm for each of the three graph data structures (CSR, CSC and COO). Plot these in a chart. Can you explain why some formats result in lower execution time than others?

(iii) Modify your code to use single-precision floating-point numbers instead of double-precision floating-point numbers for one of the three sparse matrix formats by performing a search-replace operation (this affects the PageRank.java and Driver.java files). Record the residual error at the end of each power iteration step and the average execution time when using single-precision vs. double-precision floating-point numbers. Report these numbers using charts. Can you explain this result?

Submission

Your submission will consist of three parts: a write-up containing your responses to Q1 and Q2, and a discussion of your findings for Q3, your completed code for Q3 submitted to a git repository on gitlab2.eeecs.qub.ac.uk, and the same code submitted to an online test server.

· The write-up is a PDF document containing your answers to Questions 1-3. Submit it through Canvas. Do not put your name, student ID or other identifying information in the write-up as it will be reviewed anonymously.

When plotting charts in response to Q3, take care to present them carefully, clearly label all components, scale them properly so they fit on the page, and adjust font sizes and colours to be readable.

Unfortunately, neither Microsoft Word nor Excel come with good default settings.

· Develop your code for Q3 through a private git repository hosted on gitlab2.eeecs.qub.ac.uk to which you will provide access to the users [email protected], [email protected], [email protected], [email protected]. When you add these users, myself and the demonstrators will be emailed about the details of the repository.

Make sure to make frequent commits to the repository as the commit history can inform the marking in case your program is not fully functioning.

· Your code will be submitted through an online testing and evaluation system3 available at http://hvan.eeecs.qub.ac.uk/ using the contest ‘2223_A1’. This system will test the correctness of your code in a few sample situations by checking the correctness of the computed values. The relative ranking of your solution compared to others is irrelevant for this assignment. You will be informed of your login credentials for this site in due time.