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

Repair ci #386

Merged
merged 4 commits into from
Oct 27, 2023
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/wide_integer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ jobs:
strategy:
fail-fast: false
matrix:
standard: [ c++14, c++17, c++20, c++2b ]
standard: [ c++14, c++17, c++20 ]
compiler: [ g++-12, clang++-14 ]
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -818,7 +818,7 @@ jobs:
strategy:
fail-fast: false
matrix:
standard: [ c++20, c++2b ]
standard: [ c++20 ]
compiler: [ g++-12, clang++-14 ]
suite: [ test_uintwide_t_xtra_from_issue_335 ]
steps:
Expand Down
19 changes: 4 additions & 15 deletions examples/example008_miller_rabin_prime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// The Boost.Multiprecision code can be found here:
// https://www.boost.org/doc/libs/1_73_0/libs/multiprecision/doc/html/boost_multiprecision/tut/primetest.html

#include <chrono>
#include <ctime>
#include <random>

#include <examples/example_uintwide_t.h>
Expand Down Expand Up @@ -43,23 +43,12 @@ namespace local_example008_miller_rabin_prime
using random_engine1_type = std::linear_congruential_engine<std::uint32_t, UINT32_C(48271), UINT32_C(0), UINT32_C(2147483647)>;
using random_engine2_type = std::mt19937;

template<typename IntegralTimePointType,
typename ClockType = std::chrono::high_resolution_clock>
template<typename IntegralTimePointType>
auto time_point() -> IntegralTimePointType
{
using local_integral_time_point_type = IntegralTimePointType;
using local_clock_type = ClockType;

const auto current_now =
static_cast<std::uintmax_t>
(
std::chrono::duration_cast<std::chrono::nanoseconds>
(
local_clock_type::now().time_since_epoch()
).count()
);

return static_cast<local_integral_time_point_type>(current_now);

return static_cast<local_integral_time_point_type>(std::clock());
}

auto example008_miller_rabin_prime_run() -> bool
Expand Down
14 changes: 7 additions & 7 deletions examples/example009_timed_mul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
///////////////////////////////////////////////////////////////////

#include <algorithm>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <iterator>
Expand Down Expand Up @@ -89,17 +89,17 @@ auto ::math::wide_integer::example009_timed_mul() -> bool
std::uint64_t count = 0U;
std::size_t index = 0U;

std::intmax_t total_time { };
float total_time { };

const std::chrono::high_resolution_clock::time_point begin = std::chrono::high_resolution_clock::now();
const auto begin = std::clock();

for(;;)
{
local_timed_mul::local_a().at(index) * local_timed_mul::local_b().at(index);

const std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now();
const auto end = std::clock();

total_time = static_cast<std::intmax_t>(std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count());
total_time = static_cast<float>(static_cast<float>(end - begin) / CLOCKS_PER_SEC);

++count;
++index;
Expand All @@ -109,13 +109,13 @@ auto ::math::wide_integer::example009_timed_mul() -> bool
index = 0U;
}

if(total_time > INTMAX_C(5999))
if(total_time > static_cast<float>(6.0L)) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
{
break;
}
}

const float kops_per_sec = static_cast<float>(count) / static_cast<float>(static_cast<std::uint32_t>(total_time));
const float kops_per_sec = static_cast<float>(count) / static_cast<float>(static_cast<float>(total_time * 1000.0F));

