summaryrefslogtreecommitdiffstats
path: root/testsuites/benchmarks/linpack/linpack-pc.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/benchmarks/linpack/linpack-pc.c')
-rw-r--r--testsuites/benchmarks/linpack/linpack-pc.c211
1 files changed, 39 insertions, 172 deletions
diff --git a/testsuites/benchmarks/linpack/linpack-pc.c b/testsuites/benchmarks/linpack/linpack-pc.c
index a5e68696f1..5b8bc1c378 100644
--- a/testsuites/benchmarks/linpack/linpack-pc.c
+++ b/testsuites/benchmarks/linpack/linpack-pc.c
@@ -193,6 +193,8 @@
***************************************************************************
*/
+#define DP
+#define ROLL
#ifdef SP
#define REAL float
@@ -216,17 +218,14 @@
#endif
-#define NTIMES 10
+#define NTIMES atoi(argv[1])
#include <stdio.h>
#include <math.h>
-#include <conio.h>
#include <stdlib.h>
static REAL atime[9][15];
-static char this_month;
-static int this_year;
void print_time (int row);
void matgen (REAL a[], int lda, int n, REAL b[], REAL *norma);
@@ -240,56 +239,25 @@ void dscal (int n, REAL da, REAL dx[], int incx);
REAL ddot (int n, REAL dx[], int incx, REAL dy[], int incy);
/* TIME TIME TIME TIME TIME TIME TIME TIME TIME TIME TIME TIME TIME */
- #include <time.h> /* for following time functions only */
- REAL second()
+ #include <sys/time.h> /* for following time functions only */
+ static REAL second(void)
{
- REAL secs;
- clock_t Time;
- Time = clock();
- secs = (REAL)Time / (REAL)CLOCKS_PER_SEC;
- return secs ;
- }
+ struct timeval tv;
-/* DATE DATE DATE DATE DATE DATE DATE DATE DATE DATE DATE DATE DATE */
- #include <dos.h> /* for following date functions only */
- void what_date()
- {
- /* Watcom */
- struct dosdate_t adate;
- _dos_getdate( &adate );
- this_month = adate.month;
- this_year = adate.year;
-
- /* Borland
- struct date adate;
- getdate( &adate );
- this_month = adate.da_mon;
- this_year = adate.da_year;
- */
- return;
+ gettimeofday(&tv, NULL);
+ return (double)tv.tv_sec + (double)tv.tv_usec * 1e-6;
}
-
-main ()
+int main (int argc, char **argv)
{
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;
+ int 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");
- Endit = getch();
- exit (0);
- }
+ char *compiler, *options;
/************************************************************************
* Enter details of compiler and options used *
@@ -350,10 +318,10 @@ main ()
(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");
+ fprintf(stdout,"Times are reported for matrices of order %5d\n",n);
+ fprintf(stdout,"1 pass times for array with leading dimension of%5d\n\n",lda);
+ fprintf(stdout," dgefa dgesl total Mflops unit");
+ fprintf(stdout," ratio\n");
atime[2][0] = total;
if (total > 0.0)
@@ -374,7 +342,7 @@ main ()
* Calculate overhead of executing matgen procedure *
************************************************************************/
- fprintf (stderr,"\nCalculating matgen overhead\n");
+ fprintf (stdout,"\nCalculating matgen overhead\n");
pass = -20;
loop = NTIMES;
do
@@ -387,7 +355,7 @@ main ()
}
time2 = second();
overhead1 = (time2 - time1);
- fprintf (stderr,"%10d times %6.2f seconds\n", loop, overhead1);
+ fprintf (stdout,"%10d times %6.2f seconds\n", loop, overhead1);
if (overhead1 > 5.0)
{
pass = 0;
@@ -408,13 +376,13 @@ main ()
overhead1 = overhead1 / (double)loop;
- fprintf (stderr,"Overhead for 1 matgen %12.5f seconds\n\n", overhead1);
+ fprintf (stdout,"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");
+ fprintf (stdout,"Calculating matgen/dgefa passes for 5 seconds\n");
pass = -20;
ntimes = NTIMES;
do
@@ -427,7 +395,7 @@ main ()
dgefa(a,lda,n,ipvt,&info );
}
time2 = second() - time1;
- fprintf (stderr,"%10d times %6.2f seconds\n", ntimes, time2);
+ fprintf (stdout,"%10d times %6.2f seconds\n", ntimes, time2);
if (time2 > 5.0)
{
pass = 0;
@@ -449,10 +417,10 @@ main ()
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");
+ fprintf (stdout,"Passes used %10d \n\n", ntimes);
+ fprintf(stdout,"Times for array with leading dimension of%4d\n\n",lda);
+ fprintf(stdout," dgefa dgesl total Mflops unit");
+ fprintf(stdout," ratio\n");
/************************************************************************
* Execute 5 passes *
@@ -492,10 +460,10 @@ main ()
print_time(j);
}
atime[3][6] = atime[3][6] / 5.0;
- fprintf (stderr,"Average %11.2f\n",
+ fprintf (stdout,"Average %11.2f\n",
(double)atime[3][6]);
- fprintf (stderr,"\nCalculating matgen2 overhead\n");
+ fprintf (stdout,"\nCalculating matgen2 overhead\n");
/************************************************************************
* Calculate overhead of executing matgen procedure *
@@ -510,10 +478,10 @@ main ()
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");
+ fprintf (stdout,"Overhead for 1 matgen %12.5f seconds\n\n", overhead2);
+ fprintf(stdout,"Times for array with leading dimension of%4d\n\n",ldaa);
+ fprintf(stdout," dgefa dgesl total Mflops unit");
+ fprintf(stdout," ratio\n");
/************************************************************************
* Execute 5 passes *
@@ -553,7 +521,7 @@ main ()
print_time(j);
}
atime[3][12] = atime[3][12] / 5.0;
- fprintf (stderr,"Average %11.2f\n",
+ fprintf (stdout,"Average %11.2f\n",
(double)atime[3][12]);
/************************************************************************
@@ -563,109 +531,16 @@ main ()
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");
- Endit = getch();
+ fprintf(stdout,"\n");
+ fprintf(stdout,ROLLING);fprintf(stdout,PREC);
+ fprintf(stdout," Precision %11.2f Mflops \n\n",mflops);
}
/*----------------------*/
void print_time (int row)
{
-fprintf(stderr,"%11.5f%11.5f%11.5f%11.2f%11.4f%11.4f\n", (double)atime[0][row],
+fprintf(stdout,"%11.5f%11.5f%11.5f%11.2f%11.4f%11.4f\n", (double)atime[0][row],
(double)atime[1][row], (double)atime[2][row], (double)atime[3][row],
(double)atime[4][row], (double)atime[5][row]);
return;
@@ -950,10 +825,7 @@ void daxpy(int n, REAL da, REAL dx[], int incx, REAL dy[], int incy)
*/
{
- int i,ix,iy,m,mp1;
-
- mp1 = 0;
- m = 0;
+ int i,ix,iy;
if(n <= 0) return;
if (da == ZERO) return;
@@ -1019,10 +891,7 @@ REAL ddot(int n, REAL dx[], int incx, REAL dy[], int incy)
{
REAL dtemp;
- int i,ix,iy,m,mp1;
-
- mp1 = 0;
- m = 0;
+ int i,ix,iy;
dtemp = ZERO;
@@ -1086,10 +955,7 @@ void dscal(int n, REAL da, REAL dx[], int incx)
*/
{
- int i,m,mp1,nincx;
-
- mp1 = 0;
- m = 0;
+ int i,nincx;
if(n <= 0)return;
if(incx != 1) {
@@ -1150,6 +1016,7 @@ int idamax(int n, REAL dx[], int incx)
if( n < 1 ) return(-1);
if(n ==1 ) return(0);
+ itemp = -1;
if(incx != 1) {
/* code for increment not equal to 1 */