gpt4 book ai didi

c - MPI 中的矩阵乘法 : Column-wise partitioning of second matrix

转载 作者:行者123 更新时间:2023-11-30 19:46:24 24 4
gpt4 key购买 nike

我正在解决一个问题,我需要通过将矩阵之一的列切片到不同的处理器来在 MPI 中进行矩阵乘法。A*B=C,B要被切片

我执行以下操作:

MPI_Bcast(A, n*n, MPI_DOUBLE, 0, MPI_COMM_WORLD); 其中 A 分配给所有等级

MPI_Type_vector(n, n/p, n, MPI_DOUBLE, &tmp_type);
MPI_Type_create_resized(tmp_type, 0, n/p*sizeof(double), &col_type);
MPI_Type_commit(&col_type);

where n-size of A & B and p-no. of processors

MPI_Scatter(B, 1, col_type, b, n/p*n, MPI_DOUBLE, 0, MPI_COMM_WORLD);其中 B 仅分配在 root 上,b 分配在所有rank上

cblas_dgemm( CblasRowMajor, CblasNoTrans, CblasNoTrans, n, n/p, n, 1.0, A, n, b, n/p, 0.0, c, n/p );其中 c 分配在所有等级上(每个处理器上的乘法由 BLAS 例程完成)

MPI_Gather(c, n/p*n, MPI_DOUBLE, C, 1, col_type, 0, MPI_COMM_WORLD);其中 C 仅分配在根上

我的代码确实可以完成小矩阵(大小<62)所需的操作。但对于大于此的矩阵,它会失败并给出以下错误:

[csicluster01:12280] *** An error occurred in MPI_Gather
[csicluster01:12280] *** on communicator MPI_COMM_WORLD
[csicluster01:12280] *** MPI_ERR_TRUNCATE: message truncated
[csicluster01:12280] *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort)
--------------------------------------------------------------------------
mpirun has exited due to process rank 0 with PID 12280 on
node csicluster01 exiting without calling "finalize". This may
have caused other processes in the application to be
terminated by signals sent by mpirun (as reported here).
--------------------------------------------------------------------------

这里是否有任何我无法弄清楚的明显错误?或者问题是否可能是由于所使用的处理器的某些问题造成的?

最佳答案

问题可能来自

MPI_Type_create_resized(tmp_type, 0, n/p*sizeof(double), &col_type);

您可能需要更改它

MPI_Type_create_resized(tmp_type, 0, n/p*n*sizeof(double), &col_type);

这种改变看起来很合乎逻辑,因为你执行了类似的事情

MPI_Scatter(B, 1, col_type, b, n/p*n, MPI_DOUBLE, 0, MPI_COMM_WORLD);

但我不知道此更改是否解决了您的列分区问题。它可能会解决MPI_Gather()触发错误的问题。

再见,

关于c - MPI 中的矩阵乘法 : Column-wise partitioning of second matrix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23979229/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com