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

Function Matrix_cannon_gather

code/Chapter11/mympi.h:63–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

mainFunction · 0.70
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected