Example #1
0
        public void RunBasicScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));

            var result = Sse2.Xor(
                Sse2.LoadVector128((UInt32 *)(_dataTable.inArray1Ptr)),
                Sse2.LoadVector128((UInt32 *)(_dataTable.inArray2Ptr))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
Example #2
0
        public void RunReflectionScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned));

            var result = typeof(Sse41).GetMethod(nameof(Sse41.RoundToNegativeInfinity), new Type[] { typeof(Vector128 <Double>) })
                         .Invoke(null, new object[] {
                Sse2.LoadAlignedVector128((Double *)(_dataTable.inArrayPtr))
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector128 <Double>)(result));
            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
        }
Example #3
0
        public void RunBasicScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned));

            var result = Sse41.Extract(
                Sse2.LoadAlignedVector128((UInt64 *)(_dataTable.inArrayPtr)),
                129
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
        }
        public void RunBasicScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned));

            Avx2.MaskStore(
                (UInt64 *)_dataTable.outArrayPtr,
                Sse2.LoadAlignedVector128((UInt64 *)(_dataTable.inArray1Ptr)),
                Sse2.LoadAlignedVector128((UInt64 *)(_dataTable.inArray2Ptr))
                );

            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
        public void RunBasicScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned));

            var result = Sse2.ShiftRightLogical(
                Sse2.LoadAlignedVector128((UInt16 *)(_dataTable.inArrayPtr)),
                16
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
        }
        public void RunClsVarScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));

            var result = Sse2.ShiftRightLogical(
                _clsVar,
                16
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_clsVar, _dataTable.outArrayPtr);
        }
        public void RunLclVarScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned));

            var firstOp  = Sse2.LoadAlignedVector128((Int64 *)(_dataTable.inArray1Ptr));
            var secondOp = Sse2.LoadAlignedVector128((Int64 *)(_dataTable.inArray2Ptr));
            var thirdOp  = Sse2.LoadAlignedVector128((Int64 *)(_dataTable.inArray3Ptr));
            var result   = Sse41.BlendVariable(firstOp, secondOp, thirdOp);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr);
        }
        public void RunClsVarScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));

            var result = Sse2.CompareOrdered(
                _clsVar1,
                _clsVar2
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
        }
Example #9
0
        public void RunStructLclFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));

            var test   = TestStruct.Create();
            var result = Avx2.BroadcastScalarToVector128(
                Sse2.LoadVector128((Int32 *)(&test._fld1))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, _dataTable.outArrayPtr);
        }
Example #10
0
        public void RunReflectionScenario_LoadAligned()
        {
            var result = typeof(Fma).GetMethod(nameof(Fma.MultiplyAddScalar), new Type[] { typeof(Vector128 <Double>), typeof(Vector128 <Double>), typeof(Vector128 <Double>) })
                         .Invoke(null, new object[] {
                Sse2.LoadAlignedVector128((Double *)(_dataTable.inArray1Ptr)),
                Sse2.LoadAlignedVector128((Double *)(_dataTable.inArray2Ptr)),
                Sse2.LoadAlignedVector128((Double *)(_dataTable.inArray3Ptr))
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector128 <Double>)(result));
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
        }
Example #11
0
        public void RunReflectionScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned));

            var result = typeof(Avx2).GetMethod(nameof(Avx2.BroadcastScalarToVector128), new Type[] { typeof(Vector128 <Int32>) })
                         .Invoke(null, new object[] {
                Sse2.LoadAlignedVector128((Int32 *)(_dataTable.inArray1Ptr))
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector128 <Int32>)(result));
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
        }
Example #12
0
            public void RunStructFldScenario_Load(SimpleUnaryOpTest__BroadcastScalarToVector128Int32 testClass)
            {
                fixed(Vector128 <Int32> *pFld1 = &_fld1)
                {
                    var result = Avx2.BroadcastScalarToVector128(
                        Sse2.LoadVector128((Int32 *)(pFld1))
                        );

                    Unsafe.Write(testClass._dataTable.outArrayPtr, result);
                    testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
                }
            }
