

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The code for a parallel processing algorithm to perform matrix multiplication between two matrices 'a' and 'b' of sizes m x n and n x 1 respectively. The algorithm uses multiple processors to increase the efficiency of the computation. The code for processor 0 and other processors.
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Question 1 (a)
Array a[m][n] b[n][1] res[m][1]; Increment=m/(pq); begin For i=1 to m do For j=1 to n do Read a[i][j]; End for; End for; For i=1 to n do Read b[i][1]; End for; For i=1 to (pq -1) do Send (I, a [iincrement][0],incrementn); End for; For i=1 to (pq -1) do Send (I , b [0][0],n1); End for; For i=1 to increment do For j=1 to n do Res[i][1]= Res[i][1] + (a[i][i] * b[j][1]); End for;
End for; For i=1 to (pq -1) do Receive (I, Res [iincrement][0],increment*1); End for; Write res[m][1]; End
Pid = get_processor_id(); Increment=m/(pq); Begin Receive (0, a [iincrement][0],incrementn); Receive (0, b, n1); For i = Pidincrement to (Pidincrement)+ increment-1 do For j=1 to n do Res[i][1]= Res[i][1] + (a[i][j] * b[j][1]); End for; End for; Send (0,Res[Pidincrement][1],increment1 ); End