LAL  7.5.0.1-fe68b98
VectorMathTest.c File Reference

Prototypes

int main (int argc, char *argv[])
 

Go to the source code of this file.

Data Structures

struct  UserInput_t
 

Macros

#define frand()   (rand() / (REAL4)RAND_MAX)
 
#define Relerr(dx, x)   (fabsf(x)>0 ? fabsf((dx)/(x)) : fabsf(dx) )
 
#define Relerrd(dx, x)   (fabs(x)>0 ? fabs((dx)/(x)) : fabs(dx) )
 
#define cRelerr(dx, x)   (cabsf(x)>0 ? cabsf((dx)/(x)) : fabsf(dx) )
 
#define TESTBENCH_VECTORMATH_S2I(name, in)
 
#define TESTBENCH_VECTORMATH_S2S(name, in)
 
#define TESTBENCH_VECTORMATH_S2SS(name, in)
 
#define TESTBENCH_VECTORMATH_SS2S(name, in1, in2)
 
#define TESTBENCH_VECTORMATH_SS2uU(name, in1, in2)
 
#define TESTBENCH_VECTORMATH_DD2D(name, in1, in2)
 
#define TESTBENCH_VECTORMATH_CC2C(name, in1, in2)
 
#define TESTBENCH_VECTORMATH_D2D(name, in)
 

Macro Definition Documentation

◆ frand

#define frand ( )    (rand() / (REAL4)RAND_MAX)

Definition at line 37 of file VectorMathTest.c.

◆ Relerr

#define Relerr (   dx,
 
)    (fabsf(x)>0 ? fabsf((dx)/(x)) : fabsf(dx) )

Definition at line 38 of file VectorMathTest.c.

◆ Relerrd

#define Relerrd (   dx,
 
)    (fabs(x)>0 ? fabs((dx)/(x)) : fabs(dx) )

Definition at line 39 of file VectorMathTest.c.

◆ cRelerr

#define cRelerr (   dx,
 
)    (cabsf(x)>0 ? cabsf((dx)/(x)) : fabsf(dx) )

Definition at line 40 of file VectorMathTest.c.

◆ TESTBENCH_VECTORMATH_S2I

