-
Notifications
You must be signed in to change notification settings - Fork 42
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
Better support for ARM and other architectures #11
Comments
Just fixed an error that I found. |
That addresses the cases where too few digits were being generated. I'm still seeing unexpected trailing zeros, though. |
Could you give me some specific examples so that I can test on my machine? |
Here are a few binary32 values that give me unexpected trailing zeros on ARM32 but give the expected result on x86_64:
|
Okay, I think I fixed it now. By the way, do you know of a way to more correctly deciding availability of intrinsics like
or
|
Would 8-bit / AVR compatibility make any sense for this algorithm? |
@malachib Admittedly that's something that has never been in my consideration so far. But, I'd say, why not? First of all, the code as-is is supposed to be portable as long as things like However, the code currently just assumes that I did a bit of googling and it seems that floating-point support in 8-bit AVR toolchains is sort of irregular, is that right? Like, some toolchains use binary32 for both I've been keeping in mind that the library eventually needs to support some exotic Also, will the resulting code really be appropriate for specific platforms in your mind regarding performance/binary size is another question that I have no idea how to answer. But I'd want to see how it goes. Thanks for the interest! |
@jk-jeon a very thoughtful response, thank you! I typically in fact use ESP32 Espressif chips, but for auxiliary testing I use Arduino AVR which last I checked used a very old GCC (last I checked it was 4.x or 5.x, but apparently they are up to 7.x https://github.com/arduino/toolchain-avr ). I doubt the format has changed between those releases - I always presumed they used IEEE-754, Presumed being the key word. I did notice you had some specialization possibilities for other formats, kudos to that architecture. AVRs definitely come with serious size constraints, so even a 512-byte ROM lookup buffer isn't a slam dunk for those little guys. But might be worth it. I wanted to ask the question because the algorithm perhaps isn't even viable without native 32-bit/64-bit integer support at the MCU level. Basically asking more questions than giving answers... lol. |
@malachib So I checked the AVR LibC user manual, and it seems:
Given these, I think probably the code as-is may just work there, both for
EDIT: Ah, wait. No, there is a big "if" here: I need several standard C++ headers... I obviously don't use some "advanced" things like So there seems to be several projects that tries to port freestanding C++ headers into 8-bit AVR chips, but I'm not sure if you're okay with relying on such a thing. |
@jk-jeon right on. I have lots of thoughts on this
Anyone who turns on that option and expects standards-conforming libraries to function OK are summarily dismissed
Not surprising. Long double, too https://www.avrfreaks.net/s/topic/a5C3l000000UbfZEAS/t158593
Yes.
100 bytes would be great. Definitely let's not shoot for binary64. I mean, we (you?) would have to spin up a whole custom float64 type, right? If anyone truly needs it, I motion they have to ask. Your stack stuff I can only rely on your good judgement. AVRs definitely don't have much RAM. But, so many things are byte-aligned and IIRC pointers are 16 bit. So that's gotta help.
I got you covered in this area. I am the author of one of those projects https://github.com/malachi-iot/estdlib and even started some preliminary work in anticipation of porting your code in. I use AVRs and ESP32s for my J1939/CAN projects (my own float->char converter is truly gruesome). I'm eager to chuck in your code to test it. Though I can tell you I will definitely need that 100 byte optimization ... fitting J1939 on an AVR with 32k of ROM is no easy feat! Perhaps we should start a github discussion? |
I agree.
From the link:
Hmm.... okay but if I really start working on this I will consider binary64 much later.
Yeah, I think I need some mechanism to detect the toolchain and define an appropriate macro accordingly.
It requires some work. I think I will probably work on it in the near future but please don't expect it to be done too soon.
So according to the link you provided,
Neat. But if it's not supposed to be a conforming (freestanding or not) standard library implementation, I need to provide some way to configure the library to replace those std functions I'm currently relying on. But I don't want to uglify the code by replacing An idea that immediately pops up in my mind is to detect a user-provided macro
inside the Downsides are (1) all needed stuffs needs to be in the same namespace, and they should have the exact same (unqualified) names as their std counterparts, (2) including necessary headers might be annoying, and it now turns the list of std things this library internally uses into a part of the library's interface, (3) not sure what will happen to the "blessed functions" like Any ideas?
Please feel free to make one! By the way, just to make sure, you're aware that Dragonbox cannot be used as a compatible replacement of |
#57 Discussion started! |
Thanks to Tim Kientzle (@tbkka), it turned out that the current code is not working correctly with ARM processors. I believe this is due to errors in fallback implementations of intrinsics. Also the current
#define
switches are not able to correctly detect availabilities of intrinsics for ARM processors, resulting in suboptimal code generation.See: swiftlang/swift#35299.
The text was updated successfully, but these errors were encountered: