Below you will find two sequential codes. Augment the code snippets with OpenMP pragmas if applicable. You have to make

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Below you will find two sequential codes. Augment the code snippets with OpenMP pragmas if applicable. You have to make

Post by answerhappygod »

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.
a)
// 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; j++){
sum = 0;
for (k = 0; k < L; k++){
sum += A[i*L + k] * B[k*N + j];
}
C[i*N + j] = sum;
}
}
b)
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; j++){
s[j] = 0;
for (k = -2; k < 3; k++){
s[j] += 0.2 * v[j+k];
}
}
for (j = 0; j < N; j++){
v[j] = s[j];
}
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply