From c3e5ff2ab9d94c90b0c2d7effbd5ed573f819a00 Mon Sep 17 00:00:00 2001 From: Fei Peng Date: Mon, 26 Mar 2018 17:09:22 -0700 Subject: Port VectorReturn test to Vector128/256 --- .../HardwareIntrinsics/X86/General/IsSupported.cs | 56 ++ .../X86/General/IsSupported_r.csproj | 33 ++ .../X86/General/IsSupported_ro.csproj | 33 ++ .../HardwareIntrinsics/X86/General/VectorRet.cs | 644 +++++++++++++++++++++ .../X86/General/VectorRet_r.csproj | 34 ++ .../X86/General/VectorRet_ro.csproj | 34 ++ .../src/JIT/HardwareIntrinsics/X86/IsSupported.cs | 56 -- .../HardwareIntrinsics/X86/IsSupported_r.csproj | 33 -- .../HardwareIntrinsics/X86/IsSupported_ro.csproj | 33 -- 9 files changed, 834 insertions(+), 122 deletions(-) create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet_ro.csproj delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/IsSupported.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/IsSupported_r.csproj delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/IsSupported_ro.csproj (limited to 'tests/src/JIT') diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported.cs b/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported.cs new file mode 100644 index 0000000000..abdc108536 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported.cs @@ -0,0 +1,56 @@ +// 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.Intrinsics.X86; +using System.Numerics; + +namespace IntelHardwareIntrinsicTest +{ + class Program + { + static int Main(string[] args) + { + bool result = true; + + if (Sse.IsSupported && int.TryParse(Environment.GetEnvironmentVariable("COMPlus_EnableIncompleteISAClass"), out var enableIncompleteIsa) && (enableIncompleteIsa != 0)) + { + // X86 platforms + if (Vector.Count == 32 && !Avx2.IsSupported) + { + result = false; + } + + if (Vector.Count == 16 && Vector.IsHardwareAccelerated && !Sse2.IsSupported) + { + result = false; + } + } + + // Reflection call + var issupported = "get_IsSupported"; + if (Convert.ToBoolean(typeof(Sse).GetMethod(issupported).Invoke(null, null)) != Sse.IsSupported || + Convert.ToBoolean(typeof(Sse2).GetMethod(issupported).Invoke(null, null)) != Sse2.IsSupported || + Convert.ToBoolean(typeof(Sse3).GetMethod(issupported).Invoke(null, null)) != Sse3.IsSupported || + Convert.ToBoolean(typeof(Ssse3).GetMethod(issupported).Invoke(null, null)) != Ssse3.IsSupported || + Convert.ToBoolean(typeof(Sse41).GetMethod(issupported).Invoke(null, null)) != Sse41.IsSupported || + Convert.ToBoolean(typeof(Sse42).GetMethod(issupported).Invoke(null, null)) != Sse42.IsSupported || + Convert.ToBoolean(typeof(Aes).GetMethod(issupported).Invoke(null, null)) != Aes.IsSupported || + Convert.ToBoolean(typeof(Avx).GetMethod(issupported).Invoke(null, null)) != Avx.IsSupported || + Convert.ToBoolean(typeof(Avx2).GetMethod(issupported).Invoke(null, null)) != Avx2.IsSupported || + Convert.ToBoolean(typeof(Fma).GetMethod(issupported).Invoke(null, null)) != Fma.IsSupported || + Convert.ToBoolean(typeof(Lzcnt).GetMethod(issupported).Invoke(null, null)) != Lzcnt.IsSupported || + Convert.ToBoolean(typeof(Bmi1).GetMethod(issupported).Invoke(null, null)) != Bmi1.IsSupported || + Convert.ToBoolean(typeof(Bmi2).GetMethod(issupported).Invoke(null, null)) != Bmi2.IsSupported || + Convert.ToBoolean(typeof(Popcnt).GetMethod(issupported).Invoke(null, null)) != Popcnt.IsSupported || + Convert.ToBoolean(typeof(Pclmulqdq).GetMethod(issupported).Invoke(null, null)) != Pclmulqdq.IsSupported + ) + { + result = false; + } + return result ? 100 : 0; + } + + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported_r.csproj new file mode 100644 index 0000000000..e77c5dc2ad --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported_r.csproj @@ -0,0 +1,33 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + None + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported_ro.csproj new file mode 100644 index 0000000000..e8f88b5a40 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/IsSupported_ro.csproj @@ -0,0 +1,33 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + None + True + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet.cs b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet.cs new file mode 100644 index 0000000000..479b529e07 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet.cs @@ -0,0 +1,644 @@ +// 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.Intrinsics; +using System.Runtime.Intrinsics.X86; +using System.Runtime.CompilerServices; + +internal partial class IntelHardwareIntrinsicTest +{ + private const int Pass = 100; + private const int Fail = -1; + + private static Vector128[] s_v128_array; + private static Vector128 s_v128_0; + private static Vector128 s_v128_1; + private static Vector128 s_v128_2; + private static Vector128 s_v128_3; + + private static Vector128[] s_v128i_array; + private static Vector128 s_v128i_0; + private static Vector128 s_v128i_1; + private static Vector128 s_v128i_2; + private static Vector128 s_v128i_3; + + private static Vector256[] s_v256_array; + private static Vector256 s_v256_0; + private static Vector256 s_v256_1; + private static Vector256 s_v256_2; + private static Vector256 s_v256_3; + + private static Vector256[] s_v256i_array; + private static Vector256 s_v256i_0; + private static Vector256 s_v256i_1; + private static Vector256 s_v256i_2; + private static Vector256 s_v256i_3; + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void init() + { + Random random = new Random(100); + + if (Sse.IsSupported) + { + s_v128_array = new Vector128[10]; + for (int i = 0; i < 10; i++) + { + s_v128_array[i] = Sse.SetAllVector128(random.Next(100)); + } + s_v128_0 = Sse.SetAllVector128((float)random.Next(100)); + s_v128_1 = Sse.SetAllVector128((float)random.Next(100)); + s_v128_2 = Sse.SetAllVector128((float)random.Next(100)); + s_v128_3 = Sse.SetAllVector128((float)random.Next(100)); + } + + if (Sse2.IsSupported) + { + s_v128i_array = new Vector128[10]; + for (int i = 0; i < 10; i++) + { + s_v128i_array[i] = Sse2.SetAllVector128((short)random.Next(100)); + } + s_v128i_0 = Sse2.SetAllVector128((short)random.Next(100)); + s_v128i_1 = Sse2.SetAllVector128((short)random.Next(100)); + s_v128i_2 = Sse2.SetAllVector128((short)random.Next(100)); + s_v128i_3 = Sse2.SetAllVector128((short)random.Next(100)); + } + + if (Avx.IsSupported) + { + s_v256_array = new Vector256[10]; + for (int i = 0; i < 10; i++) + { + s_v256_array[i] = Avx.SetAllVector256((float)random.Next(100)); + } + s_v256_0 = Avx.SetAllVector256((float)random.Next(100)); + s_v256_1 = Avx.SetAllVector256((float)random.Next(100)); + s_v256_2 = Avx.SetAllVector256((float)random.Next(100)); + s_v256_3 = Avx.SetAllVector256((float)random.Next(100)); + } + + if (Avx2.IsSupported) + { + s_v256i_array = new Vector256[10]; + for (int i = 0; i < 10; i++) + { + s_v256i_array[i] = Avx.SetAllVector256((byte)random.Next(100)); + } + s_v256i_0 = Avx.SetAllVector256((byte)random.Next(100)); + s_v256i_1 = Avx.SetAllVector256((byte)random.Next(100)); + s_v256i_2 = Avx.SetAllVector256((byte)random.Next(100)); + s_v256i_3 = Avx.SetAllVector256((byte)random.Next(100)); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector128 F1_v128(float t) + { + float ti = 1 - t; + float t0 = ti * ti * ti; + float t1 = 3 * ti * ti * t; + float t2 = 3 * ti * t * t; + float t3 = t * t * t; + Vector128 tmp1 = Sse.Add(Sse.Subtract(Sse.SetAllVector128(t0), s_v128_0), Sse.Subtract(Sse.SetAllVector128(t1), s_v128_1)); + Vector128 tmp2 = Sse.Add(Sse.Subtract(Sse.SetAllVector128(t2), s_v128_2), Sse.Subtract(Sse.SetAllVector128(t3), s_v128_3)); + return Sse.Add(tmp1, tmp2); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector128 F2_v128(float u) + { + if (u < 0) + return s_v128_array[0]; + if (u >= 1) + return s_v128_array[1]; + if (u < 0.1) + return s_v128_array[2]; + if (u > 0.9) + return s_v128_array[3]; + return F1_v128(u); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector128 F1_v128i(int t) + { + int ti = 1 - t; + int t0 = ti * ti * ti; + int t1 = 3 * ti * ti * t; + int t2 = 3 * ti * t * t; + int t3 = t * t * t; + Vector128 tmp1 = Sse2.Add(Sse2.Subtract(Sse2.SetAllVector128((short)t0), s_v128i_0), Sse2.Subtract(Sse2.SetAllVector128((short)t1), s_v128i_1)); + Vector128 tmp2 = Sse2.Add(Sse2.Subtract(Sse2.SetAllVector128((short)t2), s_v128i_2), Sse2.Subtract(Sse2.SetAllVector128((short)t3), s_v128i_3)); + return Sse2.Add(tmp1, tmp2); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector128 F2_v128i(short u) + { + if (u < 0) + return s_v128i_array[0]; + if (u >= 10) + return s_v128i_array[1]; + if (u < 0.1) + return s_v128i_array[2]; + if (u > 90) + return s_v128i_array[3]; + return F1_v128i(u); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector256 F1_v256(float t) + { + float ti = 1 - t; + float t0 = ti * ti * ti; + float t1 = 3 * ti * ti * t; + float t2 = 3 * ti * t * t; + float t3 = t * t * t; + Vector256 tmp1 = Avx.Add(Avx.Subtract(Avx.SetAllVector256(t0), s_v256_0), Avx.Subtract(Avx.SetAllVector256(t1), s_v256_1)); + Vector256 tmp2 = Avx.Add(Avx.Subtract(Avx.SetAllVector256(t2), s_v256_2), Avx.Subtract(Avx.SetAllVector256(t3), s_v256_3)); + return Avx.Add(tmp1, tmp2); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector256 F2_v256(float u) + { + if (u < 0) + return s_v256_array[0]; + if (u >= 1) + return s_v256_array[1]; + if (u < 0.1) + return s_v256_array[2]; + if (u > 0.9) + return s_v256_array[3]; + return F1_v256(u); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector256 F1_v256i(int t) + { + int ti = 1 - t; + int t0 = ti * ti * ti; + int t1 = 3 * ti * ti * t; + int t2 = 3 * ti * t * t; + int t3 = t * t * t; + Vector256 tmp1 = Avx2.Add(Avx2.Subtract(Avx.SetAllVector256((byte)t0), s_v256i_0), Avx2.Subtract(Avx.SetAllVector256((byte)t1), s_v256i_1)); + Vector256 tmp2 = Avx2.Add(Avx2.Subtract(Avx.SetAllVector256((byte)t2), s_v256i_2), Avx2.Subtract(Avx.SetAllVector256((byte)t3), s_v256i_3)); + return Avx2.Add(tmp1, tmp2); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector256 F2_v256i(byte u) + { + if (u < 0) + return s_v256i_array[0]; + if (u >= 10) + return s_v256i_array[1]; + if (u < 0.1) + return s_v256i_array[2]; + if (u > 90) + return s_v256i_array[3]; + return F1_v256i(u); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector128 Vector128One() where T : struct + { + if (typeof(T) == typeof(float)) + { + return Sse.StaticCast(Sse.SetAllVector128(1.0f)); + } + else if (typeof(T) == typeof(double)) + { + return Sse.StaticCast(Sse2.SetAllVector128((double)1)); + } + else if (typeof(T) == typeof(byte)) + { + return Sse.StaticCast(Sse2.SetAllVector128((byte)1)); + } + else if (typeof(T) == typeof(sbyte)) + { + return Sse.StaticCast(Sse2.SetAllVector128((sbyte)1)); + } + else if (typeof(T) == typeof(short)) + { + return Sse.StaticCast(Sse2.SetAllVector128((short)1)); + } + else if (typeof(T) == typeof(ushort)) + { + return Sse.StaticCast(Sse2.SetAllVector128((ushort)1)); + } + else if (typeof(T) == typeof(int)) + { + return Sse.StaticCast(Sse2.SetAllVector128((int)1)); + } + else if (typeof(T) == typeof(uint)) + { + return Sse.StaticCast(Sse2.SetAllVector128((uint)1)); + } + else if (typeof(T) == typeof(long)) + { + return Sse.StaticCast(Sse2.SetAllVector128((long)1)); + } + else if (typeof(T) == typeof(ulong)) + { + return Sse.StaticCast(Sse2.SetAllVector128((ulong)1)); + } + else + { + throw new NotSupportedException(); + } + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector256 Vector256One() where T : struct + { + return Avx.SetAllVector256((T)Convert.ChangeType(1, typeof(T))); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector128 Vector128PlusOne(Vector128 v1) where T : struct + { + Vector128 v2 = Vector128One(); + if (typeof(T) == typeof(float)) + { + return Sse.StaticCast(Sse.Add(Sse.StaticCast(v1), Sse.StaticCast(v2))); + } + else if (typeof(T) == typeof(double)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(v1), Sse.StaticCast(v2))); + } + else if (typeof(T) == typeof(byte)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(v1), Sse.StaticCast(v2))); + } + else if (typeof(T) == typeof(sbyte)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(v1), Sse.StaticCast(v2))); + } + else if (typeof(T) == typeof(short)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(v1), Sse.StaticCast(v2))); + } + else if (typeof(T) == typeof(ushort)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(v1), Sse.StaticCast(v2))); + } + else if (typeof(T) == typeof(int)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(v1), Sse.StaticCast(v2))); + } + else if (typeof(T) == typeof(uint)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(v1), Sse.StaticCast(v2))); + } + else if (typeof(T) == typeof(long)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(v1), Sse.StaticCast(v2))); + } + else if (typeof(T) == typeof(ulong)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(v1), Sse.StaticCast(v2))); + } + else + { + throw new NotSupportedException(); + } + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector256 Vector256PlusOne(Vector256 v1) where T : struct + { + Vector256 v2 = Vector256One(); + if (typeof(T) == typeof(float)) + { + return Avx.StaticCast(Avx.Add(Avx.StaticCast(v1), Avx.StaticCast(v2))); + } + else if (typeof(T) == typeof(double)) + { + return Avx.StaticCast(Avx.Add(Avx.StaticCast(v1), Avx.StaticCast(v2))); + } + else if (typeof(T) == typeof(byte)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(v1), Avx.StaticCast(v2))); + } + else if (typeof(T) == typeof(sbyte)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(v1), Avx.StaticCast(v2))); + } + else if (typeof(T) == typeof(short)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(v1), Avx.StaticCast(v2))); + } + else if (typeof(T) == typeof(ushort)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(v1), Avx.StaticCast(v2))); + } + else if (typeof(T) == typeof(int)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(v1), Avx.StaticCast(v2))); + } + else if (typeof(T) == typeof(uint)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(v1), Avx.StaticCast(v2))); + } + else if (typeof(T) == typeof(long)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(v1), Avx.StaticCast(v2))); + } + else if (typeof(T) == typeof(ulong)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(v1), Avx.StaticCast(v2))); + } + else + { + throw new NotSupportedException(); + } + } + + public static unsafe int Vector128ReturnTest() + { + Vector128 v1 = Sse.SetAllVector128(2.0f); + Vector128 vres1 = Vector128PlusOne(v1); + + float* result1 = stackalloc float[4]; + Sse.Store(result1, vres1); + + for (int i = 0; i < 4; ++i) + { + if (result1[i] != 3.0f) + { + Console.WriteLine("Expected result is " + 3.0f); + Console.WriteLine("Instead got " + result1[i]); + Console.WriteLine("FAILED"); + return Fail; + } + } + + + Vector128 v2 = Sse2.SetAllVector128((int)5); + Vector128 vres2 = Vector128PlusOne(v2); + + int* result2 = stackalloc int[4]; + Sse2.Store(result2, vres2); + + for (int i = 0; i < 4; ++i) + { + if (result2[i] != 6) + { + Console.WriteLine("Expected result is " + 6); + Console.WriteLine("Instead got " + result2[i]); + Console.WriteLine("FAILED"); + return Fail; + } + } + + return Pass; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector128 GetVector128Int16One() + { + return Sse2.SetAllVector128((short)1); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector128 GetVector128Int16PlusOne(Vector128 v1) + { + Vector128 v2 = GetVector128Int16One(); + return Sse2.Add(v1, v2); + } + + public static unsafe int Vector128Int16ReturnTest() + { + Vector128 v1 = Sse2.SetVector128(10, 9, 8, 7, 6, 5, 4, 3); + Vector128 vres = GetVector128Int16PlusOne(v1); + + short* result = stackalloc short[8]; + Sse2.Store(result, vres); + + if ((result[0] != 4) || (result[1] != 5) || (result[2] != 6) || (result[3] != 7) || + (result[4] != 8) || (result[5] != 9) || (result[6] != 10) || (result[7] != 11)) + { + Console.WriteLine("Vector128Int16ReturnTest did not return expected value"); + Console.Write("[ "); + for (int i = 0; i < 8; i++) + { + Console.Write(result[i] + ", "); + } + Console.Write("]"); + return Fail; + } + + return Pass; + } + + public static unsafe int Vector256ReturnTest() + { + Vector256 v1 = Avx.SetAllVector256(2.0f); + Vector256 vres1 = Vector256PlusOne(v1); + + float* result1 = stackalloc float[8]; + Avx.Store(result1, vres1); + + for (int i = 0; i < 8; ++i) + { + if (result1[i] != 3.0f) + { + Console.WriteLine("Expected result is " + 3.0f); + Console.WriteLine("Instead got " + result1[i]); + Console.WriteLine("FAILED"); + return Fail; + } + } + + + Vector256 v2 = Avx.SetAllVector256((int)5); + Vector256 vres2 = Vector256PlusOne(v2); + + int* result2 = stackalloc int[8]; + Avx.Store(result2, vres2); + + for (int i = 0; i < 8; ++i) + { + if (result2[i] != 6) + { + Console.WriteLine("Expected result is " + 6); + Console.WriteLine("Instead got " + result2[i]); + Console.WriteLine("FAILED"); + return Fail; + } + } + + return Pass; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector256 GetVector256Int32One() + { + return Avx.SetAllVector256(1); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static Vector256 GetVector256Int32PlusOne(Vector256 v1) + { + Vector256 v2 = GetVector256Int32One(); + return Avx2.Add(v1, v2); + } + + public static unsafe int Vector256Int32ReturnTest() + { + Vector256 v1 = Avx.SetVector256(10, 9, 8, 7, 6, 5, 4, 3); + Vector256 vres = GetVector256Int32PlusOne(v1); + + int* result = stackalloc int[8]; + Avx.Store(result, vres); + + if ((result[0] != 4) || (result[1] != 5) || (result[2] != 6) || (result[3] != 7) || + (result[4] != 8) || (result[5] != 9) || (result[6] != 10) || (result[7] != 11)) + { + Console.WriteLine("Vector256Int32ReturnTest did not return expected value"); + Console.Write("[ "); + for (int i = 0; i < 8; i++) + { + Console.Write(result[i] + ", "); + } + Console.Write("]"); + return Fail; + } + + return Pass; + } + + public static unsafe int Main() + { + init(); + + if (Sse2.IsSupported) + { + Vector128 result_v128 = F2_v128(0.5F); + Vector128 expectedResult_v128 = F1_v128(0.5F); + + float* result = stackalloc float[4]; + Sse.Store(result, result_v128); + float* expResult = stackalloc float[4]; + Sse.Store(expResult, expectedResult_v128); + + for (int i = 0; i < 4; i++) + { + if (result[i] != expResult[i]) + { + Console.WriteLine("Vector128 test FAILED"); + Console.Write("[ "); + for (int j = 0; j < 4; j++) + { + Console.Write(result[j] + ", "); + } + Console.WriteLine("]"); + return Fail; + } + } + + if (Vector128ReturnTest() != Pass) + { + Console.WriteLine("Vector128ReturnTest FAILED"); + return Fail; + } + + Vector128 result_v128i = F2_v128i(6); + Vector128 expectedResult_v128i = F1_v128i(6); + + short* results = stackalloc short[8]; + Sse2.Store(results, result_v128i); + short* expResults = stackalloc short[8]; + Sse2.Store(expResults, expectedResult_v128i); + + for (int i = 0; i < 8; i++) + { + if (results[i] != expResults[i]) + { + Console.WriteLine("Vector128 test FAILED"); + Console.Write("[ "); + for (int j = 0; j < 8; j++) + { + Console.Write(results[j] + ", "); + } + Console.WriteLine("]"); + return Fail; + } + } + + if (Vector128Int16ReturnTest() != Pass) + { + Console.WriteLine("Vector128Int16ReturnTest FAILED"); + return Fail; + } + } + + if (Avx2.IsSupported) + { + Vector256 result_v256 = F2_v256(0.7F); + Vector256 expectedResult_v256 = F1_v256(0.7F); + + float* result = stackalloc float[8]; + Avx.Store(result, result_v256); + float* expResult = stackalloc float[8]; + Avx.Store(expResult, expectedResult_v256); + + for (int i = 0; i < 8; i++) + { + if (result[i] != expResult[i]) + { + Console.WriteLine("Vector256 test FAILED"); + Console.Write("[ "); + for (int j = 0; j < 8; j++) + { + Console.Write(result[j] + ", "); + } + Console.WriteLine("]"); + return Fail; + } + } + + if (Vector256ReturnTest() != Pass) + { + Console.WriteLine("Vector256ReturnTest FAILED"); + return Fail; + } + + Vector256 result_v256i = F2_v256i(7); + Vector256 expectedResult_v256i = F1_v256i(7); + + byte* resultb = stackalloc byte[32]; + Avx.Store(resultb, result_v256i); + byte* expResultb = stackalloc byte[32]; + Avx.Store(expResultb, expectedResult_v256i); + + for (int i = 0; i < 32; i++) + { + if (resultb[i] != expResultb[i]) + { + Console.WriteLine("Vector256 test FAILED"); + Console.Write("[ "); + for (int j = 0; j < 32; j++) + { + Console.Write(resultb[j] + ", "); + } + Console.WriteLine("]"); + return Fail; + } + } + + if (Vector256Int32ReturnTest() != Pass) + { + Console.WriteLine("Vector128Int16ReturnTest FAILED"); + return Fail; + } + } + + Console.WriteLine("PASSED"); + return Pass; + } +} \ No newline at end of file diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet_r.csproj new file mode 100644 index 0000000000..99a878cbd2 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet_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/General/VectorRet_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet_ro.csproj new file mode 100644 index 0000000000..26ed29ac51 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet_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/IsSupported.cs b/tests/src/JIT/HardwareIntrinsics/X86/IsSupported.cs deleted file mode 100644 index abdc108536..0000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/IsSupported.cs +++ /dev/null @@ -1,56 +0,0 @@ -// 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.Intrinsics.X86; -using System.Numerics; - -namespace IntelHardwareIntrinsicTest -{ - class Program - { - static int Main(string[] args) - { - bool result = true; - - if (Sse.IsSupported && int.TryParse(Environment.GetEnvironmentVariable("COMPlus_EnableIncompleteISAClass"), out var enableIncompleteIsa) && (enableIncompleteIsa != 0)) - { - // X86 platforms - if (Vector.Count == 32 && !Avx2.IsSupported) - { - result = false; - } - - if (Vector.Count == 16 && Vector.IsHardwareAccelerated && !Sse2.IsSupported) - { - result = false; - } - } - - // Reflection call - var issupported = "get_IsSupported"; - if (Convert.ToBoolean(typeof(Sse).GetMethod(issupported).Invoke(null, null)) != Sse.IsSupported || - Convert.ToBoolean(typeof(Sse2).GetMethod(issupported).Invoke(null, null)) != Sse2.IsSupported || - Convert.ToBoolean(typeof(Sse3).GetMethod(issupported).Invoke(null, null)) != Sse3.IsSupported || - Convert.ToBoolean(typeof(Ssse3).GetMethod(issupported).Invoke(null, null)) != Ssse3.IsSupported || - Convert.ToBoolean(typeof(Sse41).GetMethod(issupported).Invoke(null, null)) != Sse41.IsSupported || - Convert.ToBoolean(typeof(Sse42).GetMethod(issupported).Invoke(null, null)) != Sse42.IsSupported || - Convert.ToBoolean(typeof(Aes).GetMethod(issupported).Invoke(null, null)) != Aes.IsSupported || - Convert.ToBoolean(typeof(Avx).GetMethod(issupported).Invoke(null, null)) != Avx.IsSupported || - Convert.ToBoolean(typeof(Avx2).GetMethod(issupported).Invoke(null, null)) != Avx2.IsSupported || - Convert.ToBoolean(typeof(Fma).GetMethod(issupported).Invoke(null, null)) != Fma.IsSupported || - Convert.ToBoolean(typeof(Lzcnt).GetMethod(issupported).Invoke(null, null)) != Lzcnt.IsSupported || - Convert.ToBoolean(typeof(Bmi1).GetMethod(issupported).Invoke(null, null)) != Bmi1.IsSupported || - Convert.ToBoolean(typeof(Bmi2).GetMethod(issupported).Invoke(null, null)) != Bmi2.IsSupported || - Convert.ToBoolean(typeof(Popcnt).GetMethod(issupported).Invoke(null, null)) != Popcnt.IsSupported || - Convert.ToBoolean(typeof(Pclmulqdq).GetMethod(issupported).Invoke(null, null)) != Pclmulqdq.IsSupported - ) - { - result = false; - } - return result ? 100 : 0; - } - - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/IsSupported_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/IsSupported_r.csproj deleted file mode 100644 index e77c5dc2ad..0000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/IsSupported_r.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - - - - - - - False - - - - None - - - - - - - - - - - \ No newline at end of file diff --git a/tests/src/JIT/HardwareIntrinsics/X86/IsSupported_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/IsSupported_ro.csproj deleted file mode 100644 index e8f88b5a40..0000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/IsSupported_ro.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - - - - - - - False - - - - None - True - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3