@@ -92,46 +92,6 @@ public static unsafe bool SIMDIsAscii(this ReadOnlySpan<char> s)
9292 fixed ( char * pStart = & MemoryMarshal . GetReference ( s ) )
9393 {
9494 int i = 0 ;
95-
96- /* PAR: not unrolled
97- | Method | N | Mean | Error | StdDev |
98- |----------------------- |---- |-----------:|---------:|---------:|
99- | FastUnicodeIsAscii | 100 | 652.6 ns | 2.20 ns | 1.95 ns |
100- | StandardUnicodeIsAscii | 100 | 2,466.5 ns | 21.77 ns | 20.36 ns |
101- | RuntimeIsAscii | 100 | 2,502.7 ns | 29.81 ns | 27.89 ns |
102- | FastUnicodeIsAscii | 200 | 1,300.8 ns | 17.95 ns | 14.99 ns |
103- | StandardUnicodeIsAscii | 200 | 5,216.6 ns | 62.48 ns | 55.38 ns |
104- | RuntimeIsAscii | 200 | 5,293.2 ns | 41.50 ns | 38.82 ns |
105- | FastUnicodeIsAscii | 500 | 2,978.6 ns | 34.99 ns | 32.73 ns |
106- | StandardUnicodeIsAscii | 500 | 6,172.9 ns | 74.53 ns | 69.71 ns |
107- | RuntimeIsAscii | 500 | 6,210.8 ns | 80.82 ns | 63.10 ns | */
108-
109-
110- /* if (s.Length > 8)
111- {
112- Vector128<ushort> total = Sse41.LoadDquVector128((ushort*)pStart);
113- i += 8;
114- // unrolling could be useful here:
115- for (; i + 7 < s.Length; i += 8)
116- {
117- Vector128<ushort> raw = Sse41.LoadDquVector128((ushort*)pStart + i);
118- total = Sse2.Or(total, raw);
119- } */
120-
121-
122- /* Unrolled twice:
123- | Method | N | Mean | Error | StdDev |
124- |----------------------- |---- |-----------:|---------:|---------:|
125- | FastUnicodeIsAscii | 100 | 905.7 ns | 17.95 ns | 20.67 ns |
126- | StandardUnicodeIsAscii | 100 | 2,502.4 ns | 49.67 ns | 66.31 ns |
127- | RuntimeIsAscii | 100 | 2,522.8 ns | 32.70 ns | 30.59 ns |
128- | FastUnicodeIsAscii | 200 | 649.3 ns | 10.24 ns | 9.57 ns |
129- | StandardUnicodeIsAscii | 200 | 5,299.7 ns | 64.91 ns | 57.54 ns |
130- | RuntimeIsAscii | 200 | 5,307.2 ns | 49.18 ns | 46.00 ns |
131- | FastUnicodeIsAscii | 500 | 1,382.2 ns | 9.40 ns | 8.79 ns |
132- | StandardUnicodeIsAscii | 500 | 6,127.7 ns | 57.69 ns | 48.18 ns |
133- | RuntimeIsAscii | 500 | 6,258.2 ns | 62.05 ns | 58.05 ns | */
134-
13595 if ( s . Length > 16 ) // Adjusted for the unrolled loop
13696 {
13797 Vector128 < ushort > total = Sse41 . LoadDquVector128 ( ( ushort * ) pStart ) ;
@@ -147,40 +107,6 @@ public static unsafe bool SIMDIsAscii(this ReadOnlySpan<char> s)
147107 total = Sse2 . Or ( total , raw2 ) ;
148108 }
149109
150- // | Method | N | Mean | Error | StdDev |
151- // |----------------------- |---- |-----------:|----------:|----------:|
152- // | FastUnicodeIsAscii | 100 | 1,601.3 ns | 31.62 ns | 31.05 ns |
153- // | StandardUnicodeIsAscii | 100 | 2,502.5 ns | 49.20 ns | 65.68 ns |
154- // | RuntimeIsAscii | 100 | 2,478.5 ns | 30.08 ns | 26.66 ns |
155- // | FastUnicodeIsAscii | 200 | 653.0 ns | 6.26 ns | 5.86 ns |
156- // | StandardUnicodeIsAscii | 200 | 5,282.7 ns | 102.28 ns | 105.03 ns |
157- // | RuntimeIsAscii | 200 | 5,366.1 ns | 65.50 ns | 61.27 ns |
158- // | FastUnicodeIsAscii | 500 | 1,305.4 ns | 11.85 ns | 11.09 ns |
159- // | StandardUnicodeIsAscii | 500 | 6,235.6 ns | 103.06 ns | 96.40 ns |
160- // | RuntimeIsAscii | 500 | 6,389.6 ns | 103.20 ns | 96.53 ns |
161-
162-
163- // if (s.Length > 32) // Adjusted for the 4x unrolled loop
164- // {
165- // Vector128<ushort> total = Sse41.LoadDquVector128((ushort*)pStart);
166- // i += 8;
167-
168- // // 4x loop unrolling
169- // for (; i + 31 < s.Length; i += 32)
170- // {
171- // Vector128<ushort> raw1 = Sse41.LoadDquVector128((ushort*)pStart + i);
172- // Vector128<ushort> raw2 = Sse41.LoadDquVector128((ushort*)pStart + i + 8);
173- // Vector128<ushort> raw3 = Sse41.LoadDquVector128((ushort*)pStart + i + 16);
174- // Vector128<ushort> raw4 = Sse41.LoadDquVector128((ushort*)pStart + i + 24);
175-
176- // total = Sse2.Or(total, raw1);
177- // total = Sse2.Or(total, raw2);
178- // total = Sse2.Or(total, raw3);
179- // total = Sse2.Or(total, raw4);
180- // }
181-
182-
183-
184110 Vector128 < ushort > b127 = Vector128 . Create ( ( ushort ) 127 ) ;
185111 Vector128 < ushort > b = Sse41 . Max ( b127 , total ) ;
186112 Vector128 < ushort > b16 = Sse41 . CompareEqual ( b , b127 ) ;
0 commit comments