Skip to content

Commit deb4f1a

Browse files
lemirejaja360
authored andcommitted
minor fixes for the yy PR
1 parent 8c13d6b commit deb4f1a

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

benchmarks/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ endif()
6767
target_link_libraries(benchmark PUBLIC fmt)
6868
target_link_libraries(benchmark PUBLIC cxxopts)
6969

70-
#target_link_libraries(benchmark PUBLIC grisu2)
7170
target_link_libraries(benchmark PUBLIC yy_double)
7271
target_link_libraries(benchmark PUBLIC double-conversion)
7372
target_link_libraries(benchmark PUBLIC ryu::ryu)

benchmarks/algorithms.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@
3232
#include "ryu/ryu.h"
3333
#include "schubfach_32.h"
3434
#include "schubfach_64.h"
35+
#if (__SIZEOF_INT128__ == 16) && (defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER))
3536
#include "yy_double.h"
36-
37+
#define YY_DOUBLE_SUPPORTED 1
38+
#else
39+
#define YY_DOUBLE_SUPPORTED 0
40+
#endif
3741
namespace Benchmarks {
3842

3943
enum Algorithm {
@@ -54,7 +58,7 @@ enum Algorithm {
5458
STD_TO_CHARS = 14,
5559
GRISU3 = 15,
5660
YY_DOUBLE = 16,
57-
COUNT = 17,
61+
COUNT // Keep last
5862
};
5963

6064
template<typename T>
@@ -95,6 +99,7 @@ int errol3(T d, std::span<char>& buffer) {
9599
errol3_dtoa(d, buffer.data()); // returns the exponent
96100
return std::strlen(buffer.data());
97101
#else
102+
std::cerr << "errol3 not supported" << std::endl;
98103
std::abort();
99104
#endif
100105
}
@@ -153,6 +158,7 @@ int netlib(T d, std::span<char>& buffer) {
153158
std::abort();
154159
}
155160
#else
161+
std::cerr << "netlib not supported" << std::endl;
156162
std::abort();
157163
#endif
158164
}
@@ -227,11 +233,15 @@ int double_conversion(T d, std::span<char>& buffer) {
227233
return strlen(builder.Finalize());
228234
}
229235

230-
// No yy_float implementation
231236
template<arithmetic_float T>
232237
int yy_double(T d, std::span<char>& buffer) {
238+
#if YY_DOUBLE_SUPPORTED
233239
const char* end_ptr = yy_double_to_string(d, buffer.data());
234240
return end_ptr - buffer.data();
241+
#else
242+
std::cerr << "yy_double not supported" << std::endl;
243+
std::abort();
244+
#endif
235245
}
236246

237247
template<arithmetic_float T>
@@ -255,6 +265,7 @@ int std_to_chars(T d, std::span<char>& buffer) {
255265
}
256266
return p - buffer.data();
257267
#else
268+
std::cerr << "std::to_chars not supported" << std::endl;
258269
std::abort();
259270
#endif
260271
}

benchmarks/benchmark.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ void process(const std::vector<T> &lines,
7575
std::cout << "# skipping " << algo.name << std::endl;
7676
continue;
7777
}
78-
7978
pretty_print(lines, algo.name, [&algo](const std::vector<T> &lines) -> int {
8079
int volume = 0;
8180
char buf[100];
@@ -205,7 +204,7 @@ int main(int argc, char **argv) {
205204
args[Benchmarks::ABSEIL] = { "abseil" , Benchmarks::abseil<T> , ABSEIL_SUPPORTED };
206205
args[Benchmarks::STD_TO_CHARS] = { "std::to_chars" , Benchmarks::std_to_chars<T> , TO_CHARS_SUPPORTED };
207206
args[Benchmarks::GRISU3] = { "grisu3" , Benchmarks::grisu3<T> , true };
208-
args[Benchmarks::YY_DOUBLE] = { "yy_double" , Benchmarks::yy_double<T> , true };
207+
args[Benchmarks::YY_DOUBLE] = { "yy_double" , Benchmarks::yy_double<T> , YY_DOUBLE_SUPPORTED };
209208
return args;
210209
};
211210

0 commit comments

Comments
 (0)