public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Sse2.CompareEqual(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); }
public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__CompareEqualUInt32(); var result = Sse2.CompareEqual(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); }
public void RunBasicScenario_LoadAligned() { var result = Sse2.CompareEqual( Sse2.LoadAlignedVector128((UInt16 *)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((UInt16 *)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); }
public void RunClsVarScenario() { var result = Sse2.CompareEqual( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); }
public void RunBasicScenario_UnsafeRead() { var result = Sse2.CompareEqual( Unsafe.Read <Vector128 <UInt16> >(_dataTable.inArray1Ptr), Unsafe.Read <Vector128 <UInt16> >(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); }
public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var op1 = Sse2.LoadAlignedVector128((Int32 *)(_dataTable.inArray1Ptr)); var op2 = Sse2.LoadAlignedVector128((Int32 *)(_dataTable.inArray2Ptr)); var result = Sse2.CompareEqual(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); }
public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var left = Unsafe.Read <Vector128 <Int32> >(_dataTable.inArray1Ptr); var right = Unsafe.Read <Vector128 <Int32> >(_dataTable.inArray2Ptr); var result = Sse2.CompareEqual(left, right); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(left, right, _dataTable.outArrayPtr); }
public static Vector128 <sbyte> CreateEscapingMask_UnsafeRelaxedJavaScriptEncoder(Vector128 <sbyte> sourceValue) { Debug.Assert(Sse2.IsSupported); Vector128 <sbyte> mask = Sse2.CompareLessThan(sourceValue, s_mask_SByte_0x20); // Control characters, and anything above 0x7E since sbyte.MaxValue is 0x7E mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_SByte_0x22)); // Quotation Mark " mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_SByte_0x5C)); // Reverse Solidus \ return(mask); }
public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var left = Sse2.LoadAlignedVector128((Byte *)(_dataTable.inArray1Ptr)); var right = Sse2.LoadAlignedVector128((Byte *)(_dataTable.inArray2Ptr)); var result = Sse2.CompareEqual(left, right); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(left, right, _dataTable.outArrayPtr); }
public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read <Vector128 <Byte> >(_dataTable.inArray1Ptr); var op2 = Unsafe.Read <Vector128 <Byte> >(_dataTable.inArray2Ptr); var result = Sse2.CompareEqual(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); }
public static bool IntrinsicEquality(this float left, float right) { var vLeft = Vector128.CreateScalarUnsafe(left).AsInt32(); var vRight = Vector128.CreateScalarUnsafe(right).AsInt32(); vLeft = Sse2.CompareEqual(vLeft, vRight); int mask = Sse.MoveMask(vLeft.AsSingle()); return(mask == -1); }
public static Vector128 <short> CreateEscapingMask_UnsafeRelaxedJavaScriptEncoder(Vector128 <short> sourceValue) { Debug.Assert(Sse2.IsSupported); // Space ' ', anything in the control characters range, and anything above short.MaxValue but less than or equal char.MaxValue Vector128 <short> mask = Sse2.CompareLessThan(sourceValue, s_mask_UInt16_0x20); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_UInt16_0x22)); // Quotation Mark '"' mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_UInt16_0x5C)); // Reverse Solidus '\' return(mask); }
public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Sse2.CompareEqual( Unsafe.Read <Vector128 <SByte> >(_dataTable.inArray1Ptr), Unsafe.Read <Vector128 <SByte> >(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); }
public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Sse2.CompareEqual( Sse2.LoadVector128((Byte *)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((Byte *)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); }
public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Sse2.CompareEqual( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); }
public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = Sse2.CompareEqual( Sse2.LoadVector128((Int32 *)(&test._fld1)), Sse2.LoadVector128((Int32 *)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); }
public static Vector128 <sbyte> CreateEscapingMask( Vector128 <sbyte> sourceValue, Vector128 <sbyte> bitMaskLookup, Vector128 <sbyte> bitPosLookup, Vector128 <sbyte> nibbleMaskSByte, Vector128 <sbyte> nullMaskSByte) { // To check if an input byte needs to be escaped or not, we use a bitmask-lookup. // Therefore we split the input byte into the low- and high-nibble, which will get // the row-/column-index in the bit-mask. // The bitmask-lookup looks like (here for example s_bitMaskLookupBasicLatin): // high-nibble // low-nibble 0 1 2 3 4 5 6 7 8 9 A B C D E F // 0 1 1 0 0 0 0 1 0 1 1 1 1 1 1 1 1 // 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 // 2 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 // 3 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 // 4 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 // 5 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 // 6 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 // 7 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 // 8 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 // 9 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 // A 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 // B 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 // C 1 1 0 1 0 1 0 0 1 1 1 1 1 1 1 1 // D 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 // E 1 1 0 1 0 0 0 0 1 1 1 1 1 1 1 1 // F 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 // // where 1 denotes the neeed for escaping, while 0 means no escaping needed. // For high-nibbles in the range 8..F every input needs to be escaped, so we // can omit them in the bit-mask, thus only high-nibbles in the range 0..7 need // to be considered, hence the entries in the bit-mask can be of type byte. // // In the bitmask-lookup for each row (= low-nibble) a bit-mask for the // high-nibbles (= columns) is created. Debug.Assert(Ssse3.IsSupported); Vector128 <sbyte> highNibbles = Sse2.And(Sse2.ShiftRightLogical(sourceValue.AsInt32(), 4).AsSByte(), nibbleMaskSByte); Vector128 <sbyte> lowNibbles = Sse2.And(sourceValue, nibbleMaskSByte); Vector128 <sbyte> bitMask = Ssse3.Shuffle(bitMaskLookup, lowNibbles); Vector128 <sbyte> bitPositions = Ssse3.Shuffle(bitPosLookup, highNibbles); Vector128 <sbyte> mask = Sse2.And(bitPositions, bitMask); mask = Sse2.CompareEqual(nullMaskSByte, Sse2.CompareEqual(nullMaskSByte, mask)); return(mask); }
public void RunStructFldScenario_Load(SimpleBinaryOpTest__CompareEqualByte testClass) { fixed(Vector128 <Byte> *pFld1 = &_fld1) fixed(Vector128 <Byte> *pFld2 = &_fld2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((Byte *)(pFld1)), Sse2.LoadVector128((Byte *)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } }
public static unsafe void CalculateDiagonalSection_Sse41 <T>(void *refDiag1Ptr, void *refDiag2Ptr, char *sourcePtr, char *targetPtr, ref int rowIndex, int columnIndex) where T : struct { if (typeof(T) == typeof(int)) { var diag1Ptr = (int *)refDiag1Ptr; var diag2Ptr = (int *)refDiag2Ptr; var sourceVector = Sse41.ConvertToVector128Int32((ushort *)sourcePtr + rowIndex - Vector128 <T> .Count); var targetVector = Sse41.ConvertToVector128Int32((ushort *)targetPtr + columnIndex - 1); targetVector = Sse2.Shuffle(targetVector, 0x1b); var substitutionCostAdjustment = Sse2.CompareEqual(sourceVector, targetVector); var substitutionCost = Sse2.Add( Sse3.LoadDquVector128(diag1Ptr + rowIndex - Vector128 <T> .Count), substitutionCostAdjustment ); var deleteCost = Sse3.LoadDquVector128(diag2Ptr + rowIndex - (Vector128 <T> .Count - 1)); var insertCost = Sse3.LoadDquVector128(diag2Ptr + rowIndex - Vector128 <T> .Count); var localCost = Sse41.Min(Sse41.Min(insertCost, deleteCost), substitutionCost); localCost = Sse2.Add(localCost, Vector128.Create(1)); Sse2.Store(diag1Ptr + rowIndex - (Vector128 <T> .Count - 1), localCost); } else if (typeof(T) == typeof(ushort)) { var diag1Ptr = (ushort *)refDiag1Ptr; var diag2Ptr = (ushort *)refDiag2Ptr; var sourceVector = Sse3.LoadDquVector128((ushort *)sourcePtr + rowIndex - Vector128 <T> .Count); var targetVector = Sse3.LoadDquVector128((ushort *)targetPtr + columnIndex - 1); targetVector = Ssse3.Shuffle(targetVector.AsByte(), REVERSE_USHORT_AS_BYTE_128).AsUInt16(); var substitutionCostAdjustment = Sse2.CompareEqual(sourceVector, targetVector); var substitutionCost = Sse2.Add( Sse3.LoadDquVector128(diag1Ptr + rowIndex - Vector128 <T> .Count), substitutionCostAdjustment ); var deleteCost = Sse3.LoadDquVector128(diag2Ptr + rowIndex - (Vector128 <T> .Count - 1)); var insertCost = Sse3.LoadDquVector128(diag2Ptr + rowIndex - Vector128 <T> .Count); var localCost = Sse41.Min(Sse41.Min(insertCost, deleteCost), substitutionCost); localCost = Sse2.Add(localCost, Vector128.Create((ushort)1)); Sse2.Store(diag1Ptr + rowIndex - (Vector128 <T> .Count - 1), localCost); } }
public static Vector128 <sbyte> CreateEscapingMask_DefaultJavaScriptEncoderBasicLatin(Vector128 <sbyte> sourceValue) { Debug.Assert(Sse2.IsSupported); Vector128 <sbyte> mask = CreateEscapingMask_UnsafeRelaxedJavaScriptEncoder(sourceValue); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_ampersandMaskSByte)); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_apostropheMaskSByte)); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_plusSignMaskSByte)); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_lessThanSignMaskSByte)); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_greaterThanSignMaskSByte)); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_graveAccentMaskSByte)); return(mask); }
public static Vector128 <sbyte> CreateEscapingMask_DefaultJavaScriptEncoderBasicLatin(Vector128 <sbyte> sourceValue) { Debug.Assert(Sse2.IsSupported); Vector128 <sbyte> mask = CreateEscapingMask_UnsafeRelaxedJavaScriptEncoder(sourceValue); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_SByte_0x26)); // Ampersand & mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_SByte_0x27)); // Apostrophe ' mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_SByte_0x2B)); // Plus sign + mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_SByte_0x3C)); // Less Than Sign < mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_SByte_0x3E)); // Greater Than Sign > mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_SByte_0x60)); // Grave Access ` return(mask); }
public unsafe static bool Compare128(byte *b0, byte *b1, int length) { const int mask = 0xFFFF; byte *lastAddr = b0 + length; byte *lastAddrMinus64 = lastAddr - 64; // unroll the loop so that we are comparing 64 bytes at a time. while (b0 < lastAddrMinus64) { if (Sse2.MoveMask(Sse2.CompareEqual(Sse2.LoadVector128(b0), Sse2.LoadVector128(b1))) != mask) { return(false); } if (Sse2.MoveMask(Sse2.CompareEqual(Sse2.LoadVector128(b0 + 16), Sse2.LoadVector128(b1 + 16))) != mask) { return(false); } if (Sse2.MoveMask(Sse2.CompareEqual(Sse2.LoadVector128(b0 + 32), Sse2.LoadVector128(b1 + 32))) != mask) { return(false); } if (Sse2.MoveMask(Sse2.CompareEqual(Sse2.LoadVector128(b0 + 48), Sse2.LoadVector128(b1 + 48))) != mask) { return(false); } b0 += 64; b1 += 64; } while (b0 < lastAddr) { if (*b0 != *b1) { return(false); } b0++; b1++; } return(true); }
unsafe private static void denoiseLineSse2(byte *pcurr, byte *pprev, byte *pnext, int cb) { byte *ip = pcurr, pp = pprev, np = pnext; nuint cnt = 0, end = (nuint)cb - (nuint)Vector128 <byte> .Count; var voffset = Vector128.Create((byte)0x80); var vthresh = Vector128.Create(denoiseThreshold); LoopTop: do { var vcurr = Sse2.LoadVector128(ip + cnt); var vprev = Sse2.LoadVector128(pp + cnt); var vnext = Sse2.LoadVector128(np + cnt); var vdiffp = Sse2.Or(Sse2.SubtractSaturate(vcurr, vprev), Sse2.SubtractSaturate(vprev, vcurr)); var vmaskp = Sse2.CompareEqual(Sse2.Max(vdiffp, vthresh), vthresh); var vdiffn = Sse2.Or(Sse2.SubtractSaturate(vcurr, vnext), Sse2.SubtractSaturate(vnext, vcurr)); var vmaskn = Sse2.CompareEqual(Sse2.Max(vdiffn, vthresh), vthresh); var vavgp = Sse2.Average(vcurr, vprev); var vavgn = Sse2.Average(vcurr, vnext); var voutval = Sse2.Average(HWIntrinsics.BlendVariable(vavgn, vavgp, vmaskp), HWIntrinsics.BlendVariable(vavgp, vavgn, vmaskn)); var voutmsk = Sse2.Or(vmaskp, vmaskn); voutval = Sse2.Average(voutval, HWIntrinsics.BlendVariable(voutval, Sse2.Average(vprev, vnext), Sse2.And(vmaskp, vmaskn))); var vcurrs = Sse2.Xor(vcurr, voffset).AsSByte(); var vprevs = Sse2.Xor(vprev, voffset).AsSByte(); var vnexts = Sse2.Xor(vnext, voffset).AsSByte(); var vsurlt = Sse2.And(Sse2.CompareGreaterThan(vcurrs, vprevs), Sse2.CompareGreaterThan(vcurrs, vnexts)); var vsurgt = Sse2.And(Sse2.CompareGreaterThan(vprevs, vcurrs), Sse2.CompareGreaterThan(vnexts, vcurrs)); voutmsk = Sse2.And(voutmsk, Sse2.Or(vsurlt, vsurgt).AsByte()); voutval = HWIntrinsics.BlendVariable(vcurr, voutval, voutmsk); Sse2.Store(ip + cnt, voutval); cnt += (nuint)Vector128 <byte> .Count; } while (cnt <= end); if (cnt < end + (nuint)Vector128 <byte> .Count) { cnt = end; goto LoopTop; } }
public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed(Vector128 <Byte> *pFld1 = &_fld1) fixed(Vector128 <Byte> *pFld2 = &_fld2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((Byte *)(pFld1)), Sse2.LoadVector128((Byte *)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } }
public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed(Vector128 <Int32> *pClsVar1 = &_clsVar1) fixed(Vector128 <Int32> *pClsVar2 = &_clsVar2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((Int32 *)(pClsVar1)), Sse2.LoadVector128((Int32 *)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } }
private static unsafe int FillBuffer(ReadOnlySpan <char> input) { int count = Math.Min(LineBuffer.Length, input.Length); int i = 0; fixed(char *buffer = LineBuffer, pInput = input) { if (Sse2.IsSupported && count >= Vector128 <ushort> .Count) { Vector128 <ushort> Space = Vector128.Create(SpaceCharUShort); //Space character do { var data = Sse2.LoadVector128((ushort *)pInput + i); var comp = Vector128 <ushort> .Zero; comp = Sse2.CompareEqual(comp, data); if (Sse41.IsSupported) { data = Sse41.BlendVariable(data, Space, comp); } else { comp = Sse2.And(comp, Space); data = Sse2.Or(data, comp); //Elements being replaced are already 0'ed } Sse2.Store((ushort *)buffer + i, data); i += Vector128 <ushort> .Count; }while ((count - i) >= Vector128 <ushort> .Count); } while (i < count) { char tmp = pInput[i]; buffer[i] = tmp == 0 ? ' ' : tmp; i += 1; } return(count); } }
public static Vector128 <sbyte> CreateEscapingMask_UnsafeRelaxedJavaScriptEncoder(Vector128 <sbyte> sourceValue) { Debug.Assert(Sse2.IsSupported); // Anything in the control characters range (except 0x7F), and anything above sbyte.MaxValue but less than or equal byte.MaxValue // That's because anything between 128 and 255 (inclusive) will overflow and become negative. Vector128 <sbyte> mask = Sse2.CompareLessThan(sourceValue, s_spaceMaskSByte); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_quotationMarkMaskSByte)); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_reverseSolidusMaskSByte)); // Leftover control character in the ASCII range - 0x7F // Since we are dealing with sbytes, 0x7F is the only value that would meet this comparison. mask = Sse2.Or(mask, Sse2.CompareGreaterThan(sourceValue, s_tildeMaskSByte)); return(mask); }
public static Vector128 <short> CreateEscapingMask_DefaultJavaScriptEncoderBasicLatin(Vector128 <short> sourceValue) { Debug.Assert(Sse2.IsSupported); Vector128 <short> mask = CreateEscapingMask_UnsafeRelaxedJavaScriptEncoder(sourceValue); mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_UInt16_0x26)); // Ampersand '&' mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_UInt16_0x27)); // Apostrophe ''' mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_UInt16_0x2B)); // Plus sign '+' mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_UInt16_0x3C)); // Less Than Sign '<' mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_UInt16_0x3E)); // Greater Than Sign '>' mask = Sse2.Or(mask, Sse2.CompareEqual(sourceValue, s_mask_UInt16_0x60)); // Grave Access '`' mask = Sse2.Or(mask, Sse2.CompareGreaterThan(sourceValue, s_mask_UInt16_0x7E)); // Tilde '~', anything above the ASCII range return(mask); }
public static unsafe bool Intrinsics(string value1, string value2) { // NotNull & NotObjectEquals var length = value1.Length; if (length != value2.Length) { return(false); } const int vectorSize = 128 / 8; const int equalsMask = unchecked ((int)(0b1111_1111_1111_1111_1111_1111_1111_1111)); fixed(char *pValue1 = value1) fixed(char *pValue2 = value2) { var ptrA = (byte *)pValue1; var ptrB = (byte *)pValue2; var i = 0; var size = length << 1; for (; i <= size - vectorSize; i += vectorSize) { var va = Sse2.LoadVector128(ptrA + i); var vb = Sse2.LoadVector128(ptrB + i); var areEqual = Sse2.CompareEqual(va, vb); if (Sse2.MoveMask(areEqual) != equalsMask) { return(false); } } // Not suitable < 16 for (; i < size; i++) { if (ptrA[i] != ptrB[i]) { return(false); } } return(true); } }
public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__CompareEqualInt32(); fixed(Vector128 <Int32> *pFld1 = &test._fld1) fixed(Vector128 <Int32> *pFld2 = &test._fld2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((Int32 *)(pFld1)), Sse2.LoadVector128((Int32 *)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } }