From f802a82f12c3b0861ea4b70ea521f62a420362a9 Mon Sep 17 00:00:00 2001 From: Fei Peng Date: Tue, 9 Oct 2018 12:49:05 -0700 Subject: [PATCH] Disable tests for generic hardware intrinsic --- .../JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj | 34 -- .../JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj | 34 -- .../X86/Avx/ExtractVector128.Byte.1.cs | 321 ------------------- .../X86/Avx/ExtractVector128.Double.1.cs | 321 ------------------- .../X86/Avx/ExtractVector128.Int16.1.cs | 321 ------------------- .../X86/Avx/ExtractVector128.Int32.1.cs | 321 ------------------- .../X86/Avx/ExtractVector128.Int64.1.cs | 321 ------------------- .../X86/Avx/ExtractVector128.SByte.1.cs | 321 ------------------- .../X86/Avx/ExtractVector128.Single.1.cs | 321 ------------------- .../X86/Avx/ExtractVector128.UInt16.1.cs | 321 ------------------- .../X86/Avx/ExtractVector128.UInt32.1.cs | 321 ------------------- .../X86/Avx/ExtractVector128.UInt64.1.cs | 321 ------------------- .../X86/Avx/InsertExtractVector128.Avx.cs | 38 --- .../X86/Avx/InsertExtractVector128_r.csproj | 60 ---- .../X86/Avx/InsertExtractVector128_ro.csproj | 60 ---- .../X86/Avx/InsertVector128.Byte.1.cs | 346 --------------------- .../X86/Avx/InsertVector128.Double.1.cs | 346 --------------------- .../X86/Avx/InsertVector128.Int16.1.cs | 346 --------------------- .../X86/Avx/InsertVector128.Int32.1.cs | 346 --------------------- .../X86/Avx/InsertVector128.Int64.1.cs | 346 --------------------- .../X86/Avx/InsertVector128.SByte.1.cs | 346 --------------------- .../X86/Avx/InsertVector128.Single.1.cs | 346 --------------------- .../X86/Avx/InsertVector128.UInt16.1.cs | 346 --------------------- .../X86/Avx/InsertVector128.UInt32.1.cs | 346 --------------------- .../X86/Avx/InsertVector128.UInt64.1.cs | 346 --------------------- .../HardwareIntrinsics/X86/Avx/Permute2x128.Avx.cs | 24 -- .../X86/Avx/Permute2x128.Avx_r.csproj | 46 --- .../X86/Avx/Permute2x128.Avx_ro.csproj | 46 --- .../X86/Avx/Permute2x128.Double.2.cs | 337 -------------------- .../X86/Avx/Permute2x128.Int32.2.cs | 337 -------------------- .../X86/Avx/Permute2x128.Int64.2.cs | 337 -------------------- .../X86/Avx/Permute2x128.Single.2.cs | 337 -------------------- .../X86/Avx/Permute2x128.UInt32.2.cs | 337 -------------------- .../X86/Avx/Permute2x128.UInt64.2.cs | 337 -------------------- .../JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs | 34 -- .../HardwareIntrinsics/X86/General/VectorUnused.cs | 2 +- .../X86/Shared/GenerateTests.csx | 34 -- .../X86/PacketTracer/PacketTracer.csproj | 58 ---- 38 files changed, 1 insertion(+), 9161 deletions(-) delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128.Avx.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128_r.csproj delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128_ro.csproj delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx_r.csproj delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx_ro.csproj delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Double.2.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Int32.2.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Int64.2.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Single.2.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.UInt32.2.cs delete mode 100644 tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.UInt64.2.cs delete mode 100644 tests/src/JIT/Performance/CodeQuality/HWIntrinsic/X86/PacketTracer/PacketTracer.csproj diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj index 9cb2b2a..79e801b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj @@ -62,16 +62,6 @@ - - - - - - - - - - @@ -158,30 +148,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj index da5faa5..0a450e6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj @@ -62,16 +62,6 @@ - - - - - - - - - - @@ -158,30 +148,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.cs deleted file mode 100644 index 0b314a6..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Byte1() - { - var test = new SimpleUnaryOpTest__ExtractVector128Byte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Byte1 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Byte); - - private static Byte[] _data = new Byte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractVector128Byte1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractVector128Byte1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.ExtractVector128( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.ExtractVector128( - Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.ExtractVector128( - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.ExtractVector128( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractVector128Byte1(); - var result = Avx.ExtractVector128(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.ExtractVector128(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray = new Byte[Op1ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray = new Byte[Op1ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Byte[] firstOp, Byte[] result, [CallerMemberName] string method = "") - { - if (result[0] != firstOp[16]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 16])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.cs deleted file mode 100644 index 53aafd6..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Double1() - { - var test = new SimpleUnaryOpTest__ExtractVector128Double1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Double1 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Double); - - private static Double[] _data = new Double[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractVector128Double1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractVector128Double1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.ExtractVector128( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.ExtractVector128( - Avx.LoadVector256((Double*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.ExtractVector128( - Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Double) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Double) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Double*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Double) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.ExtractVector128( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractVector128Double1(); - var result = Avx.ExtractVector128(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.ExtractVector128(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Double[] inArray = new Double[Op1ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Double[] inArray = new Double[Op1ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Double[] firstOp, Double[] result, [CallerMemberName] string method = "") - { - if (result[0] != firstOp[2]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 2])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.cs deleted file mode 100644 index 6b7a2ed..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Int161() - { - var test = new SimpleUnaryOpTest__ExtractVector128Int161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int161 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractVector128Int161() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractVector128Int161() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.ExtractVector128( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.ExtractVector128( - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.ExtractVector128( - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int16) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int16) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int16) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.ExtractVector128( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractVector128Int161(); - var result = Avx.ExtractVector128(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.ExtractVector128(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if (result[0] != firstOp[8]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 8])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.cs deleted file mode 100644 index f66dd67..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Int321() - { - var test = new SimpleUnaryOpTest__ExtractVector128Int321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int321 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); - - private static Int32[] _data = new Int32[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractVector128Int321() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractVector128Int321() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.ExtractVector128( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.ExtractVector128( - Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.ExtractVector128( - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int32) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int32) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int32) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.ExtractVector128( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractVector128Int321(); - var result = Avx.ExtractVector128(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.ExtractVector128(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray = new Int32[Op1ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray = new Int32[Op1ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int32[] firstOp, Int32[] result, [CallerMemberName] string method = "") - { - if (result[0] != firstOp[4]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 4])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.cs deleted file mode 100644 index 11b52ea..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Int641() - { - var test = new SimpleUnaryOpTest__ExtractVector128Int641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int641 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int64); - - private static Int64[] _data = new Int64[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractVector128Int641() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractVector128Int641() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.ExtractVector128( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.ExtractVector128( - Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.ExtractVector128( - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int64) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int64) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int64) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.ExtractVector128( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractVector128Int641(); - var result = Avx.ExtractVector128(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.ExtractVector128(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray = new Int64[Op1ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray = new Int64[Op1ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int64[] firstOp, Int64[] result, [CallerMemberName] string method = "") - { - if (result[0] != firstOp[2]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 2])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.cs deleted file mode 100644 index bd10710..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128SByte1() - { - var test = new SimpleUnaryOpTest__ExtractVector128SByte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128SByte1 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractVector128SByte1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractVector128SByte1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.ExtractVector128( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.ExtractVector128( - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.ExtractVector128( - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(SByte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(SByte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(SByte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.ExtractVector128( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractVector128SByte1(); - var result = Avx.ExtractVector128(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.ExtractVector128(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if (result[0] != firstOp[16]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 16])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.cs deleted file mode 100644 index a809723..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Single1() - { - var test = new SimpleUnaryOpTest__ExtractVector128Single1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Single1 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractVector128Single1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractVector128Single1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.ExtractVector128( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.ExtractVector128( - Avx.LoadVector256((Single*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.ExtractVector128( - Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Single) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Single) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Single*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Single) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.ExtractVector128( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Single*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractVector128Single1(); - var result = Avx.ExtractVector128(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.ExtractVector128(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - if (result[0] != firstOp[4]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 4])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.cs deleted file mode 100644 index 8054be4..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128UInt161() - { - var test = new SimpleUnaryOpTest__ExtractVector128UInt161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt161 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - - private static UInt16[] _data = new UInt16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractVector128UInt161() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractVector128UInt161() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.ExtractVector128( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.ExtractVector128( - Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.ExtractVector128( - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt16) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt16) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt16) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.ExtractVector128( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractVector128UInt161(); - var result = Avx.ExtractVector128(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.ExtractVector128(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray = new UInt16[Op1ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray = new UInt16[Op1ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(UInt16[] firstOp, UInt16[] result, [CallerMemberName] string method = "") - { - if (result[0] != firstOp[8]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 8])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.cs deleted file mode 100644 index 8deb1b0..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128UInt321() - { - var test = new SimpleUnaryOpTest__ExtractVector128UInt321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt321 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - - private static UInt32[] _data = new UInt32[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractVector128UInt321() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractVector128UInt321() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.ExtractVector128( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.ExtractVector128( - Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.ExtractVector128( - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt32) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt32) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt32) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.ExtractVector128( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractVector128UInt321(); - var result = Avx.ExtractVector128(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.ExtractVector128(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray = new UInt32[Op1ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray = new UInt32[Op1ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(UInt32[] firstOp, UInt32[] result, [CallerMemberName] string method = "") - { - if (result[0] != firstOp[4]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 4])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.cs deleted file mode 100644 index d277ff5..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128UInt641() - { - var test = new SimpleUnaryOpTest__ExtractVector128UInt641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt641 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - - private static UInt64[] _data = new UInt64[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractVector128UInt641() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractVector128UInt641() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.ExtractVector128( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.ExtractVector128( - Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.ExtractVector128( - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt64) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt64) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.ExtractVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt64) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.ExtractVector128( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)); - var result = Avx.ExtractVector128(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractVector128UInt641(); - var result = Avx.ExtractVector128(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.ExtractVector128(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray = new UInt64[Op1ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray = new UInt64[Op1ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(UInt64[] firstOp, UInt64[] result, [CallerMemberName] string method = "") - { - if (result[0] != firstOp[2]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 2])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128.Avx.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128.Avx.cs deleted file mode 100644 index 63f9233..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128.Avx.cs +++ /dev/null @@ -1,38 +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.Collections.Generic; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - static Program() - { - TestList = new Dictionary() { - ["ExtractVector128.Byte.1"] = ExtractVector128Byte1, - ["ExtractVector128.SByte.1"] = ExtractVector128SByte1, - ["ExtractVector128.Int16.1"] = ExtractVector128Int161, - ["ExtractVector128.UInt16.1"] = ExtractVector128UInt161, - ["ExtractVector128.Int32.1"] = ExtractVector128Int321, - ["ExtractVector128.UInt32.1"] = ExtractVector128UInt321, - ["ExtractVector128.Int64.1"] = ExtractVector128Int641, - ["ExtractVector128.UInt64.1"] = ExtractVector128UInt641, - ["ExtractVector128.Single.1"] = ExtractVector128Single1, - ["ExtractVector128.Double.1"] = ExtractVector128Double1, - ["InsertVector128.Byte.1"] = InsertVector128Byte1, - ["InsertVector128.SByte.1"] = InsertVector128SByte1, - ["InsertVector128.Int16.1"] = InsertVector128Int161, - ["InsertVector128.UInt16.1"] = InsertVector128UInt161, - ["InsertVector128.Int32.1"] = InsertVector128Int321, - ["InsertVector128.UInt32.1"] = InsertVector128UInt321, - ["InsertVector128.Int64.1"] = InsertVector128Int641, - ["InsertVector128.UInt64.1"] = InsertVector128UInt641, - ["InsertVector128.Single.1"] = InsertVector128Single1, - ["InsertVector128.Double.1"] = InsertVector128Double1, - }; - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128_r.csproj deleted file mode 100644 index 99d8287..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128_r.csproj +++ /dev/null @@ -1,60 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - true - - - - - - - False - - - - Embedded - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128_ro.csproj deleted file mode 100644 index 3532561..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128_ro.csproj +++ /dev/null @@ -1,60 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - true - - - - - - - False - - - - Embedded - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.cs deleted file mode 100644 index 69546c7..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.cs +++ /dev/null @@ -1,346 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Byte1() - { - var test = new SimpleBinaryOpTest__InsertVector128Byte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Byte1 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Byte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Byte); - - private static Byte[] _data1 = new Byte[Op1ElementCount]; - private static Byte[] _data2 = new Byte[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__InsertVector128Byte1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleBinaryOpTest__InsertVector128Byte1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Byte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.InsertVector128( - Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)), - LoadVector128((Byte*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)), - LoadVector128((Byte*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.InsertVector128( - _clsVar1, - _clsVar2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)); - var right = LoadVector128((Byte*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)); - var right = LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__InsertVector128Byte1(); - var result = Avx.InsertVector128(test._fld1, test._fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.InsertVector128(_fld1, _fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector128 right, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray1 = new Byte[Op1ElementCount]; - Byte[] inArray2 = new Byte[Op2ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray1 = new Byte[Op1ElementCount]; - Byte[] inArray2 = new Byte[Op2ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Byte[] left, Byte[] right, Byte[] result, [CallerMemberName] string method = "") - { - if (result[0] != left[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 15 ? result[i] != right[i - 16] : result[i] != left[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.cs deleted file mode 100644 index a435cc1..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.cs +++ /dev/null @@ -1,346 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Double1() - { - var test = new SimpleBinaryOpTest__InsertVector128Double1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Double1 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Double); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Double); - - private static Double[] _data1 = new Double[Op1ElementCount]; - private static Double[] _data2 = new Double[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__InsertVector128Double1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleBinaryOpTest__InsertVector128Double1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.InsertVector128( - Avx.LoadVector256((Double*)(_dataTable.inArray1Ptr)), - LoadVector128((Double*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Double*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Double*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Double) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Double) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Double*)(_dataTable.inArray1Ptr)), - LoadVector128((Double*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Double) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Double*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Double*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.InsertVector128( - _clsVar1, - _clsVar2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((Double*)(_dataTable.inArray1Ptr)); - var right = LoadVector128((Double*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((Double*)(_dataTable.inArray1Ptr)); - var right = LoadAlignedVector128((Double*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__InsertVector128Double1(); - var result = Avx.InsertVector128(test._fld1, test._fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.InsertVector128(_fld1, _fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector128 right, void* result, [CallerMemberName] string method = "") - { - Double[] inArray1 = new Double[Op1ElementCount]; - Double[] inArray2 = new Double[Op2ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Double[] inArray1 = new Double[Op1ElementCount]; - Double[] inArray2 = new Double[Op2ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") - { - if (result[0] != left[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 1 ? result[i] != right[i - 2] : result[i] != left[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.cs deleted file mode 100644 index 6132cad..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.cs +++ /dev/null @@ -1,346 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Int161() - { - var test = new SimpleBinaryOpTest__InsertVector128Int161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int161 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data1 = new Int16[Op1ElementCount]; - private static Int16[] _data2 = new Int16[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__InsertVector128Int161() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleBinaryOpTest__InsertVector128Int161() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(0, short.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(0, short.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.InsertVector128( - Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), - LoadVector128((Int16*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Int16*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int16) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int16) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), - LoadVector128((Int16*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int16) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Int16*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.InsertVector128( - _clsVar1, - _clsVar2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)); - var right = LoadVector128((Int16*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)); - var right = LoadAlignedVector128((Int16*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__InsertVector128Int161(); - var result = Avx.InsertVector128(test._fld1, test._fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.InsertVector128(_fld1, _fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector128 right, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray1 = new Int16[Op1ElementCount]; - Int16[] inArray2 = new Int16[Op2ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray1 = new Int16[Op1ElementCount]; - Int16[] inArray2 = new Int16[Op2ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") - { - if (result[0] != left[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 7 ? result[i] != right[i - 8] : result[i] != left[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.cs deleted file mode 100644 index ac69626..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.cs +++ /dev/null @@ -1,346 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Int321() - { - var test = new SimpleBinaryOpTest__InsertVector128Int321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int321 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); - - private static Int32[] _data1 = new Int32[Op1ElementCount]; - private static Int32[] _data2 = new Int32[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__InsertVector128Int321() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleBinaryOpTest__InsertVector128Int321() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(0, int.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.InsertVector128( - Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), - LoadVector128((Int32*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int32) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int32) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), - LoadVector128((Int32*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int32) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.InsertVector128( - _clsVar1, - _clsVar2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)); - var right = LoadVector128((Int32*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)); - var right = LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__InsertVector128Int321(); - var result = Avx.InsertVector128(test._fld1, test._fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.InsertVector128(_fld1, _fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector128 right, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray1 = new Int32[Op1ElementCount]; - Int32[] inArray2 = new Int32[Op2ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray1 = new Int32[Op1ElementCount]; - Int32[] inArray2 = new Int32[Op2ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") - { - if (result[0] != left[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 3 ? result[i] != right[i - 4] : result[i] != left[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.cs deleted file mode 100644 index c998558..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.cs +++ /dev/null @@ -1,346 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Int641() - { - var test = new SimpleBinaryOpTest__InsertVector128Int641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int641 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int64); - - private static Int64[] _data1 = new Int64[Op1ElementCount]; - private static Int64[] _data2 = new Int64[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__InsertVector128Int641() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleBinaryOpTest__InsertVector128Int641() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(0, int.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.InsertVector128( - Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)), - LoadVector128((Int64*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Int64*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int64) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int64) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)), - LoadVector128((Int64*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Int64) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Int64*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.InsertVector128( - _clsVar1, - _clsVar2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)); - var right = LoadVector128((Int64*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)); - var right = LoadAlignedVector128((Int64*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__InsertVector128Int641(); - var result = Avx.InsertVector128(test._fld1, test._fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.InsertVector128(_fld1, _fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector128 right, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray1 = new Int64[Op1ElementCount]; - Int64[] inArray2 = new Int64[Op2ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray1 = new Int64[Op1ElementCount]; - Int64[] inArray2 = new Int64[Op2ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int64[] left, Int64[] right, Int64[] result, [CallerMemberName] string method = "") - { - if (result[0] != left[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 1 ? result[i] != right[i - 2] : result[i] != left[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.cs deleted file mode 100644 index 11bbf03..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.cs +++ /dev/null @@ -1,346 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128SByte1() - { - var test = new SimpleBinaryOpTest__InsertVector128SByte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__InsertVector128SByte1 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data1 = new SByte[Op1ElementCount]; - private static SByte[] _data2 = new SByte[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__InsertVector128SByte1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleBinaryOpTest__InsertVector128SByte1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.InsertVector128( - Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), - LoadVector128((SByte*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((SByte*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(SByte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(SByte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), - LoadVector128((SByte*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(SByte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((SByte*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.InsertVector128( - _clsVar1, - _clsVar2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)); - var right = LoadVector128((SByte*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)); - var right = LoadAlignedVector128((SByte*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__InsertVector128SByte1(); - var result = Avx.InsertVector128(test._fld1, test._fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.InsertVector128(_fld1, _fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector128 right, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray1 = new SByte[Op1ElementCount]; - SByte[] inArray2 = new SByte[Op2ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray1 = new SByte[Op1ElementCount]; - SByte[] inArray2 = new SByte[Op2ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(SByte[] left, SByte[] right, SByte[] result, [CallerMemberName] string method = "") - { - if (result[0] != left[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 15 ? result[i] != right[i - 16] : result[i] != left[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.cs deleted file mode 100644 index e485ed4..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.cs +++ /dev/null @@ -1,346 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Single1() - { - var test = new SimpleBinaryOpTest__InsertVector128Single1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Single1 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data1 = new Single[Op1ElementCount]; - private static Single[] _data2 = new Single[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__InsertVector128Single1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleBinaryOpTest__InsertVector128Single1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.InsertVector128( - Avx.LoadVector256((Single*)(_dataTable.inArray1Ptr)), - LoadVector128((Single*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Single*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Single) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Single) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Single*)(_dataTable.inArray1Ptr)), - LoadVector128((Single*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(Single) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Single*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.InsertVector128( - _clsVar1, - _clsVar2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((Single*)(_dataTable.inArray1Ptr)); - var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((Single*)(_dataTable.inArray1Ptr)); - var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__InsertVector128Single1(); - var result = Avx.InsertVector128(test._fld1, test._fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.InsertVector128(_fld1, _fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector128 right, void* result, [CallerMemberName] string method = "") - { - Single[] inArray1 = new Single[Op1ElementCount]; - Single[] inArray2 = new Single[Op2ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Single[] inArray1 = new Single[Op1ElementCount]; - Single[] inArray2 = new Single[Op2ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") - { - if (result[0] != left[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 3 ? result[i] != right[i - 4] : result[i] != left[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.cs deleted file mode 100644 index fd6677b..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.cs +++ /dev/null @@ -1,346 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128UInt161() - { - var test = new SimpleBinaryOpTest__InsertVector128UInt161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt161 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - - private static UInt16[] _data1 = new UInt16[Op1ElementCount]; - private static UInt16[] _data2 = new UInt16[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__InsertVector128UInt161() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleBinaryOpTest__InsertVector128UInt161() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.InsertVector128( - Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), - LoadVector128((UInt16*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((UInt16*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt16) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt16) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), - LoadVector128((UInt16*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt16) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((UInt16*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.InsertVector128( - _clsVar1, - _clsVar2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)); - var right = LoadVector128((UInt16*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)); - var right = LoadAlignedVector128((UInt16*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__InsertVector128UInt161(); - var result = Avx.InsertVector128(test._fld1, test._fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.InsertVector128(_fld1, _fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector128 right, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray1 = new UInt16[Op1ElementCount]; - UInt16[] inArray2 = new UInt16[Op2ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray1 = new UInt16[Op1ElementCount]; - UInt16[] inArray2 = new UInt16[Op2ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt16[] left, UInt16[] right, UInt16[] result, [CallerMemberName] string method = "") - { - if (result[0] != left[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 7 ? result[i] != right[i - 8] : result[i] != left[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.cs deleted file mode 100644 index 912fd6c..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.cs +++ /dev/null @@ -1,346 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128UInt321() - { - var test = new SimpleBinaryOpTest__InsertVector128UInt321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt321 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - - private static UInt32[] _data1 = new UInt32[Op1ElementCount]; - private static UInt32[] _data2 = new UInt32[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__InsertVector128UInt321() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleBinaryOpTest__InsertVector128UInt321() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.InsertVector128( - Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), - LoadVector128((UInt32*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt32) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt32) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), - LoadVector128((UInt32*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt32) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.InsertVector128( - _clsVar1, - _clsVar2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)); - var right = LoadVector128((UInt32*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)); - var right = LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__InsertVector128UInt321(); - var result = Avx.InsertVector128(test._fld1, test._fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.InsertVector128(_fld1, _fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector128 right, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray1 = new UInt32[Op1ElementCount]; - UInt32[] inArray2 = new UInt32[Op2ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray1 = new UInt32[Op1ElementCount]; - UInt32[] inArray2 = new UInt32[Op2ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") - { - if (result[0] != left[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 3 ? result[i] != right[i - 4] : result[i] != left[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.cs deleted file mode 100644 index 50b7c6d..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.cs +++ /dev/null @@ -1,346 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Reflection; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128UInt641() - { - var test = new SimpleBinaryOpTest__InsertVector128UInt641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt641 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - - private static UInt64[] _data1 = new UInt64[Op1ElementCount]; - private static UInt64[] _data2 = new UInt64[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__InsertVector128UInt641() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleBinaryOpTest__InsertVector128UInt641() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.InsertVector128( - Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)), - LoadVector128((UInt64*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((UInt64*)(_dataTable.inArray2Ptr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt64) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt64) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)), - LoadVector128((UInt64*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethods(BindingFlags.Public | BindingFlags.Static) - .FirstOrDefault( mi => mi.Name == nameof(Avx.InsertVector128) && mi.IsGenericMethod) - .MakeGenericMethod(new[] { typeof(UInt64) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)), - LoadAlignedVector128((UInt64*)(_dataTable.inArray2Ptr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.InsertVector128( - _clsVar1, - _clsVar2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)); - var right = LoadVector128((UInt64*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)); - var right = LoadAlignedVector128((UInt64*)(_dataTable.inArray2Ptr)); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__InsertVector128UInt641(); - var result = Avx.InsertVector128(test._fld1, test._fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.InsertVector128(_fld1, _fld2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector128 right, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray1 = new UInt64[Op1ElementCount]; - UInt64[] inArray2 = new UInt64[Op2ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray1 = new UInt64[Op1ElementCount]; - UInt64[] inArray2 = new UInt64[Op2ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt64[] left, UInt64[] right, UInt64[] result, [CallerMemberName] string method = "") - { - if (result[0] != left[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 1 ? result[i] != right[i - 2] : result[i] != left[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx.cs deleted file mode 100644 index 598b34d..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx.cs +++ /dev/null @@ -1,24 +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.Collections.Generic; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - static Program() - { - TestList = new Dictionary() { - ["Permute2x128.Double.2"] = Permute2x128Double2, - ["Permute2x128.Single.2"] = Permute2x128Single2, - ["Permute2x128.Int32.2"] = Permute2x128Int322, - ["Permute2x128.UInt32.2"] = Permute2x128Int322, - ["Permute2x128.Int64.2"] = Permute2x128Int642, - ["Permute2x128.UInt64.2"] = Permute2x128UInt642, - }; - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx_r.csproj deleted file mode 100644 index 3d8f6a2..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx_r.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - true - - - - - - - False - - - - Embedded - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx_ro.csproj deleted file mode 100644 index d362008..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx_ro.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - true - - - - - - - False - - - - Embedded - True - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Double.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Double.2.cs deleted file mode 100644 index 3df7e70..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Double.2.cs +++ /dev/null @@ -1,337 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void Permute2x128Double2() - { - var test = new SimpleBinaryOpTest__Permute2x128Double2(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__Permute2x128Double2 - { - private const int VectorSize = 32; - - private const int Op1ElementCount = VectorSize / sizeof(Double); - private const int Op2ElementCount = VectorSize / sizeof(Double); - private const int RetElementCount = VectorSize / sizeof(Double); - - private static Double[] _data1 = new Double[Op1ElementCount]; - private static Double[] _data2 = new Double[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector256 _clsVar2; - - private Vector256 _fld1; - private Vector256 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__Permute2x128Double2() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), VectorSize); - } - - public SimpleBinaryOpTest__Permute2x128Double2() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), VectorSize); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], VectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Permute2x128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Permute2x128( - Avx.LoadVector256((Double*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((Double*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Permute2x128( - Avx.LoadAlignedVector256((Double*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((Double*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Double) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Double) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Double*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((Double*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Double) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Double*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((Double*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Permute2x128( - _clsVar1, - _clsVar2, - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((Double*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadVector256((Double*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((Double*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadAlignedVector256((Double*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__Permute2x128Double2(); - var result = Avx.Permute2x128(test._fld1, test._fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Permute2x128(_fld1, _fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") - { - Double[] inArray1 = new Double[Op1ElementCount]; - Double[] inArray2 = new Double[Op2ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Double[] inArray1 = new Double[Op1ElementCount]; - Double[] inArray2 = new Double[Op2ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") - { - if (BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(right[0])) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if (i > 1 ? (BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i - 2])) : (BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(right[i]))) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Permute2x128)}(Vector256.2, Vector256): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Int32.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Int32.2.cs deleted file mode 100644 index cb0a2dd..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Int32.2.cs +++ /dev/null @@ -1,337 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void Permute2x128Int322() - { - var test = new SimpleBinaryOpTest__Permute2x128Int322(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__Permute2x128Int322 - { - private const int VectorSize = 32; - - private const int Op1ElementCount = VectorSize / sizeof(Int32); - private const int Op2ElementCount = VectorSize / sizeof(Int32); - private const int RetElementCount = VectorSize / sizeof(Int32); - - private static Int32[] _data1 = new Int32[Op1ElementCount]; - private static Int32[] _data2 = new Int32[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector256 _clsVar2; - - private Vector256 _fld1; - private Vector256 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__Permute2x128Int322() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), VectorSize); - } - - public SimpleBinaryOpTest__Permute2x128Int322() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), VectorSize); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(0, int.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], VectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Permute2x128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Permute2x128( - Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Permute2x128( - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Int32) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Int32) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Int32) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Permute2x128( - _clsVar1, - _clsVar2, - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__Permute2x128Int322(); - var result = Avx.Permute2x128(test._fld1, test._fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Permute2x128(_fld1, _fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray1 = new Int32[Op1ElementCount]; - Int32[] inArray2 = new Int32[Op2ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray1 = new Int32[Op1ElementCount]; - Int32[] inArray2 = new Int32[Op2ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") - { - if (result[0] != right[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if (i > 3 ? (result[i] != left[i - 4]) : (result[i] != right[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Permute2x128)}(Vector256.2, Vector256): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Int64.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Int64.2.cs deleted file mode 100644 index ddbcaa8..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Int64.2.cs +++ /dev/null @@ -1,337 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void Permute2x128Int642() - { - var test = new SimpleBinaryOpTest__Permute2x128Int642(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__Permute2x128Int642 - { - private const int VectorSize = 32; - - private const int Op1ElementCount = VectorSize / sizeof(Int64); - private const int Op2ElementCount = VectorSize / sizeof(Int64); - private const int RetElementCount = VectorSize / sizeof(Int64); - - private static Int64[] _data1 = new Int64[Op1ElementCount]; - private static Int64[] _data2 = new Int64[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector256 _clsVar2; - - private Vector256 _fld1; - private Vector256 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__Permute2x128Int642() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), VectorSize); - } - - public SimpleBinaryOpTest__Permute2x128Int642() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), VectorSize); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(0, int.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int64[RetElementCount], VectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Permute2x128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Permute2x128( - Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Permute2x128( - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Int64) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Int64) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Int64) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Permute2x128( - _clsVar1, - _clsVar2, - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__Permute2x128Int642(); - var result = Avx.Permute2x128(test._fld1, test._fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Permute2x128(_fld1, _fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray1 = new Int64[Op1ElementCount]; - Int64[] inArray2 = new Int64[Op2ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray1 = new Int64[Op1ElementCount]; - Int64[] inArray2 = new Int64[Op2ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int64[] left, Int64[] right, Int64[] result, [CallerMemberName] string method = "") - { - if (result[0] != right[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if (i > 1 ? (result[i] != left[i - 2]) : (result[i] != right[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Permute2x128)}(Vector256.2, Vector256): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Single.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Single.2.cs deleted file mode 100644 index bcec95d..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Single.2.cs +++ /dev/null @@ -1,337 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void Permute2x128Single2() - { - var test = new SimpleBinaryOpTest__Permute2x128Single2(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__Permute2x128Single2 - { - private const int VectorSize = 32; - - private const int Op1ElementCount = VectorSize / sizeof(Single); - private const int Op2ElementCount = VectorSize / sizeof(Single); - private const int RetElementCount = VectorSize / sizeof(Single); - - private static Single[] _data1 = new Single[Op1ElementCount]; - private static Single[] _data2 = new Single[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector256 _clsVar2; - - private Vector256 _fld1; - private Vector256 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__Permute2x128Single2() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), VectorSize); - } - - public SimpleBinaryOpTest__Permute2x128Single2() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), VectorSize); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], VectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Permute2x128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Permute2x128( - Avx.LoadVector256((Single*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((Single*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Permute2x128( - Avx.LoadAlignedVector256((Single*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((Single*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Single) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Single) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Single*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((Single*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(Single) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Single*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((Single*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Permute2x128( - _clsVar1, - _clsVar2, - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((Single*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadVector256((Single*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((Single*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadAlignedVector256((Single*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__Permute2x128Single2(); - var result = Avx.Permute2x128(test._fld1, test._fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Permute2x128(_fld1, _fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") - { - Single[] inArray1 = new Single[Op1ElementCount]; - Single[] inArray2 = new Single[Op2ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Single[] inArray1 = new Single[Op1ElementCount]; - Single[] inArray2 = new Single[Op2ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") - { - if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[0])) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if (i > 3 ? (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i - 4])) : (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[i]))) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Permute2x128)}(Vector256.2, Vector256): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.UInt32.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.UInt32.2.cs deleted file mode 100644 index 751d0a4..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.UInt32.2.cs +++ /dev/null @@ -1,337 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void Permute2x128UInt322() - { - var test = new SimpleBinaryOpTest__Permute2x128UInt322(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__Permute2x128UInt322 - { - private const int VectorSize = 32; - - private const int Op1ElementCount = VectorSize / sizeof(UInt32); - private const int Op2ElementCount = VectorSize / sizeof(UInt32); - private const int RetElementCount = VectorSize / sizeof(UInt32); - - private static UInt32[] _data1 = new UInt32[Op1ElementCount]; - private static UInt32[] _data2 = new UInt32[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector256 _clsVar2; - - private Vector256 _fld1; - private Vector256 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__Permute2x128UInt322() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), VectorSize); - } - - public SimpleBinaryOpTest__Permute2x128UInt322() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), VectorSize); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], VectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Permute2x128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Permute2x128( - Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Permute2x128( - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(UInt32) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(UInt32) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(UInt32) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Permute2x128( - _clsVar1, - _clsVar2, - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__Permute2x128UInt322(); - var result = Avx.Permute2x128(test._fld1, test._fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Permute2x128(_fld1, _fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray1 = new UInt32[Op1ElementCount]; - UInt32[] inArray2 = new UInt32[Op2ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray1 = new UInt32[Op1ElementCount]; - UInt32[] inArray2 = new UInt32[Op2ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") - { - if (result[0] != right[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if (i > 3 ? (result[i] != left[i - 4]) : (result[i] != right[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Permute2x128)}(Vector256.2, Vector256): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.UInt64.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.UInt64.2.cs deleted file mode 100644 index 305b3a8..0000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.UInt64.2.cs +++ /dev/null @@ -1,337 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void Permute2x128UInt642() - { - var test = new SimpleBinaryOpTest__Permute2x128UInt642(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleBinaryOpTest__Permute2x128UInt642 - { - private const int VectorSize = 32; - - private const int Op1ElementCount = VectorSize / sizeof(UInt64); - private const int Op2ElementCount = VectorSize / sizeof(UInt64); - private const int RetElementCount = VectorSize / sizeof(UInt64); - - private static UInt64[] _data1 = new UInt64[Op1ElementCount]; - private static UInt64[] _data2 = new UInt64[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector256 _clsVar2; - - private Vector256 _fld1; - private Vector256 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static SimpleBinaryOpTest__Permute2x128UInt642() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), VectorSize); - } - - public SimpleBinaryOpTest__Permute2x128UInt642() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), VectorSize); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt64[RetElementCount], VectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Permute2x128( - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Permute2x128( - Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Permute2x128( - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr)), - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(UInt64) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Unsafe.Read>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(UInt64) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)), - Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Permute2x128)).MakeGenericMethod( new Type[] { typeof(UInt64) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)), - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr)), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Permute2x128( - _clsVar1, - _clsVar2, - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = Unsafe.Read>(_dataTable.inArray2Ptr); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var left = Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var left = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)); - var right = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr)); - var result = Avx.Permute2x128(left, right, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleBinaryOpTest__Permute2x128UInt642(); - var result = Avx.Permute2x128(test._fld1, test._fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Permute2x128(_fld1, _fld2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray1 = new UInt64[Op1ElementCount]; - UInt64[] inArray2 = new UInt64[Op2ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray1 = new UInt64[Op1ElementCount]; - UInt64[] inArray2 = new UInt64[Op2ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), VectorSize); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt64[] left, UInt64[] right, UInt64[] result, [CallerMemberName] string method = "") - { - if (result[0] != right[0]) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if (i > 1 ? (result[i] != left[i - 2]) : (result[i] != right[i])) - { - Succeeded = false; - break; - } - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Permute2x128)}(Vector256.2, Vector256): {method} failed:"); - Console.WriteLine($" left: ({string.Join(", ", left)})"); - Console.WriteLine($" right: ({string.Join(", ", right)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs index a0e07b7..1483ebd 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs @@ -47,16 +47,6 @@ namespace JIT.HardwareIntrinsics.X86 ["Extract.UInt64.3"] = ExtractUInt643, ["Extract.Int64.19"] = ExtractInt6419, ["Extract.UInt64.19"] = ExtractUInt6419, - ["ExtendToVector256.Byte"] = ExtendToVector256Byte, - ["ExtendToVector256.Double"] = ExtendToVector256Double, - ["ExtendToVector256.Int16"] = ExtendToVector256Int16, - ["ExtendToVector256.Int32"] = ExtendToVector256Int32, - ["ExtendToVector256.Int64"] = ExtendToVector256Int64, - ["ExtendToVector256.SByte"] = ExtendToVector256SByte, - ["ExtendToVector256.Single"] = ExtendToVector256Single, - ["ExtendToVector256.UInt16"] = ExtendToVector256UInt16, - ["ExtendToVector256.UInt32"] = ExtendToVector256UInt32, - ["ExtendToVector256.UInt64"] = ExtendToVector256UInt64, ["ExtractVector128.Byte.1.Store"] = ExtractVector128Byte1Store, ["ExtractVector128.SByte.1.Store"] = ExtractVector128SByte1Store, ["ExtractVector128.Int16.1.Store"] = ExtractVector128Int161Store, @@ -143,30 +133,6 @@ namespace JIT.HardwareIntrinsics.X86 ["Shuffle.Double.1"] = ShuffleDouble1, ["Subtract.Double"] = SubtractDouble, ["Subtract.Single"] = SubtractSingle, - ["TestC.Byte"] = TestCByte, - ["TestC.Int16"] = TestCInt16, - ["TestC.Int32"] = TestCInt32, - ["TestC.Int64"] = TestCInt64, - ["TestC.SByte"] = TestCSByte, - ["TestC.UInt16"] = TestCUInt16, - ["TestC.UInt32"] = TestCUInt32, - ["TestC.UInt64"] = TestCUInt64, - ["TestNotZAndNotC.Byte"] = TestNotZAndNotCByte, - ["TestNotZAndNotC.Int16"] = TestNotZAndNotCInt16, - ["TestNotZAndNotC.Int32"] = TestNotZAndNotCInt32, - ["TestNotZAndNotC.Int64"] = TestNotZAndNotCInt64, - ["TestNotZAndNotC.SByte"] = TestNotZAndNotCSByte, - ["TestNotZAndNotC.UInt16"] = TestNotZAndNotCUInt16, - ["TestNotZAndNotC.UInt32"] = TestNotZAndNotCUInt32, - ["TestNotZAndNotC.UInt64"] = TestNotZAndNotCUInt64, - ["TestZ.Byte"] = TestZByte, - ["TestZ.Int16"] = TestZInt16, - ["TestZ.Int32"] = TestZInt32, - ["TestZ.Int64"] = TestZInt64, - ["TestZ.SByte"] = TestZSByte, - ["TestZ.UInt16"] = TestZUInt16, - ["TestZ.UInt32"] = TestZUInt32, - ["TestZ.UInt64"] = TestZUInt64, ["Xor.Single"] = XorSingle, ["Xor.Double"] = XorDouble, }; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused.cs b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused.cs index 331a176..bcc5665 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused.cs @@ -36,7 +36,7 @@ internal partial class IntelHardwareIntrinsicTest if (Avx.IsSupported) { Vector256 v1 = Avx.SetAllVector256(t1); - v1 = Avx.Permute2x128(v1, Avx.SetAllVector256(t2), 1); + v1 = Vector256Add(v1, Avx.SetAllVector256(t2)); } return Pass; } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx index 506b66b..1e35bd0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx @@ -533,16 +533,6 @@ private static readonly (string templateFileName, Dictionary tem ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "3", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "19", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "19", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse", ["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "result[0] != firstOp[8]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 8])"}), @@ -629,30 +619,6 @@ private static readonly (string templateFileName, Dictionary tem ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Shuffle", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(left[1])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[3]) != BitConverter.DoubleToInt64Bits(right[2])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Subtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Subtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Xor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[i]) ^ BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Xor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), }; diff --git a/tests/src/JIT/Performance/CodeQuality/HWIntrinsic/X86/PacketTracer/PacketTracer.csproj b/tests/src/JIT/Performance/CodeQuality/HWIntrinsic/X86/PacketTracer/PacketTracer.csproj deleted file mode 100644 index 5411880..0000000 --- a/tests/src/JIT/Performance/CodeQuality/HWIntrinsic/X86/PacketTracer/PacketTracer.csproj +++ /dev/null @@ -1,58 +0,0 @@ - - - - - Debug - AnyCPU - 2.1 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - .NETStandard,Version=v1.4 - netstandard1.4 - true - - - - - - pdbonly - true - - - - - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(JitPackagesConfigFileDirectory)benchmark+intrinsic\obj\project.assets.json - - -- 2.7.4