Question 2: Below you will find two sequential codes. Augment the code snippets with OpenMP pragmas if applicable. You h
Posted: Sun May 15, 2022 2:00 pm
Question 2: Below you will find two sequential codes. Augment the code snippets with OpenMP pragmas if applicable. You have to make sure that no dependencies are broken and thus the algorithm still computes correct result. Please include all the necessary clauses in the programs, including the variable scope clauses. If the algorithm is parallelizable, briefly discuss your parallelization strategy. Otherwise, explain why it cannot be parallelized. Justify your claims. (2a) (10 points} Dense matrix multiplication = = = // computes the product of an M x L matrix A // with an L x N matrix B double sum 0; for (i 0; i < M; i++) { for (j = 0; j < N; itt) { 0 sum 0; for (k = 0; k < L; k++) { sum += A[i*L + k] * B[k*N + j]; } Chi*N + j] = sum; } = = }
(2b) {10 points} Repetitive Smoothing of a Vector = = // v is a pre-initialized array of length N // s is the smoothed version of v, pre-initialized with v // M is the number of iterations for (i 0; i < M; i++) { for (j = 2; j < N-2; i++) { j [j] 0; for (k = -2; k< 3; k++) { ; [j] = 0.2 v[i+k]; } } for (j = 0; j < N; i++) { ; itt wjl s[j]; } } =
(2b) {10 points} Repetitive Smoothing of a Vector = = // v is a pre-initialized array of length N // s is the smoothed version of v, pre-initialized with v // M is the number of iterations for (i 0; i < M; i++) { for (j = 2; j < N-2; i++) { j [j] 0; for (k = -2; k< 3; k++) { ; [j] = 0.2 v[i+k]; } } for (j = 0; j < N; i++) { ; itt wjl s[j]; } } =