mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-14 02:18:54 +00:00
v1.1.1
This commit is contained in:
56
packages/third-party/benchmark/linpack/linpack.c
vendored
56
packages/third-party/benchmark/linpack/linpack.c
vendored
@@ -24,9 +24,20 @@ You must specify one of -DSP or -DDP to compile correctly.
|
||||
You must specify one of -DROLL or -DUNROLL to compile correctly.
|
||||
|
||||
*/
|
||||
#include <rtconfig.h>
|
||||
|
||||
//#define SP
|
||||
#ifdef ARCH_RISCV_FPU_S
|
||||
#define SP
|
||||
#else
|
||||
/*
|
||||
* If the chip does not support floating-point, then this program is executed
|
||||
* with software double precision floating-point.
|
||||
*/
|
||||
#define DP
|
||||
#endif
|
||||
|
||||
#define FABS(x) ((x > 0) ? (x) : (-x))
|
||||
|
||||
#define __NO_OS__
|
||||
#define UNROLL
|
||||
|
||||
@@ -35,6 +46,7 @@ You must specify one of -DROLL or -DUNROLL to compile correctly.
|
||||
#define ZERO 0.0
|
||||
#define ONE 1.0
|
||||
#define PREC "Single "
|
||||
#define FLOOR_REAL floorf
|
||||
#endif
|
||||
|
||||
#ifdef DP
|
||||
@@ -42,6 +54,7 @@ You must specify one of -DROLL or -DUNROLL to compile correctly.
|
||||
#define ZERO 0.0e0
|
||||
#define ONE 1.0e0
|
||||
#define PREC "Double "
|
||||
#define FLOOR_REAL floor
|
||||
#endif
|
||||
|
||||
#define NTIMES 10
|
||||
@@ -65,18 +78,18 @@ int print_time (row)
|
||||
int row;
|
||||
{
|
||||
#ifndef AIC_PRINT_FLOAT_CUSTOM
|
||||
fprintf(stderr,"%11.2f%11.2f%11.2f%11.0f%11.2f%11.2f\n", (double)timer[0][row],
|
||||
(double)timer[1][row], (double)timer[2][row], (double)timer[3][row],
|
||||
(double)timer[4][row], (double)timer[5][row]);
|
||||
fprintf(stderr,"%11.2f%11.2f%11.2f%11.0f%11.2f%11.2f\n", (REAL)timer[0][row],
|
||||
(REAL)timer[1][row], (REAL)timer[2][row], (REAL)timer[3][row],
|
||||
(REAL)timer[4][row], (REAL)timer[5][row]);
|
||||
#else
|
||||
/* print float */
|
||||
double p_f[6] = {0};
|
||||
REAL p_f[6] = {0};
|
||||
unsigned int p_i1[6] = {0};
|
||||
unsigned int p_i2[6] = {0};
|
||||
int i = 0;
|
||||
|
||||
for (i=0; i<6; i++){
|
||||
p_f[i] = (double)timer[i][row];
|
||||
p_f[i] = (REAL)timer[i][row];
|
||||
p_i1[i] = (unsigned int)p_f[i];
|
||||
p_i2[i] = (unsigned int)((p_f[i]-p_i1[i])*100.0);
|
||||
}
|
||||
@@ -537,12 +550,12 @@ int incx,n;
|
||||
/* code for increment not equal to 1 */
|
||||
|
||||
ix = 0;
|
||||
dmax = fabs((double)dx[0]);
|
||||
dmax = FABS(dx[0]);
|
||||
ix = ix + incx;
|
||||
for (i = 1; i < n; i++) {
|
||||
if(fabs((double)dx[ix]) > dmax) {
|
||||
if(FABS(dx[ix]) > dmax) {
|
||||
itemp = i;
|
||||
dmax = fabs((double)dx[ix]);
|
||||
dmax = FABS(dx[ix]);
|
||||
}
|
||||
ix = ix + incx;
|
||||
}
|
||||
@@ -552,11 +565,11 @@ int incx,n;
|
||||
/* code for increment equal to 1 */
|
||||
|
||||
itemp = 0;
|
||||
dmax = fabs((double)dx[0]);
|
||||
dmax = FABS(dx[0]);
|
||||
for (i = 1; i < n; i++) {
|
||||
if(fabs((double)dx[i]) > dmax) {
|
||||
if(FABS(dx[i]) > dmax) {
|
||||
itemp = i;
|
||||
dmax = fabs((double)dx[i]);
|
||||
dmax = FABS(dx[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -605,9 +618,9 @@ REAL x;
|
||||
while (eps == ZERO) {
|
||||
b = a - ONE;
|
||||
c = b + b + b;
|
||||
eps = fabs((double)(c-ONE));
|
||||
eps = FABS((c-ONE));
|
||||
}
|
||||
return(eps*fabs((double)x));
|
||||
return(eps*FABS(x));
|
||||
}
|
||||
|
||||
/*----------------------*/
|
||||
@@ -739,6 +752,7 @@ return clock()/1.0e6;
|
||||
}
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <aic_common.h>
|
||||
#include <aic_time.h>
|
||||
|
||||
|
||||
@@ -853,10 +867,8 @@ void test_linpack()
|
||||
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]);
|
||||
resid = (resid > FABS(b[i])) ? resid : FABS(b[i]);
|
||||
normx = (normx > FABS(x[i])) ? normx : FABS(x[i]);
|
||||
}
|
||||
eps = epslon((REAL)ONE);
|
||||
residn = resid/( n*norma*normx*eps );
|
||||
@@ -864,8 +876,8 @@ void test_linpack()
|
||||
printf(" norm. resid resid machep");
|
||||
printf(" x[0]-1 x[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);
|
||||
(REAL)residn, (REAL)resid, (REAL)eps,
|
||||
(REAL)x[0]-1, (REAL)x[n-1]-1);
|
||||
|
||||
fprintf(stderr," times are reported for matrices of order %5d\n",n);
|
||||
fprintf(stderr," dgefa dgesl total kflops unit");
|
||||
@@ -999,10 +1011,10 @@ void test_linpack()
|
||||
|
||||
kf = (timer[3][3] < timer[3][7]) ? timer[3][3] : timer[3][7];
|
||||
kf = (kf > ZERO) ? (kf + .5) : (kf - .5);
|
||||
if (fabs((double)kf) < ONE)
|
||||
if (FABS(kf) < ONE)
|
||||
kflops = 0;
|
||||
else {
|
||||
kflops = floor(fabs((double)kf));
|
||||
kflops = FLOOR_REAL(FABS(kf));
|
||||
if (kf < ZERO) kflops = -kflops;
|
||||
}
|
||||
|
||||
|
||||
@@ -177,6 +177,10 @@
|
||||
# define MAX(x,y) ((x)>(y)?(x):(y))
|
||||
# endif
|
||||
|
||||
#ifdef ARCH_RISCV_FPU_S
|
||||
#define double float
|
||||
#endif
|
||||
|
||||
#ifndef STREAM_TYPE
|
||||
#define STREAM_TYPE double
|
||||
#endif
|
||||
|
||||
@@ -66,19 +66,44 @@ C**********************************************************************
|
||||
#define CPU_FREQ (hal_clk_get_freq(CLK_CPU)/1000000)
|
||||
|
||||
/* map the FORTRAN math functions, etc. to the C versions */
|
||||
#define DSIN sin
|
||||
#define DCOS cos
|
||||
#define DATAN atan
|
||||
#define DLOG log
|
||||
#define DEXP exp
|
||||
#define DSQRT sqrt
|
||||
#ifdef ARCH_RISCV_FPU_S
|
||||
#define SP
|
||||
#else
|
||||
/*
|
||||
* If the chip does not support floating-point, then this program is executed
|
||||
* with software double precision floating-point.
|
||||
*/
|
||||
#define DP
|
||||
#endif
|
||||
|
||||
#ifdef SP
|
||||
#define REAL float
|
||||
#define SIN sinf
|
||||
#define COS cosf
|
||||
#define ATAN atanf
|
||||
#define LOG logf
|
||||
#define EXP expf
|
||||
#define SQRT sqrtf
|
||||
#define STR_REAL "Single"
|
||||
#endif
|
||||
|
||||
#ifdef DP
|
||||
#define REAL double
|
||||
#define SIN sin
|
||||
#define COS cos
|
||||
#define ATAN atan
|
||||
#define LOG log
|
||||
#define EXP exp
|
||||
#define SQRT sqrt
|
||||
#define STR_REAL "Double"
|
||||
#endif
|
||||
#define IF if
|
||||
|
||||
/* function prototypes */
|
||||
void POUT(long N, long J, long K, double X1, double X2, double X3, double X4);
|
||||
void PA(double E[]);
|
||||
void POUT(long N, long J, long K, REAL X1, REAL X2, REAL X3, REAL X4);
|
||||
void PA(REAL E[]);
|
||||
void P0(void);
|
||||
void P3(double X, double Y, double *Z);
|
||||
void P3(REAL X, REAL Y, REAL *Z);
|
||||
#define USAGE "usage: whetdc [-c] [loops]\n"
|
||||
|
||||
static long my_time(int t)
|
||||
@@ -89,7 +114,7 @@ static long my_time(int t)
|
||||
/*
|
||||
COMMON T,T1,T2,E1(4),J,K,L
|
||||
*/
|
||||
double T,T1,T2,E1[5];
|
||||
REAL T,T1,T2,E1[5];
|
||||
int J,K,L;
|
||||
|
||||
int
|
||||
@@ -98,7 +123,7 @@ whetstone_main(int argc, char *argv[])
|
||||
/* used in the FORTRAN version */
|
||||
long I;
|
||||
long N1, N2, N3, N4, N6, N7, N8, N9, N10, N11;
|
||||
double X1,X2,X3,X4,X,Y,Z;
|
||||
REAL X1,X2,X3,X4,X,Y,Z;
|
||||
long LOOP;
|
||||
int II, JJ;
|
||||
|
||||
@@ -280,8 +305,8 @@ C
|
||||
Y = 0.5;
|
||||
|
||||
for (I = 1; I <= N7; I++) {
|
||||
X = T * DATAN(T2*DSIN(X)*DCOS(X)/(DCOS(X+Y)+DCOS(X-Y)-1.0));
|
||||
Y = T * DATAN(T2*DSIN(Y)*DCOS(Y)/(DCOS(X+Y)+DCOS(X-Y)-1.0));
|
||||
X = T * ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0));
|
||||
Y = T * ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0));
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
@@ -350,7 +375,7 @@ C
|
||||
X = 0.75;
|
||||
|
||||
for (I = 1; I <= N11; I++)
|
||||
X = DSQRT(DEXP(DLOG(X)/T1));
|
||||
X = SQRT(EXP(LOG(X)/T1));
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (JJ==II)POUT(N11,J,K,X,X,X,X);
|
||||
@@ -393,11 +418,11 @@ C--------------------------------------------------------------------
|
||||
|
||||
#ifndef AIC_PRINT_FLOAT_CUSTOM
|
||||
if (KIPS >= 1000.0) {
|
||||
printf("C Converted Double Precision Whetstones: %.1f MIPS\n", KIPS/1000.0);
|
||||
printf("C Converted %s Precision Whetstones: %.1f MIPS\n", STR_REAL, KIPS/1000.0);
|
||||
printf("Score(CPU %ldMHz): %.2f\n", CPU_FREQ, KIPS/1000.0/CPU_FREQ);
|
||||
}
|
||||
else {
|
||||
printf("C Converted Double Precision Whetstones: %.1f KIPS\n", KIPS);
|
||||
printf("C Converted %s Precision Whetstones: %.1f KIPS\n", STR_REAL, KIPS);
|
||||
}
|
||||
#else
|
||||
/* print float */
|
||||
@@ -409,7 +434,7 @@ C--------------------------------------------------------------------
|
||||
p_f = KIPS/1000.0;
|
||||
p_i1 = (unsigned int)p_f;
|
||||
p_i2 = (unsigned int)((p_f-p_i1)*10.0);
|
||||
printf("C Converted Double Precision Whetstones: %d.%d MIPS\n", p_i1, p_i2);
|
||||
printf("C Converted %s Precision Whetstones: %d.%d MIPS\n", STR_REAL, p_i1, p_i2);
|
||||
|
||||
p_f = KIPS/1000.0/CPU_FREQ;
|
||||
p_i1 = (unsigned int)p_f;
|
||||
@@ -420,7 +445,7 @@ C--------------------------------------------------------------------
|
||||
p_f = KIPS;
|
||||
p_i1 = (unsigned int)p_f;
|
||||
p_i2 = (unsigned int)((p_f-p_i1)*10.0);
|
||||
printf("C Converted Double Precision Whetstones: %d.%d KIPS\n", p_i1, p_i2);
|
||||
printf("C Converted %s Precision Whetstones: %d.%d KIPS\n", STR_REAL, p_i1, p_i2);
|
||||
}
|
||||
#endif
|
||||
if (continuous)
|
||||
@@ -430,7 +455,7 @@ C--------------------------------------------------------------------
|
||||
}
|
||||
|
||||
void
|
||||
PA(double E[])
|
||||
PA(REAL E[])
|
||||
{
|
||||
J = 0;
|
||||
|
||||
@@ -454,9 +479,9 @@ P0(void)
|
||||
}
|
||||
|
||||
void
|
||||
P3(double X, double Y, double *Z)
|
||||
P3(REAL X, REAL Y, REAL *Z)
|
||||
{
|
||||
double X1, Y1;
|
||||
REAL X1, Y1;
|
||||
|
||||
X1 = X;
|
||||
Y1 = Y;
|
||||
@@ -467,7 +492,7 @@ P3(double X, double Y, double *Z)
|
||||
|
||||
#ifdef PRINTOUT
|
||||
void
|
||||
POUT(long N, long J, long K, double X1, double X2, double X3, double X4)
|
||||
POUT(long N, long J, long K, REAL X1, REAL X2, REAL X3, REAL X4)
|
||||
{
|
||||
printf("%7ld %7ld %7ld %12.4e %12.4e %12.4e %12.4e\n",
|
||||
N, J, K, X1, X2, X3, X4);
|
||||
|
||||
Reference in New Issue
Block a user