Skip to content

Feature/from chars rvv - #2

Open
e4d08 wants to merge 10 commits into
developfrom
feature/from_chars_rvv
Open

e4d08 wants to merge 10 commits into
developfrom
feature/from_chars_rvv

Conversation

@e4d08

@e4d08 e4d08 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

No description provided.

e4d08 added 10 commits July 23, 2026 14:32
The BOOST_UUID_USE_RISCV_V config macro is automatically defined when
the compiler defines __riscv_v, indicating RISC-V Vector Extension
(V 1.0+) support is available. The macro is also added to the
BOOST_UUID_NO_SIMD exclusion list.
This adds a RISC-V Vector (RVV) implementation of the from_chars
algorithm, ported from the x86 SIMD implementation. The RVV version
supports VLEN >= 128 and handles narrow and wide character types
(char, char16_t, char32_t).

The implementation follows the same structure as from_chars_x86.hpp:
deinterleaving of input character pairs, dash validation, hex character
validation, and nibble packing. It uses two separate expected dash
vectors (one per character pair) instead of x86's single shuffled
vector, as RVV's vrgather-based deinterleaving makes this approach
more natural.

The generic fallback path is preserved: both the x86 and RISC-V SIMD
paths dispatch to from_chars_generic when std::is_constant_evaluated()
is true.
Use the number of available characters as the vector length instead of
copying them into a zero-initialized temporary buffer. The lanes above n
are tail-agnostic, but they are never observed, since the parse has
already failed and the result is not stored. With the temporary buffers
gone, the memcpy helper is no longer used and its include is dropped.
Template the core on the character type and load each constant where it
is used instead of passing seven preloaded vectors, shortening the
signature. No change in behavior.
Check __riscv_vector and __riscv_v_min_vlen instead of __riscv_v, so that
targets with shorter vectors (Zve32*, Zve64*) use the generic
implementation rather than producing incorrect results. The vector length
the algorithm requires is now specified where it is used instead of being
passed around as a vl parameter.
The valid masks were only negated right after being computed, so a single
non-zero test replaces the vmseq/vmnand pair.
All four dashes are at character positions 8..23, so sliding chars1 down by
8 and chars2 into lanes 8..15 gives a single vector to check against one
dash constant, instead of two comparisons plus a dash character splat. The
middle constant replaces mm_expected_dashes1 and mm_expected_dashes2.
load_vector128 was a one-line wrapper around the load intrinsic. Inline it
at its call sites, where the required vector length is already available as
the local vl.
@e4d08
e4d08 force-pushed the feature/from_chars_rvv branch from b730de9 to 2dafb46 Compare September 12, 2026 21:54
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.

1 participant