/* gcc linpack.c cpuidc64.o cpuida64.o -m64 -lrt -lc -lm -o linpack
*
* Linpack 100x100 Benchmark In C/C++ For PCs
*
* Different compilers can produce different floating point numeric
* results, probably due to compiling instructions in a different
* sequence. As the program checks these, they may need to be changed.
* The log file indicates non-standard results and these values can
* be copied and pasted into this program. See // Values near the
* end of main().
*
* Different compilers do not optimise the code in the same way.
* This can lead to wide variations in benchmark speeds. See results
* with MS6 compiler ID and compare with those from same CPUs from
* the Watcom compiler generated code.
*
***************************************************************************
*/
#define _CRT_SECURE_NO_WARNINGS 1
#ifdef WIN32
#include <Windows.h>
#else
#include <sys/time.h>
#endif
#define UNROLL
#ifndef SP
#define DP
#endif
#ifdef SP
#define REAL float
#define ZERO 0.0
#define ONE 1.0
#define PREC "Single"
#endif
#ifdef DP
#define REAL double
#define ZERO 0.0e0
#define ONE 1.0e0
#define PREC "Double"
#endif
#ifdef ROLL
#define ROLLING "Rolled"
#endif
#ifdef UNROLL
#define ROLLING "Unrolled"
#endif
// VERSION
#ifdef CNNT
#define options "Non-optimised"
#define opt "0"
#else
// #define options "Optimised"
#define options "Opt 3 64 Bit"
#define opt "1"
#endif
#define NTIMES 10
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
/* this is truly rank, but it's minimally invasive, and lifted in part from the STREAM scores */
static double secs;
#ifndef WIN32
double mysecond()
{
struct timeval tp;
struct timezone tzp;
int i;
i = gettimeofday(&tp,&tzp);
return ( (double) tp.tv_sec + (double) tp.tv_usec * 1.e-6 );
}
#else
double mysecond()
{
static LARGE_INTEGER freq = {0};
LARGE_INTEGER count = {0};
if(freq.QuadPart == 0LL) {
QueryPerformanceFrequency(&freq);
}
QueryPerformanceCounter(&count);
return (double)count.QuadPart / (double)freq.QuadPart;
}
#endif
void start_time()
{
secs = mysecond();
}
void end_time()
{
secs = mysecond() - secs;
}
void print_time (int row);
void matgen (REAL a[], int lda, int n, REAL b[], REAL *norma);
void dgefa (REAL a[], int lda, int n, int ipvt[], int *info);
void dgesl (REAL a[],int lda,int n,int ipvt[],REAL b[],int job);
void dmxpy (int n1, REAL y[], int n2, int ldm, REAL x[], REAL m[]);
void daxpy (int n, REAL da, REAL dx[], int incx, REAL dy[], int incy);
REAL epslon (REAL x);
int idamax (int n, REAL dx[], int incx);
void dscal (int n, REAL da, REAL dx[], int incx);
REAL ddot (int n, REAL dx[], int incx, REAL dy[], int incy);
static REAL atime[9][15];
double runSecs = 1;
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,tm2,epsn,x1,x2;
REAL mflops;
static int ipvt[200],n,i,j,ntimes,info,l