public void RunStructFldScenario(SimpleUnaryOpTest__Abs_Vector128_Int32 testClass)
            {
                var result = AdvSimd.Abs(_fld1);

                Unsafe.Write(testClass._dataTable.outArrayPtr, result);
                testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
            }
        internal static unsafe float AbsMaxAdvSimd64(this ReadOnlySpan <float> array)
        {
            const int StepSize = 4; // Vector128<float>.Count;

            Debug.Assert(array.Length >= StepSize, "Input can't be smaller than the vector size.");

            int len = array.Length;
            int rem = len % StepSize;
            int fit = len - rem;

            fixed(float *p = array)
            {
                Vector128 <float> maxVec = AdvSimd.Abs(AdvSimd.LoadVector128(p));

                for (int i = StepSize; i < fit; i += StepSize)
                {
                    maxVec = AdvSimd.Max(maxVec, AdvSimd.Abs(AdvSimd.LoadVector128(p + i)));
                }

                if (rem != 0)
                {
                    maxVec = AdvSimd.Max(maxVec, AdvSimd.Abs(AdvSimd.LoadVector128(p + len - StepSize)));
                }

                return(AdvSimd.Arm64.MaxAcross(maxVec).ToScalar());
            }
        }
        public void RunClassFldScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));

            var result = AdvSimd.Abs(_fld1);

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

            var test   = TestStruct.Create();
            var result = AdvSimd.Abs(test._fld1);

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

            var test   = new SimpleUnaryOpTest__Abs_Vector128_Int32();
            var result = AdvSimd.Abs(test._fld1);

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

            var op1    = AdvSimd.LoadVector128((Int32 *)(_dataTable.inArray1Ptr));
            var result = AdvSimd.Abs(op1);

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

            var op1    = Unsafe.Read <Vector64 <SByte> >(_dataTable.inArray1Ptr);
            var result = AdvSimd.Abs(op1);

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

            var result = AdvSimd.Abs(
                Unsafe.Read <Vector128 <Int32> >(_dataTable.inArray1Ptr)
                );

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

            var result = AdvSimd.Abs(
                AdvSimd.LoadVector64((SByte *)(_dataTable.inArray1Ptr))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
        }
            public void RunStructFldScenario_Load(SimpleUnaryOpTest__Abs_Vector128_Int32 testClass)
            {
                fixed(Vector128 <Int32> *pFld1 = &_fld1)
                {
                    var result = AdvSimd.Abs(
                        AdvSimd.LoadVector128((Int32 *)(pFld1))
                        );

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

            fixed(Vector128 <Int32> *pFld1 = &_fld1)
            {
                var result = AdvSimd.Abs(
                    AdvSimd.LoadVector128((Int32 *)(pFld1))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(_fld1, _dataTable.outArrayPtr);
            }
        }
Exemple #12
0
        public void RunClsVarScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));

            fixed(Vector64 <SByte> *pClsVar1 = &_clsVar1)
            {
                var result = AdvSimd.Abs(
                    AdvSimd.LoadVector64((SByte *)(pClsVar1))
                    );

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

            var test = new SimpleUnaryOpTest__Abs_Vector128_Int32();

            fixed(Vector128 <Int32> *pFld1 = &test._fld1)
            {
                var result = AdvSimd.Abs(
                    AdvSimd.LoadVector128((Int32 *)(pFld1))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(test._fld1, _dataTable.outArrayPtr);
            }
        }
        private static void AbsAdvSimd(ReadOnlySpan <float> a, Span <float> s)
        {
            var remainder = a.Length & 3;
            var length    = a.Length - remainder;

            fixed(float *ptr = a)
            {
                fixed(float *ptrS = s)
                {
                    for (var i = 0; i < length; i += 4)
                    {
                        var j = AdvSimd.LoadVector128(ptr + i);

                        AdvSimd.Store(ptrS + i, AdvSimd.Abs(j));
                    }
                }
            }

            if (remainder != 0)
            {
                AbsNaive(a, s, length, a.Length);
            }
        }