Example #13
0
        public void RunReflectionScenario_LoadAligned()
        {
            var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128 <Int32>), typeof(Int32), typeof(byte) })
                         .Invoke(null, new object[] {
                Sse2.LoadAlignedVector128((Int32 *)(_dataTable.inArrayPtr)),
                (int)2,
                (byte)1
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector128 <Int32>)(result));
            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
        }
        public void RunBasicScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned));

            var result = Ssse3.MultiplyHighRoundScale(
                Sse2.LoadAlignedVector128((Int16 *)(_dataTable.inArray1Ptr)),
                Sse2.LoadAlignedVector128((Int16 *)(_dataTable.inArray2Ptr))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
        public void RunBasicScenario_UnsafeRead()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));

            var result = Sse2.ShiftRightLogical(
                Unsafe.Read <Vector128 <UInt16> >(_dataTable.inArrayPtr),
                16
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
        }
        public void RunBasicScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned));

            var result = Sse2.CompareOrdered(
                Sse2.LoadAlignedVector128((Double *)(_dataTable.inArray1Ptr)),
                Sse2.LoadAlignedVector128((Double *)(_dataTable.inArray2Ptr))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
        public void RunBasicScenario_UnsafeRead()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));

            var result = Sse2.CompareOrdered(
                Unsafe.Read <Vector128 <Double> >(_dataTable.inArray1Ptr),
                Unsafe.Read <Vector128 <Double> >(_dataTable.inArray2Ptr)
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
        public void RunReflectionScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));

            var result = typeof(Sse2).GetMethod(nameof(Sse2.ConvertToVector128Single), new Type[] { typeof(Vector128 <Double>) })
                         .Invoke(null, new object[] {
                Sse2.LoadVector128((Double *)(_dataTable.inArrayPtr))
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector128 <Single>)(result));
            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
        }
Example #19
0
        public static unsafe void AESPseudoRoundXOR(
            byte[] keys,
            byte[] input,
            byte[] xor,
            int offset)
        {
            Vector128 <byte>[] roundKeys = new Vector128 <byte> [10];

            fixed(byte *roundKeyPtr = keys)
            {
                roundKeys[0] = Sse2.LoadVector128(roundKeyPtr + 0);
                roundKeys[1] = Sse2.LoadVector128(roundKeyPtr + 16);
                roundKeys[2] = Sse2.LoadVector128(roundKeyPtr + 32);
                roundKeys[3] = Sse2.LoadVector128(roundKeyPtr + 48);
                roundKeys[4] = Sse2.LoadVector128(roundKeyPtr + 64);
                roundKeys[5] = Sse2.LoadVector128(roundKeyPtr + 80);
                roundKeys[6] = Sse2.LoadVector128(roundKeyPtr + 96);
                roundKeys[7] = Sse2.LoadVector128(roundKeyPtr + 112);
                roundKeys[8] = Sse2.LoadVector128(roundKeyPtr + 128);
                roundKeys[9] = Sse2.LoadVector128(roundKeyPtr + 144);
            }

            fixed(byte *keyPtr = input, xorPtr = xor)
            {
                Vector128 <byte> d;

                int xorOffset = offset;

                for (int i = 0; i < CryptoNight.Constants.INIT_SIZE_BLOCK; i++)
                {
                    d = Sse2.LoadVector128(keyPtr + (i * BLOCK_SIZE));

                    d = Sse2.Xor(d, Sse2.LoadVector128(xorPtr + xorOffset));

                    /* Increase offset by 128 bits (16 bytes) */
                    xorOffset += 16;

                    d = Aes.Encrypt(d, roundKeys[0]);
                    d = Aes.Encrypt(d, roundKeys[1]);
                    d = Aes.Encrypt(d, roundKeys[2]);
                    d = Aes.Encrypt(d, roundKeys[3]);
                    d = Aes.Encrypt(d, roundKeys[4]);
                    d = Aes.Encrypt(d, roundKeys[5]);
                    d = Aes.Encrypt(d, roundKeys[6]);
                    d = Aes.Encrypt(d, roundKeys[7]);
                    d = Aes.Encrypt(d, roundKeys[8]);
                    d = Aes.Encrypt(d, roundKeys[9]);

                    Sse2.Store(keyPtr + (i * BLOCK_SIZE), d);
                }
            }
        }
Example #20
0
        public void RunStructLclFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));

            var test   = TestStruct.Create();
            var result = Sse41.RoundCurrentDirectionScalar(
                Sse2.LoadVector128((Double *)(&test._fld1)),
                Sse2.LoadVector128((Double *)(&test._fld2))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
        }
