linpack.docx
- 文档编号:4908504
- 上传时间:2022-12-11
- 格式:DOCX
- 页数:25
- 大小:20.62KB
linpack.docx
《linpack.docx》由会员分享,可在线阅读,更多相关《linpack.docx(25页珍藏版)》请在冰豆网上搜索。
linpack
/*
TranslatedtoCbyBonnieToy5/88
-modifiedon2/25/94tofixaproblemwithdaxpyfor
unequalincrementsorequalincrementsnotequalto1.
JackDongarra
-modifiedon08/27/09fixtypoline270,plusset'ix'to0
inthecaseincxisnot1
JulieLangou
TocompilesingleprecisionversionforSun-4:
cc-DSP-O4-fsingle-fsingle2clinpack.c-lm
TocompiledoubleprecisionversionforSun-4:
cc-DDP-O4clinpack.c-lm
ToobtainrolledsourceBLAS,add-DROLLtothecommandlines.
ToobtainunrolledsourceBLAS,add-DUNROLLtothecommandlines.
Youmustspecifyoneof-DSPor-DDPtocompilecorrectly.
Youmustspecifyoneof-DROLLor-DUNROLLtocompilecorrectly.
*/
#ifdefSP
#defineREALfloat
#defineZERO0.0
#defineONE1.0
#definePREC"Single"
#endif
#ifdefDP
#defineREALdouble
#defineZERO0.0e0
#defineONE1.0e0
#definePREC"Double"
#endif
#defineNTIMES10
#ifdefROLL
#defineROLLING"Rolled"
#endif
#ifdefUNROLL
#defineROLLING"Unrolled"
#endif
#include
#include
staticREALtime[9][9];
main()
{
staticREALaa[200][200],a[200][201],b[200],x[200];
REALcray,ops,total,norma,normx;
REALresid,residn,eps,t1,tm,tm2;
REALepslon(),second(),kf;
staticintipvt[200],n,i,ntimes,info,lda,ldaa,kflops;
lda=201;
ldaa=200;
cray=.056;
n=100;
fprintf(stdout,ROLLING);fprintf(stdout,PREC);fprintf(stdout,"PrecisionLinpack\n\n");
fprintf(stderr,ROLLING);fprintf(stderr,PREC);fprintf(stderr,"PrecisionLinpack\n\n");
ops=(2.0e0*(n*n*n))/3.0+2.0*(n*n);
matgen(a,lda,n,b,&norma);
t1=second();
dgefa(a,lda,n,ipvt,&info);
time[0][0]=second()-t1;
t1=second();
dgesl(a,lda,n,ipvt,b,0);
time[1][0]=second()-t1;
total=time[0][0]+time[1][0];
/*computearesidualtoverifyresults.*/
for(i=0;i x[i]=b[i]; } matgen(a,lda,n,b,&norma); for(i=0;i b[i]=-b[i]; } dmxpy(n,b,n,lda,x,a); resid=0.0; normx=0.0; for(i=0;i resid=(resid>fabs((double)b[i])) ? resid: fabs((double)b[i]); normx=(normx>fabs((double)x[i])) ? normx: fabs((double)x[i]); } eps=epslon((REAL)ONE); residn=resid/(n*norma*normx*eps); printf("norm.residresidmachep"); printf("x[0]-1x[n-1]-1\n"); printf("%8.1f%16.8e%16.8e%16.8e%16.8e\n", (double)residn,(double)resid,(double)eps, (double)x[0]-1,(double)x[n-1]-1); fprintf(stderr,"timesarereportedformatricesoforder%5d\n",n); fprintf(stderr,"dgefadgesltotalkflopsunit"); fprintf(stderr,"ratio\n"); time[2][0]=total; time[3][0]=ops/(1.0e3*total); time[4][0]=2.0e3/time[3][0]; time[5][0]=total/cray; fprintf(stderr,"timesforarraywithleadingdimensionof%5d\n",lda); print_time(0); matgen(a,lda,n,b,&norma); t1=second(); dgefa(a,lda,n,ipvt,&info); time[0][1]=second()-t1; t1=second(); dgesl(a,lda,n,ipvt,b,0); time[1][1]=second()-t1; total=time[0][1]+time[1][1]; time[2][1]=total; time[3][1]=ops/(1.0e3*total); time[4][1]=2.0e3/time[3][1]; time[5][1]=total/cray; matgen(a,lda,n,b,&norma); t1=second(); dgefa(a,lda,n,ipvt,&info); time[0][2]=second()-t1; t1=second(); dgesl(a,lda,n,ipvt,b,0); time[1][2]=second()-t1; total=time[0][2]+time[1][2]; time[2][2]=total; time[3][2]=ops/(1.0e3*total); time[4][2]=2.0e3/time[3][2]; time[5][2]=total/cray; ntimes=NTIMES; tm2=0.0; t1=second(); for(i=0;i tm=second(); matgen(a,lda,n,b,&norma); tm2=tm2+second()-tm; dgefa(a,lda,n,ipvt,&info); } time[0][3]=(second()-t1-tm2)/ntimes; t1=second(); for(i=0;i dgesl(a,lda,n,ipvt,b,0); } time[1][3]=(second()-t1)/ntimes; total=time[0][3]+time[1][3]; time[2][3]=total; time[3][3]=ops/(1.0e3*total); time[4][3]=2.0e3/time[3][3]; time[5][3]=total/cray; print_time (1); print_time (2); print_time(3); matgen(aa,ldaa,n,b,&norma); t1=second(); dgefa(aa,ldaa,n,ipvt,&info); time[0][4]=second()-t1; t1=second(); dgesl(aa,ldaa,n,ipvt,b,0); time[1][4]=second()-t1; total=time[0][4]+time[1][4]; time[2][4]=total; time[3][4]=ops/(1.0e3*total); time[4][4]=2.0e3/time[3][4]; time[5][4]=total/cray; matgen(aa,ldaa,n,b,&norma); t1=second(); dgefa(aa,ldaa,n,ipvt,&info); time[0][5]=second()-t1; t1=second(); dgesl(aa,ldaa,n,ipvt,b,0); time[1][5]=second()-t1; total=time[0][5]+time[1][5]; time[2][5]=total; time[3][5]=ops/(1.0e3*total); time[4][5]=2.0e3/time[3][5]; time[5][5]=total/cray; matgen(aa,ldaa,n,b,&norma); t1=second(); dgefa(aa,ldaa,n,ipvt,&info); time[0][6]=second()-t1; t1=second(); dgesl(aa,ldaa,n,ipvt,b,0); time[1][6]=second()-t1; total=time[0][6]+time[1][6]; time[2][6]=total; time[3][6]=ops/(1.0e3*total); time[4][6]=2.0e3/time[3][6]; time[5][6]=total/cray; ntimes=NTIMES; tm2=0; t1=second(); for(i=0;i tm=second(); matgen(aa,ldaa,n,b,&norma); tm2=tm2+second()-tm; dgefa(aa,ldaa,n,ipvt,&info); } time[0][7]=(second()-t1-tm2)/ntimes; t1=second(); for(i=0;i dgesl(aa,ldaa,n,ipvt,b,0); } time[1][7]=(second()-t1)/ntimes; total=time[0][7]+time[1][7]; time[2][7]=total; time[3][7]=ops/(1.0e3*total); time[4][7]=2.0e3/time[3][7]; time[5][7]=total/cray; /*thefollowingcodesequenceimplementsthesemanticsof theFortranintrinsics"nint(min(time[3][3],time[3][7]))"*/ kf=(time[3][3]
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- linpack