Starting from:
$30

$24

Parallel Computing Assignment 3



    1. (1 mark) Write an MPI program to compute the sum of an array of elements. Computation load should be balanced across processes. Input: Number of elements in the array. Output: Array sum (Print only once).

    2. (1 mark) Write an MPI program to exchange an array of elements. Each process has an array of N elements. Rank 0 sends data to Rank 1, Rank 1 to Rank 2, ..., Rank n-1 to Rank n, and Rank n to Rank 0. Input: Number of elements in the array. Output: Array elements of all processes.

    3. (1 mark) Write an MPI program to compute the sum of an array of elements. Assume that the array cannot be stored on a single process i.e., you cannot have int array[N] in one process, and then send the data to other processes. Initialize the array with its index values i.e., array[i] = i. Distribute the array such that computation work across processes is balanced. Input: Number of elements in the array. Output: Array sum (Print only once).

    4. (1 mark) Write an MPI program to compute the sum of an array of elements. Assume that the array cannot be stored on a single process i.e., you cannot have int array[N] in one process, and then send the data to other processes. Initialize the array with its index values i.e., array[i] = i. Distribute the array such that the amount of computation work across processes is balanced. Your program should support block distribution, cyclic distribution, and block cyclic distribution of the array. Read about distribution of data. Why do you think


1

various distribution schemes are required? Input: Number of elements in the array. Array

distribution = block, cyclic, block cyclic. Output: Array sum (Print only once).

    5. (1 mark) Write a threaded program (pthread/any thread library) to compute the sum of an array of elements. Can you write the program without using locks? Input: Number of elements in the array. Output: Array sum (Print only once).

    6. (1 mark) Write an OpenMP program to compute the sum of an array of elements. Input: Number of elements in the array. Output: Array sum (Print only once).

    7. (2 marks) Write an MPI+OpenMP program to compute the sum of an array of elements. Use OpenMP to compute the local sum, and MPI to compute the global sum. Input: Number of elements in the array. Output: Array sum (Print only once).

    8. (2 marks) Write an MPI program to compute the product of two vectors i.e.,


V T V

. Input: Size of the vector. Output: Scalar value (Print only once).

    9. (1 mark) Write an OpenMP program to multiply two matrices. Input: Matrix 1 size: m X n

Matrix 2 size: n X p. Output: Array sum (Print only once).

    10. (2 marks) Each process has an array of N elements. Start at Rank 0. Generate a random number. Compute X = (random number) / (number of processes)). Send the array of data from Rank 0 to Rank X. At Rank X, generate a random number and compute new X using the same formula. Send data from Rank X to Rank new X. Continue this process for m iterations. If you think such a program cannot be written, explain the reasoning behind it as comments in the code le. Input: Number of elements in the array. Iteration count, m. Output: Array elements of all processes.

    11. (3 marks) Implement iittp barrier() in MPI. The barrier should work both across processes and threads within a process i.e., all threads across processes should synchronize after the call. Do not use MPI Barrier().


Space for rough work/gra  ti/doodles




















2

More products