正在加载图片...
B 对所有处理器 my rank( my rank=0,…,p-1)同时执行如下的算法 /*消去过程* for i=0 to m-l de (1)if( my rankj)then/*对于主行前面的块 (1.1)=湾pj/*v为主元素的行号* /*确定本处理器所存的未消元部分的最大元及其位置存于数组 lmax中* (1. 3)for k=i+I to m-I do for ty to n-l do if(a[k, g]>Imax[OJ) Imax[0]=ak,t], Imax[1]=k Imax[2 =t, Imax 3 =my rank end if end for nd f if nk≥nth (2. 3for k-i to m-l do for ty to n-l do if(a(k, n]>Imax(O)) Imax[0]=a[k,], Imax[1=k, Imax[2=t, Imax 3] =my rank end fo or (3)用Al! gather操作将每个处理器中的lmax元素广播到其它所有处理器中 (4)*确定最大元及其位置* maxvalue=getpivort(max), maxrow=getrow(max maxcolumngetcolumn( max), maxrank- getrank(max) (5)列交换* if( maccollum≠v)then 5.1)for f=0 to 交换a,和a[t, maxcolum end for (5.2)交换 shifi[v]和shf column (6)*行交换* if(my rank-j) thenBegin 对所有处理器 my_rank(my_rank=0,…, p-1)同时执行如下的算法: /*消去过程*/ for i=0 to m-1 do for j=0 to p-1 do (1)if (my_rank<j) then /*对于主行前面的块*/ (1.1)v=i*p+j /* v 为主元素的行号*/ /*确定本处理器所存的未消元部分的最大元及其位置存于数组 lmax 中*/ (1.2)lmax(0)=a[i+1,v] (1.3)for k=i+1 to m-1 do for t=v to n-1 do if (│a[k,t]│>lmax[0]) lmax[0]= a[k,t], lmax[1]=k , lmax[2]=t ,lmax[3]=my_rank end if end for end for end if (2)if (my_rank ≥ j) then (2.1)v=i*p+j (2.2)lmax[0]=a[i,v] (2.3)for k=i to m-1 do for t=v to n-1 do if (│a[k,t]│>lmax[0]) lmax[0]= a[k,t], lmax[1]=k, lmax[2]=t , lmax[3]=my_rank end if end for end for end if (3)用Allgather 操作将每个处理器中的lmax元素广播到其它所有处理器中 (4)/*确定最大元及其位置*/ maxvalue=getpivort(max),maxrow=getrow(max) maxcolumn=getcolumn(max),maxrank= getrank(max) (5)/*列交换*/ if (maxcolumn ≠ v) then (5.1)for t=0 to m-1 do 交换 a[t,v]和 a[t,maxcolumn] end for (5.2)交换 shift[v]和 shift[maxcolumn] end if (6)/*行交换*/ if (my_rank=j) then
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有