Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f8fa06

Browse files
kunalspathaktmds
authored andcommitted
Disable load/store vector APIs until Mono adds support for it (dotnet#96944)
* Revert "[libs] Skip AdvSimdEncode on Mono (dotnet#96829)" This reverts commit 1a76e37. * Revert "Use multi-reg load/store for EncodeToUtf8 (dotnet#95513)" This reverts commit fdb03ca. * Wrap load/store vector APIs in '#if false' * Disable load/store vector tests * remove the trailing space
1 parent f02b44b commit 2f8fa06

File tree

5 files changed

+454
-430
lines changed

5 files changed

+454
-430
lines changed

src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Encoder.cs

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,6 @@ public static unsafe OperationStatus EncodeToUtf8(ReadOnlySpan<byte> bytes, Span
8585
goto DoneExit;
8686
}
8787

88-
#if !MONO // https://github.com/dotnet/runtime/issues/93081
89-
end = srcMax - 48;
90-
if (AdvSimd.Arm64.IsSupported && (end >= src))
91-
{
92-
AdvSimdEncode(ref src, ref dest, end, maxSrcLength, destLength, srcBytes, destBytes);
93-
94-
if (src == srcEnd)
95-
goto DoneExit;
96-
}
97-
#endif
98-
9988
end = srcMax - 16;
10089
if ((Ssse3.IsSupported || AdvSimd.Arm64.IsSupported) && BitConverter.IsLittleEndian && (end >= src))
10190
{
@@ -491,66 +480,6 @@ private static unsafe void Avx2Encode(ref byte* srcBytes, ref byte* destBytes, b
491480
destBytes = dest;
492481
}
493482

494-
#if !MONO // https://github.com/dotnet/runtime/issues/93081
495-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
496-
[CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
497-
private static unsafe void AdvSimdEncode(ref byte* srcBytes, ref byte* destBytes, byte* srcEnd, int sourceLength, int destLength, byte* srcStart, byte* destStart)
498-
{
499-
// C# implementatino of https://github.com/aklomp/base64/blob/3a5add8652076612a8407627a42c768736a4263f/lib/arch/neon64/enc_loop.c
500-
Vector128<byte> str1;
501-
Vector128<byte> str2;
502-
Vector128<byte> str3;
503-
Vector128<byte> res1;
504-
Vector128<byte> res2;
505-
Vector128<byte> res3;
506-
Vector128<byte> res4;
507-
Vector128<byte> tblEnc1 = Vector128.Create("ABCDEFGHIJKLMNOP"u8).AsByte();
508-
Vector128<byte> tblEnc2 = Vector128.Create("QRSTUVWXYZabcdef"u8).AsByte();
509-
Vector128<byte> tblEnc3 = Vector128.Create("ghijklmnopqrstuv"u8).AsByte();
510-
Vector128<byte> tblEnc4 = Vector128.Create("wxyz0123456789+/"u8).AsByte();
511-
byte* src = srcBytes;
512-
byte* dest = destBytes;
513-
514-
// If we have Neon support, pick off 48 bytes at a time for as long as we can.
515-
do
516-
{
517-
// Load 48 bytes and deinterleave:
518-
AssertRead<Vector128<byte>>(src, srcStart, sourceLength);
519-
(str1, str2, str3) = AdvSimd.Arm64.LoadVector128x3AndUnzip(src);
520-
521-
// Divide bits of three input bytes over four output bytes:
522-
res1 = AdvSimd.ShiftRightLogical(str1, 2);
523-
res2 = AdvSimd.ShiftRightLogical(str2, 4);
524-
res3 = AdvSimd.ShiftRightLogical(str3, 6);
525-
res2 = AdvSimd.ShiftLeftAndInsert(res2, str1, 4);
526-
res3 = AdvSimd.ShiftLeftAndInsert(res3, str2, 2);
527-
528-
// Clear top two bits:
529-
res2 &= AdvSimd.DuplicateToVector128((byte)0x3F);
530-
res3 &= AdvSimd.DuplicateToVector128((byte)0x3F);
531-
res4 = str3 & AdvSimd.DuplicateToVector128((byte)0x3F);
532-
533-
// The bits have now been shifted to the right locations;
534-
// translate their values 0..63 to the Base64 alphabet.
535-
// Use a 64-byte table lookup:
536-
res1 = AdvSimd.Arm64.VectorTableLookup((tblEnc1, tblEnc2, tblEnc3, tblEnc4), res1);
537-
res2 = AdvSimd.Arm64.VectorTableLookup((tblEnc1, tblEnc2, tblEnc3, tblEnc4), res2);
538-
res3 = AdvSimd.Arm64.VectorTableLookup((tblEnc1, tblEnc2, tblEnc3, tblEnc4), res3);
539-
res4 = AdvSimd.Arm64.VectorTableLookup((tblEnc1, tblEnc2, tblEnc3, tblEnc4), res4);
540-
541-
// Interleave and store result:
542-
AssertWrite<Vector128<byte>>(dest, destStart, destLength);
543-
AdvSimd.Arm64.StoreVector128x4AndZip(dest, (res1, res2, res3, res4));
544-
545-
src += 48;
546-
dest += 64;
547-
} while (src <= srcEnd);
548-
549-
srcBytes = src;
550-
destBytes = dest;
551-
}
552-
#endif // !MONO
553-
554483
[MethodImpl(MethodImplOptions.AggressiveInlining)]
555484
[CompExactlyDependsOn(typeof(Ssse3))]
556485
[CompExactlyDependsOn(typeof(AdvSimd.Arm64))]

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/AdvSimd.PlatformNotSupported.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,9 @@ internal Arm64() { }
15501550
/// </summary>
15511551
public static Vector128<ulong> InsertSelectedScalar(Vector128<ulong> result, [ConstantExpected(Max = (byte)(1))] byte resultIndex, Vector128<ulong> value, [ConstantExpected(Max = (byte)(1))] byte valueIndex) { throw new PlatformNotSupportedException(); }
15521552

1553+
#if false
1554+
// Should be disabled until Mono implements these APIs. See https://github.com/dotnet/runtime/issues/93081
1555+
15531556
/// <summary>
15541557
/// A64: LD2 { Vn.16B, Vn+1.16B }[Vm], [Xn]
15551558
/// </summary>
@@ -1699,6 +1702,7 @@ internal Arm64() { }
16991702
/// A64: LD4 { Vn.2D, Vn+1.2D, Vn+2.2D, Vn+3.2D }[Vm], [Xn]
17001703
/// </summary>
17011704
public static unsafe (Vector128<double> Value1, Vector128<double> Value2, Vector128<double> Value3, Vector128<double> Value4) LoadAndInsertScalar((Vector128<double>, Vector128<double>, Vector128<double>, Vector128<double>) values, [ConstantExpected(Max = (byte)(1))] byte index, double* address) { throw new PlatformNotSupportedException(); }
1705+
#endif
17021706

17031707
/// <summary>
17041708
/// float64x2_t vld1q_dup_f64 (float64_t const * ptr)
@@ -1718,6 +1722,9 @@ internal Arm64() { }
17181722
/// </summary>
17191723
public static unsafe Vector128<ulong> LoadAndReplicateToVector128(ulong* address) { throw new PlatformNotSupportedException(); }
17201724

1725+
#if false
1726+
// Should be disabled until Mono implements these APIs. See https://github.com/dotnet/runtime/issues/93081
1727+
17211728
/// <summary>
17221729
/// A64: LD2R { Vn.16B, Vn+1.16B }, [Xn]
17231730
/// </summary>
@@ -1867,6 +1874,7 @@ internal Arm64() { }
18671874
/// A64: LD4R { Vn.2D, Vn+1.2D, Vn+2.2D, Vn+3.2D }, [Xn]
18681875
/// </summary>
18691876
public static unsafe (Vector128<double> Value1, Vector128<double> Value2, Vector128<double> Value3, Vector128<double> Value4) LoadAndReplicateToVector128x4(double* address) { throw new PlatformNotSupportedException(); }
1877+
#endif
18701878

18711879
/// <summary>
18721880
/// A64: LDP Dt1, Dt2, [Xn]
@@ -2098,6 +2106,9 @@ internal Arm64() { }
20982106
/// </summary>
20992107
public static unsafe (Vector128<ulong> Value1, Vector128<ulong> Value2) LoadPairVector128NonTemporal(ulong* address) { throw new PlatformNotSupportedException(); }
21002108

2109+
#if false
2110+
// Should be disabled until Mono implements these APIs. See https://github.com/dotnet/runtime/issues/93081
2111+
21012112
/// <summary>
21022113
/// A64: LD2 { Vn.16B, Vn+1.16B }, [Xn]
21032114
/// </summary>
@@ -2397,6 +2408,7 @@ internal Arm64() { }
23972408
/// A64: LD1 { Vn.2D, Vn+1.2D, Vn+2.2D, Vn+3.2D }, [Xn]
23982409
/// </summary>
23992410
public static unsafe (Vector128<double> Value1, Vector128<double> Value2, Vector128<double> Value3, Vector128<double> Value4) LoadVector128x4(double* address) { throw new PlatformNotSupportedException(); }
2411+
#endif
24002412

24012413
/// <summary>
24022414
/// float64x2_t vmaxq_f64 (float64x2_t a, float64x2_t b)
@@ -3776,6 +3788,9 @@ internal Arm64() { }
37763788
/// </summary>
37773789
public static unsafe void StorePairScalarNonTemporal(uint* address, Vector64<uint> value1, Vector64<uint> value2) { throw new PlatformNotSupportedException(); }
37783790

3791+
#if false
3792+
// Should be disabled until Mono implements these APIs. See https://github.com/dotnet/runtime/issues/93081
3793+
37793794
/// <summary>
37803795
/// void vst2_lane_s8 (int8_t * ptr, int8x16x2_t val, const int lane)
37813796
/// A64: ST2 { Vt.16B, Vt+1.16B }[index], [Xn]
@@ -4246,6 +4261,7 @@ internal Arm64() { }
42464261
/// A64: ST1 { Vn.2D, Vn+1.2D, Vn+2.2D, Vn+3.2D }, [Xn]
42474262
/// </summary>
42484263
public static unsafe void StoreVector128x4(double* address, (Vector128<double> Value1, Vector128<double> Value2, Vector128<double> Value3, Vector128<double> Value4) value) { throw new PlatformNotSupportedException(); }
4264+
#endif
42494265

42504266
/// <summary>
42514267
/// float64x2_t vsubq_f64 (float64x2_t a, float64x2_t b)
@@ -9160,6 +9176,9 @@ internal Arm64() { }
91609176
/// </summary>
91619177
public static unsafe Vector128<ulong> LoadAndInsertScalar(Vector128<ulong> value, [ConstantExpected(Max = (byte)(1))] byte index, ulong* address) { throw new PlatformNotSupportedException(); }
91629178

9179+
#if false
9180+
// Should be disabled until Mono implements these APIs. See https://github.com/dotnet/runtime/issues/93081
9181+
91639182
/// <summary>
91649183
/// A64: LD2 { Vn.8B, Vn+1.8B }[Vm], [Xn]
91659184
/// </summary>
@@ -9264,6 +9283,7 @@ internal Arm64() { }
92649283
/// A64: LD4 { Vn.2S, Vn+1.2S, Vn+2.2S, Vn+3.2S }[Vm], [Xn]
92659284
/// </summary>
92669285
public static unsafe (Vector64<float> Value1, Vector64<float> Value2, Vector64<float> Value3, Vector64<float> Value4) LoadAndInsertScalar((Vector64<float>, Vector64<float>, Vector64<float>, Vector64<float>) values, [ConstantExpected(Max = (byte)(1))] byte index, float* address) { throw new PlatformNotSupportedException(); }
9286+
#endif
92679287

92689288
/// <summary>
92699289
/// uint8x8_t vld1_dup_u8 (uint8_t const * ptr)
@@ -9363,6 +9383,9 @@ internal Arm64() { }
93639383
/// </summary>
93649384
public static unsafe Vector128<uint> LoadAndReplicateToVector128(uint* address) { throw new PlatformNotSupportedException(); }
93659385

9386+
#if false
9387+
// Should be disabled until Mono implements these APIs. See https://github.com/dotnet/runtime/issues/93081
9388+
93669389
/// <summary>
93679390
/// A64: LD2R { Vn.8B, Vn+1.8B }, [Xn]
93689391
/// </summary>
@@ -9467,6 +9490,7 @@ internal Arm64() { }
94679490
/// A64: LD4R { Vn.2S, Vn+1.2S, Vn+2.2S, Vn+3.2S }, [Xn]
94689491
/// </summary>
94699492
public static unsafe (Vector64<float> Value1, Vector64<float> Value2, Vector64<float> Value3, Vector64<float> Value4) LoadAndReplicateToVector64x4(float* address) { throw new PlatformNotSupportedException(); }
9493+
#endif
94709494

94719495
/// <summary>
94729496
/// uint8x8_t vld1_u8 (uint8_t const * ptr)
@@ -9608,6 +9632,9 @@ internal Arm64() { }
96089632
/// </summary>
96099633
public static unsafe Vector128<ulong> LoadVector128(ulong* address) { throw new PlatformNotSupportedException(); }
96109634

9635+
#if false
9636+
// Should be disabled until Mono implements these APIs. See https://github.com/dotnet/runtime/issues/93081
9637+
96119638
/// <summary>
96129639
/// A64: LD2 { Vn.8B, Vn+1.8B }, [Xn]
96139640
/// </summary>
@@ -9817,6 +9844,7 @@ internal Arm64() { }
98179844
/// A64: LD1 { Vn.2S, Vn+1.2S, Vn+2.2S, Vn+3.2S }, [Xn]
98189845
/// </summary>
98199846
public static unsafe (Vector64<float> Value1, Vector64<float> Value2, Vector64<float> Value3, Vector64<float> Value4) LoadVector64x4(float* address) { throw new PlatformNotSupportedException(); }
9847+
#endif
98209848

98219849
/// <summary>
98229850
/// uint8x8_t vmax_u8 (uint8x8_t a, uint8x8_t b)
@@ -15928,6 +15956,9 @@ internal Arm64() { }
1592815956
/// </summary>
1592915957
public static unsafe void StoreSelectedScalar(ulong* address, Vector128<ulong> value, [ConstantExpected(Max = (byte)(1))] byte index) { throw new PlatformNotSupportedException(); }
1593015958

15959+
#if false
15960+
// Should be disabled until Mono implements these APIs. See https://github.com/dotnet/runtime/issues/93081
15961+
1593115962
/// <summary>
1593215963
/// A64: ST2 { Vt.8B, Vt+1.8B }[index], [Xn]
1593315964
/// </summary>
@@ -16242,6 +16273,7 @@ internal Arm64() { }
1624216273
/// A64: ST1 { Vn.2S, Vn+1.2S, Vn+2.2S, Vn+3.2S }, [Xn]
1624316274
/// </summary>
1624416275
public static unsafe void StoreVector64x4(float* address, (Vector64<float> Value1, Vector64<float> Value2, Vector64<float> Value3, Vector64<float> Value4) value) { throw new PlatformNotSupportedException(); }
16276+
#endif
1624516277

1624616278
/// <summary>
1624716279
/// uint8x8_t vsub_u8 (uint8x8_t a, uint8x8_t b)

0 commit comments

Comments
 (0)