CSC 429 Mid Fall 12
CSC 429 Mid Fall 12
CSC 429 Mid Fall 12
ASSUMPTIONS: Throughout the exam, if not specially specified, you may assume that
n is a multiple of p, and p is a power of two. You may assume that it takes one operation
to compute a+b and one operation to compute a b (product of a and b), given a and b.
1. In the ________ PRAM, processors must write the same value into the shared
memory cell.
A. Arbitrary
B. Common
C. Priority
D. Comibing
A. EREW
B. CREW
C. ERCW
D. CRCW
A. Star-Connected Network
B. Crossbar Networks
C. 3d-mesh Network
D. Hypercube Network
4. In the completely connected network with N nodes, there are totally ________
linkes(edges).
A. N
B. 2N
C. N(N-1)/2
D. N2
5. What is diameter of hypercube network with 64 processors? __________
A. 6
B. 8
C. 12
D. 16
A. n
B. log n
C. n/log n
D. none of the above
Problem 2 (15 points)
Explain dichotomy of parallel computing platforms based on control structure (Flynn’s
taxonomy of computer architectures). Vector Processing features single instruction on
multiple data sets. Which structure does Vector Processing belongs to? In which
structure, different processors may be executing different instructions on different pieces
of data at any time?
#include <mpi.h>
int main(int argc, char **argv) {
int nprocs, mypid, myval, i, total;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&mypid );
printf("Hello world from process %d of total %d\n",mypid,nprocs);
myval=mypid;
if (pid!=0)
{
MPI_Send(&myval,1,MPI_INT,0,1,MPI_COMM_WORLD);
printf("Send a number %d from processor %d\n",myval,mypid);
}
else
{
for(i=1; i<nprocs;i++)
{
MPI_Recv(&total,1,MPI_INT,i,1,MPI_COMM_WORLD,&status);
myval=myval+total;
}
printf("Receive total value of %d\n",myval);
}
MPI_Finalize();
}
+1000(that is, ). Note he is going to apply for 10 processing nodes for his program.
1. (15 points) This user has finished the partial program named parallelSum.c as
below. Please help him complete the program.
#define N 1000
main (int argc, char **argv)
{
int nprocs, mypid, i, mysum=0;
int total;
MPI_Status status;
printf( "Partial sum from process %d of total %d is : %d. \n", mypid, nprocs,
mysum);
if (mypid!=0)
{
3. (2 points) The programmer opened the script file, which is shown as follows.
Please help him revise the script file correctly.
#!/bin/bash
#PBS -N job4
#PBS -q production
#PBS -l select=8:ncpus=1
#PBS -l place=free
#PBS -V
cd $PBS_O_WORKDIR
+.
Output: The parallel sum x = x + x + … + x .
1 2 p
(a) Assume p>=n, give or cite an efficient EREW PRAM algorithm that finds
the parallel sum x. (10 points)
(b) Assume p<n, give an EREW PRAM algorithm that finds the parallel sum
x in at most n/p + lg p steps. (5 points)
Extra Credit (15 points)
Input: A p-processor CRCW PRAM, and two integers x and n (Note: p>=n).
Output: The value of xn.
(1) If n is a power of 2, how fast can you calculate the value of xn on single
processor? Can you calculate faster on p-processor? (10 points)
(2) If n is not a power of 2, how fast can you calculate the value of xn on single
processor? Can you calculate faster on p-processor? (10 points)
Note: You final grade for this midterm is min{100, (your grade on problem 1-6) + (your
grade on extra credit)}