矩阵乘法与mpi

时间:2012-11-15 17:13:47

标签: c parallel-processing mpi matrix-multiplication openmpi

我是并行编程的新手。我试图将两个矩阵相乘。我已将问题分区如下:

让操作为mat3 = mat1 x mat2 我正在将mat2广播到通信器中的所有进程,并切掉mat1的行条并将它们分散到commnicator组中的进程。在所有进程都有整个mat2和mat1的相应条带之后,它们将条带与mat2相乘,然后我使用聚集操作和进程的本地结果,并将整个结果累积到根进程中。

我想知道在通用计算机中是否有更好的问题分区来乘以两个矩阵。

我的实现是在OpenMPI中。

1 个答案:

答案 0 :(得分:4)

关于矩阵乘法的文献中有多种算法可以扩展到MPI范例。例如:

> 1Dsystolic [1] 
> 2D-systolic, Cannon’s algorithm [2];
> Fox’s algorithm [3];
> Berntsen’s algorithm [4];
> DNS algorithm [5].

如果忽略矩阵属性(稀疏等),它基本上会恢复数据如何在进程之间分配,以最小化同步和负载不平衡(每个进程之间分配的工作量)。

在这个recent work中,您可以看到两种不同的数据分布方法以及它们之间的比较。

文件:

[1] Golub G.H and Van C.H L., “Matrix Computations.”,Johns Hopkins University Press, 1989.
[2] Whaley R. C., Petitet A., Dongarra J. J., “Automated empirical optimizations of software and the ATLAS project” Parallel Computing 27, 1.2 (2001), 3.35.
[3] Fox G. C., Otto S. W., and Hey A. J. G., “Matrix algorithms on a hypercube I:
Matrix multiplication”,Parallel Computing, vol. 4, pp. 17-31. 1987.
[4] Berntsen J.,“Communication efficient matrix multiplication on hypercubes, Parallel Computing”, vol. 12, pp. 335-342, 1989.
[5] Ranka S. and Sahni S., “Hypercube Algorithms for Image Processing and Pattern Recognition”, Springer- Verlag, New York, NY, 1990.