public override ulong Run(CancellationToken cancellationToken)
        {
            if (!Ssse3.IsSupported)
            {
                return(0uL);
            }

            var randomFloatingSpan = new Span <int>(new[] { randomInt, randomInt, randomInt, randomInt });
            var dst        = new Span <int>(Enumerable.Repeat(int.MaxValue / 2, 4).ToArray());
            var iterations = 0uL;

            unsafe
            {
                fixed(int *pdst = dst)
                fixed(int *psrc = randomFloatingSpan)
                {
                    var srcVector = Sse2.LoadVector128(psrc);
                    var dstVector = Sse2.LoadVector128(pdst);

                    while (!cancellationToken.IsCancellationRequested)
                    {
                        for (var j = 0; j < LENGTH; j++)
                        {
                            dstVector = Ssse3.HorizontalSubtract(dstVector, srcVector);
                        }

                        Sse2.Store(pdst, dstVector);

                        iterations++;
                    }
                }
            }

            return(iterations);
        }
Beispiel #2
0
            public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalSubtractInt32 testClass)
            {
                var result = Ssse3.HorizontalSubtract(_fld1, _fld2);

                Unsafe.Write(testClass._dataTable.outArrayPtr, result);
                testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
            }
Beispiel #3
0
        public void RunClassFldScenario()
        {
            var result = Ssse3.HorizontalSubtract(_fld1, _fld2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
        }
Beispiel #4
0
        public void RunStructLclFldScenario()
        {
            var test   = TestStruct.Create();
            var result = Ssse3.HorizontalSubtract(test._fld1, test._fld2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
        }
Beispiel #5
0
        public void RunClassLclFldScenario()
        {
            var test   = new HorizontalBinaryOpTest__HorizontalSubtractInt16();
            var result = Ssse3.HorizontalSubtract(test._fld1, test._fld2);

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

            var result = Ssse3.HorizontalSubtract(_fld1, _fld2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
        }
Beispiel #7
0
        public void RunLclVarScenario_LoadAligned()
        {
            var left   = Sse2.LoadAlignedVector128((Int16 *)(_dataTable.inArray1Ptr));
            var right  = Sse2.LoadAlignedVector128((Int16 *)(_dataTable.inArray2Ptr));
            var result = Ssse3.HorizontalSubtract(left, right);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(left, right, _dataTable.outArrayPtr);
        }
Beispiel #8
0
        public void RunLclVarScenario_UnsafeRead()
        {
            var left   = Unsafe.Read <Vector128 <Int16> >(_dataTable.inArray1Ptr);
            var right  = Unsafe.Read <Vector128 <Int16> >(_dataTable.inArray2Ptr);
            var result = Ssse3.HorizontalSubtract(left, right);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(left, right, _dataTable.outArrayPtr);
        }
Beispiel #9
0
        public void RunClsVarScenario()
        {
            var result = Ssse3.HorizontalSubtract(
                _clsVar1,
                _clsVar2
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
        }
Beispiel #10
0
        public void RunBasicScenario_LoadAligned()
        {
            var result = Ssse3.HorizontalSubtract(
                Sse2.LoadAlignedVector128((Int16 *)(_dataTable.inArray1Ptr)),
                Sse2.LoadAlignedVector128((Int16 *)(_dataTable.inArray2Ptr))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
Beispiel #11
0
        public void RunBasicScenario_UnsafeRead()
        {
            var result = Ssse3.HorizontalSubtract(
                Unsafe.Read <Vector128 <Int16> >(_dataTable.inArray1Ptr),
                Unsafe.Read <Vector128 <Int16> >(_dataTable.inArray2Ptr)
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
Beispiel #12
0
        public void RunStructLclFldScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));

            var test   = TestStruct.Create();
            var result = Ssse3.HorizontalSubtract(test._fld1, test._fld2);

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

            var test   = new HorizontalBinaryOpTest__HorizontalSubtractInt32();
            var result = Ssse3.HorizontalSubtract(test._fld1, test._fld2);

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

            var left   = Sse2.LoadVector128((Int16 *)(_dataTable.inArray1Ptr));
            var right  = Sse2.LoadVector128((Int16 *)(_dataTable.inArray2Ptr));
            var result = Ssse3.HorizontalSubtract(left, right);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(left, right, _dataTable.outArrayPtr);
        }
Beispiel #15
0
        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 = Ssse3.HorizontalSubtract(op1, op2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(op1, op2, _dataTable.outArrayPtr);
        }
Beispiel #16
0
        public void RunLclVarScenario_UnsafeRead()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));

            var op1    = Unsafe.Read <Vector128 <Int32> >(_dataTable.inArray1Ptr);
            var op2    = Unsafe.Read <Vector128 <Int32> >(_dataTable.inArray2Ptr);
            var result = Ssse3.HorizontalSubtract(op1, op2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(op1, op2, _dataTable.outArrayPtr);
        }
Beispiel #17
0
        public void RunBasicScenario_UnsafeRead()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));

            var result = Ssse3.HorizontalSubtract(
                Unsafe.Read <Vector128 <Int16> >(_dataTable.inArray1Ptr),
                Unsafe.Read <Vector128 <Int16> >(_dataTable.inArray2Ptr)
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
Beispiel #18
0
        public void RunBasicScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));

            var result = Ssse3.HorizontalSubtract(
                Sse2.LoadVector128((Int32 *)(_dataTable.inArray1Ptr)),
                Sse2.LoadVector128((Int32 *)(_dataTable.inArray2Ptr))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
Beispiel #19
0
        public void RunStructLclFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));

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

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
        }
Beispiel #20
0
            public void RunStructFldScenario_Load(HorizontalBinaryOpTest__HorizontalSubtractInt32 testClass)
            {
                fixed(Vector128 <Int32> *pFld1 = &_fld1)
                fixed(Vector128 <Int32> *pFld2 = &_fld2)
                {
                    var result = Ssse3.HorizontalSubtract(
                        Sse2.LoadVector128((Int32 *)(pFld1)),
                        Sse2.LoadVector128((Int32 *)(pFld2))
                        );

                    Unsafe.Write(testClass._dataTable.outArrayPtr, result);
                    testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
                }
            }
        public void RunClsVarScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));

            fixed(Vector128 <Int16> *pClsVar1 = &_clsVar1)
            fixed(Vector128 <Int16> *pClsVar2 = &_clsVar2)
            {
                var result = Ssse3.HorizontalSubtract(
                    Sse2.LoadVector128((Int16 *)(pClsVar1)),
                    Sse2.LoadVector128((Int16 *)(pClsVar2))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
            }
        }
Beispiel #22
0
        public void RunClassFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));

            fixed(Vector128 <Int32> *pFld1 = &_fld1)
            fixed(Vector128 <Int32> *pFld2 = &_fld2)
            {
                var result = Ssse3.HorizontalSubtract(
                    Sse2.LoadVector128((Int32 *)(pFld1)),
                    Sse2.LoadVector128((Int32 *)(pFld2))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
            }
        }
        public void RunClassLclFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));

            var test = new HorizontalBinaryOpTest__HorizontalSubtractInt16();

            fixed(Vector128 <Int16> *pFld1 = &test._fld1)
            fixed(Vector128 <Int16> *pFld2 = &test._fld2)
            {
                var result = Ssse3.HorizontalSubtract(
                    Sse2.LoadVector128((Int16 *)(pFld1)),
                    Sse2.LoadVector128((Int16 *)(pFld2))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
            }
        }
Beispiel #24
0
 public static Vector128 <int> _mm_hsub_epi32(Vector128 <int> left, Vector128 <int> right)
 {
     return(Ssse3.HorizontalSubtract(left, right));
 }