Example #21
0
        public void RunReflectionScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));

            var result = typeof(Sse41).GetMethod(nameof(Sse41.RoundCurrentDirectionScalar), new Type[] { typeof(Vector128 <Double>), typeof(Vector128 <Double>) })
                         .Invoke(null, new object[] {
                Sse2.LoadVector128((Double *)(_dataTable.inArray1Ptr)),
                Sse2.LoadVector128((Double *)(_dataTable.inArray2Ptr))
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector128 <Double>)(result));
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
        public void RunReflectionScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned));

            var result = typeof(Sse2).GetMethod(nameof(Sse2.ShiftLeftLogical), new Type[] { typeof(Vector128 <UInt32>), typeof(byte) })
                         .Invoke(null, new object[] {
                Sse2.LoadAlignedVector128((UInt32 *)(_dataTable.inArrayPtr)),
                (byte)1
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector128 <UInt32>)(result));
            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
        }
        public void RunBasicScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned));

            var result = Fma.MultiplySubtractNegatedScalar(
                Sse2.LoadAlignedVector128((Double *)(_dataTable.inArray1Ptr)),
                Sse2.LoadAlignedVector128((Double *)(_dataTable.inArray2Ptr)),
                Sse2.LoadAlignedVector128((Double *)(_dataTable.inArray3Ptr))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
        }
            public void RunStructFldScenario_Load(BooleanBinaryOpTest__CompareScalarOrderedLessThanBoolean testClass)
            {
                fixed(Vector128 <Double> *pFld1 = &_fld1)
                fixed(Vector128 <Double> *pFld2 = &_fld2)
                {
                    var result = Sse2.CompareScalarOrderedLessThan(
                        Sse2.LoadVector128((Double *)(pFld1)),
                        Sse2.LoadVector128((Double *)(pFld2))
                        );

                    testClass.ValidateResult(_fld1, _fld2, result);
                }
            }
Example #25
0
        private static void Aes256Assist1(ref Vector128 <byte> t1, ref Vector128 <byte> t2)
        {
            Vector128 <byte> t4;

            t2 = Sse2.Shuffle(t2.AsInt32(), 0xff).AsByte();
            t4 = Sse2.ShiftLeftLogical128BitLane(t1, 0x04);
            t1 = Sse2.Xor(t1, t4);
            t4 = Sse2.ShiftLeftLogical128BitLane(t4, 0x04);
            t1 = Sse2.Xor(t1, t4);
            t4 = Sse2.ShiftLeftLogical128BitLane(t4, 0x04);
            t1 = Sse2.Xor(t1, t4);
            t1 = Sse2.Xor(t1, t2);
        }
Example #26
0
        public void RunStructLclFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));

            var test   = TestStruct.Create();
            var result = Ssse3.HorizontalAdd(
                Sse2.LoadVector128((Int16 *)(&test._fld1)),
                Sse2.LoadVector128((Int16 *)(&test._fld2))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
        }
Example #27
0
        public void RunReflectionScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned));

            var result = typeof(Ssse3).GetMethod(nameof(Ssse3.HorizontalAdd), new Type[] { typeof(Vector128 <Int16>), typeof(Vector128 <Int16>) })
                         .Invoke(null, new object[] {
                Sse2.LoadAlignedVector128((Int16 *)(_dataTable.inArray1Ptr)),
                Sse2.LoadAlignedVector128((Int16 *)(_dataTable.inArray2Ptr))
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector128 <Int16>)(result));
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
        public void RunReflectionScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned));

            var result = typeof(Avx).GetMethod(nameof(Avx.ExtendToVector256))
                         .MakeGenericMethod(new Type[] { typeof(Int64) })
                         .Invoke(null, new object[] {
                Sse2.LoadAlignedVector128((Int64 *)(_dataTable.inArrayPtr))
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector256 <Int64>)(result));
            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
        }
Example #29
0
        public void RunReflectionScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));

            var result = typeof(Sse2).GetMethod(nameof(Sse2.UnpackLow), new Type[] { typeof(Vector128 <UInt64>), typeof(Vector128 <UInt64>) })
                         .Invoke(null, new object[] {
                Sse2.LoadVector128((UInt64 *)(_dataTable.inArray1Ptr)),
                Sse2.LoadVector128((UInt64 *)(_dataTable.inArray2Ptr))
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector128 <UInt64>)(result));
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
Example #30
0
        public void RunReflectionScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned));

            var result = typeof(Sse2.X64).GetMethod(nameof(Sse2.X64.ConvertScalarToVector128Double), new Type[] { typeof(Vector128 <Double>), typeof(Int64) })
                         .Invoke(null, new object[] {
                Sse2.LoadAlignedVector128((Double *)(_dataTable.inArray1Ptr)),
                _dataTable.inData2
            });

            Unsafe.Write(_dataTable.outArrayPtr, (Vector128 <Double>)(result));
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inData2, _dataTable.outArrayPtr);
        }