diff --git a/include/rvvlm.h b/include/rvvlm.h index a5ac3a0..eccf2b8 100644 --- a/include/rvvlm.h +++ b/include/rvvlm.h @@ -71,6 +71,9 @@ union sui64_fp64 { } \ } while (0) +#define VSRL_I_AS_U(x, nbits, vlen) \ + U_AS_I(__riscv_vsrl(I_AS_U((x)), (nbits), (vlen))) + #define PSTEP(coeff_j, x, poly, vlen) \ __riscv_vfmadd((poly), (x), VFMV_VF((coeff_j), (vlen)), (vlen)) @@ -93,6 +96,13 @@ union sui64_fp64 { __riscv_vsra(__riscv_vsmul((POLY), (X), 1, (vlen)), (K), (vlen)), \ (COEFF_j), (vlen)) +#define PSTEP_I_HI_SRA(COEFF_j, X, K, POLY, vlen) \ + __riscv_vadd(__riscv_vsra(__riscv_vmulh((POLY), (X), (vlen)), (K), (vlen)), \ + (COEFF_j), (vlen)) + +#define PSTEP_I_HI(COEFF_j, X, POLY, vlen) \ + __riscv_vadd(__riscv_vmulh((POLY), (X), (vlen)), (COEFF_j), (vlen)) + #define PSTEPN_I(COEFF_j, X, POLY, vlen) \ __riscv_vrsub(__riscv_vsmul((POLY), (X), 1, (vlen)), (COEFF_j), (vlen)) diff --git a/include/rvvlm_erfcinvD.inc.h b/include/rvvlm_erfcinvD.inc.h index 609f797..147328b 100644 --- a/include/rvvlm_erfcinvD.inc.h +++ b/include/rvvlm_erfcinvD.inc.h @@ -74,8 +74,6 @@ void F_VER1(API) { VFLOAT vx, vx_sign, vy, vy_special; VBOOL special_args; - VFLOAT dummy; - SET_ROUNDTONEAREST; // stripmining over input arguments for (; _inarg_n > 0; _inarg_n -= vlen) { @@ -85,8 +83,6 @@ void F_VER1(API) { // Handle Inf and NaN EXCEPTION_HANDLING_ERFCINV(vx, special_args, vy_special, vlen); - dummy = VFMV_VF(3.1415926535, vlen); - vx_sign = __riscv_vfrsub(vx, fp_posOne, vlen); VFLOAT two_minus_x = __riscv_vfadd(vx_sign, fp_posOne, vlen); VBOOL x_gt_1 = __riscv_vmflt(vx_sign, fp_posZero, vlen); @@ -97,6 +93,7 @@ void F_VER1(API) { VFLOAT w_hi, w_lo, w_hi_left, w_lo_left, y_hi, y_lo; VINT T, T_left, T_tiny; VBOOL x_is_tiny; + x_is_tiny = __riscv_vmxor(x_is_tiny, x_is_tiny, vlen); if (__riscv_vcpop(x_in_left, vlen) > 0) { VFLOAT x_left = VFMV_VF(0x1.0p-3, vlen); @@ -110,10 +107,8 @@ void F_VER1(API) { 0x1.0p-63, vlen); if (__riscv_vcpop(x_is_tiny, vlen) > 0) { VFLOAT w_hi_dummy, w_lo_dummy; - SQRTX_4_TRANSFORM(y_hi, y_lo, w_hi_dummy, w_lo_dummy, T_tiny, 0x1.0p65, - 0x1.0p-65, vlen); - dummy = __riscv_vfmul(__riscv_vfcvt_f(T_tiny, vlen), 0x1.0p-2, vlen); - dummy = __riscv_vfsub(dummy, __riscv_vfcvt_f(T_left, vlen), vlen); + SQRTX_4_TRANSFORM(y_hi, y_lo, w_hi_dummy, w_lo_dummy, T_tiny, 0x1.0p64, + 0x1.0p-64, vlen); } } w_hi = VFMV_VF(fp_posOne, vlen); @@ -200,7 +195,8 @@ void F_VER1(API) { if (__riscv_vcpop(x_is_tiny, vlen) > 0) { VFLOAT p_hi_tiny, p_lo_tiny, q_hi_tiny, q_lo_tiny; - ERFCINV_PQ_TINY(T_tiny, p_hi_tiny, p_lo_tiny, q_hi_tiny, q_lo_tiny, vlen); + ERFCINV_PQ_HILO_TINY(T_tiny, p_hi_tiny, p_lo_tiny, q_hi_tiny, q_lo_tiny, + vlen); p_hi = __riscv_vmerge(p_hi, p_hi_tiny, x_is_tiny, vlen); p_lo = __riscv_vmerge(p_lo, p_lo_tiny, x_is_tiny, vlen); q_hi = __riscv_vmerge(q_hi, q_hi_tiny, x_is_tiny, vlen); @@ -220,8 +216,6 @@ void F_VER1(API) { vy = __riscv_vfsgnj(vy, vx_sign, vlen); vy = __riscv_vmerge(vy, vy_special, special_args, vlen); - // vy = dummy; - // copy vy into y and increment addr pointers VFSTORE_OUTARG1(vy, vlen); diff --git a/include/rvvlm_inverrorfuncsD.h b/include/rvvlm_inverrorfuncsD.h index 8e1b619..df670a3 100644 --- a/include/rvvlm_inverrorfuncsD.h +++ b/include/rvvlm_inverrorfuncsD.h @@ -35,6 +35,52 @@ #define Q_tiny_9 0x5e4a26a7c1415755 // sacle 57 #define DELTA_Q0_tiny 0x1.8a7adad44d65ap-4 // scale 66 +#define Q50_84 +// Using [P,Q]_tiny_[HI,LO]_k, HI in Q50, LO in Q84 +#if defined(Q50_84) +#define P_tiny_HI_0 -0x8593442eL +#define P_tiny_LO_0 -0x4e7245b3L +#define P_tiny_HI_1 -0x7f3dc156b1L +#define P_tiny_LO_1 -0x1f0300096L +#define P_tiny_HI_2 -0x20dbbc67b1b8L +#define P_tiny_LO_2 -0xbc59b742L +#define P_tiny_HI_3 -0x30c75b8264d44L +#define P_tiny_LO_3 -0x18a421ab9L +#define P_tiny_HI_4 -0x1ab06f39e5addeL +#define P_tiny_LO_4 -0x180f2a477L +#define P_tiny_HI_5 -0x3d698fc2964a9cL +#define P_tiny_LO_5 0xc3d4ab0bL +#define P_tiny_HI_6 0x7f7d6a748d0c2fL +#define P_tiny_LO_6 0x1729754e9L +#define P_tiny_HI_7 0x18b100818c77848L +#define P_tiny_LO_7 0x1aca73439L +#define P_tiny_HI_8 0x4be1ed5d031774L +#define P_tiny_LO_8 -0x3b6c5afbL +#define P_tiny_HI_9 0x156a7e2e54e260L +#define P_tiny_LO_9 0x1a0c336beL + +#define Q_tiny_HI_0 -0x85933cdaL +#define Q_tiny_LO_0 -0xb5b39d61L +#define Q_tiny_HI_1 -0x7f3de4b69fL +#define Q_tiny_LO_1 -0x151d1cd35L +#define Q_tiny_HI_2 -0x20dd8dc1da27L +#define Q_tiny_LO_2 -0x1706945d7L +#define Q_tiny_HI_3 -0x30dc92d1cd231L +#define Q_tiny_LO_3 0xabde03f9L +#define Q_tiny_HI_4 -0x1af5fcee397d58L +#define Q_tiny_LO_4 -0xc3530d28L +#define Q_tiny_HI_5 -0x42639eeec1d051L +#define Q_tiny_LO_5 0x662b41ecL +#define Q_tiny_HI_6 0x6182b99f6ca998L +#define Q_tiny_LO_6 0x938a5e35L +#define Q_tiny_HI_7 0x17a6848dc07624aL +#define Q_tiny_LO_7 0x8a0484b7L +#define Q_tiny_HI_8 0x105ecd6aac52b12L +#define Q_tiny_LO_8 0x1d1e38258L +#define Q_tiny_HI_9 0xbc944d4f8282afL +#define Q_tiny_LO_9 -0x155b50b48L +#endif + // erfinv(+-1) = +-Inf with divide by zero // erfinv(x) |x| > 1, real is NaN with invalid // erfinv(NaN) is NaN, invalid if input is signalling NaN @@ -211,3 +257,73 @@ __riscv_vsub(Q, __riscv_vfcvt_x(q_hi_tiny, (vlen)), (vlen)), (vlen)); \ q_lo_tiny = __riscv_vfadd(q_lo, DELTA_Q0_tiny, (vlen)); \ } while (0) + +#define UPDATE_P_LO(COEFF, T, P_HI, P_LO, P_tmp, K, vlen) \ + do { \ + (P_LO) = PSTEP_I_HI((COEFF), (T), (P_LO), (vlen)); \ + (P_tmp) = __riscv_vmul((T), (P_HI), (vlen)); \ + (P_tmp) = VSRL_I_AS_U((P_tmp), (K), (vlen)); \ + (P_LO) = __riscv_vadd((P_LO), (P_tmp), (vlen)); \ + } while (0) + +#define ERFCINV_PQ_HILO_TINY(T, p_hi_tiny, p_lo_tiny, q_hi_tiny, q_lo_tiny, \ + vlen) \ + do { \ + /* T is in scale of 64 */ \ + VINT P_HI, P_LO, Q_HI, Q_LO, P_tmp, Q_tmp; \ + \ + P_HI = VMVI_VX(P_tiny_HI_9, (vlen)); \ + P_LO = VMVI_VX(P_tiny_LO_9, (vlen)); \ + \ + UPDATE_P_LO(P_tiny_LO_8, (T), P_HI, P_LO, P_tmp, 30, (vlen)); \ + P_HI = PSTEP_I_HI(P_tiny_HI_8, (T), P_HI, (vlen)); \ + UPDATE_P_LO(P_tiny_LO_7, (T), P_HI, P_LO, P_tmp, 30, (vlen)); \ + P_HI = PSTEP_I_HI(P_tiny_HI_7, (T), P_HI, (vlen)); \ + UPDATE_P_LO(P_tiny_LO_6, (T), P_HI, P_LO, P_tmp, 30, (vlen)); \ + P_HI = PSTEP_I_HI(P_tiny_HI_6, (T), P_HI, (vlen)); \ + UPDATE_P_LO(P_tiny_LO_5, (T), P_HI, P_LO, P_tmp, 30, (vlen)); \ + P_HI = PSTEP_I_HI(P_tiny_HI_5, (T), P_HI, (vlen)); \ + UPDATE_P_LO(P_tiny_LO_4, (T), P_HI, P_LO, P_tmp, 30, (vlen)); \ + P_HI = PSTEP_I_HI(P_tiny_HI_4, (T), P_HI, (vlen)); \ + UPDATE_P_LO(P_tiny_LO_3, (T), P_HI, P_LO, P_tmp, 30, (vlen)); \ + P_HI = PSTEP_I_HI(P_tiny_HI_3, (T), P_HI, (vlen)); \ + UPDATE_P_LO(P_tiny_LO_2, (T), P_HI, P_LO, P_tmp, 30, (vlen)); \ + P_HI = PSTEP_I_HI(P_tiny_HI_2, (T), P_HI, (vlen)); \ + UPDATE_P_LO(P_tiny_LO_1, (T), P_HI, P_LO, P_tmp, 30, (vlen)); \ + P_HI = PSTEP_I_HI(P_tiny_HI_1, (T), P_HI, (vlen)); \ + UPDATE_P_LO(P_tiny_LO_0, (T), P_HI, P_LO, P_tmp, 30, (vlen)); \ + P_HI = PSTEP_I_HI(P_tiny_HI_0, (T), P_HI, (vlen)); \ + \ + Q_HI = VMVI_VX(Q_tiny_HI_9, (vlen)); \ + Q_LO = VMVI_VX(Q_tiny_LO_9, (vlen)); \ + \ + UPDATE_P_LO(Q_tiny_LO_8, (T), Q_HI, Q_LO, Q_tmp, 30, (vlen)); \ + Q_HI = PSTEP_I_HI(Q_tiny_HI_8, (T), Q_HI, (vlen)); \ + UPDATE_P_LO(Q_tiny_LO_7, (T), Q_HI, Q_LO, Q_tmp, 30, (vlen)); \ + Q_HI = PSTEP_I_HI(Q_tiny_HI_7, (T), Q_HI, (vlen)); \ + UPDATE_P_LO(Q_tiny_LO_6, (T), Q_HI, Q_LO, Q_tmp, 30, (vlen)); \ + Q_HI = PSTEP_I_HI(Q_tiny_HI_6, (T), Q_HI, (vlen)); \ + UPDATE_P_LO(Q_tiny_LO_5, (T), Q_HI, Q_LO, Q_tmp, 30, (vlen)); \ + Q_HI = PSTEP_I_HI(Q_tiny_HI_5, (T), Q_HI, (vlen)); \ + UPDATE_P_LO(Q_tiny_LO_4, (T), Q_HI, Q_LO, Q_tmp, 30, (vlen)); \ + Q_HI = PSTEP_I_HI(Q_tiny_HI_4, (T), Q_HI, (vlen)); \ + UPDATE_P_LO(Q_tiny_LO_3, (T), Q_HI, Q_LO, Q_tmp, 30, (vlen)); \ + Q_HI = PSTEP_I_HI(Q_tiny_HI_3, (T), Q_HI, (vlen)); \ + UPDATE_P_LO(Q_tiny_LO_2, (T), Q_HI, Q_LO, Q_tmp, 30, (vlen)); \ + Q_HI = PSTEP_I_HI(Q_tiny_HI_2, (T), Q_HI, (vlen)); \ + UPDATE_P_LO(Q_tiny_LO_1, (T), Q_HI, Q_LO, Q_tmp, 30, (vlen)); \ + Q_HI = PSTEP_I_HI(Q_tiny_HI_1, (T), Q_HI, (vlen)); \ + UPDATE_P_LO(Q_tiny_LO_0, (T), Q_HI, Q_LO, Q_tmp, 30, (vlen)); \ + Q_HI = PSTEP_I_HI(Q_tiny_HI_0, (T), Q_HI, (vlen)); \ + \ + VFLOAT A = __riscv_vfcvt_f(P_HI, (vlen)); \ + p_lo_tiny = __riscv_vfcvt_f(P_LO, (vlen)); \ + p_hi_tiny = __riscv_vfmadd(p_lo_tiny, 0x1.0p-34, A, (vlen)); \ + p_lo_tiny = __riscv_vfmadd(p_lo_tiny, 0x1.0p-34, \ + __riscv_vfsub(A, p_hi_tiny, (vlen)), (vlen)); \ + VFLOAT B = __riscv_vfcvt_f(Q_HI, (vlen)); \ + q_lo_tiny = __riscv_vfcvt_f(Q_LO, (vlen)); \ + q_hi_tiny = __riscv_vfmadd(q_lo_tiny, 0x1.0p-34, B, (vlen)); \ + q_lo_tiny = __riscv_vfmadd(q_lo_tiny, 0x1.0p-34, \ + __riscv_vfsub(B, q_hi_tiny, (vlen)), (vlen)); \ + } while (0) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 89ccd76..18873fc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,38 +4,40 @@ set(TEST_SOURCES src/test_infra.cpp -# src/test_acos.cpp -# src/test_acosI.cpp -# src/test_acospi.cpp -# src/test_acospiI.cpp -# src/test_asin.cpp -# src/test_asinI.cpp -# src/test_asinpi.cpp -# src/test_asinpiI.cpp -# src/test_atan.cpp -# src/test_atanI.cpp -# src/test_atanpi.cpp -# src/test_atanpiI.cpp -# src/test_atan2.cpp -# src/test_atan2I.cpp -# src/test_atan2pi.cpp -# src/test_atan2piI.cpp -# src/test_acosh.cpp -# src/test_acoshI.cpp -# src/test_asinh.cpp -# src/test_asinhI.cpp -# src/test_atanh.cpp -# src/test_atanhI.cpp -# src/test_cbrt.cpp -# src/test_cbrtI.cpp -# src/test_cdfnorm.cpp -# src/test_cdfnormI.cpp + src/test_acos.cpp + src/test_acosI.cpp + src/test_acospi.cpp + src/test_acospiI.cpp + src/test_asin.cpp + src/test_asinI.cpp + src/test_asinpi.cpp + src/test_asinpiI.cpp + src/test_atan.cpp + src/test_atanI.cpp + src/test_atanpi.cpp + src/test_atanpiI.cpp + src/test_atan2.cpp + src/test_atan2I.cpp + src/test_atan2pi.cpp + src/test_atan2piI.cpp + src/test_acosh.cpp + src/test_acoshI.cpp + src/test_asinh.cpp + src/test_asinhI.cpp + src/test_atanh.cpp + src/test_atanhI.cpp + src/test_cbrt.cpp + src/test_cbrtI.cpp + src/test_cdfnorm.cpp + src/test_cdfnormI.cpp src/test_erf.cpp src/test_erfI.cpp src/test_erfc.cpp src/test_erfcI.cpp src/test_erfinv.cpp + src/test_erfinvI.cpp src/test_erfcinv.cpp + src/test_erfcinvI.cpp src/test_exp.cpp src/test_expI.cpp src/test_exp2.cpp @@ -44,37 +46,37 @@ set(TEST_SOURCES src/test_exp10I.cpp src/test_expm1.cpp src/test_expm1I.cpp -# src/test_log.cpp -# src/test_logI.cpp -# src/test_log2.cpp -# src/test_log2I.cpp -# src/test_log10.cpp -# src/test_log10I.cpp -# src/test_log1p.cpp -# src/test_log1pI.cpp -# src/test_pow.cpp -# src/test_powI.cpp -# src/test_cos.cpp -# src/test_cosI.cpp -# src/test_sin.cpp -# src/test_sinI.cpp -# src/test_cospi.cpp -# src/test_cospiI.cpp -# src/test_sinpi.cpp -# src/test_sinpiI.cpp -# src/test_sincos.cpp -# src/test_sincosI.cpp -# src/test_sincospi.cpp -# src/test_sincospiI.cpp -# src/test_tan.cpp -# src/test_tanI.cpp -# src/test_tanpi.cpp -# src/test_cosh.cpp -# src/test_coshI.cpp -# src/test_sinh.cpp -# src/test_sinhI.cpp -# src/test_tanh.cpp -# src/test_tanhI.cpp + src/test_log.cpp + src/test_logI.cpp + src/test_log2.cpp + src/test_log2I.cpp + src/test_log10.cpp + src/test_log10I.cpp + src/test_log1p.cpp + src/test_log1pI.cpp + src/test_pow.cpp + src/test_powI.cpp + src/test_cos.cpp + src/test_cosI.cpp + src/test_sin.cpp + src/test_sinI.cpp + src/test_cospi.cpp + src/test_cospiI.cpp + src/test_sinpi.cpp + src/test_sinpiI.cpp + src/test_sincos.cpp + src/test_sincosI.cpp + src/test_sincospi.cpp + src/test_sincospiI.cpp + src/test_tan.cpp + src/test_tanI.cpp + src/test_tanpi.cpp + src/test_cosh.cpp + src/test_coshI.cpp + src/test_sinh.cpp + src/test_sinhI.cpp + src/test_tanh.cpp + src/test_tanhI.cpp ) add_executable(test_veclibm ${TEST_SOURCES}) diff --git a/test/include/test_infra.h b/test/include/test_infra.h index ccb01ab..8d5c096 100644 --- a/test/include/test_infra.h +++ b/test/include/test_infra.h @@ -9,6 +9,8 @@ #define COMMENT(comment) \ { printf("\n=====\t" comment "\n"); } +// Most common interface: testing on 1 interval +// for 1-in-1-out unit-stride function void report_err_fp64(void (*test_func)(size_t, const double *, double *), long double (*ref_func)(long double), double, double, int, double = 1.0); @@ -16,15 +18,17 @@ void report_err_fp64(void (*test_func)(size_t, const double *, double *), void report_err_fp64(void (*test_func)(size_t, const double *, double *, double *), long double (*ref_func)(long double), int, double, double, - int); + int, double = 1.0); void report_err_fp64(void (*test_func)(size_t, const double *, double *), long double (*ref_func)(long double), const double *, int); +// Second most common interface: testing on 1 interval +// for 1-in-1-out general-stride function void report_err_fp64(void (*test_func)(size_t, const double *, size_t, double *, size_t), long double (*ref_func)(long double), double, double, int, - int, int); + int, int, double = 1.0); void report_err_fp64(void (*test_func)(size_t, const double *, size_t, double *, size_t, double *, size_t), @@ -34,23 +38,34 @@ void report_err_fp64(void (*test_func)(size_t, const double *, size_t, double *, void report_err2_fp64(void (*test_func)(size_t, const double *, const double *, double *), long double (*ref_func)(long double, long double), double, - double, int, double, double, int, bool); + double, int, double, double, int, bool, double = 1.0); void report_err2_fp64(void (*test_func)(size_t, const double *, size_t, const double *, size_t, double *, size_t), long double (*ref_func)(long double, long double), double, - double, int, int, double, double, int, int, int, bool); + double, int, int, double, double, int, int, int, bool, + double = 1.0); +// Testing a function where we only have a reference version for its inverse +// Testing on 1 interval for 1-in-1-out and unit-stride void report_err_byinv_fp64(void (*test_func)(size_t, const double *, double *), long double (*ref_inv_func)(long double), long double (*ref_inv_func_prime)(long double), double, double, int, double = 1.0); +// Testing a function where we only have a reference version for its inverse +// Testing on 1 interval for 1-in-1-out and general-stride +void report_err_byinv_fp64(void (*test_func)(size_t, const double *, size_t, + double *, size_t), + long double (*ref_inv_func)(long double), + long double (*ref_inv_func_prime)(long double), + double, double, int, int, int, double = 1.0); + void report_err_pow_fp64(void (*test_func)(size_t, const double *, const double *, double *), long double (*ref_func)(long double, long double), - double, double, double, int); + double, double, double, int, double = 1.0); void report_err_fp80(void (*test_func)(size_t, const double *, const double *, double *, double *), diff --git a/test/src/test_acos.cpp b/test/src/test_acos.cpp index cf13183..f0ee50f 100644 --- a/test/src/test_acos.cpp +++ b/test/src/test_acos.cpp @@ -19,21 +19,21 @@ TEST(acos, test) { x_start = -0x1.0p-40; x_end = 0x1.0p-40; ; - nb_tests = 40000; + nb_tests = 100000; report_err_fp64(rvvlm_acos, acosl, x_start, x_end, nb_tests); x_start = -0.5; x_end = 0.5; - nb_tests = 40000; + nb_tests = 100000; report_err_fp64(rvvlm_acos, acosl, x_start, x_end, nb_tests); x_start = 0.5; x_end = 1.0; - nb_tests = 40000; + nb_tests = 100000; report_err_fp64(rvvlm_acos, acosl, x_start, x_end, nb_tests); x_start = -1.0; x_end = -0.5; - nb_tests = 40000; + nb_tests = 100000; report_err_fp64(rvvlm_acos, acosl, x_start, x_end, nb_tests); } diff --git a/test/src/test_acosh.cpp b/test/src/test_acosh.cpp index e7433fa..388a596 100644 --- a/test/src/test_acosh.cpp +++ b/test/src/test_acosh.cpp @@ -23,16 +23,16 @@ TEST(acosh, test) { x_start = 0x1.0p0; x_end = 0x1.0p2; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_acosh, acoshl, x_start, x_end, nb_tests); x_start = 0x1.0p490; x_end = 0x1.0p520; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_acosh, acoshl, x_start, x_end, nb_tests); x_start = 0x1.0p1020; x_end = 0x1.FFFFFFFFFFp1023; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_acosh, acoshl, x_start, x_end, nb_tests); } diff --git a/test/src/test_acospi.cpp b/test/src/test_acospi.cpp index 72a34ad..cf851f9 100644 --- a/test/src/test_acospi.cpp +++ b/test/src/test_acospi.cpp @@ -18,21 +18,21 @@ TEST(acospi, test) { x_start = -0x1.0p-40; x_end = 0x1.0p-40; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_acospi, acospil, x_start, x_end, nb_tests); x_start = -0.5; x_end = 0.5; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_acospi, acospil, x_start, x_end, nb_tests); x_start = 0.5; x_end = 1.0; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_acospi, acospil, x_start, x_end, nb_tests); x_start = -1.0; x_end = -0.5; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_acospi, acospil, x_start, x_end, nb_tests); } diff --git a/test/src/test_asin.cpp b/test/src/test_asin.cpp index 97f8b1d..79979fa 100644 --- a/test/src/test_asin.cpp +++ b/test/src/test_asin.cpp @@ -24,16 +24,16 @@ TEST(asin, test) { x_start = 0.0; x_end = 0.5; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_asin, asinl, x_start, x_end, nb_tests); x_start = 0.5; x_end = 1.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_asin, asinl, x_start, x_end, nb_tests); x_start = -1.0; x_end = 1.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_asin, asinl, x_start, x_end, nb_tests); } diff --git a/test/src/test_asinh.cpp b/test/src/test_asinh.cpp index 131a9c2..51f20ff 100644 --- a/test/src/test_asinh.cpp +++ b/test/src/test_asinh.cpp @@ -28,17 +28,17 @@ TEST(asinh, test) { x_start = 0x1.0p-20; x_end = 0x1.0p-10; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); x_start = 0x1.0p-6; x_end = 0x1.0p0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); x_start = 0x1.0p0; x_end = 0x1.0p2; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); x_start = -0x1.0p0; @@ -48,7 +48,7 @@ TEST(asinh, test) { x_start = 0x1.0p490; x_end = 0x1.0p520; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); x_start = 0x1.0p1020; diff --git a/test/src/test_asinpi.cpp b/test/src/test_asinpi.cpp index 820975c..cad7a5f 100644 --- a/test/src/test_asinpi.cpp +++ b/test/src/test_asinpi.cpp @@ -18,21 +18,21 @@ TEST(asinpI, test) { x_start = -0x1.0p-40; x_end = 0x1.0p-40; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_asinpi, asinpil, x_start, x_end, nb_tests); x_start = 0.0; x_end = 0.5; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_asinpi, asinpil, x_start, x_end, nb_tests); x_start = 0.5; x_end = 1.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_asinpi, asinpil, x_start, x_end, nb_tests); x_start = -1.0; x_end = 1.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_asinpi, asinpil, x_start, x_end, nb_tests); } diff --git a/test/src/test_atan.cpp b/test/src/test_atan.cpp index 96f4faf..a4c6705 100644 --- a/test/src/test_atan.cpp +++ b/test/src/test_atan.cpp @@ -19,21 +19,21 @@ TEST(atan, test) { x_start = -0x1.0p-40; x_end = 0x1.0p-40; ; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atan, atanl, x_start, x_end, nb_tests); x_start = 0.0; x_end = 1.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atan, atanl, x_start, x_end, nb_tests); x_start = 1.0; x_end = 100.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atan, atanl, x_start, x_end, nb_tests); x_start = -10.0; x_end = 10.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atan, atanl, x_start, x_end, nb_tests); } diff --git a/test/src/test_atan2.cpp b/test/src/test_atan2.cpp index d7818a7..6c890f8 100644 --- a/test/src/test_atan2.cpp +++ b/test/src/test_atan2.cpp @@ -15,26 +15,26 @@ TEST(atan2, test) { COMMENT("atan2: current chosen algorithm; reduced argument in FP64 only") - // show_special2_fp64(rvvlm_atan2, swap_xy, "Special Value handling of this - // function"); + show_special2_fp64(rvvlm_atan2, swap_xy, + "Special Value handling of this function"); x_start = 0x1.000000001p0; x_end = 0x1.ffffffffffp0; - ; + nb_x = 8; y_start = 0x1.01p0; y_end = 0x1.fffp0; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); x_start = 0x1.000000001p0; x_end = 0x1.ffffffffffp0; - ; + nb_x = 8; y_start = 0x1.01p1020; y_end = 0x1.ffffffffp1020; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -44,7 +44,7 @@ TEST(atan2, test) { nb_x = 8; y_start = 0x1.01p-1020; y_end = 0x1.ffffffffp-1020; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -54,7 +54,7 @@ TEST(atan2, test) { nb_x = 8; y_start = 0x1.01p0; y_end = 0x1.fffp0; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -64,7 +64,7 @@ TEST(atan2, test) { nb_x = 8; y_start = 0x1.01p1020; y_end = 0x1.ffffffffp1020; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -74,7 +74,7 @@ TEST(atan2, test) { nb_x = 8; y_start = 0x1.01p-1020; y_end = 0x1.ffffffffp-1020; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -84,7 +84,7 @@ TEST(atan2, test) { nb_x = 8; y_start = -0x1.01p0; y_end = -0x1.fffp0; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -94,7 +94,7 @@ TEST(atan2, test) { nb_x = 8; y_start = -0x1.01p1020; y_end = -0x1.ffffffffp1020; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -104,7 +104,7 @@ TEST(atan2, test) { nb_x = 8; y_start = -0x1.01p-1020; y_end = -0x1.ffffffffp-1020; - nb_y = 1000000; + nb_y = 200000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -114,7 +114,7 @@ TEST(atan2, test) { nb_x = 8; y_start = -0x1.01p0; y_end = -0x1.fffp0; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -124,7 +124,7 @@ TEST(atan2, test) { nb_x = 8; y_start = -0x1.01p1020; y_end = -0x1.ffffffffp1020; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -134,7 +134,7 @@ TEST(atan2, test) { nb_x = 8; y_start = -0x1.01p-1020; y_end = -0x1.ffffffffp-1020; - nb_y = 1000000; + nb_y = 20000; report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); } diff --git a/test/src/test_atan2pi.cpp b/test/src/test_atan2pi.cpp index 7af60dd..d3bbf65 100644 --- a/test/src/test_atan2pi.cpp +++ b/test/src/test_atan2pi.cpp @@ -23,7 +23,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = 0x1.01p0; y_end = 0x1.fffp0; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -32,7 +32,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = 0x1.01p1020; y_end = 0x1.ffffffffp1020; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -41,7 +41,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = 0x1.01p-1020; y_end = 0x1.ffffffffp-1020; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -50,7 +50,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = 0x1.01p0; y_end = 0x1.fffp0; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -59,7 +59,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = 0x1.01p1020; y_end = 0x1.ffffffffp1020; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -68,7 +68,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = 0x1.01p-1020; y_end = 0x1.ffffffffp-1020; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -77,7 +77,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = -0x1.01p0; y_end = -0x1.fffp0; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -86,7 +86,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = -0x1.01p1020; y_end = -0x1.ffffffffp1020; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -95,7 +95,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = -0x1.01p-1020; y_end = -0x1.ffffffffp-1020; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -104,7 +104,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = -0x1.01p0; y_end = -0x1.fffp0; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -113,7 +113,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = -0x1.01p1020; y_end = -0x1.ffffffffp1020; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); @@ -122,7 +122,7 @@ TEST(atan2pi, test) { nb_x = 8; y_start = -0x1.01p-1020; y_end = -0x1.ffffffffp-1020; - nb_y = 1000000; + nb_y = 50000; report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, y_end, nb_y, swap_xy); } diff --git a/test/src/test_atanh.cpp b/test/src/test_atanh.cpp index d03fa27..da48400 100644 --- a/test/src/test_atanh.cpp +++ b/test/src/test_atanh.cpp @@ -28,31 +28,31 @@ TEST(atanh, test) { x_start = 0x1.0p-20; x_end = 0x1.0p-10; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); x_start = 0x1.0p-10; x_end = 0x1.ffp-3; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); x_start = 0x1.00p-9; x_end = 0x1.0p-2; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); x_start = 0x1.0p-1; x_end = 0x1.0p0 - 0x1.0p-51; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); x_start = -0x1.0p-1; x_end = -(0x1.0p0 - 0x1.0p-51); - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); x_start = -1.0 + 0x1.0p-53; x_end = 1.0 - 0x1.0p-51; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); } diff --git a/test/src/test_atanpi.cpp b/test/src/test_atanpi.cpp index 0f86b21..0f49c62 100644 --- a/test/src/test_atanpi.cpp +++ b/test/src/test_atanpi.cpp @@ -19,21 +19,21 @@ TEST(atanpi, test) { x_start = -0x1.0p-40; x_end = 0x1.0p-40; ; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atanpi, atanpil, x_start, x_end, nb_tests); x_start = 0.0; x_end = 1.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atanpi, atanpil, x_start, x_end, nb_tests); x_start = 1.0; x_end = 100.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atanpi, atanpil, x_start, x_end, nb_tests); x_start = -10.0; x_end = 10.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_atanpi, atanpil, x_start, x_end, nb_tests); } diff --git a/test/src/test_cbrt.cpp b/test/src/test_cbrt.cpp index e687f8a..fc4979f 100644 --- a/test/src/test_cbrt.cpp +++ b/test/src/test_cbrt.cpp @@ -18,7 +18,7 @@ TEST(cbrt, test) { x_start = 0x1.0p-1074; x_end = 0x1.0p-1064; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); x_start = -0x1.0p-1064; @@ -28,31 +28,31 @@ TEST(cbrt, test) { x_start = 0x1.0p0; x_end = 0x1.0p8; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); x_start = 0x1.0p-8; x_end = 0x1.0p-4; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); x_start = -0x1.0p0; x_end = -0x1.0p8; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); x_start = -0x1.0p-8; x_end = -0x1.0p-4; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); x_start = 0x1.0p1020; x_end = 0x1.fffffp1023; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); x_start = -0x1.0p1020; x_end = -0x1.fffffp1023; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); } diff --git a/test/src/test_cdfnorm.cpp b/test/src/test_cdfnorm.cpp index 452ca10..e96c5f3 100644 --- a/test/src/test_cdfnorm.cpp +++ b/test/src/test_cdfnorm.cpp @@ -18,36 +18,36 @@ TEST(cdfnorm, test) { x_start = -0x1.0p0; x_end = 0x1.0p0; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); x_start = 0x1.0p-2; x_end = 0x1.0p0; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); report_err_fp64(rvvlm_cdfnorm, cdfnorml, -x_start, -x_end, nb_tests); x_start = 0x1.0p0; x_end = 0x1.0p3; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); report_err_fp64(rvvlm_cdfnorm, cdfnorml, -x_start, -x_end, nb_tests); x_start = 0x1.0p3; x_end = 30.0; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); report_err_fp64(rvvlm_cdfnorm, cdfnorml, -x_start, -x_end, nb_tests); x_start = 0x1.0p-80; x_end = 0x1.0p-50; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); report_err_fp64(rvvlm_cdfnorm, cdfnorml, -x_start, -x_end, nb_tests); x_start = 0x1.0p-50; x_end = 0x1.0p-10; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); report_err_fp64(rvvlm_cdfnorm, cdfnorml, -x_start, -x_end, nb_tests); } diff --git a/test/src/test_cos.cpp b/test/src/test_cos.cpp index 1eeb0b5..2fa86aa 100644 --- a/test/src/test_cos.cpp +++ b/test/src/test_cos.cpp @@ -8,31 +8,62 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(cos, test) { +TEST(cos, special) { unsigned long nb_tests; double x_start, x_end; COMMENT("cos: current chosen algorithm; reduced argument in FP64 only") show_special_fp64(rvvlm_cos, "Special Value handling of this function"); +} + +TEST(cos, small_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("cos: current chosen algorithm; reduced argument in FP64 only") x_start = -0.78; x_end = 0.78; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); x_start = -6.0; x_end = 6.0; - nb_tests = 4000000; + nb_tests = 100000; + report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); +} + +TEST(cos, medium_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("cos: current chosen algorithm; reduced argument in FP64 only") + + x_start = 1.0; + x_end = 0x1.0p23; + nb_tests = 100000; + report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); + + x_start = 0x1.0p25; + x_end = 0x1.0p100; + nb_tests = 100000; report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); +} + +TEST(cos, large_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("cos: current chosen algorithm; reduced argument in FP64 only") x_start = 1.0; x_end = 0x1.0p23; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); x_start = 0x1.0p25; x_end = 0x1.0p100; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); } diff --git a/test/src/test_cosh.cpp b/test/src/test_cosh.cpp index a3abecf..b351879 100644 --- a/test/src/test_cosh.cpp +++ b/test/src/test_cosh.cpp @@ -8,31 +8,57 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(cosh, test) { +TEST(cosh, special) { unsigned long nb_tests; double x_start, x_end; COMMENT("cosh: current chosen algorithm; reduced argument in FP64 only") show_special_fp64(rvvlm_cosh, "Special Value handling of this function"); +} + +TEST(cosh, small_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("cosh: current chosen algorithm; reduced argument in FP64 only") x_start = -0.346; x_end = 0.346; - nb_tests = 4000000; - report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); - - x_start = 0x1.0p-30; - x_end = 1.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); x_start = -6.0; x_end = 6.0; - nb_tests = 4000000; + nb_tests = 40000; + report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); +} + +TEST(cosh, medium_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("cosh: current chosen algorithm; reduced argument in FP64 only") + + x_start = 30.0; + x_end = 40.0; + nb_tests = 40000; + report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); + + x_start = 50.0; + x_end = 60.0; + nb_tests = 40000; report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); +} + +TEST(cosh, large_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("cosh: current chosen algorithm; reduced argument in FP64 only") - x_start = 1.0; - x_end = 0x1.0p3; - nb_tests = 4000000; + x_start = 60.0; + x_end = 70.0; + nb_tests = 40000; report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); } diff --git a/test/src/test_cospi.cpp b/test/src/test_cospi.cpp index b0982c4..0193cc7 100644 --- a/test/src/test_cospi.cpp +++ b/test/src/test_cospi.cpp @@ -18,16 +18,16 @@ TEST(cospi, test) { x_start = -0.5; x_end = 0.5; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_cospi, cospil, x_start, x_end, nb_tests); x_start = -0x1.0p3; x_end = 0x1.0p3; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_cospi, cospil, x_start, x_end, nb_tests); x_start = 0x1.0p3; x_end = 0x1.0p60; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_cospi, cospil, x_start, x_end, nb_tests); } diff --git a/test/src/test_erfc.cpp b/test/src/test_erfc.cpp index e0f149f..37ea5b6 100644 --- a/test/src/test_erfc.cpp +++ b/test/src/test_erfc.cpp @@ -25,7 +25,7 @@ TEST(erfc, medium_args) { x_start = -0x1.0p0; x_end = 0x1.0p0; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_erfc, erfcl, x_start, x_end, nb_tests); } @@ -37,7 +37,7 @@ TEST(erfc, around_one) { x_start = 0x1.0p-1; x_end = 0x1.0p1; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_erfc, erfcl, x_start, x_end, nb_tests); report_err_fp64(rvvlm_erfc, erfcl, -x_start, -x_end, nb_tests); } @@ -50,7 +50,7 @@ TEST(erfc, large) { x_start = 0x1.0p1; x_end = 0x1.0p3; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_erfc, erfcl, x_start, x_end, nb_tests); report_err_fp64(rvvlm_erfc, erfcl, -x_start, -x_end, nb_tests); } diff --git a/test/src/test_erfcinv.cpp b/test/src/test_erfcinv.cpp index e937fcf..5dfae21 100644 --- a/test/src/test_erfcinv.cpp +++ b/test/src/test_erfcinv.cpp @@ -24,27 +24,22 @@ TEST(erfcinv, tiny_args) { COMMENT("erfcinv: current chosen algorithm; reduced argument in FP64 only") x_start = 0x1.0p-1074; - ; x_end = 0x1.0p-1000; nb_tests = 40000; - double thres = 3.5; report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, - nb_tests, thres); + nb_tests); x_start = 0x1.0p-1000; - ; x_end = 0x1.0p-500; nb_tests = 40000; - thres = 2.5; report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, - nb_tests, thres); + nb_tests); - x_start = 0x1.0p-500; - ; - x_end = 0x1.0p-52; + x_start = 0x1.0p-55; + x_end = 0x1.0p-53; nb_tests = 40000; report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, - nb_tests, thres); + nb_tests); } TEST(erfcinv, small_args) { diff --git a/test/src/test_erfcinv.foo b/test/src/test_erfcinv.foo deleted file mode 100755 index 43231db..0000000 --- a/test/src/test_erfcinv.foo +++ /dev/null @@ -1,109 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Rivos Inc. -// -// SPDX-License-Identifier: Apache-2.0 - -#include -#include - -#include "rvvlm.h" -#include "test_infra.h" - -#define COMMENT(comment) \ - { printf("\n=====\t" comment "\n"); } - -int main() { - unsigned long nb_tests; - double x_start, x_end; - - COMMENT("erfcinv: current chosen algorithm; reduced argument in FP64 only") - - show_special_fp64(rvvlm_erfcinv, "Special Value handling of this function"); - - x_start = 0x1.0p-5; - x_end = 0x1.0p-2; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-2; - x_end = 0x1.0p-1; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-1; - x_end = 0x1.fffp-1; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 1.0 + 0x1.0p-5; - x_end = 1.0 + 0x1.6p-2; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 2.0 - 0x1.0p-52; - x_end = 1.0 + 0x1.6p-1; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0.24; - x_end = 0.3; - nb_tests = 2; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-54; - x_end = 0x1.0p-53; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-55; - x_end = 0x1.0p-54; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-56; - x_end = 0x1.0p-55; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-57; - x_end = 0x1.0p-56; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-58; - x_end = 0x1.0p-57; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-59; - x_end = 0x1.0p-58; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-60; - x_end = 0x1.0p-59; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-100; - x_end = 0x1.0p-60; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-500; - x_end = 0x1.0p-100; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-1022; - x_end = 0x1.0p-100; - nb_tests = 100000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - x_start = 0x1.0p-1074; - x_end = 0x1.0p-1022; - nb_tests = 10000; - report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, nb_tests); - - return 0; -} - diff --git a/test/src/test_erfcinvI.cpp b/test/src/test_erfcinvI.cpp new file mode 100644 index 0000000..9c9485d --- /dev/null +++ b/test/src/test_erfcinvI.cpp @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2023 Rivos Inc. +// +// SPDX-License-Identifier: Apache-2.0 + +#include +#include + +#include "rvvlm.h" +#include "test_infra.h" + +TEST(erfcinvI, test) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("erfcinvI: current chosen algorithm; reduced argument in FP64 only") + + x_start = 0.5; + x_end = 1.75; + nb_tests = 30; + int stride_x = 21; + int stride_y = 30; + report_err_byinv_fp64(rvvlm_erfcinvI, erfcl, erfcl_prime, x_start, x_end, + nb_tests, stride_x, stride_y); +} diff --git a/test/src/test_erfinvI.cpp b/test/src/test_erfinvI.cpp new file mode 100644 index 0000000..c42ffc0 --- /dev/null +++ b/test/src/test_erfinvI.cpp @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2023 Rivos Inc. +// +// SPDX-License-Identifier: Apache-2.0 + +#include +#include + +#include "rvvlm.h" +#include "test_infra.h" + +TEST(erfinvI, test) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("erfinvI: current chosen algorithm; reduced argument in FP64 only") + + x_start = -0.7; + x_end = 0.7; + nb_tests = 30; + int stride_x = 21; + int stride_y = 30; + report_err_byinv_fp64(rvvlm_erfinvI, erfl, erfl_prime, x_start, x_end, + nb_tests, stride_x, stride_y); +} diff --git a/test/src/test_infra.cpp b/test/src/test_infra.cpp index 686501e..d55bc26 100644 --- a/test/src/test_infra.cpp +++ b/test/src/test_infra.cpp @@ -217,7 +217,7 @@ void report_err_fp64(void (*test_func)(size_t, const double *, double *), void report_err_fp64(void (*test_func)(size_t, const double *, double *, double *), long double (*ref_func)(long double), int which_output, - double start, double end, int nb_pts) { + double start, double end, int nb_pts, double threshold) { long double y_ref; double *x, *y, *z, delta; @@ -290,6 +290,8 @@ void report_err_fp64(void (*test_func)(size_t, const double *, double *, } printf("Maximum observed ULP error is %3.3Lf\n", max_ulp_err); + EXPECT_LT(max_ulp_err, threshold); + free(x); free(y); free(z); @@ -298,7 +300,8 @@ void report_err_fp64(void (*test_func)(size_t, const double *, double *, void report_err_fp64(void (*test_func)(size_t, const double *, size_t, double *, size_t), long double (*ref_func)(long double), double start, - double end, int nb_pts, int stride_in, int stride_out) { + double end, int nb_pts, int stride_in, int stride_out, + double threshold) { long double y_ref; double *x, *y, delta; @@ -366,6 +369,8 @@ void report_err_fp64(void (*test_func)(size_t, const double *, size_t, double *, } printf("Maximum observed ULP error is %3.3lf\n", max_ulp_err); + EXPECT_LT(max_ulp_err, threshold); + free(x); free(y); } @@ -542,10 +547,97 @@ void report_err_byinv_fp64(void (*test_func)(size_t, const double *, double *), return; } +void report_err_byinv_fp64(void (*test_func)(size_t, const double *, size_t, + double *, size_t), + long double (*ref_inv_func)(long double), + long double (*ref_inv_func_prime)(long double), + double start, double end, int nb_pts, int stride_in, + int stride_out, double threshold) { + + long double f_inv_ref; + double *x, *y, delta; + long double abs_err, rel_err, ulp_err; + long double max_abs_err, max_rel_err, max_ulp_err; + + x = (double *)malloc(nb_pts * sizeof(double) * stride_in); + y = (double *)malloc(nb_pts * sizeof(double) * stride_out); + + if (nb_pts <= 1) { + delta = 0.0; + nb_pts = 1; + } else { + delta = (end - start) / (double)(nb_pts - 1); + } + + max_abs_err = 0.0L; + max_rel_err = 0.0L; + max_ulp_err = 0.0L; + + // fill up the set of test points + for (int i = 0; i < nb_pts; ++i) { + x[i * stride_in] = start + (double)i * delta; + } + + // call function under test + test_func((size_t)nb_pts, x, (size_t)stride_in, y, (size_t)stride_out); + + // now for each point we compute error and log the max + for (int j = 0; j < nb_pts; j++) { + f_inv_ref = ref_inv_func((long double)y[j * stride_out]); + abs_err = (long double)x[j * stride_in] - f_inv_ref; + abs_err = abs_err / ref_inv_func_prime((long double)y[j * stride_out]); + abs_err = ABS(abs_err); + + if (ABS(y[j * stride_out]) > 0.0) { + rel_err = abs_err / ABS(y[j * stride_out]); + } else { + rel_err = abs_err / 0x1.0p-1074; + } + ulp_err = abs_err / ulp_64(y[j * stride_out]); + + max_abs_err = MAX(max_abs_err, abs_err); + max_rel_err = MAX(max_rel_err, rel_err); + max_ulp_err = MAX(max_ulp_err, ulp_err); + + if (VERBOSE) { + union sui64_fp64 xxx, yyy; + xxx.f = x[j * stride_in]; + yyy.f = y[j * stride_out]; + printf("--input %24.17le, 0x%016lx, output %24.17le, 0x%016lx \n", xxx.f, + xxx.ui, yyy.f, yyy.ui); + printf(" inverse of computed value %28.25Le\n\n", f_inv_ref); + printf(" abs err %8.3Le, rel err %8.3Le, ulp err %8.3Le\n\n", abs_err, + rel_err, ulp_err); + printf(" max observered abs err %8.3Le\n", max_abs_err); + } + } + printf("----------------------------\n"); + if ((ABS(start) > 100.) || (ABS(end) < 1.e-2)) { + printf("Tested %d points in [%8.3le, %8.3le]\n", nb_pts, start, end); + } else { + printf("Tested %d points in [%3.3lf, %3.3lf]\n", nb_pts, start, end); + } + printf("Maximum observed absolute error is %8.3Le\n", max_abs_err); + printf("Maximum observed relative error is %8.3Le\n", max_rel_err); + if (max_rel_err > 0.0) { + printf(" which is 2^(%3.3Lf)\n", + log2(max_rel_err)); + } + printf("Maximum observed ULP error is %3.3Lf\n", max_ulp_err); + + EXPECT_LT(max_ulp_err, threshold); + + free(x); + free(y); + + return; +} + void report_err_pow_fp64(void (*test_func)(size_t, const double *, const double *, double *), long double (*ref_func)(long double, long double), - double target, double start, double end, int nb_pts) { + double target, double start, double end, int nb_pts, + double threshold) { long double z_ref; double *x, *y, *z, delta; @@ -615,6 +707,8 @@ void report_err_pow_fp64(void (*test_func)(size_t, const double *, } printf("Maximum observed ULP error is %3.3Lf\n", max_ulp_err); + EXPECT_LT(max_ulp_err, threshold); + free(x); free(y); free(z); @@ -742,8 +836,8 @@ void report_err2_fp64(void (*test_func)(size_t, const double *, const double *, double *), long double (*ref_func)(long double, long double), double start_x, double end_x, int nb_pts_x, - double start_y, double end_y, int nb_pts_y, - bool swap_xy) { + double start_y, double end_y, int nb_pts_y, bool swap_xy, + double threshold) { long double z_ref; double *x, *y, *z, delta_x, delta_y; @@ -852,6 +946,8 @@ void report_err2_fp64(void (*test_func)(size_t, const double *, const double *, } printf("Maximum observed ULP error is %3.3Lf\n", max_ulp_err); + EXPECT_LT(max_ulp_err, threshold); + free(x); free(y); free(z); @@ -863,7 +959,7 @@ void report_err2_fp64(void (*test_func)(size_t, const double *, size_t, long double (*ref_func)(long double, long double), double start_x, double end_x, int nb_pts_x, int stride_x, double start_y, double end_y, int nb_pts_y, int stride_y, - int stride_z, bool swap_xy) { + int stride_z, bool swap_xy, double threshold) { long double z_ref; double *x, *y, *z, delta_x, delta_y; @@ -977,6 +1073,8 @@ void report_err2_fp64(void (*test_func)(size_t, const double *, size_t, } printf("Maximum observed ULP error is %3.3Lf\n", max_ulp_err); + EXPECT_LT(max_ulp_err, threshold); + free(x); free(y); free(z); diff --git a/test/src/test_log.cpp b/test/src/test_log.cpp index cb809ec..965b37e 100644 --- a/test/src/test_log.cpp +++ b/test/src/test_log.cpp @@ -8,28 +8,42 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(log, test) { +TEST(log, special) { unsigned long nb_tests; double x_start, x_end; COMMENT("log: current chosen algorithm; reduced argument in FP64 only") show_special_fp64(rvvlm_log, "Special Value handling of this function"); +} + +TEST(log, around_1) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("log: current chosen algorithm; reduced argument in FP64 only") x_start = 0.7; x_end = 1.5; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_log, logl, x_start, x_end, nb_tests); x_start = 1.0; x_end = 4.0; - nb_tests = 400000; + nb_tests = 100000; report_err_fp64(rvvlm_log, logl, x_start, x_end, nb_tests); x_start = 0.25; x_end = 1.0; - nb_tests = 4000000; + nb_tests = 1000000; report_err_fp64(rvvlm_log, logl, x_start, x_end, nb_tests); +} + +TEST(log, extreme_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("log: current chosen algorithm; reduced argument in FP64 only") x_start = 0x1.0p1023; x_end = 0x1.ffffffp1023; diff --git a/test/src/test_log10.cpp b/test/src/test_log10.cpp index 0baf028..938b7c6 100644 --- a/test/src/test_log10.cpp +++ b/test/src/test_log10.cpp @@ -8,36 +8,50 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(log10, test) { +TEST(log10, special) { unsigned long nb_tests; double x_start, x_end; COMMENT("log10: current chosen algorithm; reduced argument in FP64 only") show_special_fp64(rvvlm_log10, "Special Value handling of this function"); +} + +TEST(log10, around_1) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("log10: current chosen algorithm; reduced argument in FP64 only") x_start = 0.7; x_end = 1.5; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_log10, log10l, x_start, x_end, nb_tests); x_start = 1.0; x_end = 4.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_log10, log10l, x_start, x_end, nb_tests); x_start = 0.25; x_end = 1.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_log10, log10l, x_start, x_end, nb_tests); +} + +TEST(log10, extreme_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("log10: current chosen algorithm; reduced argument in FP64 only") x_start = 0x1.0p1023; x_end = 0x1.ffffffp1023; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_log10, log10l, x_start, x_end, nb_tests); x_start = 0x1.0p-1074; x_end = 0x1.0p-1022; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_log10, log10l, x_start, x_end, nb_tests); } diff --git a/test/src/test_log1p.cpp b/test/src/test_log1p.cpp index d1095ea..cbf3bcf 100644 --- a/test/src/test_log1p.cpp +++ b/test/src/test_log1p.cpp @@ -8,31 +8,45 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(log1p, test) { +TEST(log1p, special) { unsigned long nb_tests; double x_start, x_end; COMMENT("log1p: current chosen algorithm; reduced argument in FP64 only") show_special_fp64(rvvlm_log1p, "Special Value handling of this function"); +} + +TEST(log1p, small_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("log1p: current chosen algorithm; reduced argument in FP64 only") x_start = -0x1.0p-4; x_end = 0x1.0p-4; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_log1p, log1pl, x_start, x_end, nb_tests); x_start = -0.999999; x_end = 0.0; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_log1p, log1pl, x_start, x_end, nb_tests); +} + +TEST(log1p, large_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("log1p: current chosen algorithm; reduced argument in FP64 only") x_start = 0x1.0p1023; x_end = 0x1.ffffffp1023; - nb_tests = 4000; + nb_tests = 40000; report_err_fp64(rvvlm_log1p, log1pl, x_start, x_end, nb_tests); x_start = 0x1.0p-1074; x_end = 0x1.0p-1022; - nb_tests = 4000; + nb_tests = 40000; report_err_fp64(rvvlm_log1p, log1pl, x_start, x_end, nb_tests); } diff --git a/test/src/test_log2.cpp b/test/src/test_log2.cpp index 4616bac..3508c70 100644 --- a/test/src/test_log2.cpp +++ b/test/src/test_log2.cpp @@ -8,28 +8,42 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(log2p, test) { +TEST(log2, special) { unsigned long nb_tests; double x_start, x_end; COMMENT("log2: current chosen algorithm; reduced argument in FP64 only") show_special_fp64(rvvlm_log2, "Special Value handling of this function"); +} + +TEST(log2, around_1) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("log2: current chosen algorithm; reduced argument in FP64 only") x_start = 0.7; x_end = 1.5; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_log2, log2l, x_start, x_end, nb_tests); x_start = 1.0; x_end = 4.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_log2, log2l, x_start, x_end, nb_tests); x_start = 0.25; x_end = 1.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_log2, log2l, x_start, x_end, nb_tests); +} + +TEST(log2, extreme_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("log2: current chosen algorithm; reduced argument in FP64 only") x_start = 0x1.0p1023; x_end = 0x1.ffffffp1023; diff --git a/test/src/test_pow.cpp b/test/src/test_pow.cpp index 9a238ad..9411f0f 100644 --- a/test/src/test_pow.cpp +++ b/test/src/test_pow.cpp @@ -9,7 +9,7 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(pow, test) { +TEST(pow, special) { unsigned long nb_tests, nb_pts_x, nb_pts_y; double x_start, x_end, y_start, y_end; double target_start, target_end, delta, target; @@ -18,33 +18,65 @@ TEST(pow, test) { COMMENT("pow: current chosen algorithm; reduced argument in FP64 only") - // show_special2_fp64(rvvlm_pow, "Special Value handling of this function"); + show_special2_fp64(rvvlm_pow, swap_xy, + "Special Value handling of this function"); +} + +TEST(pow, medium_args) { + unsigned long nb_tests, nb_pts_x, nb_pts_y; + double x_start, x_end, y_start, y_end; + double target_start, target_end, delta, target; + unsigned long nb_targets; + bool swap_xy = 0; + + COMMENT("pow: current chosen algorithm; reduced argument in FP64 only") x_start = 0x1.0p-3; x_end = 0x1.0p4; - nb_pts_x = 2000; + nb_pts_x = 400; y_start = 0x1.0p-3; y_end = 0x1.0p4; - nb_pts_y = 2000; + nb_pts_y = 400; report_err2_fp64(rvvlm_pow, powl, x_start, x_end, nb_pts_x, y_start, y_end, nb_pts_y, swap_xy); nb_targets = 10; - nb_tests = 100000; + nb_tests = 10000; - x_start = 0x1.0p-10; - x_end = 0x1.0p10; + target_start = -32.0 * log(2.0); + target_end = 32.0 * log(2.0); + delta = (target_end - target_start) / (double)(nb_targets - 1); + for (int j = 0; j < nb_targets; j++) { + target = target_start + (double)j * delta; + report_err_pow_fp64(rvvlm_pow, powl, target, x_start, x_end, nb_tests); + } - target_start = -1070.0 * log(2.0); - target_end = -1020.0 * log(2.0); + target_start = -100.0 * log(2.0); + target_end = -80.0 * log(2.0); delta = (target_end - target_start) / (double)(nb_targets - 1); for (int j = 0; j < nb_targets; j++) { target = target_start + (double)j * delta; report_err_pow_fp64(rvvlm_pow, powl, target, x_start, x_end, nb_tests); } +} - target_start = -32.0 * log(2.0); - target_end = 32.0 * log(2.0); +TEST(pow, large_args) { + unsigned long nb_tests, nb_pts_x, nb_pts_y; + double x_start, x_end, y_start, y_end; + double target_start, target_end, delta, target; + unsigned long nb_targets; + bool swap_xy = 0; + + COMMENT("pow: current chosen algorithm; reduced argument in FP64 only") + + nb_targets = 10; + nb_tests = 100000; + + x_start = 0x1.0p-10; + x_end = 0x1.0p10; + + target_start = -1070.0 * log(2.0); + target_end = -1020.0 * log(2.0); delta = (target_end - target_start) / (double)(nb_targets - 1); for (int j = 0; j < nb_targets; j++) { target = target_start + (double)j * delta; @@ -77,12 +109,4 @@ TEST(pow, test) { target = target_start + (double)j * delta; report_err_pow_fp64(rvvlm_pow, powl, target, x_start, x_end, nb_tests); } - - target_start = -100.0 * log(2.0); - target_end = -80.0 * log(2.0); - delta = (target_end - target_start) / (double)(nb_targets - 1); - for (int j = 0; j < nb_targets; j++) { - target = target_start + (double)j * delta; - report_err_pow_fp64(rvvlm_pow, powl, target, x_start, x_end, nb_tests); - } } diff --git a/test/src/test_sin.cpp b/test/src/test_sin.cpp index 57e6a7d..6954d44 100644 --- a/test/src/test_sin.cpp +++ b/test/src/test_sin.cpp @@ -8,31 +8,62 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(sin, test) { +TEST(sin, special) { unsigned long nb_tests; double x_start, x_end; COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") show_special_fp64(rvvlm_sin, "Special Value handling of this function"); +} + +TEST(sin, small_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") x_start = -0.78; x_end = 0.78; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); x_start = -6.0; x_end = 6.0; - nb_tests = 4000000; + nb_tests = 100000; + report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); +} + +TEST(sin, medium_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") + + x_start = 1.0; + x_end = 0x1.0p23; + nb_tests = 100000; + report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); + + x_start = 0x1.0p25; + x_end = 0x1.0p100; + nb_tests = 100000; report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); +} + +TEST(sin, large_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") x_start = 1.0; x_end = 0x1.0p23; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); x_start = 0x1.0p25; x_end = 0x1.0p100; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); } diff --git a/test/src/test_sincos.cpp b/test/src/test_sincos.cpp index c595033..3ca7b0f 100644 --- a/test/src/test_sincos.cpp +++ b/test/src/test_sincos.cpp @@ -8,35 +8,52 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(sincos, test) { +TEST(sincos, small_args) { unsigned long nb_tests; double x_start, x_end; COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") - show_special12_fp64(rvvlm_sincos, "Special Value handling of this function"); + x_start = -0.78; + x_end = 0.78; + nb_tests = 40000; + report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); + report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); + + x_start = -6.0; + x_end = 6.0; + nb_tests = 40000; + report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); + report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); +} + +TEST(sincos, large_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") x_start = -0.78; x_end = 0.78; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); x_start = -6.0; x_end = 6.0; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); x_start = 1.0; x_end = 0x1.0p23; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); x_start = 0x1.0p25; x_end = 0x1.0p100; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); } diff --git a/test/src/test_sincospi.cpp b/test/src/test_sincospi.cpp index c57682c..51be529 100644 --- a/test/src/test_sincospi.cpp +++ b/test/src/test_sincospi.cpp @@ -19,19 +19,19 @@ TEST(sincospi, test) { x_start = -0.5; x_end = 0.5; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_sincospi, sinpil, 1, x_start, x_end, nb_tests); report_err_fp64(rvvlm_sincospi, cospil, 2, x_start, x_end, nb_tests); x_start = -0x1.0p3; x_end = 0x1.0p3; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_sincospi, sinpil, 1, x_start, x_end, nb_tests); report_err_fp64(rvvlm_sincospi, cospil, 2, x_start, x_end, nb_tests); x_start = 0x1.0p3; x_end = 0x1.0p60; - nb_tests = 400000; + nb_tests = 40000; report_err_fp64(rvvlm_sincospi, sinpil, 1, x_start, x_end, nb_tests); report_err_fp64(rvvlm_sincospi, cospil, 2, x_start, x_end, nb_tests); } diff --git a/test/src/test_sinh.cpp b/test/src/test_sinh.cpp index a3a1b6b..b1e3bd0 100644 --- a/test/src/test_sinh.cpp +++ b/test/src/test_sinh.cpp @@ -8,31 +8,57 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(sinh, test) { +TEST(sinh, special) { unsigned long nb_tests; double x_start, x_end; COMMENT("sinh: current chosen algorithm; reduced argument in FP64 only") show_special_fp64(rvvlm_sinh, "Special Value handling of this function"); +} + +TEST(sinh, small_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("sinh: current chosen algorithm; reduced argument in FP64 only") x_start = -0.346; x_end = 0.346; - nb_tests = 4000000; - report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); - - x_start = 0x1.0p-30; - x_end = 1.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); x_start = -6.0; x_end = 6.0; - nb_tests = 4000000; + nb_tests = 40000; + report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); +} + +TEST(sinh, medium_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("sinh: current chosen algorithm; reduced argument in FP64 only") + + x_start = 30.0; + x_end = 40.0; + nb_tests = 40000; + report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); + + x_start = 50.0; + x_end = 60.0; + nb_tests = 40000; report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); +} + +TEST(sinh, large_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("sinh: current chosen algorithm; reduced argument in FP64 only") - x_start = 1.0; - x_end = 0x1.0p3; - nb_tests = 4000000; + x_start = 60.0; + x_end = 70.0; + nb_tests = 40000; report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); } diff --git a/test/src/test_sinpi.cpp b/test/src/test_sinpi.cpp index 1038ed7..9e38a02 100644 --- a/test/src/test_sinpi.cpp +++ b/test/src/test_sinpi.cpp @@ -18,16 +18,16 @@ TEST(sinpi, test) { x_start = -0.5; x_end = 0.5; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_sinpi, sinpil, x_start, x_end, nb_tests); x_start = -0x1.0p3; x_end = 0x1.0p3; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_sinpi, sinpil, x_start, x_end, nb_tests); x_start = 0x1.0p3; x_end = 0x1.0p60; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_sinpi, sinpil, x_start, x_end, nb_tests); } diff --git a/test/src/test_tan.cpp b/test/src/test_tan.cpp index 31e3e18..317d3b6 100644 --- a/test/src/test_tan.cpp +++ b/test/src/test_tan.cpp @@ -8,31 +8,50 @@ #include "rvvlm.h" #include "test_infra.h" -TEST(tan, test) { +TEST(tan, special) { unsigned long nb_tests; double x_start, x_end; COMMENT("tan: current chosen algorithm; reduced argument in FP64 only") - // show_special_fp64(rvvlm_tan, "Special Value handling of this function"); + show_special_fp64(rvvlm_tan, "Special Value handling of this function"); +} + +TEST(tan, small_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("tan: current chosen algorithm; reduced argument in FP64 only") x_start = -0.7; x_end = 0.7; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_tan, tanl, x_start, x_end, nb_tests); x_start = -6.0; x_end = 6.0; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_tan, tanl, x_start, x_end, nb_tests); +} + +TEST(tan, large_args) { + unsigned long nb_tests; + double x_start, x_end; + + COMMENT("tan: current chosen algorithm; reduced argument in FP64 only") x_start = 1.0; x_end = 0x1.0p23; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_tan, tanl, x_start, x_end, nb_tests); x_start = 0x1.0p25; x_end = 0x1.0p100; - nb_tests = 4000000; + nb_tests = 100000; + report_err_fp64(rvvlm_tan, tanl, x_start, x_end, nb_tests); + + x_start = 0x1.ffffp1023; + x_end = 0x1.0p1000; + nb_tests = 100000; report_err_fp64(rvvlm_tan, tanl, x_start, x_end, nb_tests); } diff --git a/test/src/test_tanh.cpp b/test/src/test_tanh.cpp index 885aeee..4ce2b8d 100644 --- a/test/src/test_tanh.cpp +++ b/test/src/test_tanh.cpp @@ -18,16 +18,16 @@ TEST(tanh, test) { x_start = -0.78; x_end = 0.78; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_tanh, tanhl, x_start, x_end, nb_tests); x_start = -6.0; x_end = 6.0; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_tanh, tanhl, x_start, x_end, nb_tests); x_start = 1.0; x_end = 0x1.0p3; - nb_tests = 4000000; + nb_tests = 40000; report_err_fp64(rvvlm_tanh, tanhl, x_start, x_end, nb_tests); } diff --git a/test/src/test_tanpi.cpp b/test/src/test_tanpi.cpp index 19364ce..03d1a6c 100644 --- a/test/src/test_tanpi.cpp +++ b/test/src/test_tanpi.cpp @@ -18,16 +18,16 @@ TEST(tanpi, test) { x_start = -0.4999; x_end = 0.49999; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_tanpi, tanpil, x_start, x_end, nb_tests); x_start = -0x1.0p3; x_end = 0x1.0p3; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_tanpi, tanpil, x_start, x_end, nb_tests); x_start = 0x1.0p3; x_end = 0x1.0p60; - nb_tests = 4000000; + nb_tests = 100000; report_err_fp64(rvvlm_tanpi, tanpil, x_start, x_end, nb_tests); }