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

PDC MidTerm-I Spring2023

This document provides instructions for a midterm exam on parallel and distributed computing. It includes two questions: 1. Implement a serial version of the SAXPY algorithm that reads input arrays from files and calculates the average of the scaled vector. Provide a batch file to compile and time the program. 2. Design and implement a parallel version of the program using POSIX threads. Explain the partitioning strategy, synchronization approach, differences between SIMD and SPMD models, and the fork-join programming model. Map the questions to certain course learning outcomes.

Uploaded by

Fawad Rahman
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views

PDC MidTerm-I Spring2023

This document provides instructions for a midterm exam on parallel and distributed computing. It includes two questions: 1. Implement a serial version of the SAXPY algorithm that reads input arrays from files and calculates the average of the scaled vector. Provide a batch file to compile and time the program. 2. Design and implement a parallel version of the program using POSIX threads. Explain the partitioning strategy, synchronization approach, differences between SIMD and SPMD models, and the fork-join programming model. Map the questions to certain course learning outcomes.

Uploaded by

Fawad Rahman
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

RIPHAH INTERNATIONAL UNIVERSITY

I-14 CAMPUS, ISLAMABAD


Mid Term Exam
Spring 2023
Faculty of Computing
Course Title: Parallel and Distributed Section: CS 7-1
Computing

Instructor: Muhammad Aadil-Ur-Rehman Total Marks: 25

Exam Type: Practical Total Time 40 minutes

Instructions:
● Please read the question carefully before answering.
● Write to-the-point answers to manage your time intelligently.
● Wherever an explanation is required, explain in your own words.
● In case of any ambiguity, you may make assumption. But your assumption should not
contradict any statement in the question paper.
● Use proper indentation in the code.
● Test your programs before submitting, output of the program must be correct to be
considered as correct algorithm.
● You must submit this same file by renaming it with your SAP id, for example
12345.docx, Submit this file in the Midterm-I Submission link on Moellim.
● It’s an Open book Exam.
_____________________________________________

Read the following case study and answer the questions accordingly:

SAXPY stands for “Single-Precision A·X Plus Y”.  It is a function in the


standard Basic Linear Algebra Subroutines (BLAS) library. SAXPY is a
combination of scalar multiplication and vector addition, and it’s very simple: it
takes as input two vectors of 32-bit floats X and Y with n elements each, and a
scalar value a. It multiplies each element X[i] by a and adds the result to Y[i]. A
simple C implementation looks like this.
void saxpy(int n, float a, float * x, float * y) {
  for (int i = 0; i < n; ++i)
      y[i] = a*x[i] + y[i];
}

1 | Page
We want to implement a slightly modified version of SAXPY we will call it ASAXPY.
This version would also calculate average of the scaled vector. Simple C implementation
of this program is provided below:

1. [CLO-6.1] [8+2 = 10 Marks] Implement Serial version of the program, that creates two
arrays x and y from a file in provided format. Input scaler value a from program
arguments as well. Then process MSAXPY algorithm according to these inputs.
1.1. [2 Marks] [CLO-5.1] Provide a batch file to compile both programs created above.
Programs must execute with time command to trace runtime. Provide arguments to
programs as: array size 1 million and scaler value of your own choice.

File Formats:
 Both files would contain floating point numbers (equal number of inputs),
containing a single number at each line.

2. [7+2+2+2+2=15 Marks]
2.1. [CLO-6.1] Design and implement the parallel version of the program (Created above
in Question 1) in C using POSIX thread library(pthread).
2.2. [CLO-2.1] Briefly explain your selected partitioning strategy.
2.3. [CLO-2.1] Briefly explain critical section and synchronization. Also mention your
selected synchronization strategy for this program.
2.4. [CLO-2.2] Briefly explain the difference between SIMD and SPMD architecture,
according to Flynn’s taxonomy.
2.5. [CLO-2.2] Briefly explain Fork-Join Programming Model.

__________________________________________________________
Table for CLO Mapping:
Sr. No Question No. CLO Mapping
1 1, 2.1 6.1
2 1.1, 5.1
3 2.2, 2.3 2.1
4 2.4, 2.5 2.2

Table of CLOs:
1.1 List the trends in parallel and distributed computing
Explain fundamental concepts and challenges of parallel and distributed
2.1 computing including concurrency, synchronization, performance, scalability, fault
tolerance, communication, I/O
Illustrate various parallel and distributed architectures (UMA, NUMA, Flynn's
2.2 Taxonomy, Cluster, Grid, Cloud, shared memory, distributed memory), as well as
programming models (Task Parallel, Data Parallel)

2 | Page
3.1 Implement given parallel algorithms for GPU architectures (using OpenCL)

5.1 Trace performance of parallel algorithms in parallel and distributed environment

Design and implement basic parallel algorithms for shared memory environment
6.1 (using Threads, OpenMP) and for distributed environment (using Socket
Programming, Message Passing Interface, MapReduce)

3 | Page

You might also like