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

Function Matrix_col_scatter

code/Chapter11/mympi.h:82–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;
85 int temp0,temp1;
86 //将A矩阵先存储到连续的空间中再进行分发
87 if(my_id==0){
88 matrix=malloc(sizeof(data_t)*dims*dims);
89 posi=0;
90 for(i=0;i<count_p;i++)
91 for(j=0,temp0=i*col;j<dims;j++)
92 for(k=0,temp1=j*dims;k<col;k++)
93 matrix[posi++]=source_matrix[temp0+temp1+k];
94 }
95 MPI_Scatter(matrix,dims*col,MPI_FLOAT,target_matrix,dims*col,MPI_FLOAT,0,comm);
96 if(my_id==0){
97 free(matrix);
98 }
99}
100void Print_matrix(data_t *matrix,int m,int n){
101 int i,j;
102 for(i=0;i<m;i++){

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected