Тёмный
No video :(

Stephan T. Lavavej “Floating-Point <charconv>: Making Your Code 10x Faster With C++17's Final Boss” 

CppCon
Подписаться 152 тыс.
Просмотров 38 тыс.
50% 1

CppCon.org
-
Discussion & Comments: / cpp
-
Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/Cpp...
-
Floating-point numbers are ancient, mysterious, and terrifying. Over the past 30 years, the C and C++ Standards have provided many functions for floating-point/string conversions, such as C's strtof(), strtod(), and printf() %a %e %f %g, and C++'s iostreams, stof(), stod(), and to_string(). Despite this history, floating-point is far from a solved problem - these functions have ranged from annoyingly to egregiously slow, and application developers and library maintainers alike have found it exceedingly difficult to understand floating-point behavior.
This session will present new and wondrous developments in the area of floating-point conversions. If your serialization code is bottlenecked by floating-point printing, this will accelerate your code by roughly 3x to 30x (yes, times, not percent). You can also improve the human-readability of your output. Along the way, this session will cover the basics of floating-point representations, dispelling common myths like fuzziness and non-determinism.
Specifically, C++17 added 3 pages of Standardese describing the charconv header and its functions from_chars() and to_chars(). This feature has required an unexpectedly large amount of implementation work, taking over a dev-year for MSVC and becoming the last C++17 library feature to ship. Coincidentally, Ulf Adams at Google developed a novel algorithm named Ryu, which is responsible for the amazing speed of to_chars(). This session will focus on how to use charconv and how to understand its many supported formats, with a brief overview of Ryu's techniques.
-
Stephan T. Lavavej
Microsoft
Principal Software Engineer
Redmond, WA
Stephan T. Lavavej is a Principal Software Engineer at Microsoft, maintaining Visual C++'s implementation of the C++ Standard Library since 2007. He also designed a couple of C++14 features: make_unique and the transparent operator functors. He likes his initials (which people can actually spell) and cats (although he doesn't own any).
-
Videos Filmed & Edited by Bash Films: www.BashFilms.com *-----*
Register Now For CppCon 2022: cppcon.org/reg...
*-----*

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 28   
@AminAramoon
@AminAramoon 4 года назад
This guys always gives some of the best talks in CppCon
@StephanLavavej
@StephanLavavej 4 года назад
Thanks! :-)
@NonTwinBrothers
@NonTwinBrothers Год назад
I admire this channel's ability to put < and > symbols in the title even when youtube disallows it
@isitanos
@isitanos 4 года назад
Would be nice if this library provided you with constants for the right size of the buffer to accomodate the worst case for each numeric type.
@grahambest3809
@grahambest3809 4 года назад
Wow! Steven is a great speaker! Awesome talk. I did learn quite a bit of new things :-)
@mkg4215
@mkg4215 4 года назад
Great talk, as always. Ryu seems to be a real game changer.
@gast128
@gast128 4 года назад
Fast, locale independent, round trip serialization of numbers is exactly what we needed a long time ago. The additional speed improvements are always welcome. Pity that it doesn't support wchar_t. It might be an option for us to workaround it and add the conversion from string to wstring ourselves.
@StephanLavavej
@StephanLavavej 4 года назад
It would be fairly easy to template the code on character type (crucially, the lookup tables aren't affected; I use a lookup table to convert char to digit which wouldn't be possible for wider types, but that's fine), so I could imagine a proposal being accepted.
@kuhluhOG
@kuhluhOG 4 года назад
besides using a (weird/legacy) library or using the Windows API, why do you use wchar_t?
@TheEmT33
@TheEmT33 4 года назад
Packed content, concise explanation, great talk!
@movax20h
@movax20h 4 года назад
Great talk. Going to watch Ryu stuff now. As of vectorizing for 32-bit, don't bother. Using 64-bit you can assume SSE2 and use it always.
@goshisanniichi
@goshisanniichi 4 года назад
lol. Ryu is Japanese for dragon. Gotta love programmer humor.
@guiorgy
@guiorgy 2 года назад
Original algorithm: Dragon4 (1990) New algorithm: Ryu (2018) 35:40
@ReaperUnreal
@ReaperUnreal 4 года назад
Wish I'd had the "plain" to_chars mode a few years ago. I was working on a compiler and the compiler itself would crash when outputting the trace of a specific compiler test. It turns out the sprintf of a long double was overflowing the buffer and stomping the return pointer. Didn't have access to snprintf because of the platform. This is how I discovered general mode, but "plain" was really what I wanted.
@zvxcvxcz
@zvxcvxcz 4 года назад
Can we please get arbitrary (multiple) precision in the standard library though? GMP may be awesome but there is a real shortage of well supported higher level libraries utilizing multiple precision because adding the implementation is often not very straightforward. I suspect that it would be a lot easier for higher level libraries to add support if these types were available in the standard library and could be easily dropped in.
@IndellableHatesHandles
@IndellableHatesHandles Год назад
Charconv has warnings within it according to VC++, which is funny but also makes it impossible to interpret warnings as errors.
@10100rsn
@10100rsn 2 года назад
Great! And Ryu means Dragon in Japanese... Full circle now.
@jxsl13
@jxsl13 4 года назад
Great talk.
@AlwinMao
@AlwinMao 2 года назад
Link to Ulf''s 2018 PDTI talk: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-kw-U6smcLzk.html
@Astfresser
@Astfresser 2 года назад
How does gcc implement it and how does it perform for RISC-V processors? This would be crucial to know for embedded use.
@VioletGiraffe
@VioletGiraffe 4 года назад
So what exactly is wrong with multiplying and dividing by a power of 10? I often use this to trim the value to N digits after the decimal point.
@sander_bouwhuis
@sander_bouwhuis 4 года назад
I guess because log2(10)≈3.32192809489? When you divide by 10 you lose precision and it takes many more cycles. Also, he didn't state that dividing by a power of 10 in one step (e.g. div 10e5) was wrong, but repeatedly doing that (div 10 div 10 div 10 div 10 div 10) to build up the number. PS : Thanks for the CppCheck addin! (I presume you are the same guy/girl?)
@Carutsu
@Carutsu 4 года назад
Any links to Ulf talk?
@tsafin
@tsafin 4 года назад
I guess this one ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-kw-U6smcLzk.html
@nielsdegroot9138
@nielsdegroot9138 3 года назад
Check the links slide @51:00
@DrGreenGiant
@DrGreenGiant 2 года назад
Yikes, that's a lot of memory required for this then. RIP embedded use :(
@Astfresser
@Astfresser 2 года назад
I thought the same. Well i'll test it anyway, i hope theres a lot of constexpr paths that can be compiled out..
Далее
Only I get to bully my sister 😤
00:27
Просмотров 34 млн
WHY did this C++ code FAIL?
38:10
Просмотров 252 тыс.
Type punning in modern C++ - Timur Doumler - CppCon 2019
1:00:19
C++ Code Smells - Jason Turner - CppCon 2019
58:35
Просмотров 78 тыс.
Simple Code, High Performance
2:50:14
Просмотров 246 тыс.