Skip to content

Commit 17cfe8b

Browse files
authored
Merge pull request #1336 from boostorg/tuning_tests
Tuning tests cover optimize zero
2 parents 0f39329 + 0fdffe5 commit 17cfe8b

File tree

8 files changed

+75
-39
lines changed

8 files changed

+75
-39
lines changed

include/boost/decimal/detail/cmath/lgamma.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ constexpr auto lgamma_impl(const T x) noexcept
111111

112112
constexpr T half { 5, -1 };
113113

114-
result = (((x - half) * (log(x)) - x))
115-
+ log(detail::tgamma_series_expansion_asymp(one / x));
114+
result = (((x - half) * (log(x)) - x)) + log(detail::tgamma_series_expansion_asymp(one / x));
116115
}
117116
}
118117
}

test/cover/make_gcov_01_generic.gmk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright Matt Borland 2023 - 2024.
3-
# Copyright Christopher Kormanyos 2023 - 2024.
2+
# Copyright Matt Borland 2023 - 2026.
3+
# Copyright Christopher Kormanyos 2023 - 2026.
44
# Distributed under the Boost Software License,
55
# Version 1.0. (See accompanying file LICENSE_1_0.txt
66
# or copy at http://www.boost.org/LICENSE_1_0.txt)
77
# -----------------------------------------------------------------------------
88

9-
# cd /mnt/c/ChrisGitRepos/boostorg/decimal/test/cover
10-
# make prepare -f make_gcov_01_generic.gmk MY_ALL_COV=0 MY_BOOST_ROOT=/mnt/c/boost/boost_1_85_0 MY_CC=g++
11-
# make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_ALL_COV=0 MY_BOOST_ROOT=/mnt/c/boost/boost_1_85_0 MY_CC=g++
9+
# cd /mnt/c/ChrisGitRepos/modular_boost/decimal/test/cover
10+
# make prepare -f make_gcov_01_generic.gmk MY_ALL_COV=0 MY_BOOST_ROOT=/mnt/c/boost/boost_1_90_0 MY_CC=g++
11+
# make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_ALL_COV=0 MY_BOOST_ROOT=/mnt/c/boost/boost_1_90_0 MY_CC=g++
1212

1313
all: gcov
1414

test/cover/make_gcov_02_files.gmk

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright Matt Borland 2023 - 2024.
3-
# Copyright Christopher Kormanyos 2023 - 2024.
2+
# Copyright Matt Borland 2023 - 2026.
3+
# Copyright Christopher Kormanyos 2023 - 2026.
44
# Distributed under the Boost Software License,
55
# Version 1.0. (See accompanying file LICENSE_1_0.txt
66
# or copy at http://www.boost.org/LICENSE_1_0.txt)
77
# -----------------------------------------------------------------------------
88

