[all-commits] [llvm/llvm-project] abb5dd: Microsoft's floating-point to_chars powered by Ryu...

mordante via All-commits all-commits at lists.llvm.org
Sun Dec 12 07:39:31 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: abb5dd6e99df623effc935b84e86f2e886580ad7
      https://github.com/llvm/llvm-project/commit/abb5dd6e99df623effc935b84e86f2e886580ad7
  Author: Mark de Wever <koraq at xs4all.nl>
  Date:   2021-12-12 (Sun, 12 Dec 2021)

  Changed paths:
    M libcxx/CREDITS.TXT
    M libcxx/docs/ReleaseNotes.rst
    M libcxx/docs/Status/Cxx17.rst
    M libcxx/docs/Status/Cxx17Papers.csv
    M libcxx/include/__availability
    M libcxx/include/charconv
    M libcxx/lib/abi/CHANGELOG.TXT
    M libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist
    M libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist
    M libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist
    M libcxx/src/CMakeLists.txt
    M libcxx/src/charconv.cpp
    A libcxx/src/include/ryu/common.h
    A libcxx/src/include/ryu/d2fixed.h
    A libcxx/src/include/ryu/d2fixed_full_table.h
    A libcxx/src/include/ryu/d2s.h
    A libcxx/src/include/ryu/d2s_full_table.h
    A libcxx/src/include/ryu/d2s_intrinsics.h
    A libcxx/src/include/ryu/digit_table.h
    A libcxx/src/include/ryu/f2s.h
    A libcxx/src/include/ryu/ryu.h
    A libcxx/src/include/to_chars_floating_point.h
    A libcxx/src/ryu/README.txt
    A libcxx/src/ryu/d2fixed.cpp
    A libcxx/src/ryu/d2s.cpp
    A libcxx/src/ryu/f2s.cpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_fixed_precision_to_chars_test_cases_1.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_fixed_precision_to_chars_test_cases_2.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_fixed_precision_to_chars_test_cases_3.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_fixed_precision_to_chars_test_cases_4.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_from_chars_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_general_precision_to_chars_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_hex_precision_to_chars_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_scientific_precision_to_chars_test_cases_1.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_scientific_precision_to_chars_test_cases_2.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_scientific_precision_to_chars_test_cases_3.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_scientific_precision_to_chars_test_cases_4.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/double_to_chars_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/float_fixed_precision_to_chars_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/float_from_chars_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/float_general_precision_to_chars_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/float_hex_precision_to_chars_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/float_scientific_precision_to_chars_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/float_to_chars_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/floating_point_test_cases.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/test.cpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/test.hpp
    A libcxx/test/std/utilities/charconv/charconv.msvc/test.pass.cpp

  Log Message:
  -----------
  Microsoft's floating-point to_chars powered by Ryu and Ryu Printf

Microsoft would like to contribute its implementation of floating-point to_chars to libc++. This uses the impossibly fast Ryu and Ryu Printf algorithms invented by Ulf Adams at Google. Upstream repos: https://github.com/microsoft/STL and https://github.com/ulfjack/ryu .

Licensing notes: MSVC's STL is available under the Apache License v2.0 with LLVM Exception, intentionally chosen to match libc++. We've used Ryu under the Boost Software License.

This patch contains minor changes from Jorg Brown at Google, to adapt the code to libc++. He verified that it works in Google's Linux-based environment, but then I applied more changes on top of his, so any compiler errors are my fault. (I haven't tried to build and test libc++ yet.) Please tell me if we need to do anything else in order to follow https://llvm.org/docs/DeveloperPolicy.html#attribution-of-changes .

Notes:

* libc++'s integer charconv is unchanged (except for a small refactoring). MSVC's integer charconv hasn't been tuned for performance yet, so you're not missing anything.
* Floating-point from_chars isn't part of this patch because Jorg found that MSVC's implementation (derived from our CRT's strtod) was slower than Abseil's. If you're unable to use Abseil or another implementation due to licensing or technical considerations, Microsoft would be delighted if you used MSVC's from_chars (and you can just take it, or ask us to provide a patch like this). Ulf is also working on a novel algorithm for from_chars.
* This assumes that float is IEEE 32-bit, double is IEEE 64-bit, and long double is also IEEE 64-bit.
* I have added MSVC's charconv tests (the whole thing: integer/floating from_chars/to_chars), but haven't adapted them to libcxx's harness at all. (These tests will be available in the microsoft/STL repo soon.)
* Jorg added int128 codepaths. These were originally present in upstream Ryu, and I removed them from microsoft/STL purely for performance reasons (MSVC doesn't support int128; Clang on Windows does, but I found that x64 intrinsics were slightly faster).
* The implementation is split into 3 headers. In MSVC's STL, charconv contains only Microsoft-written code. xcharconv_ryu.h contains code derived from Ryu (with significant modifications and additions). xcharconv_ryu_tables.h contains Ryu's large lookup tables (they were sufficiently large to make editing inconvenient, hence the separate file). The xmeow.h convention is MSVC's for internal headers; you may wish to rename them.
* You should consider separately compiling the lookup tables (see https://github.com/microsoft/STL/issues/172 ) for compiler throughput and reduced object file size.
* See https://github.com/StephanTLavavej/llvm-project/commits/charconv for fine-grained history. (If necessary, I can perform some rebase surgery to show you what Jorg changed relative to the microsoft/STL repo; currently that's all fused into the first commit.)

Differential Revision: https://reviews.llvm.org/D70631




More information about the All-commits mailing list