ECE520 ADVANCED TOPICS IN PARALLEL AND DISTRIBUTED
COMPUTING
Homework 2, Due date: 15/04/2016
Implement and test the OpenMP program for computing a matrix-matrix product
(part of the code that computes the matrix-matrix product is given below). Vary
the number of threads for 4, 8, 12, 16, 20, 24, and 32. You can also use the
OMP_NUM_THREADS environment variable to control the number of threads.
Run the code for varied number of threads and plot the performance with varying
numbers of threads. Consider three cases in which (i) only the outermost loop is
parallelized; (ii) the outer two loops are parallelized; and (iii) all three loops are
parallelized. What is the observed result from these three cases? Analyze your
result.
You should submit your c code, your report that includes your plots and analysis.
You should submit to [email protected]
#pragma omp parallel default(private) shared (a, b, c, dim)
num_threads(4)
#pragma omp for schedule(static)
for (i = 0; i < dim; i++) {
for (j = 0; j < dim; j++) {
c(i,j) = 0;
for (k = 0; k < dim; k++) {
c(i,j) += a(i, k) * b(k, j);
}
}
}