Up-sweep and down-sweep parallel prefix
1. Implement up-sweep and down-sweep parallel prefix sum algorithm using Openmp (8 points). a. Deliverable: Just openmp code.
Up-sweep Algorithm
1: for i = 0 to n - 1 in parallel do
2: MOM = 3: end for 4: for h =1 to log n do 5: for i = 0 to it - 1 in parallel do 6: B[hJ[i] = B[h — 1J[2i] + B[h — 11[2i + 1] 7: end for 8: end for
—_i-sweep Algorithm
9: Clog n][0] = 0 10: for h = log n — 1 down to 0 do 11: for i = 0 to ik — 1 in parallel do 12: if i % 2 == 0 then 13: CNN = C[h + 14: else 15: C[hJ(iJ = C[h + i](y] + B[h][i — 1] 16: end if 17: end for 18: end for 19: for i = 0 to n — 1 in parallel do 20: = CEO, ij
Activate Wii Go to Settings t