#define TESTBENCH_VECTORMATH_S2I (   name,
  in 
)
Value:
{ \
XLAL_CHECK ( XLALVector##name##REAL4_GEN( xOutRefI4->data, in, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
tic = XLALGetCPUTime(); \
for (UINT4 l=0; l < Nruns; l ++ ) { \
XLAL_CHECK ( XLALVector##name##REAL4( xOutI4->data, in, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
} \
toc = XLALGetCPUTime(); \
for ( UINT4 i = 0; i < Ntrials; i ++ ) \
{ \
XLAL_CHECK ( xOutI4->data[i] == xOutRefI4->data[i], XLAL_ETOL, "%s: found element #%u (%i) differs from reference (%i)", #name, i, xOutI4->data[i], xOutRefI4->data[i] ); \
} \
XLALPrintInfo ( "%-32s: %4.0f Mops/sec\n", XLALVector##name##REAL4_name, (REAL8)Ntrials * Nruns / (toc - tic)/1e6 ); \
}
const char *const name
type name
Definition: UserInput.c:193
double REAL8
Double precision real floating-point number (8 bytes).
uint32_t UINT4
Four-byte unsigned integer.
float REAL4
Single precision real floating-point number (4 bytes).
REAL8 XLALGetCPUTime(void)
High-resolution CPU timer (returns result in seconds), aimed for code-timing purposes.
Definition: LogPrintf.c:270
@ XLAL_SUCCESS
Success return value (not an error number)
Definition: XLALError.h:401
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
Definition: XLALError.h:462
@ XLAL_ETOL
Failed to reach specified tolerance.
Definition: XLALError.h:458

Definition at line 43 of file VectorMathTest.c.

◆ TESTBENCH_VECTORMATH_S2S

#define TESTBENCH_VECTORMATH_S2S (   name,
  in 
)
Value:
{ \
XLAL_CHECK ( XLALVector##name##REAL4_GEN( xOutRef, in, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
tic = XLALGetCPUTime(); \
for (UINT4 l=0; l < Nruns; l ++ ) { \
XLAL_CHECK ( XLALVector##name##REAL4( xOut, in, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
} \
toc = XLALGetCPUTime(); \
maxErr = maxRelerr = 0; \
for ( UINT4 i = 0; i < Ntrials; i ++ ) \
{ \
REAL4 err = fabsf ( xOut[i] - xOutRef[i] ); \
REAL4 relerr = Relerr ( err, xOutRef[i] ); \
maxErr = fmaxf ( err, maxErr ); \
maxRelerr = fmaxf ( relerr, maxRelerr ); \
} \
XLALPrintInfo ( "%-32s: %4.0f Mops/sec [maxErr = %7.2g (tol=%7.2g), maxRelerr = %7.2g (tol=%7.2g)]\n", \
XLALVector##name##REAL4_name, (REAL8)Ntrials * Nruns / (toc - tic)/1e6, maxErr, (abstol), maxRelerr, (reltol) ); \
XLAL_CHECK ( (maxErr <= (abstol)), XLAL_ETOL, "%s: absolute error (%g) exceeds tolerance (%g)\n", #name "REAL4", maxErr, abstol ); \
XLAL_CHECK ( (maxRelerr <= (reltol)), XLAL_ETOL, "%s: relative error (%g) exceeds tolerance (%g)\n", #name "REAL4", maxRelerr, reltol ); \
}
#define Relerr(dx, x)

Definition at line 59 of file VectorMathTest.c.

◆ TESTBENCH_VECTORMATH_S2SS

#define TESTBENCH_VECTORMATH_S2SS (   name,
  in 
)
Value:
{ \
XLAL_CHECK ( XLALVector##name##REAL4_GEN( xOutRef, xOutRef2, xIn, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
tic = XLALGetCPUTime(); \
for (UINT4 l=0; l < Nruns; l ++ ) { \
XLAL_CHECK ( XLALVector##name##REAL4( xOut, xOut2, xIn, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
} \
toc = XLALGetCPUTime(); \
maxErr = maxRelerr = 0; \
for ( UINT4 i = 0; i < Ntrials; i ++ ) { \
REAL4 err1 = fabsf ( xOut[i] - xOutRef[i] ); \
REAL4 err2 = fabsf ( xOut2[i] - xOutRef2[i] ); \
REAL4 relerr1 = Relerr ( err1, xOutRef[i] ); \
REAL4 relerr2 = Relerr ( err2, xOutRef2[i] ); \
maxErr = fmaxf ( err1, maxErr ); \
maxErr = fmaxf ( err2, maxErr ); \
maxRelerr = fmaxf ( relerr1, maxRelerr ); \
maxRelerr = fmaxf ( relerr2, maxRelerr ); \
} \
XLALPrintInfo ( "%-32s: %4.0f Mops/sec [maxErr = %7.2g (tol=%7.2g), maxRelerr = %7.2g (tol=%7.2g)]\n", \
XLALVector##name##REAL4_name, (REAL8)Ntrials * Nruns / (toc - tic)/1e6, maxErr, (abstol), maxRelerr, reltol ); \
XLAL_CHECK ( (maxErr <= (abstol)), XLAL_ETOL, "%s: absolute error (%g) exceeds tolerance (%g)\n", #name "REAL4", maxErr, abstol ); \
XLAL_CHECK ( (maxRelerr <= (reltol)), XLAL_ETOL, "%s: relative error (%g) exceeds tolerance (%g)\n", #name "REAL4", maxRelerr, reltol ); \
}

Definition at line 81 of file VectorMathTest.c.

◆ TESTBENCH_VECTORMATH_SS2S

#define TESTBENCH_VECTORMATH_SS2S (   name,
  in1,
  in2 
)
Value:
{ \
XLAL_CHECK ( XLALVector##name##REAL4_GEN( xOutRef, in1, in2, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
tic = XLALGetCPUTime(); \
for (UINT4 l=0; l < Nruns; l ++ ) { \
XLAL_CHECK ( XLALVector##name##REAL4( xOut, in1, in2, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
} \
toc = XLALGetCPUTime(); \
maxErr = maxRelerr = 0; \
for ( UINT4 i = 0; i < Ntrials; i ++ ) \
{ \
REAL4 err = fabsf ( xOut[i] - xOutRef[i] ); \
REAL4 relerr = Relerr ( err, xOutRef[i] ); \
maxErr = fmaxf ( err, maxErr ); \
maxRelerr = fmaxf ( relerr, maxRelerr ); \
} \
XLALPrintInfo ( "%-32s: %4.0f Mops/sec [maxErr = %7.2g (tol=%7.2g), maxRelerr = %7.2g (tol=%7.2g)]\n", \
XLALVector##name##REAL4_name, (REAL8)Ntrials * Nruns / (toc - tic)/1e6, maxErr, (abstol), maxRelerr, (reltol) ); \
XLAL_CHECK ( (maxErr <= (abstol)), XLAL_ETOL, "%s: absolute error (%g) exceeds tolerance (%g)\n", #name "REAL4", maxErr, abstol ); \
XLAL_CHECK ( (maxRelerr <= (reltol)), XLAL_ETOL, "%s: relative error (%g) exceeds tolerance (%g)\n", #name "REAL4", maxRelerr, reltol ); \
}

Definition at line 107 of file VectorMathTest.c.

◆ TESTBENCH_VECTORMATH_SS2uU

#define TESTBENCH_VECTORMATH_SS2uU (   name,
  in1,
  in2 
)
Value:
{ \
UINT4 xCount = 0, xCountRef = 0; \
XLAL_CHECK ( XLALVector##name##REAL4_GEN( &xCountRef, xOutRefU4->data, in1, in2, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
tic = XLALGetCPUTime(); \
for (UINT4 l=0; l < Nruns; l ++ ) { \
XLAL_CHECK ( XLALVector##name##REAL4( &xCount, xOutU4->data, in1, in2, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
XLAL_CHECK ( xCount == xCountRef, XLAL_ETOL, "%s: count of found elements (%u) differs from reference (%u)", #name, xCount, xCountRef ); \
} \
toc = XLALGetCPUTime(); \
for ( UINT4 i = 0; i < xCount; i ++ ) \
{ \
XLAL_CHECK ( xOutU4->data[i] == xOutRefU4->data[i], XLAL_ETOL, "%s: found element #%u (%u) differs from reference (%u)", #name, i, xOutU4->data[i], xOutRefU4->data[i] ); \
} \
XLALPrintInfo ( "%-32s: %4.0f Mops/sec\n", XLALVector##name##REAL4_name, (REAL8)Ntrials * Nruns / (toc - tic)/1e6 ); \
}

Definition at line 130 of file VectorMathTest.c.

◆ TESTBENCH_VECTORMATH_DD2D

#define TESTBENCH_VECTORMATH_DD2D (   name,
  in1,
  in2 
)
Value:
{ \
XLAL_CHECK ( XLALVector##name##REAL8_GEN( xOutRefD, in1, in2, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
tic = XLALGetCPUTime(); \
for (UINT4 l=0; l < Nruns; l ++ ) { \
XLAL_CHECK ( XLALVector##name##REAL8( xOutD, in1, in2, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
} \
toc = XLALGetCPUTime(); \
maxErr = maxRelerr = 0; \
for ( UINT4 i = 0; i < Ntrials; i ++ ) \
{ \
REAL8 err = fabs ( xOutD[i] - xOutRefD[i] ); \
REAL8 relerr = Relerrd ( err, xOutRefD[i] ); \
maxErr = fmax ( err, maxErr ); \
maxRelerr = fmax ( relerr, maxRelerr ); \
} \
XLALPrintInfo ( "%-32s: %4.0f Mops/sec [maxErr = %7.2g (tol=%7.2g), maxRelerr = %7.2g (tol=%7.2g)]\n", \
XLALVector##name##REAL8_name, (REAL8)Ntrials * Nruns / (toc - tic)/1e6, maxErr, (abstol), maxRelerr, (reltol) ); \
XLAL_CHECK ( (maxErr <= (abstol)), XLAL_ETOL, "%s: absolute error (%g) exceeds tolerance (%g)\n", #name "REAL8", maxErr, abstol ); \
XLAL_CHECK ( (maxRelerr <= (reltol)), XLAL_ETOL, "%s: relative error (%g) exceeds tolerance (%g)\n", #name "REAL8", maxRelerr, reltol ); \
}
#define Relerrd(dx, x)

Definition at line 147 of file VectorMathTest.c.

◆ TESTBENCH_VECTORMATH_CC2C

#define TESTBENCH_VECTORMATH_CC2C (   name,
  in1,
  in2 
)
Value:
{ \
XLAL_CHECK ( XLALVector##name##COMPLEX8_GEN( xOutRefC, in1, in2, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
tic = XLALGetCPUTime(); \
for (UINT4 l=0; l < Nruns; l ++ ) { \
XLAL_CHECK ( XLALVector##name##COMPLEX8( xOutC, in1, in2, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
} \
toc = XLALGetCPUTime(); \
maxErr = maxRelerr = 0; \
for ( UINT4 i = 0; i < Ntrials; i ++ ) \
{ \
REAL4 err = cabsf ( xOutC[i] - xOutRefC[i] ); \
REAL4 relerr = cRelerr ( err, xOutRefC[i] ); \
maxErr = fmaxf ( err, maxErr ); \
maxRelerr = fmaxf ( relerr, maxRelerr ); \
} \
XLALPrintInfo ( "%-32s: %4.0f Mops/sec [maxErr = %7.2g (tol=%7.2g), maxRelerr = %7.2g (tol=%7.2g)]\n", \
XLALVector##name##COMPLEX8_name, (REAL8)Ntrials * Nruns / (toc - tic)/1e6, maxErr, (abstol), maxRelerr, (reltol) ); \
XLAL_CHECK ( (maxErr <= (abstol)), XLAL_ETOL, "%s: absolute error (%g) exceeds tolerance (%g)\n", #name "COMPLEX8", maxErr, abstol ); \
XLAL_CHECK ( (maxRelerr <= (reltol)), XLAL_ETOL, "%s: relative error (%g) exceeds tolerance (%g)\n", #name "COMPLEX8", maxRelerr, reltol ); \
}
#define cRelerr(dx, x)
float complex COMPLEX8
Single-precision floating-point complex number (8 bytes total)

Definition at line 169 of file VectorMathTest.c.

◆ TESTBENCH_VECTORMATH_D2D

#define TESTBENCH_VECTORMATH_D2D (   name,
  in 
)
Value:
{ \
XLAL_CHECK ( XLALVector##name##REAL8_GEN( xOutRefD, in, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
tic = XLALGetCPUTime(); \
for (UINT4 l=0; l < Nruns; l ++ ) { \
XLAL_CHECK ( XLALVector##name##REAL8( xOutD, in, Ntrials ) == XLAL_SUCCESS, XLAL_EFUNC ); \
} \
toc = XLALGetCPUTime(); \
maxErr = maxRelerr = 0; \
for ( UINT4 i = 0; i < Ntrials; i ++ ) \
{ \
REAL8 err = fabs ( xOut[i] - xOutRef[i] ); \
REAL8 relerr = Relerrd ( err, xOutRef[i] ); \
maxErr = fmax ( err, maxErr ); \
maxRelerr = fmax ( relerr, maxRelerr ); \
} \
XLALPrintInfo ( "%-32s: %4.0f Mops/sec [maxErr = %7.2g (tol=%7.2g), maxRelerr = %7.2g (tol=%7.2g)]\n", \
XLALVector##name##REAL8_name, (REAL8)Ntrials * Nruns / (toc - tic)/1e6, maxErr, (abstol), maxRelerr, (reltol) ); \
XLAL_CHECK ( (maxErr <= (abstol)), XLAL_ETOL, "%s: absolute error (%g) exceeds tolerance (%g)\n", #name "REAL8", maxErr, abstol ); \
XLAL_CHECK ( (maxRelerr <= (reltol)), XLAL_ETOL, "%s: relative error (%g) exceeds tolerance (%g)\n", #name "REAL8", maxRelerr, reltol ); \
}

Definition at line 192 of file VectorMathTest.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 226 of file VectorMathTest.c.