正在加载图片...
e(lfL(ij: fscanf(fdA, " %f, A+I"M+j; printf("Input of file I"dataIn. txt\n"), printf("%d\t %dun, M,N) for(=0,<M计+) MPI Recv(a,m*N, MPI FLOAT, O, myid, MPI COMM WORLD, &status); for(0 j<N: j++) MPI Recv(e, m*N, MPI FLOAT,O, myid, printf("%ft,A(LD) MPI COMM WORLD, &status); for(F0; K<N; 1++) ( int argc, char for(=0;N;j++) if(F-D)I(J=1 float’c else I(j=0; int loop, Int 11, V, Z, I, ty, int iljl; float f,g, h float sin lsin2. cos 1 float slcl float*br, bt, "bi, *bj, "zi, "zj; for(=l;≤p+) float*templ, "temp2, *buffer, buff Int counter, current; MPI Send( &(a(m*i,O)), m'N, MPI MPI Send(&(I(m10)), m"N, M float bpp, bqq, bpq, bqp: FLOAT, L,L, MPI COMM WORLD), float Imax. freeD) MPI Comm size(MPI COMM WORLD MPI Comm rank(MPI COMM WoRLD, oid get ao &myid); P-group size 0 loop=0; 0号处理器将N广播给所有处理器* MPI Bcast(&N, 1, MPI INT, 0, for(FO <N: j++) MPI COMM WORLD) a(lfA(Lj)for(j = 0; j < M; j ++) fscanf(fdA, "%f", A+i*M+j); fclose(fdA); printf("Input of file \"dataIn.txt\"\n"); printf("%d\t %d\n",M, N); for(i=0;i<M;i++) { for(j=0;j<N;j++) printf("%f\t",A(i,j)); printf("\n"); } for(i=0;i<N;i++) { for(j=0;j<N;j++) if (i==j) I(i,j)=1; else I(i,j)=0; } } void send_a() { int i; for(i=1;i<p;i++) { MPI_Send(&(A(m*i,0)),m*N, MPI _FLOAT,i,i,MPI_COMM_WORLD); MPI_Send(&(I(m*i,0)),m*N,MPI_ FLOAT, i,i,MPI_COMM_WORLD); } free(A); free(I); } void get_a() { int i,j; if (myid==0) { for(i=0;i<m;i++) for(j=0;j<N;j++) { a(i,j)=A(i,j); e(i,j)=I(i,j); } } else { MPI_Recv(a,m*N,MPI_FLOAT,0,myid, MPI_COMM_WORLD,&status); MPI_Recv(e,m*N,MPI_FLOAT,0,myid, MPI_COMM_WORLD,&status); } } int main(int argc,char **argv) { float *c; int k; int loop; int i,j,v,z,r,t,y; int i1,j1; float f,g,h; float sin1,sin2,cos1; float s1,c1; float *br,*bt,*bi,*bj,*zi,*zj; float *temp1,*temp2,*buffer,*buffee; int counter,current; int *buf; int mml,mpl; float bpp,bqq,bpq,bqp; float lmax; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD, &group_size); MPI_Comm_rank(MPI_COMM_WORLD, &myid); p=group_size; max=10.0; loop=0; if (myid==0) read_fileA(); /*0 号处理器将 N 广播给所有处理器*/ MPI_Bcast(&N,1,MPI_INT,0, MPI_COMM_WORLD); m=N/p; if (N%p!=0) m++;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有