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); }
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); }
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); }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.CompareUnorderedScalar); if (Sse2.IsSupported) { using (var doubleTable = TestTableScalarSse2 <double, double> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <double>, Vector128 <double>)value = doubleTable[i]; Vector128 <double> result = Sse2.CompareUnorderedScalar(value.Item1, value.Item2); doubleTable.SetOutArray(result); } CheckMethodEight <double, double> checkDouble = (Span <double> x, Span <double> y, Span <double> z, Span <double> a) => { if (double.IsNaN(x[0]) || double.IsNaN(y[0])) { a[0] = BitConverter.Int64BitsToDouble(-1); a[1] = x[1]; } else { a[0] = 0; a[1] = x[1]; } return(BitConverter.DoubleToInt64Bits(a[0]) == BitConverter.DoubleToInt64Bits(z[0]) && BitConverter.DoubleToInt64Bits(a[1]) == BitConverter.DoubleToInt64Bits(z[1])); }; if (!doubleTable.CheckResult(checkDouble)) { PrintError(doubleTable, methodUnderTestName, "(Span<double> x, Span<double> y, Span<double> z, Span<double> a) => CompareUnorderedScalar", checkDouble); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.SqrtScalar); if (Sse2.IsSupported) { using (var doubleTable = TestTableScalarSse2 <double, double> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <double>, Vector128 <double>)value = doubleTable[i]; Vector128 <double> result = Sse2.SqrtScalar(value.Item1); doubleTable.SetOutArray(result); } CheckMethodEight <double, double> checkDouble = (Span <double> x, Span <double> y, Span <double> z, Span <double> a) => { a[0] = Math.Sqrt(x[0]); a[1] = x[1]; return(a[0] == z[0] && a[1] == z[1]); }; if (!doubleTable.CheckResult(checkDouble)) { PrintError(doubleTable, methodUnderTestName, "(Span<double> x, Span<double> y, Span<double> z, Span<double> a) => SqrtScalar", checkDouble); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.MoveScalar); if (Sse2.IsSupported) { using (var longTable = TestTableScalarSse2 <long, long> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <long>, Vector128 <long>)value = longTable[i]; Vector128 <long> result = Sse2.MoveScalar(value.Item1); longTable.SetOutArray(result, i); } CheckMethodEight <long, long> checkLong = (Span <long> x, Span <long> y, Span <long> z, Span <long> a) => { a[0] = x[0]; a[1] = 0; return(a[0] == z[0] && a[1] == z[1]); }; if (!longTable.CheckResult(checkLong)) { PrintError(longTable, methodUnderTestName, "(Span<long> x, Span<long> y, Span<long> z, Span<long> a) => MoveScalar", checkLong); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
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); }
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); }
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); }