Skip to content

Conversation

@ylpoonlg
Copy link
Contributor

@ylpoonlg ylpoonlg commented Dec 2, 2025

Contributes to #103781, based on #104199.

Includes some changes to reduce code duplication and reuse existing code such as VectorContainsNonAsciiChar to fit in with the library. Most intrinsics are replaced with Vector128 APIs. Otherwise, I tried to encapsulate where platform-specific intrinsics are used so that it will be easier to extend to other Vector128 platforms. That would just require replacing AdvSimd.Arm64.VectorTableLookup with Vector128.Shuffle and some Vector128 replacement for AdvSimd.ExtractVector128, which can be done in a later PR.
The unit tests are also modified to improve the coverage and test cases.

Benchmark results

Neoverse-V2:

Method Input Version Mean Error Ratio
GetCharCount EnglishAllAscii Before 3.113 us 0.0026 us 1.000
GetCharCount EnglishAllAscii After 3.114 us 0.0022 us 1.000
GetCharCount EnglishMostlyAscii Before 31.269 us 0.0757 us 1.000
GetCharCount EnglishMostlyAscii After 9.970 us 0.0094 us 0.319
GetCharCount Chinese Before 34.602 us 0.1955 us 1.000
GetCharCount Chinese After 22.637 us 1.1302 us 0.654
GetCharCount Cyrillic Before 26.021 us 0.2613 us 1.000
GetCharCount Cyrillic After 11.644 us 0.0243 us 0.447
GetCharCount Greek Before 66.024 us 0.3077 us 1.000
GetCharCount Greek After 15.824 us 0.8816 us 0.240

Neoverse-N2:

Method Input Version Mean Error Ratio
GetCharCount EnglishAllAscii Before 10.390 us 0.0060 us 1.000
GetCharCount EnglishAllAscii After 3.522 us 0.0031 us 0.339
GetCharCount EnglishMostlyAscii Before 32.390 us 0.0140 us 1.000
GetCharCount EnglishMostlyAscii After 16.587 us 0.0501 us 0.512
GetCharCount Chinese Before 46.510 us 0.2420 us 1.000
GetCharCount Chinese After 38.449 us 0.0489 us 0.827
GetCharCount Cyrillic Before 39.520 us 0.2690 us 1.000
GetCharCount Cyrillic After 19.827 us 0.0017 us 0.502
GetCharCount Greek Before 85.660 us 0.4650 us 1.000
GetCharCount Greek After 26.648 us 0.0026 us 0.311

cc @dotnet/arm64-contrib @lemire @EgorBo @a74nh @SwapnilGaikwad

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Runtime.Intrinsics community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants