The formulation of the problem is not quite clear: to realize matrix multiplication by tape method with the distribution of rows of matrix B. If everything is easy with the distribution of columns, we multiply the row by the column, then I don’t imagine what algorithm they want to see. Maybe someone has code examples?
1 answer
I do not have a code (and will not), but I can offer an idea.
The matrix B divided line by line, and then the procedure of scalar multiplication of rows A by columns B is implemented in parallel via MPI.
Suppose we have two processes S and T Then the process S receives the first half of all rows B , and the process T receives the second. Next, we must multiply each row of the matrix A by each column of the matrix B Here, half of the column is in S , and the second half is in T What if we need to multiply the row a matrix A by the column b matrix B , which is already split into two parts b S and b T ?
Very simply, the string a also split into two parts a S and a T. a S goes to S and is multiplied by b S , at the same time the second half of the string a T goes to T , and is multiplied there by b T. Further, both results are added up, the resulting element of the final matrix is obtained. And so you need to repeat for each row and each column of the original matrices.
I hope I never have to encode such nonsense, it is impractical and inefficient.
Bfirst transposed (there is such a form of optimization), or you are asked to implement a rather dubious algorithm and a clumsy beauty algorithm, just to test your abilities. - Zealint