Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled tgamma test for bruteforce suite #2251

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test_conformance/math_brute_force/function_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ const Func functionList[] = {

ENTRY(tanh, 5.0f, 5.0f, 2.0f, FTZ_OFF, unaryF),
ENTRY(tanpi, 6.0f, 6.0f, 2.0f, FTZ_OFF, unaryF),
//ENTRY(tgamma, 16.0f, 16.0f, FTZ_OFF, unaryF), Commented this out until we can be sure this requirement is realistic
ENTRY(tgamma, 16.0f, 16.0f, 4.f, FTZ_OFF, unaryF),
ENTRY(trunc, 0.0f, 0.0f, 0.0f, FTZ_OFF, unaryF),

HALF_ENTRY(cos, 8192.0f, 8192.0f, FTZ_ON, unaryOF),
Expand Down
69 changes: 35 additions & 34 deletions test_conformance/math_brute_force/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,40 +277,41 @@ static int doTest(const char *name)
}

static test_definition test_list[] = {
ADD_TEST(acos), ADD_TEST(acosh), ADD_TEST(acospi),
ADD_TEST(asin), ADD_TEST(asinh), ADD_TEST(asinpi),
ADD_TEST(atan), ADD_TEST(atanh), ADD_TEST(atanpi),
ADD_TEST(atan2), ADD_TEST(atan2pi), ADD_TEST(cbrt),
ADD_TEST(ceil), ADD_TEST(copysign), ADD_TEST(cos),
ADD_TEST(cosh), ADD_TEST(cospi), ADD_TEST(exp),
ADD_TEST(exp2), ADD_TEST(exp10), ADD_TEST(expm1),
ADD_TEST(fabs), ADD_TEST(fdim), ADD_TEST(floor),
ADD_TEST(fma), ADD_TEST(fmax), ADD_TEST(fmin),
ADD_TEST(fmod), ADD_TEST(fract), ADD_TEST(frexp),
ADD_TEST(hypot), ADD_TEST(ilogb), ADD_TEST(isequal),
ADD_TEST(isfinite), ADD_TEST(isgreater), ADD_TEST(isgreaterequal),
ADD_TEST(isinf), ADD_TEST(isless), ADD_TEST(islessequal),
ADD_TEST(islessgreater), ADD_TEST(isnan), ADD_TEST(isnormal),
ADD_TEST(isnotequal), ADD_TEST(isordered), ADD_TEST(isunordered),
ADD_TEST(ldexp), ADD_TEST(lgamma), ADD_TEST(lgamma_r),
ADD_TEST(log), ADD_TEST(log2), ADD_TEST(log10),
ADD_TEST(log1p), ADD_TEST(logb), ADD_TEST(mad),
ADD_TEST(maxmag), ADD_TEST(minmag), ADD_TEST(modf),
ADD_TEST(nan), ADD_TEST(nextafter), ADD_TEST(pow),
ADD_TEST(pown), ADD_TEST(powr), ADD_TEST(remainder),
ADD_TEST(remquo), ADD_TEST(rint), ADD_TEST(rootn),
ADD_TEST(round), ADD_TEST(rsqrt), ADD_TEST(signbit),
ADD_TEST(sin), ADD_TEST(sincos), ADD_TEST(sinh),
ADD_TEST(sinpi), ADD_TEST(sqrt), ADD_TEST(sqrt_cr),
ADD_TEST(tan), ADD_TEST(tanh), ADD_TEST(tanpi),
ADD_TEST(trunc), ADD_TEST(half_cos), ADD_TEST(half_divide),
ADD_TEST(half_exp), ADD_TEST(half_exp2), ADD_TEST(half_exp10),
ADD_TEST(half_log), ADD_TEST(half_log2), ADD_TEST(half_log10),
ADD_TEST(half_powr), ADD_TEST(half_recip), ADD_TEST(half_rsqrt),
ADD_TEST(half_sin), ADD_TEST(half_sqrt), ADD_TEST(half_tan),
ADD_TEST(add), ADD_TEST(subtract), ADD_TEST(divide),
ADD_TEST(divide_cr), ADD_TEST(multiply), ADD_TEST(assignment),
ADD_TEST(not ), ADD_TEST(erf), ADD_TEST(erfc),
ADD_TEST(acos), ADD_TEST(acosh), ADD_TEST(acospi),
ADD_TEST(asin), ADD_TEST(asinh), ADD_TEST(asinpi),
ADD_TEST(atan), ADD_TEST(atanh), ADD_TEST(atanpi),
ADD_TEST(atan2), ADD_TEST(atan2pi), ADD_TEST(cbrt),
ADD_TEST(ceil), ADD_TEST(copysign), ADD_TEST(cos),
ADD_TEST(cosh), ADD_TEST(cospi), ADD_TEST(exp),
ADD_TEST(exp2), ADD_TEST(exp10), ADD_TEST(expm1),
ADD_TEST(fabs), ADD_TEST(fdim), ADD_TEST(floor),
ADD_TEST(fma), ADD_TEST(fmax), ADD_TEST(fmin),
ADD_TEST(fmod), ADD_TEST(fract), ADD_TEST(frexp),
ADD_TEST(hypot), ADD_TEST(ilogb), ADD_TEST(isequal),
ADD_TEST(isfinite), ADD_TEST(isgreater), ADD_TEST(isgreaterequal),
ADD_TEST(isinf), ADD_TEST(isless), ADD_TEST(islessequal),
ADD_TEST(islessgreater), ADD_TEST(isnan), ADD_TEST(isnormal),
ADD_TEST(isnotequal), ADD_TEST(isordered), ADD_TEST(isunordered),
ADD_TEST(ldexp), ADD_TEST(lgamma), ADD_TEST(lgamma_r),
ADD_TEST(log), ADD_TEST(log2), ADD_TEST(log10),
ADD_TEST(log1p), ADD_TEST(logb), ADD_TEST(mad),
ADD_TEST(maxmag), ADD_TEST(minmag), ADD_TEST(modf),
ADD_TEST(nan), ADD_TEST(nextafter), ADD_TEST(pow),
ADD_TEST(pown), ADD_TEST(powr), ADD_TEST(remainder),
ADD_TEST(remquo), ADD_TEST(rint), ADD_TEST(rootn),
ADD_TEST(round), ADD_TEST(rsqrt), ADD_TEST(signbit),
ADD_TEST(sin), ADD_TEST(sincos), ADD_TEST(sinh),
ADD_TEST(sinpi), ADD_TEST(sqrt), ADD_TEST(sqrt_cr),
ADD_TEST(tan), ADD_TEST(tanh), ADD_TEST(tanpi),
ADD_TEST(tgamma), ADD_TEST(trunc), ADD_TEST(half_cos),
ADD_TEST(half_divide), ADD_TEST(half_exp), ADD_TEST(half_exp2),
ADD_TEST(half_exp10), ADD_TEST(half_log), ADD_TEST(half_log2),
ADD_TEST(half_log10), ADD_TEST(half_powr), ADD_TEST(half_recip),
ADD_TEST(half_rsqrt), ADD_TEST(half_sin), ADD_TEST(half_sqrt),
ADD_TEST(half_tan), ADD_TEST(add), ADD_TEST(subtract),
ADD_TEST(divide), ADD_TEST(divide_cr), ADD_TEST(multiply),
ADD_TEST(assignment), ADD_TEST(not ), ADD_TEST(erf),
ADD_TEST(erfc),
};