{
const auto flg = std::cout.flags();
Expand Down
14 changes: 7 additions & 7 deletions examples/example009a_timed_mul_4_by_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
///////////////////////////////////////////////////////////////////

#include <algorithm>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <iterator>
Expand Down Expand Up @@ -87,9 +87,9 @@ auto ::math::wide_integer::example009a_timed_mul_4_by_4() -> bool
std::uint64_t count = 0U;
std::size_t index = 0U;

std::intmax_t total_time { };
float total_time { };

const std::chrono::high_resolution_clock::time_point begin = std::chrono::high_resolution_clock::now();
const auto begin = std::clock();

for(;;)
{
Expand All @@ -98,9 +98,9 @@ auto ::math::wide_integer::example009a_timed_mul_4_by_4() -> bool
local_timed_mul_4_by_4::local_a().at(index + 2U) * local_timed_mul_4_by_4::local_b().at(index + 2U);
local_timed_mul_4_by_4::local_a().at(index + 3U) * local_timed_mul_4_by_4::local_b().at(index + 3U);

const std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now();
const auto end = std::clock();

total_time = static_cast<std::intmax_t>(std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count());
total_time = static_cast<float>(static_cast<float>(end - begin) / CLOCKS_PER_SEC);

count += 4U;
index += 4U;
Expand All @@ -110,13 +110,13 @@ auto ::math::wide_integer::example009a_timed_mul_4_by_4() -> bool
index = 0U;
}

if(total_time > INTMAX_C(5999))
if(total_time > static_cast<float>(6.0L)) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
{
break;
}
}

const float kops_per_sec = static_cast<float>(count) / static_cast<float>(static_cast<std::uint32_t>(total_time));
const float kops_per_sec = static_cast<float>(count) / static_cast<float>(static_cast<float>(total_time * 1000.0F));

{
const auto flg = std::cout.flags();
Expand Down
14 changes: 7 additions & 7 deletions examples/example009b_timed_mul_8_by_8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
///////////////////////////////////////////////////////////////////

#include <algorithm>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <iterator>
Expand Down Expand Up @@ -87,9 +87,9 @@ auto ::math::wide_integer::example009b_timed_mul_8_by_8() -> bool
std::uint64_t count = 0U;
std::size_t index = 0U;

std::intmax_t total_time { };
float total_time { };

const std::chrono::high_resolution_clock::time_point begin = std::chrono::high_resolution_clock::now();
const auto begin = std::clock();

for(;;)
{
Expand All @@ -98,9 +98,9 @@ auto ::math::wide_integer::example009b_timed_mul_8_by_8() -> bool
local_timed_mul_8_by_8::local_a().at(index + 2U) * local_timed_mul_8_by_8::local_b().at(index + 2U);
local_timed_mul_8_by_8::local_a().at(index + 3U) * local_timed_mul_8_by_8::local_b().at(index + 3U);

const std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now();
const auto end = std::clock();

total_time = static_cast<std::intmax_t>(std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count());
total_time = static_cast<float>(static_cast<float>(end - begin) / CLOCKS_PER_SEC);

count += 4U;
index += 4U;
Expand All @@ -110,13 +110,13 @@ auto ::math::wide_integer::example009b_timed_mul_8_by_8() -> bool
index = 0U;
}

if(total_time > INTMAX_C(5999))
if(total_time > static_cast<float>(6.0L)) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
{
break;
}
}

const float kops_per_sec = static_cast<float>(count) / static_cast<float>(static_cast<std::uint32_t>(total_time));
const float kops_per_sec = static_cast<float>(count) / static_cast<float>(static_cast<float>(total_time * 1000.0F));

