大家好,我想做矩阵转置,但我是个完全的新手,请帮助我完成矩阵转置:请建议我,如果有任何来源在互联网上学习关于mpi.Should I start parallel programming first?请解决下面的空白代码......。
#include <stdio.h>
#include <mpi.h>
int main(int argc,char* argv[])
{
int rank,size,m[4];
int matrix[4][4]={
{1,2,3,4},
{5,6,7,8},
{9,10,11,12},
{13,14,15,16}
}
int transpose[4][4];
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&size);
if (rank==0)
{
//Store first row of the matrix.
}
if(size!=4)
{
exit(0);
}
else
{
}
MPI_Finalize();
}
你可以看到这里的参考资料:1. 使用MPI_Type_create_subarray发送时,可以对数组进行转置吗?2. http:/suraj.lums.edu.pk~ahmadhresourcescodematrixtransp.c。3. https:/www.macs.hw.ac.uk~hwloidlCoursesF21DPsrcsmatrix4.c。
但首先我觉得你应该尝试一些简单的例子,比如并行一些for循环的计算,比如sum或multi。