MPI Matrix Multiplication with scatter gather

后端 未结 1 1901
半阙折子戏
半阙折子戏 2021-01-28 21:05

I\'m trying to do matrix multiplication using MPI in C and we have to do a version that sequential and one parallel version. My parallel version is not giving the correct answe

相关标签:
1条回答
  • 2021-01-28 21:43

    A first problem in your code is that size might not divide N. Which means that scattering size packets of length N*N/size does not necessarily send the whole matrix. This is probably the hardest point to get right.

    As Greg Inozemtsev points out, a second problem is that you exclude process 0 from the computation, although it is responsible for a part of the matrix.

    And yet another problem is that all I/O operations (reading the coefficients at the beginning and outputting the results at the end) should be done only by process 0.

    On another note, you should specify the return type (void in this case) of your print_result function, both in the forward declaration and in the definition.

    0 讨论(0)
提交回复
热议问题