99
FILES_PRJ := $(basename $(wildcard $(PATH_SRC)/*.cpp))
1010

11-
FILES_EXCLUDE := $(PATH_SRC)/concepts_test.cpp \
11+
FILES_EXCLUDE := $(PATH_SRC)/benchmark_uint256.cpp \
12+
$(PATH_SRC)/benchmarks.cpp \
13+
$(PATH_SRC)/check_cmake_version.cpp \
14+
$(PATH_SRC)/concepts_test.cpp \
15+
$(PATH_SRC)/github_issue_1087.cpp \
16+
$(PATH_SRC)/github_issue_519.cpp \
1217
$(PATH_SRC)/link_1.cpp \
1318
$(PATH_SRC)/link_2.cpp \
1419
$(PATH_SRC)/link_3.cpp \
1520
$(PATH_SRC)/limits_link_1.cpp \
1621
$(PATH_SRC)/limits_link_2.cpp \
1722
$(PATH_SRC)/limits_link_3.cpp \
1823
$(PATH_SRC)/test_bad_evaluation_method.cpp \
24+
$(PATH_SRC)/test_boost_math_univariate_stats.cpp \
25+
$(PATH_SRC)/test_decimal32.cpp \
26+
$(PATH_SRC)/test_decimal64_basis.cpp \
27+
$(PATH_SRC)/test_decimal128_basis.cpp \
1928
$(PATH_SRC)/test_explicit_floats.cpp \
20-
$(PATH_SRC)/test_from_chars.cpp \
21-
$(PATH_SRC)/test_illegal_decimal32_implicit_conversions.cpp \
29+
$(PATH_SRC)/test_illegal_decimal128_implicit_conversions.cpp \
2230
$(PATH_SRC)/test_illegal_decimal32_fast_implicit_conversions.cpp \
31+
$(PATH_SRC)/test_illegal_decimal32_implicit_conversions.cpp \
2332
$(PATH_SRC)/test_illegal_decimal64_fast_implicit_conversions.cpp \
2433
$(PATH_SRC)/test_illegal_decimal64_implicit_conversions.cpp \
25-
$(PATH_SRC)/test_illegal_decimal128_implicit_conversions.cpp \
26-
$(PATH_SRC)/test_decimal32.cpp \
27-
$(PATH_SRC)/test_decimal64_basis.cpp \
28-
$(PATH_SRC)/test_decimal128_basis.cpp \
29-
$(PATH_SRC)/benchmarks.cpp \
30-
$(PATH_SRC)/test_boost_math_univariate_stats.cpp \
31-
$(PATH_SRC)/benchmark_uint256.cpp \
32-
$(PATH_SRC)/github_issue_519.cpp \
3334
$(PATH_SRC)/test_fprintf.cpp \
35+
$(PATH_SRC)/test_from_chars.cpp \
36+
3437

3538

3639
FILES_EXCLUDE := $(basename $(FILES_EXCLUDE))

test/cover/make_gcov_03_flags.gmk

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -----------------------------------------------------------------------------
2-
# Copyright Matt Borland 2023.
3-
# Copyright Christopher Kormanyos 2023.
2+
# Copyright Matt Borland 2023 - 2026.
3+
# Copyright Christopher Kormanyos 2023 - 2026.
44
# Distributed under the Boost Software License,
55
# Version 1.0. (See accompanying file LICENSE_1_0.txt
66
# or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -28,9 +28,13 @@ endif
2828

2929
CXXFLAGS = -march=native \
3030
-mtune=native \
31-
-O1 \
31+
-O0 \
3232
-Wextra \
3333
-Wall \
34+
-Wpedantic \
35+
-Wconversion \
36+
-Wsign-conversion \
37+
-Wno-psabi \
3438
-fno-inline-functions \
3539
-fprofile-arcs \
3640
-ftest-coverage \

test/test_acosh.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Copyright 2023 Matt Borland
2-
// Copyright 2023 Christopher Kormanyos
1+
// Copyright 2023 - 2026 Matt Borland
2+
// Copyright 2023 - 2026 Christopher Kormanyos
33
// Distributed under the Boost Software License, Version 1.0.
44
// https://www.boost.org/LICENSE_1_0.txt
55

@@ -188,6 +188,19 @@ namespace local
188188
result_is_ok = (result_val_one_is_ok && result_is_ok);
189189
}
190190

191+
for(auto i = static_cast<unsigned>(UINT8_C(0)); i < static_cast<unsigned>(UINT8_C(4)); ++i)
192+
{
193+
static_cast<void>(i);
194+
195+
const auto val_lt_one = acosh(::my_one() / static_cast<decimal_type>(dist(gen) * (dist(gen) * dist(gen))));
196+
197+
const auto result_val_lt_one_is_ok = (isnan(val_lt_one) && signbit(val_lt_one));
198+
199+
BOOST_TEST(result_val_lt_one_is_ok);
200+
201+
result_is_ok = (result_val_lt_one_is_ok && result_is_ok);
202+
}
203+
191204
for(auto i = static_cast<unsigned>(UINT8_C(0)); i < static_cast<unsigned>(UINT8_C(4)); ++i)
192205
{
193206
static_cast<void>(i);

test/test_atanh.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Copyright 2023 Matt Borland
2-
// Copyright 2023 Christopher Kormanyos
1+
// Copyright 2023 - 2026 Matt Borland
2+
// Copyright 2023 - 2026 Christopher Kormanyos
33
// Distributed under the Boost Software License, Version 1.0.
44
// https://www.boost.org/LICENSE_1_0.txt
55

@@ -216,6 +216,19 @@ namespace local
216216
result_is_ok = (result_val_zero_is_ok && result_is_ok);
217217
}
218218

219+
for(auto i = static_cast<unsigned>(UINT8_C(0)); i < static_cast<unsigned>(UINT8_C(4)); ++i)
220+
{
221+
static_cast<void>(i);
222+
223+
const auto val_gt_one_pos = atanh(::my_one() * static_cast<decimal_type>(dist(gen) * dist(gen) * dist(gen)));
224+
225+
const auto result_val_gt_one_pos_is_ok = (isnan(val_gt_one_pos) && (!signbit(val_gt_one_pos)));
226+
227+
BOOST_TEST(result_val_gt_one_pos_is_ok);
228+
229+
result_is_ok = (result_val_gt_one_pos_is_ok && result_is_ok);
230+
}
231+
219232
return result_is_ok;
220233
}
221234

test/test_lgamma.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
#include <boost/core/lightweight_test.hpp>
2424

25-
template<typename DecimalType> auto my_zero() -> DecimalType& { using decimal_type = DecimalType; static decimal_type val_zero { 0, 0 }; return val_zero; }
25+
template<typename DecimalType> auto my_zero() -> DecimalType&;
26+
template<typename DecimalType> auto my_one () -> DecimalType&;
2627

2728
namespace local
2829
{
@@ -314,7 +315,7 @@ namespace local
314315
{
315316
static_cast<void>(i);
316317

317-
const auto val_zero_neg = lgamma(-::my_zero<decimal_type>());
318+
const auto val_zero_neg = lgamma(-::my_zero<decimal_type>() * static_cast<decimal_type>(dist(gen)));
318319

319320
const auto result_val_zero_neg_is_ok = (isinf(val_zero_neg) && (!signbit(val_zero_neg)));
320321

@@ -325,7 +326,7 @@ namespace local
325326

326327
for(auto i = static_cast<unsigned>(UINT8_C(0)); i < static_cast<unsigned>(UINT8_C(6)); ++i)
327328
{
328-
const auto n_neg = -static_cast<int>(i) - 1;
329+
const auto n_neg = -static_cast<int>(i) - static_cast<int>(::my_one<decimal_type>());
329330

330331
const auto val_neg_int = lgamma( decimal_type { n_neg, 0 } );
331332

@@ -342,11 +343,11 @@ namespace local
342343

343344
for(auto i = static_cast<unsigned>(UINT8_C(1)); i <= static_cast<unsigned>(UINT8_C(2)); ++i)
344345
{
345-
decimal_type n_arg { i, 0 };
346+
const int n_arg { static_cast<int>(decimal_type { i } + static_cast<decimal_type>(dist(gen) / 10.0F)) };
346347

347-
n_arg += (::my_zero<decimal_type>() * static_cast<decimal_type>(dist(gen)));
348+
const decimal_type arg_one_or_two { n_arg, 0 };
348349

349-
const auto val_one_or_two = lgamma(n_arg);
350+
const auto val_one_or_two = lgamma(arg_one_or_two);
350351

351352
const auto result_val_one_or_two_is_ok =
352353
(
@@ -550,3 +551,6 @@ auto main() -> int
550551

551552
return (result_is_ok ? 0 : -1);
552553
}
554+
555+
template<typename DecimalType> auto my_zero() -> DecimalType& { using decimal_type = DecimalType; static decimal_type val_zero { 0 }; return val_zero; }
556+
template<typename DecimalType> auto my_one () -> DecimalType& { using decimal_type = DecimalType; static decimal_type val_one { 1 }; return val_one; }

test/test_zeta.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,27 +207,27 @@ auto test_riemann_zeta_edge() -> bool
207207
result_nan_is_ok = (isnan(riemann_zeta(decimal_type { 1 }))); result_is_ok = (result_nan_is_ok && result_is_ok); BOOST_TEST(result_is_ok);
208208
}
209209

210-
for(auto index = 0U; index < 8U; ++index)
211210
{
212-
static_cast<void>(index);
213-
214211
const decimal_type zero { ::my_zero<decimal_type>() * decimal_type(dist(gen)) };
215212

216213
const decimal_type minus_half { -5, -1 };
217214

218215
const bool result_zero_is_ok = (riemann_zeta(zero) == minus_half); result_is_ok = (result_zero_is_ok && result_is_ok); BOOST_TEST(result_is_ok);
219216
}
220217

221-
for(auto index = 0U; index < 8U; ++index)
222218
{
223-
static_cast<void>(index);
224-
225219
const int n_one { static_cast<int>(::my_one<decimal_type>() + decimal_type(dist(gen) / 150.0F)) };
226220

227221
const decimal_type one { n_one };
228222

229223
const bool result_one_is_ok = isnan(riemann_zeta(one)); result_is_ok = (result_one_is_ok && result_is_ok); BOOST_TEST(result_is_ok);
230224
}
225+
226+
{
227+
const decimal_type asymp { sqrt((std::numeric_limits<decimal_type>::max)()) * static_cast<decimal_type>(dist(gen)) };
228+
229+
const bool result_asymp_is_ok = (riemann_zeta(asymp) == ::my_one<decimal_type>()); result_is_ok = (result_asymp_is_ok && result_is_ok); BOOST_TEST(result_is_ok);
230+
}
231231
}
232232

233233
for(auto n = static_cast<unsigned>(UINT8_C(2)); n < static_cast<unsigned>(UINT8_C(6)); ++n)

0 commit comments

Comments
 (0)