コード例 #1
0
        static unsafe int Main(string[] args)
        {
            int    testResult          = Pass;
            int    testsCount          = 21;
            string methodUnderTestName = nameof(Sse2.ConvertToInt32);

            if (Sse2.IsSupported)
            {
                using (var doubleTable = TestTableScalarSse2 <double, int> .Create(testsCount, 2.0))
                    using (var intTable = TestTableScalarSse2 <int, int> .Create(testsCount, 4.0))
                    {
                        for (int i = 0; i < testsCount; i++)
                        {
                            doubleTable.SetIndex(i);
                            int result = Sse2.ConvertToInt32(doubleTable.Vector1);
                            doubleTable.SetOutArray(result);
                        }

                        for (int i = 0; i < testsCount; i++)
                        {
                            intTable.SetIndex(i);
                            int result = Sse2.ConvertToInt32(intTable.Vector1);
                            intTable.SetOutArray(result);
                        }

                        CheckMethodEightOne <double, int> checkDouble = (Span <double> x, Span <double> y, int z, ref int a) =>
                        {
                            a = (int)Math.Round(x[0], 0);
                            return(a == z);
                        };

                        if (!doubleTable.CheckResult(checkDouble))
                        {
                            PrintError(doubleTable, methodUnderTestName, "(Span<double> x, Span<double> y, int z, ref int a) => ConvertToInt32", checkDouble);
                            testResult = Fail;
                        }

                        CheckMethodEightOne <int, int> checkInt32 = (Span <int> x, Span <int> y, int z, ref int a) =>
                        {
                            a = x[0];
                            return(a == z);
                        };

                        if (!intTable.CheckResult(checkInt32))
                        {
                            PrintError(intTable, methodUnderTestName, "(Span<int> x, Span<int> y, int z, ref int a) => ConvertToInt32", checkInt32);
                            testResult = Fail;
                        }
                    }
            }
            else
            {
                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
            }

            return(testResult);
        }
