0% found this document useful (0 votes)
32 views

National University of Computer and Emerging Sciences, Lahore Campus

Uploaded by

Moazzam Sheikh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

National University of Computer and Emerging Sciences, Lahore Campus

Uploaded by

Moazzam Sheikh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

National University of Computer and Emerging Sciences, Lahore Campus

Course Name: Parallel and Distributing Computing Course Code: CS3006


Degree Program: BS (CS) Semester: Spring 2023
Exam Duration: 180 Minutes Total Marks: 80
Paper Date: 24/05/23 Weight 45
Exam Type: Final Page(s): 10
Student : Name:________________________ Roll No.________________ Section:______
Instruction: Attempt all questions on the question paper. Rough sheets can be used but it should not be
attached. If you think some information is missing then assume it and mention it clearly.

Question # 1: [15 marks, CLO # 1]

From the given options, select the best answer.

i. Which of the following combination is used by Hadoop for storage and processing?
a. AFS and MapReduce
b. HDFS and MapReduce
c. AFS and UFIDs
d. HDFS and UFIDs

ii. The mechanism of packing function parameters into a message packet is called ________.
a. Marshalling
b. RPC paradigm
c. Stubbing
d. None of the above

iii. ____________ is a meta language to describe the services offered by a service provider.
a. SOAP
b. XML
c. WSDL
d. UDDI

iv. ___________ redundancy technique does not provide error masking.


a. Active
b. Passive
c. Hybrid
d. TMR

v. ‘Google App Engine’ is an example of


a. Infrastructure as a service
b. Platform as a service
c. Software as a service
d. None of the above

vi. An f-resilient algorithm needs _____ rounds to solve consensus for f failed processors
a. f
b. f + 2
c. f + 1
d. 2f

Department of Computer Science Page1 of 10


vii. ________ is a consensus algorithm for replicated logs.
a. Logical clocks
b. Byzantine
c. YARN
d. RAFT

viii. In RPC, ________ arises when no fault-tolerance measures are applied.


a. Maybe Semantics
b. At-least-once Semantics
c. At-most-once Semantics
d. None of the given options

ix. ________ is the ability to view a distributed system as if it were a single computer.
a. Openness
b. Transparency
c. Extensibility
d. Resource Sharing

x. In _________ service model, only application and data is managed by the end-user.
a. IaaS
b. PaaS
c. SaaS
d. All of the above

True/False

i. In HDFS, DataNode is used to maintain and manage the file system metadata.
a. True
b. False
ii. In permanently evicted strategy of Fault Tolerance for spare nodes, the spares remain constant
over time.
a. True
b. False
iii. A NodeManager is a master daemon that communicates with the client, tracks resources on the
cluster, and orchestrates work by assigning tasks.
a. True
b. False
iv. Cloud is an infrastructure that involves the integrated and collaborative use of Computers,
networks, databases and scientific instruments owned and managed by multiple organizations.
a. True
b. False
v. In Karp-Flatt metric, if 𝑒𝑒 increases as 𝑝𝑝 increases, it means that parallelization overhead is
affecting the speedup.
a. True
b. False

Department of Computer Science Page2 of 10


Question # 2: [3 + 4 + 3 marks, CLO # 1]

(a) Analyze the following graph and calculate:

(i) Critical Path Length

(ii) The average degree of concurrency

(iii) Maximum speed up if the number of processes are 2

(b) Draw a 4 x 4 Omega network (4 processes and 4 mem modules) and explain how P3 will access M2.

Department of Computer Science Page3 of 10


(c) Calculate diameter, total cost and bisection width for a complete binary tree of 3 levels as shown in
the image below:

Question # 3: [4+6 marks, CLO # 1]


a) What is Amdahl’s law? According to this law if we want to double the overall speed of a system
having 60% parallelizable code then how many processors would be required?

Department of Computer Science Page4 of 10


b) Calculate the time required to transfer 500 mbits of data from Sender to Receiver3. Bandwidth of
the links is 5 mbits/s.

Question # 4: [10 marks, CLO # 3]


Suppose you have to design a reliable fault-tolerant system that has the capability to tolerate 4
hardware faults and provide 100% availability without any down-time. There is no constraint on area
and cost. However, if power could be reduced then that would be a plus. What would be the best
hardware redundancy technique in this case? Draw a figure and explain the working of the system.
You should provide complete details.

