MCPcopy Create free account
hub / github.com/AdvancedCompiler/AdvancedCompiler / Matrix_cannon_gather

Function Matrix_cannon_gather

code/Chapter12/mympi.h:60–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 }
59}
60void Matrix_cannon_gather(int N,int id,int num,int part,float *source_c,float *target_c,MPI_Comm MPI_COMM_CART){
61 float *matrixpool;//用于收集C矩阵的一维向量
62 int i,j,w,h,posi;
63 int temp0,temp1,temp2;
64 if(id==0){
65 matrixpool=(float *)malloc(sizeof(float)*N*N);
66 }
67 //先将分散的C矩阵收集到一起
68 MPI_Gather(source_c,num*num,MPI_FLOAT,matrixpool,num*num,MPI_FLOAT,0,MPI_COMM_CART);
69 if(id==0){
70 posi=0;
71 for(i=0;i<part;i++)
72 for(j=0,temp0=i*num;j<part;j++)
73 for(h=0,temp1=j*num;h<num;h++)
74 for(w=0,temp2=(temp0+h)*N;w<num;w++)
75 target_c[temp2+temp1+w]=matrixpool[posi++];
76 free(matrixpool);
77 }
78}
79void Matrix_col_scatter(int my_id,float *source_matrix,float *target_matrix,int dims,int col,int count_p,MPI_Comm comm){
80 float *matrix;
81 int i,j,k,posi;

Callers 5

mainFunction · 0.70
mainFunction · 0.70
mainFunction · 0.70
mainFunction · 0.70
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected