From fbc91fcf2319d8a307d52b00a66d982ee967ad06 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sun, 24 Dec 2017 18:39:57 -0800 Subject: Adding tests for the SSE Set, SetAll, and SetZero intrinsics --- .../HardwareIntrinsics/X86/Sse/SetAllVector128.cs | 79 ++++++++++++++++++++++ .../X86/Sse/SetAllVector128_r.csproj | 34 ++++++++++ .../X86/Sse/SetAllVector128_ro.csproj | 34 ++++++++++ .../JIT/HardwareIntrinsics/X86/Sse/SetVector128.cs | 73 ++++++++++++++++++++ .../X86/Sse/SetVector128_r.csproj | 34 ++++++++++ .../X86/Sse/SetVector128_ro.csproj | 34 ++++++++++ .../HardwareIntrinsics/X86/Sse/SetZeroVector128.cs | 79 ++++++++++++++++++++++ .../X86/Sse/SetZeroVector128_r.csproj | 34 ++++++++++ .../X86/Sse/SetZeroVector128_ro.csproj | 34 ++++++++++ 9 files changed, 435 insertions(+) create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128_ro.csproj (limited to 'tests') diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128.cs new file mode 100644 index 0000000000..576e376df0 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128.cs @@ -0,0 +1,79 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { float.NaN, float.NaN, float.NaN, float.NaN })) + { + var vf1 = Sse.SetAllVector128(3); + Unsafe.Write(floatTable.outArrayPtr, vf1); + + if (!floatTable.CheckResult((x) => x == 3)) + { + Console.WriteLine("SSE SetAllVector128 failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] outArray; + + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle outHandle; + public TestTable(T[] a) + { + this.outArray = a; + + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < outArray.Length; i++) + { + if (!check(outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128_r.csproj new file mode 100644 index 0000000000..c6f792a247 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128_ro.csproj new file mode 100644 index 0000000000..9d8ee1c764 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetAllVector128_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128.cs new file mode 100644 index 0000000000..f9aee743f0 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { float.NaN, float.NaN, float.NaN, float.NaN })) + { + var vf1 = Sse.SetVector128(1, -5, 100, 0); + Unsafe.Write(floatTable.outArrayPtr, vf1); + + if (!floatTable.CheckResult((x) => (x[0] == 0) && (x[1] == 100) && + (x[2] == -5) && (x[3] == 1))) + { + Console.WriteLine("SSE SetVector128 failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] outArray; + + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle outHandle; + public TestTable(T[] a) + { + this.outArray = a; + + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + return check(outArray); + } + + public void Dispose() + { + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128_r.csproj new file mode 100644 index 0000000000..506bce8cc1 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128_ro.csproj new file mode 100644 index 0000000000..ebcf5ed22a --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetVector128_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128.cs new file mode 100644 index 0000000000..8f6d75435b --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128.cs @@ -0,0 +1,79 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Sse.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[4] { float.NaN, float.NaN, float.NaN, float.NaN })) + { + var vf1 = Sse.SetZeroVector128(); + Unsafe.Write(floatTable.outArrayPtr, vf1); + + if (!floatTable.CheckResult((x) => BitConverter.SingleToInt32Bits(x) == 0)) + { + Console.WriteLine("SSE SetZeroVector128 failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + } + } + + + return testResult; + } + + public unsafe struct TestTable : IDisposable where T : struct + { + public T[] outArray; + + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle outHandle; + public TestTable(T[] a) + { + this.outArray = a; + + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + public bool CheckResult(Func check) + { + for (int i = 0; i < outArray.Length; i++) + { + if (!check(outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + outHandle.Free(); + } + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128_r.csproj new file mode 100644 index 0000000000..c081597e67 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128_ro.csproj new file mode 100644 index 0000000000..c8ad3bc4aa --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SetZeroVector128_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + -- cgit v1.2.3