コード例 #2
0
ファイル: ConvertToUInt64.cs プロジェクト: omajid/coreclr
        static unsafe int Main(string[] args)
        {
            int    testResult          = Pass;
            int    testsCount          = 21;
            string methodUnderTestName = nameof(Sse2.ConvertToUInt64);

            if (Sse2.IsSupported)
            {
                using (var uintTable = TestTableScalarSse2 <ulong, ulong> .Create(testsCount, 2.0))
                {
                    if (Environment.Is64BitProcess)
                    {
                        for (int i = 0; i < testsCount; i++)
                        {
                            (Vector128 <ulong>, Vector128 <ulong>)value = uintTable[i];
                            var result = Sse2.ConvertToUInt64(value.Item1);
                            uintTable.SetOutArray(result);
                        }

                        CheckMethodEightOne <ulong, ulong> checkUInt64 = (Span <ulong> x, Span <ulong> y, ulong z, ref ulong a) =>
                        {
                            a = x[0];
                            return(a == z);
                        };

                        if (!uintTable.CheckResult(checkUInt64))
                        {
                            PrintError(uintTable, methodUnderTestName, "(Span<int> x, Span<int> y, int z, ref int a) => ConvertToInt32", checkUInt64);
                            testResult = Fail;
                        }
                    }
                    else
                    {
                        try
                        {
                            for (int i = 0; i < testsCount; i++)
                            {
                                (Vector128 <ulong>, Vector128 <ulong>)value = uintTable[i];
                                var result = Sse2.ConvertToUInt64(value.Item1);
                                uintTable.SetOutArray(result);
                            }
                            testResult = Fail;
                            Console.WriteLine($"{nameof(Sse2)}.{methodUnderTestName} failed: expected PlatformNotSupportedException exception.");
                        }
                        catch (PlatformNotSupportedException)
                        {
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
            }

            return(testResult);
        }
コード例 #3
0
        static unsafe int Main(string[] args)
        {
            int    testResult          = Pass;
            int    testsCount          = 21;
            string methodUnderTestName = nameof(Sse2.ConvertToInt64WithTruncation);

            if (Sse2.IsSupported)
            {
                using (var doubleTable = TestTableScalarSse2 <double, long> .Create(testsCount, 2.0))
                {
                    if (Environment.Is64BitProcess)
                    {
                        for (int i = 0; i < testsCount; i++)
                        {
                            (Vector128 <double>, Vector128 <double>)value = doubleTable[i];
                            long result = Sse2.ConvertToInt64WithTruncation(value.Item1);
                            doubleTable.SetOutArray(result);
                        }

                        CheckMethodEightOne <double, long> checkDouble = (Span <double> x, Span <double> y, long z, ref long a) =>
                        {
                            a = (long)x[0];
                            return(a == z);
                        };

                        if (!doubleTable.CheckResult(checkDouble))
                        {
                            PrintError(doubleTable, methodUnderTestName, "(Span<double> x, Span<double> y, long z, ref long a) => ConvertToInt64", checkDouble);
                            testResult = Fail;
                        }
                    }
                    else
                    {
                        try
                        {
                            for (int i = 0; i < testsCount; i++)
                            {
                                (Vector128 <double>, Vector128 <double>)value = doubleTable[i];
                                long result = Sse2.ConvertToInt64WithTruncation(value.Item1);
                                doubleTable.SetOutArray(result);
                            }
                            testResult = Fail;
                            Console.WriteLine($"{nameof(Sse2)}.{methodUnderTestName} failed: expected PlatformNotSupportedException exception.");
                        }
                        catch (PlatformNotSupportedException)
                        {
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
            }

            return(testResult);
        }
コード例 #4
0
        static unsafe int Main(string[] args)
        {
            int    testResult          = Pass;
            int    testsCount          = 21;
            string methodUnderTestName = nameof(Sse2.SumAbsoluteDifferences);

            if (Sse2.IsSupported)
            {
                using (var byteTable = TestTableSse2 <byte, long> .Create(testsCount, 8.0))
                {
                    for (int i = 0; i < testsCount; i++)
                    {
                        (Vector128 <byte>, Vector128 <byte>)value = byteTable[i];
                        var result = Sse2.SumAbsoluteDifferences(value.Item1, value.Item2);
                        byteTable.SetOutArrayU(result);
                    }

                    CheckMethodEightOne <byte, long> checkByte = (Span <byte> x, Span <byte> y, long z, ref long a) =>
                    {
                        short[] tmpArray = new short[8];
                        for (int i = 0; i < 8; i++)
                        {
                            tmpArray[i] = (short)Math.Abs(x[i] - y[i]);
                        }

                        foreach (short s in tmpArray)
                        {
                            a += s;
                        }
                        return(a == z);
                    };

                    if (!byteTable.CheckResult(checkByte))
                    {
                        PrintError(byteTable, methodUnderTestName, "(Span<byte> x, Span<byte> y, long z, ref long a) => SumAbsoluteDifferences", checkByte);
                        testResult = Fail;
                    }
                }
            }
            else
            {
                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
            }

            return(testResult);
        }
コード例 #5
0
        static unsafe int Main(string[] args)
        {
            int    testResult          = Pass;
            int    testsCount          = 21;
            string methodUnderTestName = nameof(Sse2.ConvertToDouble);

            if (Sse2.IsSupported)
            {
                using (var doubleTable = TestTableScalarSse2 <double, double> .Create(testsCount, 2.0))
                {
                    for (int i = 0; i < testsCount; i++)
                    {
                        (Vector128 <double>, Vector128 <double>)value = doubleTable[i];
                        double result = Sse2.ConvertToDouble(value.Item1);
                        doubleTable.SetOutArray(result);
                    }

                    CheckMethodEightOne <double, double> checkDouble = (Span <double> x, Span <double> y, double z, ref double a) =>
                    {
                        a = x[0];
                        return(a == z);
                    };

                    if (!doubleTable.CheckResult(checkDouble))
                    {
                        PrintError(doubleTable, methodUnderTestName, "(Span<double> x, Span<double> y, double z, ref double a) => ConvertToDouble", checkDouble);
                        testResult = Fail;
                    }
                }
            }
            else
            {
                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
            }

            return(testResult);
        }
コード例 #6
0
        static unsafe int Main(string[] args)
        {
            int    testResult          = Pass;
            int    testsCount          = 21;
            string methodUnderTestName = nameof(Sse2.ConvertToUInt32);

            if (Sse2.IsSupported)
            {
                using (var uintTable = TestTableScalarSse2 <uint, uint> .Create(testsCount, 4.0))
                {
                    for (int i = 0; i < testsCount; i++)
                    {
                        (Vector128 <uint>, Vector128 <uint>)value = uintTable[i];
                        var result = Sse2.ConvertToUInt32(value.Item1);
                        uintTable.SetOutArray(result);
                    }

                    CheckMethodEightOne <uint, uint> checkUInt32 = (Span <uint> x, Span <uint> y, uint z, ref uint a) =>
                    {
                        a = x[0];
                        return(a == z);
                    };

                    if (!uintTable.CheckResult(checkUInt32))
                    {
                        PrintError(uintTable, methodUnderTestName, "(Span<int> x, Span<int> y, int z, ref int a) => ConvertToInt32", checkUInt32);
                        testResult = Fail;
                    }
                }
            }
            else
            {
                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
            }

            return(testResult);
        }
コード例 #7
0
        static unsafe int Main(string[] args)
        {
            int    testResult          = Pass;
            int    testsCount          = 21;
            string methodUnderTestName = nameof(Sse2.CompareLessThanOrEqualUnorderedScalar);

            if (Sse2.IsSupported)
            {
                using (var doubleTable = TestTableScalarSse2 <double, bool> .Create(testsCount, 2.0))
                {
                    for (int i = 0; i < testsCount; i++)
                    {
                        (Vector128 <double>, Vector128 <double>)value = doubleTable[i];
                        var result = Sse2.CompareLessThanOrEqualUnorderedScalar(value.Item1, value.Item2);
                        doubleTable.SetOutArray(result);
                    }

                    CheckMethodEightOne <double, bool> checkDouble = (Span <double> x, Span <double> y, bool z, ref bool a) =>
                    {
                        a = x[0] <= y[0] ? true : false;
                        return(a == z);
                    };

                    if (!doubleTable.CheckResult(checkDouble))
                    {
                        PrintError(doubleTable, methodUnderTestName, "(Span<double> x, Span<double> y, bool z, ref bool a) => CompareLessThanOrEqualUnorderedScalar", checkDouble);
                        testResult = Fail;
                    }
                }
            }
            else
            {
                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
            }

            return(testResult);
        }