Vectorized conversion from UTF-8 using stdx::simd
Bob Steagall presented his high-speed UTF-8 conversion at CppCon and C++Now where he showed that his approach outperformed most existing conversion algorithms. For some extra speed, he implemented a function for converting ASCII to char16_t/char32_t using SSE intrinsics. This latter part got me hooked, because: stdx::simd (my contribution to the Parallelism TS 2; note that I use namespace stdx = std::experimental, because the latter is just way too long.) was just sent off for publication by the C++ committee and should have made reliance on intrinsics unnecessary. I had no prior experience with vectorizing string operations (which is one of the reasons my previous vector types library Vc didn’t have 8-bit integer support). I was curious, how hard can it be? Bob’s presentation made it look like one needs access to special instructions like movmskb to get good performance. Scalability to different vector widths is unclear. The SSE intrinsics certainly won’t scale. But how much can performance actually scale, knowing that the larger the vector, the lower the chance the full vector of chars is only made up of ASCII? And what about newer ISA extensions such as SSE4.1 which adds instructions for converting unsigned char to short or int? Will it help? Most important to me, can the code be more readable and portable and at least as fast at the same time? And is there a chance for vectorization of non-ASCII code point conversions?
Vir’s blog — go fast with readable code!