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


COMP528

First Semester Examinations 2018/19

Multi-Core and Multiprocessor Programming


QUESTION 1

1a) Describe the computational composition of a typical HPC (high performance computing) cluster, including an explanation of how the login nodes may differ from the compute          nodes. List the advantages of running an MPI code on a number of compute nodes and        explain how you would run a given code on a compute node.


1b) Explain the key differences between the pt-2-pt and the collective communication          functions in MPI. Give one example where you may expect different implementations of the MPI standard to differ?


1c) In terms of OpenMP’s “fork-join” model, what is the key difference between the

compound

#pragma  omp  parallel  for

and a

#pragma  omp  parallel

containing a loop with

#pragma  omp  for


QUESTION 2

2a) What do SIMD, MIMD and SPMD stand for? In terms of these, explain how the MPI programming model differs from the OpenMP model. Why do you think “mpirun” (or

similar) is required when launching MPI but not for OpenMP


2b) How does task parallelism differ from data parallelism?


2c) For GPU programming, threads, blocks, grids and warps (to use the NVIDIA terminology)

are important levels of granularity. Explain their meaning, how they interact (including any memory sharing or synchronisations) and why the different levels are important.



QUESTION 3

3a) Consider the serial C code to form a dot product d from vectors (of N floats) a and b, where d, a, b are all floats, and N is a variable previously read in by the program.

d  =  0.0;

for   (i=0;  i

d  +=  a[i]*b[i];

}

Explain how you would parallelise this using OpenMP, giving the full and exact code needed  to appropriately parallelise this loop. What is the name for the type of common pattern that is occurring here?


3b) For a different C code that exhibits parallelism, there are no ‘for’ loops. Which OpenMP constructs would you consider instead of worksharing constructs?


3c) If we wanted to use several CPU nodes to compute the dot product (for a new code),      what parallel programming paradigm would we use? And what would be the function call to share out data from the root process to all processes (you only need name the function, you are not expected to know its full syntax)?


3d) A researcher believes they have successfully parallelised a program to undertake a      parallel sort. Having ensured reliable and reproducible timings, they run the code firstly    without parallelisation which takes 20 seconds. They rerun using 2 parallel processes (or   threads) and the time taken is reduced to 12 seconds. Presuming the parallel part of their code scales ideally, how long has been spent in the serial portion of the code. Explain       Amdahl’s Law, and apply this to determine the maximum speed-up for this code and how quickly would it then run?



QUESTION 4

4a) Explain the importance of the Top500 supercomputer listing, pointing out any limitations of this approach.


4b) Considering the data dependencies, which of the following are parallelisable by using an OpenMP “parallel for” pragma immediately before the for loop as it is currently written        (naming any particular conditions that may be necessary). Variables A,B,C are vectors and k  is a constant, and no aliasing exists.

i.     for  (int i=0; i

ii.     for  (int i=1; i

iii.     for  (int i=0; i

iv.     for  (int i=1; i

v.     for  (int i=0; i


4c) Which of those that are non parallelisable as currently written, could be changed in order to expose some parallelism – explain clearly how you would do so.



QUESTION 5

5a) What are the main considerations for determining whether to port some or part of a code to a GPU? Outline a process you would use to determine which part/s to port.


5b) Rewrite the SAXPY code fragment below as a CUDA kernel

void  saxpy(int  N,  float  *res,  float  A,  float  *x,  float  *y)

{

res[i]  =  A  *  x[i]  +  y[i];

}


5c) “False sharing” is a phenomenon of shared memory computing. By use of an example, explain when false sharing occurs and how you would consider circumventing it.