-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc][math][c23] Add f16sqrtf C23 math function #95251
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
Changes from 1 commit
3d261ba
ae9f258
d515f18
d373c14
cd9092e
e055264
42f970b
1510d2f
f561319
84de2dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -757,26 +757,32 @@ ternary_operation_one_output(Operation op, InputType x, InputType y, | |
// to build the complete error messages before sending it to the outstream `OS` | ||
// once at the end. This will stop the error messages from interleaving when | ||
// the tests are running concurrently. | ||
template <typename T> | ||
void explain_unary_operation_single_output_error(Operation op, T input, | ||
T matchValue, | ||
template <typename InputType, typename OutputType> | ||
void explain_unary_operation_single_output_error(Operation op, InputType input, | ||
OutputType matchValue, | ||
double ulp_tolerance, | ||
RoundingMode rounding) { | ||
unsigned int precision = get_precision<T>(ulp_tolerance); | ||
unsigned int precision = get_precision<InputType>(ulp_tolerance); | ||
MPFRNumber mpfrInput(input, precision); | ||
MPFRNumber mpfr_result; | ||
mpfr_result = unary_operation(op, input, precision, rounding); | ||
Comment on lines
766
to
768
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not written by me, but the naming/case isn't consistent, and the assignment could be merged with the declaration. |
||
MPFRNumber mpfrMatchValue(matchValue); | ||
tlog << "Match value not within tolerance value of MPFR result:\n" | ||
<< " Input decimal: " << mpfrInput.str() << '\n'; | ||
tlog << " Input bits: " << str(FPBits<T>(input)) << '\n'; | ||
tlog << '\n' << " Match decimal: " << mpfrMatchValue.str() << '\n'; | ||
tlog << " Match bits: " << str(FPBits<T>(matchValue)) << '\n'; | ||
tlog << '\n' << " MPFR result: " << mpfr_result.str() << '\n'; | ||
tlog << " MPFR rounded: " << str(FPBits<T>(mpfr_result.as<T>())) << '\n'; | ||
tlog << '\n'; | ||
tlog << " ULP error: " | ||
<< mpfr_result.ulp_as_mpfr_number(matchValue).str() << '\n'; | ||
cpp::array<char, 1024> msg_buf; | ||
cpp::StringStream msg(msg_buf); | ||
msg << "Match value not within tolerance value of MPFR result:\n" | ||
<< " Input decimal: " << mpfrInput.str() << '\n'; | ||
msg << " Input bits: " << str(FPBits<InputType>(input)) << '\n'; | ||
msg << '\n' << " Match decimal: " << mpfrMatchValue.str() << '\n'; | ||
msg << " Match bits: " << str(FPBits<OutputType>(matchValue)) << '\n'; | ||
msg << '\n' << " MPFR result: " << mpfr_result.str() << '\n'; | ||
msg << " MPFR rounded: " | ||
<< str(FPBits<OutputType>(mpfr_result.as<OutputType>())) << '\n'; | ||
msg << '\n'; | ||
msg << " ULP error: " << mpfr_result.ulp_as_mpfr_number(matchValue).str() | ||
<< '\n'; | ||
if (msg.overflow()) | ||
__builtin_unreachable(); | ||
Comment on lines
+783
to
+784
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The buffer size of 1024 should always be much more than enough. |
||
tlog << msg.str(); | ||
} | ||
|
||
template void explain_unary_operation_single_output_error<float>(Operation op, | ||
|
@@ -790,37 +796,10 @@ template void explain_unary_operation_single_output_error<long double>( | |
#ifdef LIBC_TYPES_HAS_FLOAT16 | ||
template void explain_unary_operation_single_output_error<float16>( | ||
Operation op, float16, float16, double, RoundingMode); | ||
#endif | ||
|
||
template <typename OutType, typename InType> | ||
void explain_unary_narrower_operation_single_output_error( | ||
Operation op, InType input, OutType matchValue, double ulp_tolerance, | ||
RoundingMode rounding) { | ||
unsigned int precision = get_precision<InType>(ulp_tolerance); | ||
MPFRNumber mpfrInput(input, precision); | ||
MPFRNumber mpfr_result; | ||
mpfr_result = unary_operation(op, input, precision, rounding); | ||
MPFRNumber mpfrMatchValue(matchValue); | ||
cpp::array<char, 4096> msg_data; | ||
cpp::StringStream msg(msg_data); | ||
msg << "Match value not within tolerance value of MPFR result:\n" | ||
<< " Input decimal: " << mpfrInput.str() << '\n'; | ||
msg << " Input bits: " << str(FPBits<InType>(input)) << '\n'; | ||
msg << '\n' << " Match decimal: " << mpfrMatchValue.str() << '\n'; | ||
msg << " Match bits: " << str(FPBits<OutType>(matchValue)) << '\n'; | ||
msg << '\n' << " MPFR result: " << mpfr_result.str() << '\n'; | ||
msg << " MPFR rounded: " << str(FPBits<OutType>(mpfr_result.as<OutType>())) | ||
<< '\n'; | ||
msg << '\n'; | ||
msg << " ULP error: " << mpfr_result.ulp_as_mpfr_number(matchValue).str() | ||
<< '\n'; | ||
tlog << msg.str(); | ||
} | ||
|
||
#ifdef LIBC_TYPES_HAS_FLOAT16 | ||
template void | ||
explain_unary_narrower_operation_single_output_error<float16, float>( | ||
Operation op, float, float16, double, RoundingMode); | ||
template void explain_unary_operation_single_output_error<float>(Operation op, | ||
float, float16, | ||
double, | ||
RoundingMode); | ||
overmighty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#endif | ||
|
||
template <typename T> | ||
|
@@ -982,11 +961,12 @@ template void explain_ternary_operation_one_output_error<long double>( | |
Operation, const TernaryInput<long double> &, long double, double, | ||
RoundingMode); | ||
|
||
template <typename T> | ||
bool compare_unary_operation_single_output(Operation op, T input, T libc_result, | ||
template <typename InputType, typename OutputType> | ||
bool compare_unary_operation_single_output(Operation op, InputType input, | ||
OutputType libc_result, | ||
double ulp_tolerance, | ||
RoundingMode rounding) { | ||
unsigned int precision = get_precision<T>(ulp_tolerance); | ||
unsigned int precision = get_precision<InputType>(ulp_tolerance); | ||
MPFRNumber mpfr_result; | ||
mpfr_result = unary_operation(op, input, precision, rounding); | ||
double ulp = mpfr_result.ulp(libc_result); | ||
|
@@ -1005,22 +985,9 @@ template bool compare_unary_operation_single_output<long double>( | |
template bool compare_unary_operation_single_output<float16>(Operation, float16, | ||
float16, double, | ||
RoundingMode); | ||
#endif | ||
|
||
template <typename OutType, typename InType> | ||
bool compare_unary_narrower_operation_single_output(Operation op, InType input, | ||
OutType libc_result, | ||
double ulp_tolerance, | ||
RoundingMode rounding) { | ||
unsigned int precision = get_precision<InType>(ulp_tolerance); | ||
MPFRNumber mpfr_result; | ||
mpfr_result = unary_operation(op, input, precision, rounding); | ||
double ulp = mpfr_result.ulp(libc_result); | ||
return (ulp <= ulp_tolerance); | ||
} | ||
#ifdef LIBC_TYPES_HAS_FLOAT16 | ||
template bool compare_unary_narrower_operation_single_output<float16, float>( | ||
Operation, float, float16, double, RoundingMode); | ||
template bool compare_unary_operation_single_output<float>(Operation, float, | ||
float16, double, | ||
RoundingMode); | ||
#endif | ||
|
||
template <typename T> | ||
|
Uh oh!
There was an error while loading. Please reload this page.