Solution:

Strategy with required number of nodes and their type:

Department of Computer Science Page5 of 10


Figure:

Explanation:

Department of Computer Science Page6 of 10


Question # 5: [1+3+3 marks, CLO # 3]

Assume we have a 4*4 matrix with the following values:


1 3 5 7
2 4 6 8
11 13 15 17
10 12 14 16

Assume each row is stored at different processes, row 1 (1, 3, 5, 7) is stored at process P0, row 2 at P1,
row 3 at P2, and row 4 (10, 12, 14, 16) at P3. We want to apply a matrix transpose. Describe:

(i) The operation that needs to take place

(ii) Draw the message originating from process P0 and show what happens at each step with this
message

0 1

3 2

(iii) Draw the message originating from process P3 and show what happens at each step with this
message

0 1

3 2

Department of Computer Science Page7 of 10


Question # 6: [8 + 2 marks, CLO # 3]

a) Show the value of the logical clock on each of the three processes after every event. This includes
after each local event and message. Also show the value of the timestamp on each message.

b) Assume three processes, PA, PB and PC. Assume PA sends a message to PC. PA has a vector clock of (4,
1, 0), whereas before receiving this message, PC has a vector clock of (0, 0, 2). What will the vector
clock of PC be after receiving this message from PA?

Department of Computer Science Page8 of 10


Question # 7: [6 + 2 marks, CLO # 2]

a) Write the output for the following piece of OpenMP code assuming that there are no errors.

#include <iostream>
#include <omp.h>
using namespace std;

int main() {
int nums[20], total = 0;
bool p;
for (int i = 0; i < 20; i++) nums[i] = i + 1;

#pragma omp parallel for num_threads(4) schedule(static, 3) private(p)


for (int j = 0; j < 20; j++) {
int n = nums[j];
p = true;
for (int k = 2; k <= (n / 2); ++k) {
if (n % k == 0) {
p = false;
break;
}
}
if (p) {
cout << "At " << omp_get_thread_num() << ": n=" << n << endl;
#pragma omp critical
total++;
}
}
cout << "\nTotal = " << total << endl;
return 0;
}

b) Would you agree that setting OMP_NESTED to TRUE in the code above would have no impact on the
code above?

Department of Computer Science Page9 of 10


Question # 8: [8 + 2 marks, CLO # 2]
a) Write the output for the following piece of code assuming that there are 8 MPI processes & no
errors.
#include <mpi.h>
#include <stdio.h>
#include <cmath>

int main(int argc, char** argv) {


MPI_Init(NULL, NULL);
MPI_Status status;
int p, recVal, my_rank, neighbor;
MPI_Comm_size(MPI_COMM_WORLD, &p);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

int* d_val = new int[p];


int myVal = pow(2, my_rank+1); // 2^(my_rank+1)
int sTag = my_rank;
if (my_rank % 2 == 0) neighbor = (my_rank + 1) % p;
else neighbor = (my_rank - 1) % p;
MPI_Sendrecv(&myVal, 1, MPI_INT, neighbor, sTag, &recVal, 1, MPI_INT, neighbor, neighbor,
MPI_COMM_WORLD, &status);
int diff = abs(myVal - recVal); // absolute value
if (my_rank> 0 &&my_rank< (p - 1)) {
if (my_rank % 2 == 1) neighbor = (my_rank + 1) % p;
else neighbor = (my_rank - 1) % p;
MPI_Sendrecv(&myVal, 1, MPI_INT, neighbor, sTag, &recVal, 1, MPI_INT, neighbor, neighbor,
MPI_COMM_WORLD, &status);
if (abs(myVal - recVal) > diff) diff = abs(myVal - recVal);
}
MPI_Gather(&diff, 1, MPI_INT, d_val, 1, MPI_INT, 0, MPI_COMM_WORLD);
if (my_rank == 0) {
int dmax = d_val[0];
for (int i = 1; i< p; i++) {
printf("d_val[%d] = %d \n", i, d_val[i]);
if (d_val[i] >dmax) dmax = d_val[i];
}
printf("\n Max = %d\n", dmax);
}
MPI_Finalize(); // Finalize the MPI environment.
}

b) Can you interpret the meaning of the value of the variable dmax in the code above?

Department of Computer Science Page10 of 10

You might also like