Exemple #1
0
        private static float8 vdiv_ushort_AVX(ushort8 dividend, ushort8 divisor)
        {
            Assert.AreNotEqual(divisor.x0, 0);
            Assert.AreNotEqual(divisor.x1, 0);
            Assert.AreNotEqual(divisor.x2, 0);
            Assert.AreNotEqual(divisor.x3, 0);
            Assert.AreNotEqual(divisor.x4, 0);
            Assert.AreNotEqual(divisor.x5, 0);
            Assert.AreNotEqual(divisor.x6, 0);
            Assert.AreNotEqual(divisor.x7, 0);

            if (Avx.IsAvxSupported)
            {
                float8 dividend_f32 = dividend;
                float8 divisor_f32  = divisor;

                float8 divisor_f32_rcp = Avx.mm256_rcp_ps(divisor_f32);


                float8 precisionLossCompensation;

                if (Fma.IsFmaSupported)
                {
                    precisionLossCompensation = Fma.mm256_fnmadd_ps(divisor_f32_rcp, divisor_f32, new v256(PRECISION_ADJUSTMENT_FACTOR));
                }
                else
                {
                    precisionLossCompensation = maxmath.mad(-divisor_f32_rcp, divisor_f32, math.asfloat(PRECISION_ADJUSTMENT_FACTOR));
                }

                precisionLossCompensation *= divisor_f32_rcp;
                precisionLossCompensation *= dividend_f32;

                return(precisionLossCompensation);
            }
            else
            {
                throw new CPUFeatureCheckException();
            }
        }