{
const auto flg = std::cout.flags();
Expand Down
14 changes: 4 additions & 10 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// cov-build --dir cov-int g++ -finline-functions -march=native -mtune=native -O3 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -std=c++14 -DWIDE_INTEGER_HAS_LIMB_TYPE_UINT64 -DWIDE_INTEGER_HAS_MUL_8_BY_8_UNROLL -I. -I/mnt/c/boost/boost_1_83_0 -pthread -lpthread test/test.cpp test/test_uintwide_t_boost_backend.cpp test/test_uintwide_t_edge_cases.cpp test/test_uintwide_t_examples.cpp test/test_uintwide_t_float_convert.cpp test/test_uintwide_t_int_convert.cpp test/test_uintwide_t_n_base.cpp test/test_uintwide_t_n_binary_ops_base.cpp examples/example000a_builtin_convert.cpp test/test_uintwide_t_spot_values.cpp examples/example000_numeric_limits.cpp examples/example001_mul_div.cpp examples/example001a_div_mod.cpp examples/example002_shl_shr.cpp examples/example003_sqrt.cpp examples/example003a_cbrt.cpp examples/example004_rootk_pow.cpp examples/example005_powm.cpp examples/example005a_pow_factors_of_p99.cpp examples/example006_gcd.cpp examples/example007_random_generator.cpp examples/example008_miller_rabin_prime.cpp examples/example008a_miller_rabin_prime.cpp examples/example009_timed_mul.cpp examples/example009a_timed_mul_4_by_4.cpp examples/example009b_timed_mul_8_by_8.cpp examples/example010_uint48_t.cpp examples/example011_uint24_t.cpp examples/example012_rsa_crypto.cpp examples/example013_ecdsa_sign_verify.cpp examples/example014_pi_spigot_wide.cpp -o wide_integer.exe
// tar caf wide-integer.bz2 cov-int

#include <chrono>
#include <ctime>
#include <iomanip>
#include <iostream>

Expand Down Expand Up @@ -99,10 +99,6 @@

namespace local {

using clock_type = std::chrono::high_resolution_clock;

const auto wide_decimal_time_start = clock_type::now();

#if !defined(UINTWIDE_T_REDUCE_TEST_DEPTH)
constexpr auto test_uintwide_t_n_binary_ops_rounds = static_cast<std::size_t>(4U); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
#else
Expand Down Expand Up @@ -549,7 +545,7 @@ auto run() -> bool // NOLINT(readability-function-cognitive-complexity)
using boost_wrapexcept_runtime_type = ::boost::wrapexcept<std::runtime_error>;
#endif

const auto start = clock_type::now();
const auto start = std::clock();

bool result_is_ok = true;

Expand Down Expand Up @@ -607,11 +603,9 @@ auto run() -> bool // NOLINT(readability-function-cognitive-complexity)
}
#endif

const auto stop = clock_type::now();
const auto stop = std::clock();

{
constexpr auto one_thousand_milliseconds = 1000.0F;

const auto flg = std::cout.flags();

std::cout << "result_is_ok: "
Expand All @@ -620,7 +614,7 @@ auto run() -> bool // NOLINT(readability-function-cognitive-complexity)
<< ", time: "
<< std::fixed
<< std::setprecision(1)
<< (static_cast<float>(std::chrono::duration_cast<std::chrono::milliseconds>(stop - start).count())) / one_thousand_milliseconds
<< static_cast<float>(static_cast<float>(stop - start) / CLOCKS_PER_SEC)
<< "s"
<< std::endl;

Expand Down
22 changes: 5 additions & 17 deletions test/test_uintwide_t_edge_cases.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2019 - 2022.
// Copyright Christopher Kormanyos 2019 - 2023.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include <chrono>
#include <ctime>
#include <random>
#include <string>
#include <vector>
Expand Down Expand Up @@ -103,8 +103,7 @@ constexpr auto loop_count_hi = static_cast<std::uint32_t>(UINT16_C(8));
#endif

// Forward declaration
template<typename IntegralTimePointType,
typename ClockType = std::chrono::high_resolution_clock>
template<typename IntegralTimePointType>
auto time_point() -> IntegralTimePointType;

#if defined(WIDE_INTEGER_NAMESPACE)
Expand Down Expand Up @@ -170,23 +169,12 @@ auto zero_as_small_unsigned_type() -> const local_uintwide_t_small_unsigned_type
auto one_as_small_unsigned_type () -> const local_uintwide_t_small_unsigned_type&;
auto m_one_as_small_signed_type () -> const local_uintwide_t_small_signed_type&;

template<typename IntegralTimePointType,
typename ClockType>
template<typename IntegralTimePointType>
auto time_point() -> IntegralTimePointType
{
using local_integral_time_point_type = IntegralTimePointType;
using local_clock_type = ClockType;

const auto current_now =
static_cast<std::uintmax_t>
(
std::chrono::duration_cast<std::chrono::nanoseconds>
(
local_clock_type::now().time_since_epoch()
).count()
);

return static_cast<local_integral_time_point_type>(current_now);
return static_cast<local_integral_time_point_type>(std::clock());
}

template<typename IntegralTypeWithStringConstruction>
Expand Down