main(int argc, char *argv[]) { int count = 10, calibrate = 1; long xtra=1; int endit, section; long x100 = 100; int duration = 100; FILE *outfile; char general[9][80] = {" "}; int getinput = 1; printf("\n %s Precision C/C++ Whetstone Benchmark\n\n", Precision); if (argc > 1) { switch (argv[1][0]) { case 'N': getinput = 0; break; case 'n': getinput = 0; break; } } if (getinput == 0) { printf ("No run time input data\n\n"); } else { printf ("With run time input data\n\n"); } outfile = fopen("Whets.txt","a+"); if (outfile == NULL) { printf ("Cannot open results file \n\n"); printf("Press any key\n"); endit = getch(); exit (0); } printf("Calibrate\n"); do { TimeUsed=0; whetstones(xtra,x100,calibrate); printf("%11.2f Seconds %10.0lf Passes (x 100)\n", TimeUsed,(SPDP)(xtra)); calibrate = calibrate + 1; count = count - 1; if (TimeUsed > 2.0) count = 0; else xtra = xtra * 5; } while (count > 0); if (TimeUsed > 0) xtra = (long)((SPDP)(duration * xtra) / TimeUsed); if (xtra < 1) xtra = 1; calibrate = 0; printf("\nUse %d passes (x 100)\n", xtra); printf("\n %s Precision C/C++ Whetstone Benchmark", Precision); printf("\n %s", compiler); printf("\n %s\n", options); /* ----------------- ---------------------------- --------- --------- --------- */ printf("\nLoop content Result MFLOPS " " MOPS Seconds\n\n"); TimeUsed=0; whetstones(xtra,x100,calibrate); printf("\nMWIPS "); if (TimeUsed>0) mwips=(float)(xtra) * (float)(x100) / (10 * TimeUsed); else mwips = 0; printf("%39.3f%19.3f\n\n",mwips,TimeUsed); if (Check == 0) printf("Wrong answer "); /************************************************************************ * Type details of hardware, software etc. * ************************************************************************/ if (getinput == 1) { printf ("Enter the following which will be added with results to file WHETS.TXT\n"); printf ("When submitting a number of results you need only provide details once\n"); printf ("but a cross reference such as an abbreviated CPU type would be useful.\n"); printf ("You can kill (exit or close) the program now and no data will be added.\n\n"); printf ("PC Supplier/model ? "); gets(general[1]); printf ("CPU chip ? "); gets(general[2]); printf ("Clock MHz ? "); gets(general[3]); printf ("Cache size ? "); gets(general[4]); printf ("Chipset & H/W options ? "); gets(general[5]); printf ("OS/DOS version ? "); gets(general[6]); printf ("Your name ? "); gets(general[7]); printf ("Company/Location ? "); gets(general[8]); printf ("E-mail address ? "); gets(general[0]); } what_date(); /************************************************************************ * Add results to output file Whets.txt * ************************************************************************/ fprintf (outfile, "----------------- -----------------------------" " --------- --------- --------- ---------" " --------- --------- --------- ---------" " ---------\n"); fprintf (outfile, "Whetstone %s Precision Benchmark in C/C++\n\n", Precision); fprintf (outfile, "Month run %d/%d\n", this_month, this_year); fprintf (outfile, "PC model %s\n", general[1]); fprintf (outfile, "CPU %s\n", general[2]); fprintf (outfile, "Clock MHz %s\n", general[3]); fprintf (outfile, "Cache %s\n", general[4]); fprintf (outfile, "H/W Options %s\n", general[5]); fprintf (outfile, "OS/DOS %s\n", general[6]); fprintf (outfile, "Compiler %s\n", compiler); fprintf (outfile, "OptLevel %s\n", options); fprintf (outfile, "Run by %s\n", general[7]); fprintf (outfile, "From %s\n", general[8]); fprintf (outfile, "E-mail address %s\n\n", general[0]); fprintf (outfile,"Loop content Result" " MFLOPS MOPS Seconds\n\n"); for (section=1; section<9; section++) { fprintf (outfile, "%s %24.17f ", headings[section], results[section]); if (loop_mops[section] == 99999) { fprintf (outfile," %9.3f %9.3f\n", loop_mflops[section], loop_time[section]); } else { fprintf (outfile, " %9.3f %9.3f\n", loop_mops[section], loop_time[section]); } } fprintf (outfile, "\nMWIPS "); fprintf (outfile, "%39.3f%20.3f\n\n",mwips,TimeUsed); fprintf (outfile, "Results to load to spreadsheet "); fprintf (outfile, " MWIPS Mflops1 Mflops2 Mflops3 Cosmops" " Expmops Fixpmops Ifmops Eqmops\n"); fprintf (outfile, "Results to load to spreadsheet "); fprintf (outfile, " %9.3f %9.3f %9.3f", mwips, loop_mflops[1], loop_mflops[2]); fprintf (outfile, " %9.3f %9.3f %9.3f", loop_mflops[6], loop_mops[5], loop_mops[8]); fprintf (outfile, " %9.3f %9.3f %9.3f\n\n", loop_mops[4], loop_mops[3], loop_mops[7]); fclose (outfile); printf ("\n"); printf ("A new results file will have been created in the same directory as the\n"); printf (".EXE files if one did not already exist. If you made a mistake on input, \n"); printf ("you can use a text editor to correct it, delete the results or copy \n"); printf ("them to a different file name. If you intend to run multiple tests you\n"); printf ("you may wish to rename WHETS.TXT with a more informative title.\n\n"); printf ("Please submit feedback and results files as a posting in Section 12\n"); printf ("or to [email protected]\n\n"); if (getinput == 1) { printf("Press any key to exit\n"); endit = getch(); printf ("\nIf this is displayed you must close the window in the normal way\n"); } }
main () { static REAL aa[200*200],a[200*201],b[200],x[200]; REAL cray,ops,total,norma,normx; REAL resid,residn,eps,t1,tm2,epsn,x1,x2; REAL mflops; static int ipvt[200],n,i,j,ntimes,info,lda,ldaa; int Endit, pass, loop; REAL overhead1, overhead2, time1, time2; FILE *outfile; char *compiler, *options, general[9][80] = {" "}; outfile = fopen("Linpack.txt","a+"); if (outfile == NULL) { printf ("Cannot open results file \n\n"); printf("Press any key\n"); #ifdef DOS Endit = getch(); #endif exit (0); } /************************************************************************ * Enter details of compiler and options used * ************************************************************************/ /*----------------- --------- --------- ---------*/ compiler = "INSERT COMPILER NAME HERE"; options = "INSERT OPTIMISATION OPTIONS HERE"; /* Include -dDP or -dSP and -dROLL or -dUNROLL */ lda = 201; ldaa = 200; cray = .056; n = 100; fprintf(stdout,ROLLING);fprintf(stdout,PREC); fprintf(stdout,"Precision Linpack Benchmark - PC Version in 'C/C++'\n\n"); fprintf(stdout,"Compiler %s\n",compiler); fprintf(stdout,"Optimisation %s\n\n",options); 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); atime[0][0] = second() - t1; t1 = second(); dgesl(a,lda,n,ipvt,b,0); atime[1][0] = second() - t1; total = atime[0][0] + atime[1][0]; /* compute a residual to verify results. */ for (i = 0; i < n; i++) { x[i] = b[i]; } matgen(a,lda,n,b,&norma); for (i = 0; i < n; i++) { b[i] = -b[i]; } dmxpy(n,b,n,lda,x,a); resid = 0.0; normx = 0.0; for (i = 0; i < n; 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(ONE); residn = resid/( n*norma*normx*eps ); epsn = eps; x1 = x[0] - 1; x2 = x[n-1] - 1; printf("norm resid resid machep"); printf(" x[0]-1 x[n-1]-1\n"); printf("%6.1f %17.8e%17.8e%17.8e%17.8e\n\n", (double)residn, (double)resid, (double)epsn, (double)x1, (double)x2); fprintf(stderr,"Times are reported for matrices of order %5d\n",n); fprintf(stderr,"1 pass times for array with leading dimension of%5d\n\n",lda); fprintf(stderr," dgefa dgesl total Mflops unit"); fprintf(stderr," ratio\n"); atime[2][0] = total; if (total > 0.0) { atime[3][0] = ops/(1.0e6*total); atime[4][0] = 2.0/atime[3][0]; } else { atime[3][0] = 0.0; atime[4][0] = 0.0; } atime[5][0] = total/cray; print_time(0); /************************************************************************ * Calculate overhead of executing matgen procedure * ************************************************************************/ fprintf (stderr,"\nCalculating matgen overhead\n"); pass = -20; loop = NTIMES; do { time1 = second(); pass = pass + 1; for ( i = 0 ; i < loop ; i++) { matgen(a,lda,n,b,&norma); } time2 = second(); overhead1 = (time2 - time1); fprintf (stderr,"%10d times %6.2f seconds\n", loop, overhead1); if (overhead1 > 5.0) { pass = 0; } if (pass < 0) { if (overhead1 < 0.1) { loop = loop * 10; } else { loop = loop * 2; } } } while (pass < 0); overhead1 = overhead1 / (double)loop; fprintf (stderr,"Overhead for 1 matgen %12.5f seconds\n\n", overhead1); /************************************************************************ * Calculate matgen/dgefa passes for 5 seconds * ************************************************************************/ fprintf (stderr,"Calculating matgen/dgefa passes for 5 seconds\n"); pass = -20; ntimes = NTIMES; do { time1 = second(); pass = pass + 1; for ( i = 0 ; i < ntimes ; i++) { matgen(a,lda,n,b,&norma); dgefa(a,lda,n,ipvt,&info ); } time2 = second() - time1; fprintf (stderr,"%10d times %6.2f seconds\n", ntimes, time2); if (time2 > 5.0) { pass = 0; } if (pass < 0) { if (time2 < 0.1) { ntimes = ntimes * 10; } else { ntimes = ntimes * 2; } } } while (pass < 0); ntimes = 5.0 * (double)ntimes / time2; if (ntimes == 0) ntimes = 1; fprintf (stderr,"Passes used %10d \n\n", ntimes); fprintf(stderr,"Times for array with leading dimension of%4d\n\n",lda); fprintf(stderr," dgefa dgesl total Mflops unit"); fprintf(stderr," ratio\n"); /************************************************************************ * Execute 5 passes * ************************************************************************/ tm2 = ntimes * overhead1; atime[3][6] = 0; for (j=1 ; j<6 ; j++) { t1 = second(); for (i = 0; i < ntimes; i++) { matgen(a,lda,n,b,&norma); dgefa(a,lda,n,ipvt,&info ); } atime[0][j] = (second() - t1 - tm2)/ntimes; t1 = second(); for (i = 0; i < ntimes; i++) { dgesl(a,lda,n,ipvt,b,0); } atime[1][j] = (second() - t1)/ntimes; total = atime[0][j] + atime[1][j]; atime[2][j] = total; atime[3][j] = ops/(1.0e6*total); atime[4][j] = 2.0/atime[3][j]; atime[5][j] = total/cray; atime[3][6] = atime[3][6] + atime[3][j]; print_time(j); } atime[3][6] = atime[3][6] / 5.0; fprintf (stderr,"Average %11.2f\n", (double)atime[3][6]); fprintf (stderr,"\nCalculating matgen2 overhead\n"); /************************************************************************ * Calculate overhead of executing matgen procedure * ************************************************************************/ time1 = second(); for ( i = 0 ; i < loop ; i++) { matgen(aa,ldaa,n,b,&norma); } time2 = second(); overhead2 = (time2 - time1); overhead2 = overhead2 / (double)loop; fprintf (stderr,"Overhead for 1 matgen %12.5f seconds\n\n", overhead2); fprintf(stderr,"Times for array with leading dimension of%4d\n\n",ldaa); fprintf(stderr," dgefa dgesl total Mflops unit"); fprintf(stderr," ratio\n"); /************************************************************************ * Execute 5 passes * ************************************************************************/ tm2 = ntimes * overhead2; atime[3][12] = 0; for (j=7 ; j<12 ; j++) { t1 = second(); for (i = 0; i < ntimes; i++) { matgen(aa,ldaa,n,b,&norma); dgefa(aa,ldaa,n,ipvt,&info ); } atime[0][j] = (second() - t1 - tm2)/ntimes; t1 = second(); for (i = 0; i < ntimes; i++) { dgesl(aa,ldaa,n,ipvt,b,0); } atime[1][j] = (second() - t1)/ntimes; total = atime[0][j] + atime[1][j]; atime[2][j] = total; atime[3][j] = ops/(1.0e6*total); atime[4][j] = 2.0/atime[3][j]; atime[5][j] = total/cray; atime[3][12] = atime[3][12] + atime[3][j]; print_time(j); } atime[3][12] = atime[3][12] / 5.0; fprintf (stderr,"Average %11.2f\n", (double)atime[3][12]); /************************************************************************ * Use minimum average as overall Mflops rating * ************************************************************************/ mflops = atime[3][6]; if (atime[3][12] < mflops) mflops = atime[3][12]; fprintf(stderr,"\n"); fprintf(stderr,ROLLING);fprintf(stderr,PREC); fprintf(stderr," Precision %11.2f Mflops \n\n",mflops); what_date(); /************************************************************************ * Type details of hardware, software etc. * ************************************************************************/ printf ("Enter the following data which will be " "appended to file Linpack.txt \n\n"); printf ("PC Supplier/model ?\n "); scanf ("%[^\n]", general[1]); fflush (stdin); printf ("CPU ?\n "); scanf ("%[^\n]", general[2]); fflush (stdin); printf ("Clock MHz ?\n "); scanf ("%[^\n]", general[3]); fflush (stdin); printf ("Cache ?\n "); scanf ("%[^\n]", general[4]); fflush (stdin); printf ("Chipset/options ?\n "); scanf ("%[^\n]", general[5]); fflush (stdin); printf ("OS/DOS version ?\n "); scanf ("%[^\n]", general[6]); fflush (stdin); printf ("Your name ?\n "); scanf ("%[^\n]", general[7]); fflush (stdin); printf ("Where from ?\n "); scanf ("%[^\n]", general[8]); fflush (stdin); printf ("Mail address ?\n "); scanf ("%[^\n]", general[0]); fflush (stdin); /************************************************************************ * Add results to output file LLloops.txt * ************************************************************************/ fprintf (outfile, "----------------- ----------------- --------- " "--------- ---------\n"); fprintf (outfile, "LINPACK BENCHMARK FOR PCs 'C/C++' n @ 100\n\n"); fprintf (outfile, "Month run %d/%d\n", this_month, this_year); fprintf (outfile, "PC model %s\n", general[1]); fprintf (outfile, "CPU %s\n", general[2]); fprintf (outfile, "Clock MHz %s\n", general[3]); fprintf (outfile, "Cache %s\n", general[4]); fprintf (outfile, "Options %s\n", general[5]); fprintf (outfile, "OS/DOS %s\n", general[6]); fprintf (outfile, "Compiler %s\n", compiler); fprintf (outfile, "OptLevel %s\n", options); fprintf (outfile, "Run by %s\n", general[7]); fprintf (outfile, "From %s\n", general[8]); fprintf (outfile, "Mail %s\n\n", general[0]); fprintf(outfile, "Rolling %s\n",ROLLING); fprintf(outfile, "Precision %s\n",PREC); fprintf(outfile, "norm. resid %16.1f\n",(double)residn); fprintf(outfile, "resid %16.8e\n",(double)resid); fprintf(outfile, "machep %16.8e\n",(double)epsn); fprintf(outfile, "x[0]-1 %16.8e\n",(double)x1); fprintf(outfile, "x[n-1]-1 %16.8e\n",(double)x2); fprintf(outfile, "matgen 1 seconds %16.5f\n",overhead1); fprintf(outfile, "matgen 2 seconds %16.5f\n",overhead2); fprintf(outfile, "Repetitions %16d\n",ntimes); fprintf(outfile, "Leading dimension %16d\n",lda); fprintf(outfile, " dgefa dgesl " " total Mflops\n"); fprintf(outfile, "1 pass seconds %16.5f %9.5f %9.5f\n", atime[0][0], atime[1][0], atime[2][0]); for (i=1 ; i<6 ; i++) { fprintf(outfile, "Repeat seconds %16.5f %9.5f %9.5f %9.2f\n", atime[0][i], atime[1][i], atime[2][i], atime[3][i]); } fprintf(outfile, "Average %46.2f\n",atime[3][6]); fprintf(outfile, "Leading dimension %16d\n",ldaa); for (i=7 ; i<12 ; i++) { fprintf(outfile, "Repeat seconds %16.5f %9.5f %9.5f %9.2f\n", atime[0][i], atime[1][i], atime[2][i], atime[3][i]); } fprintf(outfile, "Average %46.2f\n\n",atime[3][12]); fclose (outfile); printf("\nPress any key\n"); #ifdef DOS Endit = getch(); #endif }
void Proc0() { OneToFifty IntLoc1; OneToFifty IntLoc2; OneToFifty IntLoc3; char CharIndex; Enumeration EnumLoc; String30 String1Loc; String30 String2Loc; unsigned long Loops; double Microseconds, Dhrystones_Per_Second, Vax_Mips; double startclock; double benchtime; register unsigned long i; int endit, count = 10; FILE *Ap; char general[9][80] = {" "}; /* Initializations */ if ((Ap = fopen("Dhry.txt","a+")) == NULL) { printf("Can not open Dhry.txt\n\n"); printf("Press any key\n"); endit = getch(); exit(1); } /*********************************************************************** * Change for compiler and optimisation used * ***********************************************************************/ PtrGlbNext = (RecordPtr) malloc(sizeof(RecordType)); PtrGlb = (RecordPtr) malloc(sizeof(RecordType)); PtrGlb->PtrComp = PtrGlbNext; PtrGlb->Discr = Ident1; PtrGlb->EnumComp = Ident3; PtrGlb->IntComp = 40; strcpy(PtrGlb->StringComp, "DHRYSTONE PROGRAM, SOME STRING"); strcpy(String1Loc, "DHRYSTONE PROGRAM, 1'ST STRING"); printf ("\n"); printf ("Dhrystone Benchmark, Version 1.1 (Language: C or C++)\n"); printf ("\n"); if (getinput == 0) { printf ("No run time input data\n\n"); } else { printf ("With run time input data\n\n"); } printf ("Compiler %s\n", compiler); printf ("Optimisation %s\n", options); printf ("\n"); Loops = 5000; do { Loops = Loops * 2; count = count - 1; Array2Glob[8][7] = 10; /***************** -- Start Timer -- *****************/ startclock = dtime(); for (i = 0; i < Loops; ++i) { Proc5(); Proc4(); IntLoc1 = 2; IntLoc2 = 3; strcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING"); EnumLoc = Ident2; BoolGlob = ! Func2(String1Loc, String2Loc); while (IntLoc1 < IntLoc2) { IntLoc3 = 5 * IntLoc1 - IntLoc2; Proc7(IntLoc1, IntLoc2, &IntLoc3); ++IntLoc1; } Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3); Proc1(PtrGlb); for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex) if (EnumLoc == Func1(CharIndex, 'C')) Proc6(Ident1, &EnumLoc); IntLoc3 = IntLoc2 * IntLoc1; IntLoc2 = IntLoc3 / IntLoc1; IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1; Proc2(&IntLoc1); } /***************** -- Stop Timer -- *****************/ benchtime = dtime() - startclock; printf ("%12.0f runs %6.2f seconds \n",(double) Loops, benchtime); if (benchtime > 5) { count = 0; } else { if (benchtime < 0.1) { Loops = Loops * 5; } } } /* calibrate/run do while */ while (count >0); for (i = 0; i < Loops; ++i) { count = count +1; } printf ("\n"); printf ("Array2Glob8/7: "); if (Array2Glob[8][7] == count + 10) printf ("O.K. "); else printf ("WRONG "); printf ("%12.0f\n", (double) Array2Glob[8][7]); Microseconds = benchtime * 1000000 / (double) Loops; Dhrystones_Per_Second = (double) Loops / benchtime; Vax_Mips = Dhrystones_Per_Second / 1757.0; printf ("\n"); printf ("Microseconds for one run through Dhrystone: "); printf ("%12.2lf \n", Microseconds); printf ("Dhrystones per Second: "); printf ("%10.0lf \n", Dhrystones_Per_Second); printf ("VAX MIPS rating = "); printf ("%12.2lf \n",Vax_Mips); printf ("\n"); what_date(); /************************************************************************ * Type details of hardware, software etc. * ************************************************************************/ if (getinput == 1) { printf ("Enter the following which will be added with results to file DHRY.TXT\n"); printf ("When submitting a number of results you need only provide details once\n"); printf ("but a cross reference such as an abbreviated CPU type would be useful.\n"); printf ("You can kill (exit or close) the program now and no data will be added.\n\n"); printf ("PC Supplier/model ? "); gets(general[1]); printf ("CPU chip ? "); gets(general[2]); printf ("Clock MHz ? "); gets(general[3]); printf ("Cache size ? "); gets(general[4]); printf ("Chipset & H/W options ? "); gets(general[5]); printf ("OS/DOS version ? "); gets(general[6]); printf ("Your name ? "); gets(general[7]); printf ("Company/Location ? "); gets(general[8]); printf ("E-mail address ? "); gets(general[0]); } /************************************************************************ * Add results to output file Dhry.txt * ************************************************************************/ fprintf (Ap, "-------------------- -----------------------------------" "\n"); fprintf (Ap, "Dhrystone Benchmark Version 1.1 (Language: C or C++)\n\n"); fprintf (Ap, "Month run %d/%d\n", this_month, this_year); fprintf (Ap, "PC model %s\n", general[1]); fprintf (Ap, "CPU %s\n", general[2]); fprintf (Ap, "Clock MHz %s\n", general[3]); fprintf (Ap, "Cache %s\n", general[4]); fprintf (Ap, "H/W Options %s\n", general[5]); fprintf (Ap, "OS/DOS %s\n", general[6]); fprintf (Ap, "Compiler %s\n", compiler); fprintf (Ap, "OptLevel %s\n", options); fprintf (Ap, "Run by %s\n", general[7]); fprintf (Ap, "From %s\n", general[8]); fprintf (Ap, "E-Mail address %s\n\n", general[0]); fprintf (Ap, "Array2Glob8/7: "); if (Array2Glob[8][7] == Loops + 10) fprintf (Ap, "O.K. "); else fprintf (Ap, "WRONG "); fprintf (Ap, "%10d\n", Array2Glob[8][7]); fprintf (Ap, "\n"); fprintf(Ap,"Microseconds 1 loop: %12.2lf\n",Microseconds); fprintf(Ap,"Dhrystones / second: %10.0lf\n",Dhrystones_Per_Second); fprintf(Ap,"VAX MIPS rating: %12.2lf\n\n",Vax_Mips); fclose(Ap); printf ("\n"); printf ("A new results file will have been created in the same directory as the\n"); printf (".EXE files if one did not already exist. If you made a mistake on input, \n"); printf ("you can use a text editor to correct it, delete the results or copy \n"); printf ("them to a different file name. If you intend to run multiple tests you\n"); printf ("you may wish to rename DHRY.TXT with a more informative title.\n\n"); printf ("Please submit feedback and results files as a posting in Section 12\n"); printf ("or to [email protected]\n\n"); if (getinput == 1) { printf("Press any key to exit\n"); endit = getch(); printf ("\nIf this is displayed you must close the window in the normal way\n"); } }