Description
As part of effort to convert target dependent intrinsic in .NET libraries to target-independent Vector*
function, I went through intrinsics used in .NET libraries. I have the list below and some possible options to switch to cross-platform vectors if we either expand Vector API or have JIT optimize certain patterns where multiple Vector functions can achieve same result
-
Base64 Encoder/Decoder
a. Has AVX512 path
b.
c.
d. Cannot convert everything to Vector* without expanding Vector surface area -
ProbablisiticMap
a. Has AVX512 paths
b.
c. Uses the following
i. Avx512BW.PackUnsignedSaturate
ii. Avx512Vbmi.PermuteVar64x8
iii. Avx512BW.Shuffle
d. Cannot Upgrade- No way to switch PackUnsignedSaturate -
XxHashShared.c
a. No Avx512 path
b.
c. Uses Avx2.Multiply
d. Cannot switch Intrinsic Multiply to vector multiply -
BitArray.cs
a. Has AVX512 path
b.runtime/src/libraries/System.Collections/src/System/Collections/BitArray.cs
Lines 840 to 888 in f94bab0
c. Uses the following
i. Avx2.Shuffle
ii. Avx2.And
iii. Avx2.Min
iv. Avx.Store
d. Shuffle with non constant ‘indices’ will be problematic to convert- But should be fine with ShuffleUnsafe implemented -
AsciiStringSearchValuesTeddyBase.cs/ TeddyHelper.cs
a. Has AVX512F path
b.
c. Related : TeddyHelper :
d. Uses the following
i. PackUnsignedSaturate: no 1-1
ii. Shuffle – possible with shuffleunsafe
iii. Permute2x128
iv. AlignRight : no 1-1
v. PermuteVar8x64x2 -
SpanHelpers.cs : Consider all span under this umbrella
a. Has AVX512F path
b.
c. Uses the following
i. Shuffle
ii. Avx2.Permute2x128
iii. PermuteVar8x32
iv. Permute4x64
v. Avx2.And
vi. Avx2.MultiplyHigh
vii. Avx2.MultiplyLow
viii. Avx2.Or
ix. Avx2.SubtractSaturate
x. Avx2.CompareGreaterThan
xi. Avx2.Subtract
xii. Avx2.Add -
IndexOfAnyAsciiSearcher
a. No AVx512F path – Tried impl/had issues
b.
c. Uses following
i. PackUnsignedSaturate
ii. Shuffle -
Matrix4x4.Impl
a. No avx512 path and in some cases avx paths
b.
c. Uses foll
i. Shuffle/Permute – constant indices..so possible?
ii. UnpackLow
iii. UnpackHigh -
Ascii.Equality
a. Avx512 path added
b.
c. Already uses Vector – switch check? -
Ascii.Utility.
a. Has avx512 path
b.
c. Uses Testz/ PackUnsignedSaturate – can possibly move to more efficient patterns similar to ‘HasMatch’
BitArray is the only one where it’s feasible currently and that’s dependent on #99596
Some patterns we can consider
Sse2.multiply
– vector multiply does not work the same way. Vector version stores only the lower half after multiplication. Intrinsic version(for sse and avx upgrades type uint->ulong for eg). SoWiden -> Multiply
might work