[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] odd/glibc-expm1-log1p 37b3a6c 2/2: Investigate expm1
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] odd/glibc-expm1-log1p 37b3a6c 2/2: Investigate expm1 and log1p timings more carefully |
Date: |
Tue, 6 Oct 2020 17:10:01 -0400 (EDT) |
branch: odd/glibc-expm1-log1p
commit 37b3a6cf2295941cff6c3333f54ae9e452022577
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Investigate expm1 and log1p timings more carefully
Ran the code in each "mete" function 100000 times rather than once.
It appears now that the previous commit must be submitted to
https://retractionwatch.com/
for having rejected a hypothesis that is objectively confirmed.
New timings:
i686-w64-mingw32-gcc-8.3-win32
std::pow 5.845e-02 s mean; 55755 us least of 18 runs
std::expm1 4.180e-02 s mean; 41640 us least of 24 runs
double i365 7.312e-03 s mean; 7290 us least of 100 runs
long double i365 7.007e-03 s mean; 6861 us least of 100 runs
expm1 glibc i365 1.216e-03 s mean; 1184 us least of 100 runs
empty function 4.952e-07 s mean; 0 us least of 20196 runs
x86_64-pc-linux-gnu gcc-9
std::pow 2.108e-01 s mean; 210170 us least of 5 runs
std::expm1 7.932e-02 s mean; 79044 us least of 13 runs
double i365 2.258e-03 s mean; 2224 us least of 100 runs
long double i365 1.407e-02 s mean; 13887 us least of 72 runs
expm1 glibc i365 2.186e-03 s mean; 2154 us least of 100 runs
empty function 2.558e-08 s mean; 0 us least of 390913 runs
This seems to suggest that glibc's implementation of these functions
is six or seven times as fast as MinGW-w64's, which seems extraordinary.
It also appears to suggest that porting glibc to i686-w64-mingw32 could
make that system run twice as fast as x86_64-pc-linux-gnu, which sounds
like the superluminal neutrino experiment--more likely, our measurements
are faulty.
---
math_functions_test.cpp | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/math_functions_test.cpp b/math_functions_test.cpp
index e3afcac..b8dc149 100644
--- a/math_functions_test.cpp
+++ b/math_functions_test.cpp
@@ -556,50 +556,66 @@ void sample_results()
// less inaccurate than an alternative using std::expm1() and std::log1p().
void mete0()
{
+ for(int i = 0; i < 100000; ++i)
+ {
double volatile x;
stifle_warning_for_unused_value(x);
x = i_upper_12_over_12_from_i_naive<double>()(0.04);
x = i_from_i_upper_12_over_12_naive<double>()(0.04);
x = d_upper_12_from_i_naive <double>()(0.04);
x = net_i_from_gross_naive<double,365>()(0.04, 0.007, 0.003);
+ }
}
// This implementation uses production functors.
void mete1()
{
+ for(int i = 0; i < 100000; ++i)
+ {
double volatile x;
stifle_warning_for_unused_value(x);
x = i_upper_12_over_12_from_i<double>()(0.04);
x = i_from_i_upper_12_over_12<double>()(0.04);
x = d_upper_12_from_i <double>()(0.04);
x = net_i_from_gross<double,365>()(0.04, 0.007, 0.003);
+ }
}
void mete2()
{
+ for(int i = 0; i < 100000; ++i)
+ {
double volatile x;
stifle_warning_for_unused_value(x);
x = i_upper_n_over_n_from_i_T<double,365>()(0.01);
+ }
}
void mete3()
{
+ for(int i = 0; i < 100000; ++i)
+ {
double volatile x;
stifle_warning_for_unused_value(x);
x = static_cast<double>(i_upper_n_over_n_from_i_T<long
double,365>()(0.01));
+ }
}
void mete4()
{
+ for(int i = 0; i < 100000; ++i)
+ {
double volatile x;
stifle_warning_for_unused_value(x);
x = i_upper_n_over_n_from_i_glibc<double,365>()(0.01);
+ }
}
void mete5()
{
- double volatile x;
- stifle_warning_for_unused_value(x);
+ for(int i = 0; i < 100000; ++i)
+ {
+ }
}
void assay_speed()