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

Add optimized (smaller) lookup table for float type parsing #103

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jrahlf
Copy link
Contributor

@jrahlf jrahlf commented Sep 12, 2021

Reduce code size if only float accuracy is needed for parsing, implements #99

Pro:

Con:

  • minimal binary code size increase if both double and float types are used for parsing
  • increases code bloat

The correct LUT is selected in compute_product_approximation, depending on the bit_precision.
Currently it selects the float LUT, if the bit_precision is smaller than 27. I actually do not like this switch, do you have a better proposal?

Adds:

  • script/table_generation_float.py
  • tests/example_test_float.cpp
  • tests/example_test_mixed.cpp

…files to test/benchmark code sizes. Add script to generate float lookup table.
@lemire
Copy link
Member

lemire commented Sep 12, 2021

Since one goal is to eventually move this library toward supporting from_chars fully, I am not sure I like the idea of sacrificing the general case for what I see as a rather specific use case (you want to use from_chars but you also only care about binary32).

Certainly, anything that increases the binary bloat of the general case does not move us in the right direction, I think. The idea of better supporting the isolated use case (from_chars but only with binary32) is nice, but I think it should come with no compromise over the general case.

Cheers!

@IRainman
Copy link

IRainman commented Apr 7, 2025

fmt has many config macroses that improve performance and size. Like this, PR functionality can be added by FMT_USE_FLOAT, FMT_USE_DOUBLE, FMT_USE_LONG_DOUBLE.

I definitely understand why jrahlf want to add this table. It is very useful for gaming, embedded, and other places in industry. Also, I'm still working on the #307 .

P. S. After all, float128 also needs optimisation and realisation in the library because it exists since 2008 in IEEE and the community already added this type to boost library, for example. It's all real usage types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants