diff options
author | Fei Peng <fei.peng@intel.com> | 2018-10-09 12:49:05 -0700 |
---|---|---|
committer | Fei Peng <fei.peng@intel.com> | 2018-10-09 12:49:05 -0700 |
commit | f802a82f12c3b0861ea4b70ea521f62a420362a9 (patch) | |
tree | 23bc28cc78beaa4d5f29b835b0f50baa6d0bb374 /tests/src | |
parent | a5cc85cf1567910b179f1ef4e1e09a858b574562 (diff) | |
download | coreclr-f802a82f12c3b0861ea4b70ea521f62a420362a9.tar.gz coreclr-f802a82f12c3b0861ea4b70ea521f62a420362a9.tar.bz2 coreclr-f802a82f12c3b0861ea4b70ea521f62a420362a9.zip |
Disable tests for generic hardware intrinsic
Diffstat (limited to 'tests/src')
38 files changed, 1 insertions, 9161 deletions
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj index 9cb2b2a646..79e801b0f7 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 @@ <Compile Include="Extract.UInt32.22.cs" /> <Compile Include="Extract.Int64.19.cs" /> <Compile Include="Extract.UInt64.19.cs" /> - <Compile Include="ExtendToVector256.Byte.cs" /> - <Compile Include="ExtendToVector256.Double.cs" /> - <Compile Include="ExtendToVector256.Int16.cs" /> - <Compile Include="ExtendToVector256.Int32.cs" /> - <Compile Include="ExtendToVector256.Int64.cs" /> - <Compile Include="ExtendToVector256.SByte.cs" /> - <Compile Include="ExtendToVector256.Single.cs" /> - <Compile Include="ExtendToVector256.UInt16.cs" /> - <Compile Include="ExtendToVector256.UInt32.cs" /> - <Compile Include="ExtendToVector256.UInt64.cs" /> <Compile Include="ExtractVector128.Byte.1.Store.cs" /> <Compile Include="ExtractVector128.SByte.1.Store.cs" /> <Compile Include="ExtractVector128.Int16.1.Store.cs" /> @@ -158,30 +148,6 @@ <Compile Include="Shuffle.Double.1.cs" /> <Compile Include="Subtract.Double.cs" /> <Compile Include="Subtract.Single.cs" /> - <Compile Include="TestC.Byte.cs" /> - <Compile Include="TestC.Int16.cs" /> - <Compile Include="TestC.Int32.cs" /> - <Compile Include="TestC.Int64.cs" /> - <Compile Include="TestC.SByte.cs" /> - <Compile Include="TestC.UInt16.cs" /> - <Compile Include="TestC.UInt32.cs" /> - <Compile Include="TestC.UInt64.cs" /> - <Compile Include="TestNotZAndNotC.Byte.cs" /> - <Compile Include="TestNotZAndNotC.Int16.cs" /> - <Compile Include="TestNotZAndNotC.Int32.cs" /> - <Compile Include="TestNotZAndNotC.Int64.cs" /> - <Compile Include="TestNotZAndNotC.SByte.cs" /> - <Compile Include="TestNotZAndNotC.UInt16.cs" /> - <Compile Include="TestNotZAndNotC.UInt32.cs" /> - <Compile Include="TestNotZAndNotC.UInt64.cs" /> - <Compile Include="TestZ.Byte.cs" /> - <Compile Include="TestZ.Int16.cs" /> - <Compile Include="TestZ.Int32.cs" /> - <Compile Include="TestZ.Int64.cs" /> - <Compile Include="TestZ.SByte.cs" /> - <Compile Include="TestZ.UInt16.cs" /> - <Compile Include="TestZ.UInt32.cs" /> - <Compile Include="TestZ.UInt64.cs" /> <Compile Include="Xor.Double.cs" /> <Compile Include="Xor.Single.cs" /> <Compile Include="Program.Avx.cs" /> diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj index da5faa589c..0a450e6820 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 @@ <Compile Include="Extract.UInt32.22.cs" /> <Compile Include="Extract.Int64.19.cs" /> <Compile Include="Extract.UInt64.19.cs" /> - <Compile Include="ExtendToVector256.Byte.cs" /> - <Compile Include="ExtendToVector256.Double.cs" /> - <Compile Include="ExtendToVector256.Int16.cs" /> - <Compile Include="ExtendToVector256.Int32.cs" /> - <Compile Include="ExtendToVector256.Int64.cs" /> - <Compile Include="ExtendToVector256.SByte.cs" /> - <Compile Include="ExtendToVector256.Single.cs" /> - <Compile Include="ExtendToVector256.UInt16.cs" /> - <Compile Include="ExtendToVector256.UInt32.cs" /> - <Compile Include="ExtendToVector256.UInt64.cs" /> <Compile Include="ExtractVector128.Byte.1.Store.cs" /> <Compile Include="ExtractVector128.SByte.1.Store.cs" /> <Compile Include="ExtractVector128.Int16.1.Store.cs" /> @@ -158,30 +148,6 @@ <Compile Include="Shuffle.Double.1.cs" /> <Compile Include="Subtract.Double.cs" /> <Compile Include="Subtract.Single.cs" /> - <Compile Include="TestC.Byte.cs" /> - <Compile Include="TestC.Int16.cs" /> - <Compile Include="TestC.Int32.cs" /> - <Compile Include="TestC.Int64.cs" /> - <Compile Include="TestC.SByte.cs" /> - <Compile Include="TestC.UInt16.cs" /> - <Compile Include="TestC.UInt32.cs" /> - <Compile Include="TestC.UInt64.cs" /> - <Compile Include="TestNotZAndNotC.Byte.cs" /> - <Compile Include="TestNotZAndNotC.Int16.cs" /> - <Compile Include="TestNotZAndNotC.Int32.cs" /> - <Compile Include="TestNotZAndNotC.Int64.cs" /> - <Compile Include="TestNotZAndNotC.SByte.cs" /> - <Compile Include="TestNotZAndNotC.UInt16.cs" /> - <Compile Include="TestNotZAndNotC.UInt32.cs" /> - <Compile Include="TestNotZAndNotC.UInt64.cs" /> - <Compile Include="TestZ.Byte.cs" /> - <Compile Include="TestZ.Int16.cs" /> - <Compile Include="TestZ.Int32.cs" /> - <Compile Include="TestZ.Int64.cs" /> - <Compile Include="TestZ.SByte.cs" /> - <Compile Include="TestZ.UInt16.cs" /> - <Compile Include="TestZ.UInt32.cs" /> - <Compile Include="TestZ.UInt64.cs" /> <Compile Include="Xor.Double.cs" /> <Compile Include="Xor.Single.cs" /> <Compile Include="Program.Avx.cs" /> 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 0b314a6b3b..0000000000 --- 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<Vector256<Byte>>() / sizeof(Byte); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); - - private static Byte[] _data = new Byte[Op1ElementCount]; - - private static Vector256<Byte> _clsVar; - - private Vector256<Byte> _fld; - - private SimpleUnaryOpTest__DataTable<Byte, Byte> _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<Vector256<Byte>, byte>(ref _clsVar), ref Unsafe.As<Byte, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Byte>>()); - } - - 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<Vector256<Byte>, byte>(ref _fld), ref Unsafe.As<Byte, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Byte>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable<Byte, Byte>(_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<Vector256<Byte>>(_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<Vector256<Byte>>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(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<Byte>)(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<Byte>)(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<Vector256<Byte>>(_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<Byte> firstOp, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray = new Byte[Op1ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>()); - - 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<Byte, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<Byte>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>()); - - 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)}<Byte>(Vector256<Byte><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 53aafd6827..0000000000 --- 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<Vector256<Double>>() / sizeof(Double); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); - - private static Double[] _data = new Double[Op1ElementCount]; - - private static Vector256<Double> _clsVar; - - private Vector256<Double> _fld; - - private SimpleUnaryOpTest__DataTable<Double, Double> _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<Vector256<Double>, byte>(ref _clsVar), ref Unsafe.As<Double, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); - } - - 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<Vector256<Double>, byte>(ref _fld), ref Unsafe.As<Double, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable<Double, Double>(_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<Vector256<Double>>(_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<Vector256<Double>>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Double>)(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<Double>)(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<Double>)(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<Vector256<Double>>(_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<Double> firstOp, void* result, [CallerMemberName] string method = "") - { - Double[] inArray = new Double[Op1ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); - - 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<Double, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<Double>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); - - 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)}<Double>(Vector256<Double><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 6b7a2ed634..0000000000 --- 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<Vector256<Int16>>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector256<Int16> _clsVar; - - private Vector256<Int16> _fld; - - private SimpleUnaryOpTest__DataTable<Int16, Int16> _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<Vector256<Int16>, byte>(ref _clsVar), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int16>>()); - } - - 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<Vector256<Int16>, byte>(ref _fld), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int16>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable<Int16, Int16>(_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<Vector256<Int16>>(_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<Vector256<Int16>>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int16>)(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<Int16>)(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<Int16>)(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<Vector256<Int16>>(_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<Int16> firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int16>>()); - - 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<Int16, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<Int16>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int16>>()); - - 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)}<Int16>(Vector256<Int16><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 f66dd67090..0000000000 --- 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<Vector256<Int32>>() / sizeof(Int32); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); - - private static Int32[] _data = new Int32[Op1ElementCount]; - - private static Vector256<Int32> _clsVar; - - private Vector256<Int32> _fld; - - private SimpleUnaryOpTest__DataTable<Int32, Int32> _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<Vector256<Int32>, byte>(ref _clsVar), ref Unsafe.As<Int32, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int32>>()); - } - - 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<Vector256<Int32>, byte>(ref _fld), ref Unsafe.As<Int32, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int32>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable<Int32, Int32>(_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<Vector256<Int32>>(_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<Vector256<Int32>>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(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<Int32>)(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<Int32>)(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<Vector256<Int32>>(_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<Int32> firstOp, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray = new Int32[Op1ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); - - 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<Int32, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<Int32>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); - - 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)}<Int32>(Vector256<Int32><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 11b52eaa83..0000000000 --- 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<Vector256<Int64>>() / sizeof(Int64); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); - - private static Int64[] _data = new Int64[Op1ElementCount]; - - private static Vector256<Int64> _clsVar; - - private Vector256<Int64> _fld; - - private SimpleUnaryOpTest__DataTable<Int64, Int64> _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<Vector256<Int64>, byte>(ref _clsVar), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int64>>()); - } - - 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<Vector256<Int64>, byte>(ref _fld), ref Unsafe.As<Int64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Int64>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable<Int64, Int64>(_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<Vector256<Int64>>(_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<Vector256<Int64>>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(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<Int64>)(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<Int64>)(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<Vector256<Int64>>(_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<Int64> firstOp, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray = new Int64[Op1ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>()); - - 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<Int64, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<Int64>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>()); - - 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)}<Int64>(Vector256<Int64><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 bd10710acc..0000000000 --- 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<Vector256<SByte>>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector256<SByte> _clsVar; - - private Vector256<SByte> _fld; - - private SimpleUnaryOpTest__DataTable<SByte, SByte> _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<Vector256<SByte>, byte>(ref _clsVar), ref Unsafe.As<SByte, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); - } - - 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<Vector256<SByte>, byte>(ref _fld), ref Unsafe.As<SByte, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable<SByte, SByte>(_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<Vector256<SByte>>(_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<Vector256<SByte>>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128<SByte>)(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<SByte>)(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<SByte>)(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<Vector256<SByte>>(_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<SByte> firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<SByte>>()); - - 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<SByte, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<SByte>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<SByte>>()); - - 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)}<SByte>(Vector256<SByte><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 a8097235ae..0000000000 --- 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<Vector256<Single>>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector256<Single> _clsVar; - - private Vector256<Single> _fld; - - private SimpleUnaryOpTest__DataTable<Single, Single> _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<Vector256<Single>, byte>(ref _clsVar), ref Unsafe.As<Single, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Single>>()); - } - - 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<Vector256<Single>, byte>(ref _fld), ref Unsafe.As<Single, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<Single>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable<Single, Single>(_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<Vector256<Single>>(_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<Vector256<Single>>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Single>)(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<Single>)(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<Single>)(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<Vector256<Single>>(_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<Single> firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Single>>()); - - 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<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<Single>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Single>>()); - - 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)}<Single>(Vector256<Single><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 8054be42d3..0000000000 --- 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<Vector256<UInt16>>() / sizeof(UInt16); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); - - private static UInt16[] _data = new UInt16[Op1ElementCount]; - - private static Vector256<UInt16> _clsVar; - - private Vector256<UInt16> _fld; - - private SimpleUnaryOpTest__DataTable<UInt16, UInt16> _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<Vector256<UInt16>, byte>(ref _clsVar), ref Unsafe.As<UInt16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<UInt16>>()); - } - - 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<Vector256<UInt16>, byte>(ref _fld), ref Unsafe.As<UInt16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<UInt16>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable<UInt16, UInt16>(_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<Vector256<UInt16>>(_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<Vector256<UInt16>>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(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<UInt16>)(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<UInt16>)(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<Vector256<UInt16>>(_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<UInt16> firstOp, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray = new UInt16[Op1ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); - - 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<UInt16, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<UInt16>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); - - 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)}<UInt16>(Vector256<UInt16><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 8deb1b0d74..0000000000 --- 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<Vector256<UInt32>>() / sizeof(UInt32); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); - - private static UInt32[] _data = new UInt32[Op1ElementCount]; - - private static Vector256<UInt32> _clsVar; - - private Vector256<UInt32> _fld; - - private SimpleUnaryOpTest__DataTable<UInt32, UInt32> _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<Vector256<UInt32>, byte>(ref _clsVar), ref Unsafe.As<UInt32, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); - } - - 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<Vector256<UInt32>, byte>(ref _fld), ref Unsafe.As<UInt32, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable<UInt32, UInt32>(_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<Vector256<UInt32>>(_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<Vector256<UInt32>>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt32>)(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<UInt32>)(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<UInt32>)(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<Vector256<UInt32>>(_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<UInt32> firstOp, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray = new UInt32[Op1ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); - - 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<UInt32, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); - - 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)}<UInt32>(Vector256<UInt32><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 d277ff55fc..0000000000 --- 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<Vector256<UInt64>>() / sizeof(UInt64); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt64>>() / sizeof(UInt64); - - private static UInt64[] _data = new UInt64[Op1ElementCount]; - - private static Vector256<UInt64> _clsVar; - - private Vector256<UInt64> _fld; - - private SimpleUnaryOpTest__DataTable<UInt64, UInt64> _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<Vector256<UInt64>, byte>(ref _clsVar), ref Unsafe.As<UInt64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<UInt64>>()); - } - - 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<Vector256<UInt64>, byte>(ref _fld), ref Unsafe.As<UInt64, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector256<UInt64>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable<UInt64, UInt64>(_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<Vector256<UInt64>>(_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<Vector256<UInt64>>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt64>)(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<UInt64>)(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<UInt64>)(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<Vector256<UInt64>>(_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<UInt64> firstOp, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray = new UInt64[Op1ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); - - 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<UInt64, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector256<UInt64>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); - - 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)}<UInt64>(Vector256<UInt64><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 63f9233ef1..0000000000 --- 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<string, Action>() { - ["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 99d8287887..0000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128_r.csproj +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> - <OutputType>Exe</OutputType> - <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - </PropertyGroup> - <!-- Default configurations to help VS understand the configurations --> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> - <ItemGroup> - <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> - <Visible>False</Visible> - </CodeAnalysisDependentAssemblyPaths> - </ItemGroup> - <PropertyGroup> - <DebugType>Embedded</DebugType> - <Optimize></Optimize> - </PropertyGroup> - <ItemGroup> - <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> - </ItemGroup> - <ItemGroup> - <Compile Include="ExtractVector128.Byte.1.cs" /> - <Compile Include="ExtractVector128.SByte.1.cs" /> - <Compile Include="ExtractVector128.Int16.1.cs" /> - <Compile Include="ExtractVector128.UInt16.1.cs" /> - <Compile Include="ExtractVector128.Int32.1.cs" /> - <Compile Include="ExtractVector128.UInt32.1.cs" /> - <Compile Include="ExtractVector128.Int64.1.cs" /> - <Compile Include="ExtractVector128.UInt64.1.cs" /> - <Compile Include="ExtractVector128.Single.1.cs" /> - <Compile Include="ExtractVector128.Double.1.cs" /> - <Compile Include="InsertVector128.Byte.1.cs" /> - <Compile Include="InsertVector128.SByte.1.cs" /> - <Compile Include="InsertVector128.Int16.1.cs" /> - <Compile Include="InsertVector128.UInt16.1.cs" /> - <Compile Include="InsertVector128.Int32.1.cs" /> - <Compile Include="InsertVector128.UInt32.1.cs" /> - <Compile Include="InsertVector128.Int64.1.cs" /> - <Compile Include="InsertVector128.UInt64.1.cs" /> - <Compile Include="InsertVector128.Single.1.cs" /> - <Compile Include="InsertVector128.Double.1.cs" /> - <Compile Include="InsertExtractVector128.Avx.cs" /> - <Compile Include="..\Shared\BooleanBinOpTest_DataTable.cs" /> - <Compile Include="..\Shared\BooleanTwoCmpOpTest_DataTable.cs" /> - <Compile Include="..\Shared\Program.cs" /> - <Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" /> - <Compile Include="..\Shared\SimpleTernOpTest_DataTable.cs" /> - <Compile Include="..\Shared\SimpleUnOpTest_DataTable.cs" /> - </ItemGroup> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> - <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> -</Project> 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 35325619bc..0000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertExtractVector128_ro.csproj +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> - <OutputType>Exe</OutputType> - <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - </PropertyGroup> - <!-- Default configurations to help VS understand the configurations --> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> - <ItemGroup> - <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> - <Visible>False</Visible> - </CodeAnalysisDependentAssemblyPaths> - </ItemGroup> - <PropertyGroup> - <DebugType>Embedded</DebugType> - <Optimize>True</Optimize> - </PropertyGroup> - <ItemGroup> - <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> - </ItemGroup> - <ItemGroup> - <Compile Include="ExtractVector128.Byte.1.cs" /> - <Compile Include="ExtractVector128.SByte.1.cs" /> - <Compile Include="ExtractVector128.Int16.1.cs" /> - <Compile Include="ExtractVector128.UInt16.1.cs" /> - <Compile Include="ExtractVector128.Int32.1.cs" /> - <Compile Include="ExtractVector128.UInt32.1.cs" /> - <Compile Include="ExtractVector128.Int64.1.cs" /> - <Compile Include="ExtractVector128.UInt64.1.cs" /> - <Compile Include="ExtractVector128.Single.1.cs" /> - <Compile Include="ExtractVector128.Double.1.cs" /> - <Compile Include="InsertVector128.Byte.1.cs" /> - <Compile Include="InsertVector128.SByte.1.cs" /> - <Compile Include="InsertVector128.Int16.1.cs" /> - <Compile Include="InsertVector128.UInt16.1.cs" /> - <Compile Include="InsertVector128.Int32.1.cs" /> - <Compile Include="InsertVector128.UInt32.1.cs" /> - <Compile Include="InsertVector128.Int64.1.cs" /> - <Compile Include="InsertVector128.UInt64.1.cs" /> - <Compile Include="InsertVector128.Single.1.cs" /> - <Compile Include="InsertVector128.Double.1.cs" /> - <Compile Include="InsertExtractVector128.Avx.cs" /> - <Compile Include="..\Shared\BooleanBinOpTest_DataTable.cs" /> - <Compile Include="..\Shared\BooleanTwoCmpOpTest_DataTable.cs" /> - <Compile Include="..\Shared\Program.cs" /> - <Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" /> - <Compile Include="..\Shared\SimpleTernOpTest_DataTable.cs" /> - <Compile Include="..\Shared\SimpleUnOpTest_DataTable.cs" /> - </ItemGroup> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> - <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> -</Project> 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 69546c70a4..0000000000 --- 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<Vector256<Byte>>() / sizeof(Byte); - private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Byte>>() / sizeof(Byte); - - private static Byte[] _data1 = new Byte[Op1ElementCount]; - private static Byte[] _data2 = new Byte[Op2ElementCount]; - - private static Vector256<Byte> _clsVar1; - private static Vector128<Byte> _clsVar2; - - private Vector256<Byte> _fld1; - private Vector128<Byte> _fld2; - - private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _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<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Byte>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); - } - - 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<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Byte>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); - - 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<Byte, Byte, Byte>(_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<Vector256<Byte>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Byte>>(_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<Vector256<Byte>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Byte>)(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<Byte>)(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<Byte>)(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<Vector256<Byte>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector128<Byte>>(_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<Byte> left, Vector128<Byte> 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<Byte, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Byte>>()); - - 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<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector256<Byte>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<Byte>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Byte>>()); - - 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)}<Byte>(Vector256<Byte>, Vector128<Byte>.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 a435cc14c7..0000000000 --- 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<Vector256<Double>>() / sizeof(Double); - private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); - - private static Double[] _data1 = new Double[Op1ElementCount]; - private static Double[] _data2 = new Double[Op2ElementCount]; - - private static Vector256<Double> _clsVar1; - private static Vector128<Double> _clsVar2; - - private Vector256<Double> _fld1; - private Vector128<Double> _fld2; - - private SimpleBinaryOpTest__DataTable<Double, Double, Double> _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<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); - } - - 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<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); - - 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<Double, Double, Double>(_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<Vector256<Double>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Double>>(_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<Vector256<Double>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(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<Double>)(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<Double>)(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<Vector256<Double>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector128<Double>>(_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<Double> left, Vector128<Double> 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<Double, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Double>>()); - - 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<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector256<Double>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<Double>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Double>>()); - - 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)}<Double>(Vector256<Double>, Vector128<Double>.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 6132cadd08..0000000000 --- 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<Vector256<Int16>>() / sizeof(Int16); - private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Int16>>() / sizeof(Int16); - - private static Int16[] _data1 = new Int16[Op1ElementCount]; - private static Int16[] _data2 = new Int16[Op2ElementCount]; - - private static Vector256<Int16> _clsVar1; - private static Vector128<Int16> _clsVar2; - - private Vector256<Int16> _fld1; - private Vector128<Int16> _fld2; - - private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _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<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Int16>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); - } - - 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<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Int16>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); - - 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<Int16, Int16, Int16>(_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<Vector256<Int16>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Int16>>(_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<Vector256<Int16>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int16>)(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<Int16>)(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<Int16>)(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<Vector256<Int16>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector128<Int16>>(_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<Int16> left, Vector128<Int16> 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<Int16, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int16>>()); - - 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<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector256<Int16>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<Int16>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int16>>()); - - 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)}<Int16>(Vector256<Int16>, Vector128<Int16>.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 ac69626179..0000000000 --- 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<Vector256<Int32>>() / sizeof(Int32); - private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Int32>>() / sizeof(Int32); - - private static Int32[] _data1 = new Int32[Op1ElementCount]; - private static Int32[] _data2 = new Int32[Op2ElementCount]; - - private static Vector256<Int32> _clsVar1; - private static Vector128<Int32> _clsVar2; - - private Vector256<Int32> _fld1; - private Vector128<Int32> _fld2; - - private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _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<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Int32>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>()); - } - - 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<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Int32>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>()); - - 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<Int32, Int32, Int32>(_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<Vector256<Int32>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Int32>>(_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<Vector256<Int32>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Int32>>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int32>)(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<Int32>)(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<Int32>)(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<Vector256<Int32>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector128<Int32>>(_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<Int32> left, Vector128<Int32> 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<Int32, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int32>>()); - - 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<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector256<Int32>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<Int32>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int32>>()); - - 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)}<Int32>(Vector256<Int32>, Vector128<Int32>.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 c998558b52..0000000000 --- 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<Vector256<Int64>>() / sizeof(Int64); - private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Int64>>() / sizeof(Int64); - - private static Int64[] _data1 = new Int64[Op1ElementCount]; - private static Int64[] _data2 = new Int64[Op2ElementCount]; - - private static Vector256<Int64> _clsVar1; - private static Vector128<Int64> _clsVar2; - - private Vector256<Int64> _fld1; - private Vector128<Int64> _fld2; - - private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _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<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Int64>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); - } - - 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<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Int64>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); - - 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<Int64, Int64, Int64>(_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<Vector256<Int64>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Int64>>(_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<Vector256<Int64>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int64>)(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<Int64>)(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<Int64>)(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<Vector256<Int64>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector128<Int64>>(_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<Int64> left, Vector128<Int64> 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<Int64, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int64>>()); - - 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<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector256<Int64>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<Int64>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Int64>>()); - - 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)}<Int64>(Vector256<Int64>, Vector128<Int64>.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 11bbf03f1e..0000000000 --- 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<Vector256<SByte>>() / sizeof(SByte); - private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<SByte>>() / sizeof(SByte); - - private static SByte[] _data1 = new SByte[Op1ElementCount]; - private static SByte[] _data2 = new SByte[Op2ElementCount]; - - private static Vector256<SByte> _clsVar1; - private static Vector128<SByte> _clsVar2; - - private Vector256<SByte> _fld1; - private Vector128<SByte> _fld2; - - private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _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<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); - } - - 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<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); - - 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<SByte, SByte, SByte>(_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<Vector256<SByte>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<SByte>>(_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<Vector256<SByte>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<SByte>)(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<SByte>)(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<SByte>)(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<Vector256<SByte>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector128<SByte>>(_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<SByte> left, Vector128<SByte> 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<SByte, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<SByte>>()); - - 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<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector256<SByte>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<SByte>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<SByte>>()); - - 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)}<SByte>(Vector256<SByte>, Vector128<SByte>.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 e485ed4d77..0000000000 --- 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<Vector256<Single>>() / sizeof(Single); - private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<Single>>() / sizeof(Single); - - private static Single[] _data1 = new Single[Op1ElementCount]; - private static Single[] _data2 = new Single[Op2ElementCount]; - - private static Vector256<Single> _clsVar1; - private static Vector128<Single> _clsVar2; - - private Vector256<Single> _fld1; - private Vector128<Single> _fld2; - - private SimpleBinaryOpTest__DataTable<Single, Single, Single> _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<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Single>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); - } - - 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<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Single>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); - - 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<Single, Single, Single>(_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<Vector256<Single>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Single>>(_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<Vector256<Single>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(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<Single>)(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<Single>)(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<Vector256<Single>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector128<Single>>(_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<Single> left, Vector128<Single> 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<Single, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Single>>()); - - 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<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector256<Single>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<Single>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<Single>>()); - - 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)}<Single>(Vector256<Single>, Vector128<Single>.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 fd6677b2c5..0000000000 --- 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<Vector256<UInt16>>() / sizeof(UInt16); - private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<UInt16>>() / sizeof(UInt16); - - private static UInt16[] _data1 = new UInt16[Op1ElementCount]; - private static UInt16[] _data2 = new UInt16[Op2ElementCount]; - - private static Vector256<UInt16> _clsVar1; - private static Vector128<UInt16> _clsVar2; - - private Vector256<UInt16> _fld1; - private Vector128<UInt16> _fld2; - - private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _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<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt16>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); - } - - 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<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt16>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); - - 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<UInt16, UInt16, UInt16>(_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<Vector256<UInt16>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<UInt16>>(_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<Vector256<UInt16>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<UInt16>)(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<UInt16>)(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<UInt16>)(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<Vector256<UInt16>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector128<UInt16>>(_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<UInt16> left, Vector128<UInt16> 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<UInt16, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<UInt16>>()); - - 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<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector256<UInt16>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<UInt16>>()); - - 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)}<UInt16>(Vector256<UInt16>, Vector128<UInt16>.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 912fd6cb70..0000000000 --- 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<Vector256<UInt32>>() / sizeof(UInt32); - private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<UInt32>>() / sizeof(UInt32); - - private static UInt32[] _data1 = new UInt32[Op1ElementCount]; - private static UInt32[] _data2 = new UInt32[Op2ElementCount]; - - private static Vector256<UInt32> _clsVar1; - private static Vector128<UInt32> _clsVar2; - - private Vector256<UInt32> _fld1; - private Vector128<UInt32> _fld2; - - private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _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<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); - } - - 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<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); - - 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<UInt32, UInt32, UInt32>(_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<Vector256<UInt32>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<UInt32>>(_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<Vector256<UInt32>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<UInt32>)(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<UInt32>)(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<UInt32>)(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<Vector256<UInt32>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector128<UInt32>>(_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<UInt32> left, Vector128<UInt32> 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<UInt32, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); - - 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<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); - - 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)}<UInt32>(Vector256<UInt32>, Vector128<UInt32>.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 50b7c6d722..0000000000 --- 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<Vector256<UInt64>>() / sizeof(UInt64); - private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt64>>() / sizeof(UInt64); - private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<UInt64>>() / sizeof(UInt64); - - private static UInt64[] _data1 = new UInt64[Op1ElementCount]; - private static UInt64[] _data2 = new UInt64[Op2ElementCount]; - - private static Vector256<UInt64> _clsVar1; - private static Vector128<UInt64> _clsVar2; - - private Vector256<UInt64> _fld1; - private Vector128<UInt64> _fld2; - - private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _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<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt64>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); - } - - 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<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt64>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); - - 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<UInt64, UInt64, UInt64>(_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<Vector256<UInt64>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<UInt64>>(_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<Vector256<UInt64>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<UInt64>)(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<UInt64>)(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<UInt64>)(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<Vector256<UInt64>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector128<UInt64>>(_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<UInt64> left, Vector128<UInt64> 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<UInt64, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<UInt64>>()); - - 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<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), (uint)Unsafe.SizeOf<Vector256<UInt64>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<UInt64>>()); - - 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)}<UInt64>(Vector256<UInt64>, Vector128<UInt64>.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 598b34d343..0000000000 --- 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<string, Action>() { - ["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 3d8f6a2d27..0000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx_r.csproj +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> - <OutputType>Exe</OutputType> - <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - </PropertyGroup> - <!-- Default configurations to help VS understand the configurations --> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> - <ItemGroup> - <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> - <Visible>False</Visible> - </CodeAnalysisDependentAssemblyPaths> - </ItemGroup> - <PropertyGroup> - <DebugType>Embedded</DebugType> - <Optimize></Optimize> - </PropertyGroup> - <ItemGroup> - <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Permute2x128.Single.2.cs" /> - <Compile Include="Permute2x128.Double.2.cs" /> - <Compile Include="Permute2x128.Int32.2.cs" /> - <Compile Include="Permute2x128.UInt32.2.cs" /> - <Compile Include="Permute2x128.Int64.2.cs" /> - <Compile Include="Permute2x128.UInt64.2.cs" /> - <Compile Include="Permute2x128.Avx.cs" /> - <Compile Include="..\Shared\BooleanBinOpTest_DataTable.cs" /> - <Compile Include="..\Shared\BooleanTwoCmpOpTest_DataTable.cs" /> - <Compile Include="..\Shared\Program.cs" /> - <Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" /> - <Compile Include="..\Shared\SimpleTernOpTest_DataTable.cs" /> - <Compile Include="..\Shared\SimpleUnOpTest_DataTable.cs" /> - </ItemGroup> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> - <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> -</Project> 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 d362008baa..0000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute2x128.Avx_ro.csproj +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> - <OutputType>Exe</OutputType> - <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - </PropertyGroup> - <!-- Default configurations to help VS understand the configurations --> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> - <ItemGroup> - <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> - <Visible>False</Visible> - </CodeAnalysisDependentAssemblyPaths> - </ItemGroup> - <PropertyGroup> - <DebugType>Embedded</DebugType> - <Optimize>True</Optimize> - </PropertyGroup> - <ItemGroup> - <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Permute2x128.Single.2.cs" /> - <Compile Include="Permute2x128.Double.2.cs" /> - <Compile Include="Permute2x128.Int32.2.cs" /> - <Compile Include="Permute2x128.UInt32.2.cs" /> - <Compile Include="Permute2x128.Int64.2.cs" /> - <Compile Include="Permute2x128.UInt64.2.cs" /> - <Compile Include="Permute2x128.Avx.cs" /> - <Compile Include="..\Shared\BooleanBinOpTest_DataTable.cs" /> - <Compile Include="..\Shared\BooleanTwoCmpOpTest_DataTable.cs" /> - <Compile Include="..\Shared\Program.cs" /> - <Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" /> - <Compile Include="..\Shared\SimpleTernOpTest_DataTable.cs" /> - <Compile Include="..\Shared\SimpleUnOpTest_DataTable.cs" /> - </ItemGroup> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> - <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> -</Project> 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 3df7e70ea9..0000000000 --- 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<Double> _clsVar1; - private static Vector256<Double> _clsVar2; - - private Vector256<Double> _fld1; - private Vector256<Double> _fld2; - - private SimpleBinaryOpTest__DataTable<Double, Double, Double> _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<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(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<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(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<Double, Double, Double>(_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<Vector256<Double>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<Double>>(_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<Vector256<Double>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(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<Double>)(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<Double>)(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<Vector256<Double>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector256<Double>>(_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<Double> left, Vector256<Double> 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<Double, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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)}<Double>(Vector256<Double>.2, Vector256<Double>): {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 cb0a2ddb12..0000000000 --- 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<Int32> _clsVar1; - private static Vector256<Int32> _clsVar2; - - private Vector256<Int32> _fld1; - private Vector256<Int32> _fld2; - - private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _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<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(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<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(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<Int32, Int32, Int32>(_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<Vector256<Int32>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<Int32>>(_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<Vector256<Int32>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<Int32>>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int32>)(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<Int32>)(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<Int32>)(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<Vector256<Int32>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector256<Int32>>(_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<Int32> left, Vector256<Int32> 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<Int32, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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)}<Int32>(Vector256<Int32>.2, Vector256<Int32>): {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 ddbcaa8c6c..0000000000 --- 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<Int64> _clsVar1; - private static Vector256<Int64> _clsVar2; - - private Vector256<Int64> _fld1; - private Vector256<Int64> _fld2; - - private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _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<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(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<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(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<Int64, Int64, Int64>(_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<Vector256<Int64>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<Int64>>(_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<Vector256<Int64>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<Int64>>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Int64>)(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<Int64>)(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<Int64>)(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<Vector256<Int64>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector256<Int64>>(_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<Int64> left, Vector256<Int64> 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<Int64, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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)}<Int64>(Vector256<Int64>.2, Vector256<Int64>): {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 bcec95d79c..0000000000 --- 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<Single> _clsVar1; - private static Vector256<Single> _clsVar2; - - private Vector256<Single> _fld1; - private Vector256<Single> _fld2; - - private SimpleBinaryOpTest__DataTable<Single, Single, Single> _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<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(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<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(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<Single, Single, Single>(_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<Vector256<Single>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<Single>>(_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<Vector256<Single>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<Single>>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(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<Single>)(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<Single>)(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<Vector256<Single>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector256<Single>>(_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<Single> left, Vector256<Single> 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<Single, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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)}<Single>(Vector256<Single>.2, Vector256<Single>): {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 751d0a4fe7..0000000000 --- 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<UInt32> _clsVar1; - private static Vector256<UInt32> _clsVar2; - - private Vector256<UInt32> _fld1; - private Vector256<UInt32> _fld2; - - private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _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<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(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<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(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<UInt32, UInt32, UInt32>(_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<Vector256<UInt32>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<UInt32>>(_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<Vector256<UInt32>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<UInt32>)(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<UInt32>)(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<UInt32>)(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<Vector256<UInt32>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector256<UInt32>>(_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<UInt32> left, Vector256<UInt32> 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<UInt32, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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)}<UInt32>(Vector256<UInt32>.2, Vector256<UInt32>): {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 305b3a8c20..0000000000 --- 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<UInt64> _clsVar1; - private static Vector256<UInt64> _clsVar2; - - private Vector256<UInt64> _fld1; - private Vector256<UInt64> _fld2; - - private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _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<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(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<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(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<UInt64, UInt64, UInt64>(_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<Vector256<UInt64>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<UInt64>>(_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<Vector256<UInt64>>(_dataTable.inArray1Ptr), - Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray2Ptr), - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256<UInt64>)(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<UInt64>)(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<UInt64>)(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<Vector256<UInt64>>(_dataTable.inArray1Ptr); - var right = Unsafe.Read<Vector256<UInt64>>(_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<UInt64> left, Vector256<UInt64> 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<UInt64, byte>(ref inArray1[0]), left); - Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), right); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(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)}<UInt64>(Vector256<UInt64>.2, Vector256<UInt64>): {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 a0e07b776f..1483ebd328 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 331a176448..bcc5665b9a 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<T> v1 = Avx.SetAllVector256<T>(t1); - v1 = Avx.Permute2x128(v1, Avx.SetAllVector256<T>(t2), 1); + v1 = Vector256Add<T>(v1, Avx.SetAllVector256<T>(t2)); } return Pass; } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx index 506b66b5a8..1e35bd0ca4 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<string, string> tem ("ExtractScalarTest.template", new Dictionary<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> tem ("ImmBinOpTest.template", new Dictionary<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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<string, string> { ["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 54118803a9..0000000000 --- a/tests/src/JIT/Performance/CodeQuality/HWIntrinsic/X86/PacketTracer/PacketTracer.csproj +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <SchemaVersion>2.1</SchemaVersion> - <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> - <OutputType>Exe</OutputType> - <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> - <NuGetTargetMoniker>.NETStandard,Version=v1.4</NuGetTargetMoniker> - <NuGetTargetMonikerShort>netstandard1.4</NuGetTargetMonikerShort> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - </PropertyGroup> - <!-- Default configurations to help VS understand the configurations --> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> - <PropertyGroup> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - </PropertyGroup> - - <ItemGroup> - <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> - <Visible>False</Visible> - </CodeAnalysisDependentAssemblyPaths> - </ItemGroup> - <ItemGroup> - <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Program.cs" /> - <Compile Include="Camera.cs" /> - <Compile Include="Color.cs" /> - <Compile Include="ColorPacket.cs" /> - <Compile Include="Intersections.cs" /> - <Compile Include="LightPacket.cs" /> - <Compile Include="ObjectPacket.cs" /> - <Compile Include="ObjectPool.cs" /> - <Compile Include="PacketTracer.cs" /> - <Compile Include="PlanePacket.cs" /> - <Compile Include="ProducerConsumerCollectionBase.cs" /> - <Compile Include="RayPacket.cs" /> - <Compile Include="Scene.cs" /> - <Compile Include="SpherePacket.cs" /> - <Compile Include="Surface.cs" /> - <Compile Include="Surfaces.cs" /> - <Compile Include="Vector.cs" /> - <Compile Include="VectorPacket.cs" /> - <Compile Include="VectorMath.cs" /> - </ItemGroup> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> - <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> - <PropertyGroup> - <ProjectAssetsFile>$(JitPackagesConfigFileDirectory)benchmark+intrinsic\obj\project.assets.json</ProjectAssetsFile> - </PropertyGroup> -</Project> |