#undef ADD_TEST
Expand Down
6 changes: 5 additions & 1 deletion test_conformance/math_brute_force/reference_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,8 @@ int reference_not(double x)
return r;
}

double reference_tgamma(double x) { return tgamma(x); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we can rely on libc's tgamma for the reference computation? Known Maximum Errors in Math Functions seems to indicate that most tgamma libc implementations have a rather large ULP value.

Copy link
Contributor Author

@shajder shajder Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, thanks! Computing reference values for tgamma seems challenging. As far as I understand, each implementation is subject to non-zero error. Please correct me if I am wrong at any point, I see few directions to follow:

  • pre-computed high-precision values taken from MatLab or similar software. This approach will definitely impact the source code with a separate path for tgamma processing.
  • limiting tgamma arguments for integral values which will result in zero error outcome. As with the previous proposition, this approach will result as a separate path for tgamma processing.
  • implementing a procedure to compute tgamma reference values with maximum known-error. According to this paper OpenLibm contains tgamma implementation with error<1ULP. Moreover, license looks friendly for other open source projects. Then we could take into account the known-error by enlarging the error from table 65.

I will appreciate discussion over this subject, thanks!


#pragma mark -
#pragma mark Double testing

Expand Down Expand Up @@ -5771,4 +5773,6 @@ long double reference_erfcl(long double x) { return erfc(x); }
long double reference_erfl(long double x) { return erf(x); }

double reference_erfc(double x) { return erfc(x); }
double reference_erf(double x) { return erf(x); }
double reference_erf(double x) { return erf(x); }

long double reference_tgammal(long double x) { return tgamma(x); }
9 changes: 7 additions & 2 deletions test_conformance/math_brute_force/reference_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ double reference_ldexp(double x, int n);

double reference_assignment(double x);
int reference_not(double x);

double reference_erfc(double x);
double reference_erf(double x);
double reference_tgamma(double x);

// -- for testing fast-relaxed

double reference_relaxed_acos(double);
Expand Down Expand Up @@ -238,6 +243,6 @@ int reference_notl(long double x);

long double reference_erfcl(long double x);
long double reference_erfl(long double x);
double reference_erfc(double x);
double reference_erf(double x);
long double reference_tgammal(long double x);

#endif
Loading