Skip to content

Commit

Permalink
Apply needed changes to conform to the last commit.
Browse files Browse the repository at this point in the history
Also fixed several minor issues.
  • Loading branch information
jk-jeon committed Mar 28, 2024
1 parent 09c474e commit a8d4ab1
Show file tree
Hide file tree
Showing 11 changed files with 742 additions and 727 deletions.
18 changes: 9 additions & 9 deletions subproject/benchmark/source/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class benchmark_holder {
auto out_itr = (*result_array_itr).second[digits].begin();

if (digits == 0) {
std::cout << "Benchmarking " << name_func_pair.first
<< " with uniformly random " << float_name << "'s...\n";
std::cout << "Benchmarking " << name_func_pair.first << " with uniformly random "
<< float_name << "'s...\n";
}
else {
std::cout << "Benchmarking " << name_func_pair.first
Expand Down Expand Up @@ -123,13 +123,13 @@ register_function_for_benchmark::register_function_for_benchmark(std::string_vie
};

register_function_for_benchmark::register_function_for_benchmark(std::string_view name,
void (*func_double)(double,
char*)) {
void (*func_double)(double, char*)) {
benchmark_holder<double>::get_instance().register_function(name, func_double);
};

register_function_for_benchmark::register_function_for_benchmark(
std::string_view name, void (*func_float)(float, char*), void (*func_double)(double, char*)) {
register_function_for_benchmark::register_function_for_benchmark(std::string_view name,
void (*func_float)(float, char*),
void (*func_double)(double, char*)) {
benchmark_holder<float>::get_instance().register_function(name, func_float);
benchmark_holder<double>::get_instance().register_function(name, func_double);
};
Expand Down Expand Up @@ -169,7 +169,7 @@ static void benchmark_test(std::string_view float_name, std::size_t number_of_un
out_file << "name,sample,bit_representation,time\n";

char buffer[64];
typename jkj::dragonbox::default_float_traits<Float>::carrier_uint br;
typename jkj::dragonbox::default_float_bit_carrier_conversion_traits<Float>::carrier_uint br;
for (auto& name_result_pair : out) {
for (auto const& data_time_pair : name_result_pair.second[0]) {
std::memcpy(&br, &data_time_pair.first, sizeof(Float));
Expand Down Expand Up @@ -198,8 +198,8 @@ static void benchmark_test(std::string_view float_name, std::size_t number_of_un
for (unsigned int digits = 1; digits <= benchmark_holder<Float>::max_digits; ++digits) {
for (auto const& data_time_pair : name_result_pair.second[digits]) {
jkj::dragonbox::to_chars(data_time_pair.first, buffer);
out_file << "\"" << name_result_pair.first << "\"," << digits << "," << buffer
<< "," << data_time_pair.second << "\n";
out_file << "\"" << name_result_pair.first << "\"," << digits << "," << buffer << ","
<< data_time_pair.second << "\n";
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions subproject/common/include/random_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@ Float uniformly_randomly_generate_finite_float(RandGen& rg) {

template <class Float, class RandGen>
Float uniformly_randomly_generate_general_float(RandGen& rg) {
using ieee754_traits = jkj::dragonbox::default_float_traits<Float>;
using carrier_uint = typename ieee754_traits::carrier_uint;
using default_float_bit_carrier_conversion_traits =
jkj::dragonbox::default_float_bit_carrier_conversion_traits<Float>;
using carrier_uint = typename default_float_bit_carrier_conversion_traits::carrier_uint;
using uniform_distribution = std::uniform_int_distribution<carrier_uint>;

// Generate sign bit
auto bit_representation = uniform_distribution{0, std::numeric_limits<carrier_uint>::max()}(rg);
return ieee754_traits::carrier_to_float(bit_representation);
return default_float_bit_carrier_conversion_traits::carrier_to_float(bit_representation);
}

template <class Float>
Expand All @@ -127,8 +128,8 @@ struct std_string_to_float<double> {
// However, I don't think there is an easy way to do it correctly.
template <class Float, class RandGen>
Float randomly_generate_float_with_given_digits(unsigned int digits, RandGen& rg) {
using ieee754_traits = jkj::dragonbox::default_float_traits<Float>;
using carrier_uint = typename ieee754_traits::carrier_uint;
using conversion_traits = jkj::dragonbox::default_float_bit_carrier_conversion_traits<Float>;
using carrier_uint = typename conversion_traits::carrier_uint;
using signed_int_t = std::make_signed_t<carrier_uint>;

assert(digits >= 1);
Expand Down
Loading

0 comments on commit a8d4ab1

Please sign in to comment.