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