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

ENH: Use Ryu #20

Open
HaoZeke opened this issue Sep 3, 2023 · 4 comments
Open

ENH: Use Ryu #20

HaoZeke opened this issue Sep 3, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@HaoZeke
Copy link
Member

HaoZeke commented Sep 3, 2023

Or another floating point library. As is done upstream.

@alugowski
Copy link
Contributor

Pardon if this is a silly question, but I'm not up to date on how R extensions are built. How much control do you have over what compiler is used? I ask because all major compilers' latest versions basically bundle Ryu as part of the standard library. The reason FMM vendors Ryu is to support older compilers in wide use that do not. Basically if you can use std::to_chars with floats then you're probably already using Ryu.

fast_float for the read side might have more value. It's also getting bundled with compilers, but not all yet. MSVC is still in PR I believe, and LLVM only uses it for the C methods and not for std::from_chars. On the other hand fast_float is a single header, so integrating it is very easy compared to Ryu. Just add the header to the include dir and define FMM_USE_FAST_FLOAT.

@HaoZeke
Copy link
Member Author

HaoZeke commented Sep 12, 2023

Pardon if this is a silly question, but I'm not up to date on how R extensions are built. How much control do you have over what compiler is used? I ask because all major compilers' latest versions basically bundle Ryu as part of the standard library. The reason FMM vendors Ryu is to support older compilers in wide use that do not. Basically if you can use std::to_chars with floats then you're probably already using Ryu.

That's a great question. For packages which are meant for CRAN (the Comprehensive R Archive Network, like PyPi for R), it is generally safe to assume GCC 10 (as part of the Rtools42 compiler toolchain), though up-to-date / current versions should have GCC 12 from Rtools43. I think GCC 10 only had integer support for std::to_chars but I might be wrong.

fast_float for the read side might have more value. It's also getting bundled with compilers, but not all yet. MSVC is still in PR I believe, and LLVM only uses it for the C methods and not for std::from_chars. On the other hand fast_float is a single header, so integrating it is very easy compared to Ryu. Just add the header to the include dir and define FMM_USE_FAST_FLOAT.

Makes sense, will do, thank you :)

@alugowski
Copy link
Contributor

Yeah that's old enough to need Ryu/Dragonbox/fast_float. The upside is that you'll see some very large speedup, especially on 4+ cores.

Ryu isn't too hard to add either. Just a few .c files to add to your target, or build and link a small library.

@alugowski
Copy link
Contributor

GCC 12 from Rtools43.

I checked again, and GCC 12 is the first one with the fast methods bundled. So if you're able to use GCC 12 then there's nothing more to do :)

@HaoZeke HaoZeke added the enhancement New feature or request label Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants