コード例 #1
0
ファイル: AndNot.Single.cs プロジェクト: omajid/coreclr
        public void RunBasicScenario_LoadAligned()
        {
            var result = Avx.AndNot(
                Avx.LoadAlignedVector256((Single *)(_dataTable.inArray1Ptr)),
                Avx.LoadAlignedVector256((Single *)(_dataTable.inArray2Ptr))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
コード例 #2
0
        public void RunStructLclFldScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));

            var test   = TestStruct.Create();
            var result = Avx.AndNot(test._fld1, test._fld2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
        }
コード例 #3
0
ファイル: AndNot.Single.cs プロジェクト: omajid/coreclr
        public void RunBasicScenario_UnsafeRead()
        {
            var result = Avx.AndNot(
                Unsafe.Read <Vector256 <Single> >(_dataTable.inArray1Ptr),
                Unsafe.Read <Vector256 <Single> >(_dataTable.inArray2Ptr)
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
コード例 #4
0
        public void RunClsVarScenario()
        {
            var result = Avx.AndNot(
                _clsVar1,
                _clsVar2
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
        }
コード例 #5
0
        public void RunClassLclFldScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));

            var test   = new SimpleBinaryOpTest__AndNotDouble();
            var result = Avx.AndNot(test._fld1, test._fld2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
        }
コード例 #6
0
ファイル: AndNot.Single.cs プロジェクト: rfht/coreclr-openbsd
        public void RunLclVarScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));

            var left   = Avx.LoadVector256((Single *)(_dataTable.inArray1Ptr));
            var right  = Avx.LoadVector256((Single *)(_dataTable.inArray2Ptr));
            var result = Avx.AndNot(left, right);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(left, right, _dataTable.outArrayPtr);
        }
コード例 #7
0
ファイル: AndNot.Single.cs プロジェクト: zwei222/coreclr
        public void RunLclVarScenario_UnsafeRead()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));

            var op1    = Unsafe.Read <Vector256 <Single> >(_dataTable.inArray1Ptr);
            var op2    = Unsafe.Read <Vector256 <Single> >(_dataTable.inArray2Ptr);
            var result = Avx.AndNot(op1, op2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(op1, op2, _dataTable.outArrayPtr);
        }
コード例 #8
0
ファイル: AndNot.Single.cs プロジェクト: zwei222/coreclr
        public void RunLclVarScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned));

            var op1    = Avx.LoadAlignedVector256((Single *)(_dataTable.inArray1Ptr));
            var op2    = Avx.LoadAlignedVector256((Single *)(_dataTable.inArray2Ptr));
            var result = Avx.AndNot(op1, op2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(op1, op2, _dataTable.outArrayPtr);
        }
コード例 #9
0
        public void RunBasicScenario_UnsafeRead()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));

            var result = Avx.AndNot(
                Unsafe.Read <Vector256 <Double> >(_dataTable.inArray1Ptr),
                Unsafe.Read <Vector256 <Double> >(_dataTable.inArray2Ptr)
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
コード例 #10
0
        public void RunBasicScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned));

            var result = Avx.AndNot(
                Avx.LoadAlignedVector256((Double *)(_dataTable.inArray1Ptr)),
                Avx.LoadAlignedVector256((Double *)(_dataTable.inArray2Ptr))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
コード例 #11
0
ファイル: AndNot.Single.cs プロジェクト: zwei222/coreclr
        public void RunClsVarScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));

            var result = Avx.AndNot(
                _clsVar1,
                _clsVar2
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
        }
コード例 #12
0
ファイル: AndNot.Single.cs プロジェクト: zwei222/coreclr
        public void RunStructLclFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));

            var test   = TestStruct.Create();
            var result = Avx.AndNot(
                Avx.LoadVector256((Single *)(&test._fld1)),
                Avx.LoadVector256((Single *)(&test._fld2))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
        }
コード例 #13
0
ファイル: AndNot.Single.cs プロジェクト: zwei222/coreclr
            public void RunStructFldScenario_Load(SimpleBinaryOpTest__AndNotSingle testClass)
            {
                fixed(Vector256 <Single> *pFld1 = &_fld1)
                fixed(Vector256 <Single> *pFld2 = &_fld2)
                {
                    var result = Avx.AndNot(
                        Avx.LoadVector256((Single *)(pFld1)),
                        Avx.LoadVector256((Single *)(pFld2))
                        );

                    Unsafe.Write(testClass._dataTable.outArrayPtr, result);
                    testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
                }
            }
コード例 #14
0
ファイル: AndNot.Single.cs プロジェクト: zwei222/coreclr
        public void RunClassFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));

            fixed(Vector256 <Single> *pFld1 = &_fld1)
            fixed(Vector256 <Single> *pFld2 = &_fld2)
            {
                var result = Avx.AndNot(
                    Avx.LoadVector256((Single *)(pFld1)),
                    Avx.LoadVector256((Single *)(pFld2))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
            }
        }
コード例 #15
0
        public void RunClsVarScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));

            fixed(Vector256 <Double> *pClsVar1 = &_clsVar1)
            fixed(Vector256 <Double> *pClsVar2 = &_clsVar2)
            {
                var result = Avx.AndNot(
                    Avx.LoadVector256((Double *)(pClsVar1)),
                    Avx.LoadVector256((Double *)(pClsVar2))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
            }
        }
コード例 #16
0
        public void RunClassLclFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));

            var test = new SimpleBinaryOpTest__AndNotDouble();

            fixed(Vector256 <Double> *pFld1 = &test._fld1)
            fixed(Vector256 <Double> *pFld2 = &test._fld2)
            {
                var result = Avx.AndNot(
                    Avx.LoadVector256((Double *)(pFld1)),
                    Avx.LoadVector256((Double *)(pFld2))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
            }
        }
コード例 #17
0
 // Element-wise absolute value.
 // see https://stackoverflow.com/a/5987631/159834
 public static Vector256 <double> Abs(this Vector256 <double> v)
 => Avx.AndNot(NegZero, v);
コード例 #18
0
        public unsafe void Process(MutableByteImage currentPicture, MutableByteImage nextPicture)
        {
            float MaxFactor = 1;

            float[] attackAr = new float[] { Attack, Attack, Attack, Attack };
            float[] decayAr  = new float[] { Decay, Decay, Decay, Decay };

            int length = nextPicture.Data.Length;

            float *MaxFactorPtr = &MaxFactor;

            fixed(float *AttackPtr = attackAr)
            fixed(float *DecayPtr     = decayAr)
            fixed(byte *currentPicPtr = currentPicture.Data)
            fixed(byte *nextPicPtr    = nextPicture.Data)
            {
                byte *currentPxPtr = currentPicPtr;
                byte *nextPxPtr    = nextPicPtr;


                int remainingLength = length % 4;

                for (int i = 0; i < length; i += 4)
                {
                    var currentColor     = *nextPxPtr;
                    var workingDataColor = *currentPxPtr;

                    var currentColorPtr     = nextPxPtr;
                    var workingDataColorPtr = currentPxPtr;

                    var cmpResult = Avx.ConvertToVector128Single(
                        Sse2.CompareGreaterThan(
                            Sse41.ConvertToVector128Int32(currentColorPtr),
                            Sse41.ConvertToVector128Int32(workingDataColorPtr)
                            ));

                    var pixelFactor = Avx.Add(
                        Avx.And(cmpResult, Avx.BroadcastScalarToVector128(AttackPtr)),
                        Avx.AndNot(cmpResult, Avx.BroadcastScalarToVector128(DecayPtr))
                        );

                    var result = Avx.Add(
                        Avx.Multiply(
                            Avx.Subtract(
                                Avx.BroadcastScalarToVector128(MaxFactorPtr),
                                pixelFactor),
                            Sse41.ConvertToVector128Single(
                                Sse41.ConvertToVector128Int32(workingDataColorPtr))
                            ),
                        Avx.Multiply(
                            pixelFactor,
                            Sse41.ConvertToVector128Single(
                                Sse41.ConvertToVector128Int32(currentColorPtr))));

                    // TODO improve Store
                    *currentPxPtr = (byte)Avx.Extract(result, 0);
                    currentPxPtr++;
                    *currentPxPtr = (byte)Avx.Extract(result, 1);
                    currentPxPtr++;
                    *currentPxPtr = (byte)Avx.Extract(result, 2);
                    currentPxPtr++;
                    *currentPxPtr = (byte)Avx.Extract(result, 3);
                    currentPxPtr++;

                    nextPxPtr += 4;
                }

                for (int i = 0; i < remainingLength; i++)
                {
                    var currentColor     = *nextPxPtr;
                    var workingDataColor = *currentPxPtr;

                    var newPixelFactor = workingDataColor < currentColor ? Attack : Decay;

                    var newPixelValue = (byte)((currentColor * newPixelFactor) + (workingDataColor * (1 - newPixelFactor)));

                    *currentPxPtr = newPixelValue;
                    currentPxPtr++;
                    nextPxPtr++;
                }
            }
        }
コード例 #19
0
        // Bitwise

        public static f32 BitwiseAndNot_f32(f32 a, f32 b)
        {
            return(Avx.AndNot(b, a));
        }
コード例 #20
0
 public static f32 NMask_f32(f32 a, m32 m)
 {
     return(Avx.AndNot(m.AsSingle(), a));
 }