diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs index 1fd61ec3e1e1..03a33131c88c 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs @@ -234,11 +234,6 @@ public static class Avx /// public static Vector256 DuplicateOddIndexed(Vector256 value) { throw new PlatformNotSupportedException(); } - /// - /// __int8 _mm256_extract_epi8 (__m256i a, const int index) - /// HELPER - /// - public static sbyte Extract(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __int8 _mm256_extract_epi8 (__m256i a, const int index) /// HELPER @@ -248,11 +243,6 @@ public static class Avx /// __int16 _mm256_extract_epi16 (__m256i a, const int index) /// HELPER /// - public static short Extract(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __int16 _mm256_extract_epi16 (__m256i a, const int index) - /// HELPER - /// public static ushort Extract(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __int32 _mm256_extract_epi32 (__m256i a, const int index) @@ -638,45 +628,45 @@ public static class Avx /// __m128 _mm_maskload_ps (float const * mem_addr, __m128i mask) /// VMASKMOVPS xmm, xmm, m128 /// - public static unsafe Vector128 MaskLoad(float* address, Vector128 mask) { throw new PlatformNotSupportedException(); } + public static unsafe Vector128 MaskLoad(float* address, Vector128 mask) { throw new PlatformNotSupportedException(); } /// /// __m128d _mm_maskload_pd (double const * mem_addr, __m128i mask) /// VMASKMOVPD xmm, xmm, m128 /// - public static unsafe Vector128 MaskLoad(double* address, Vector128 mask) { throw new PlatformNotSupportedException(); } + public static unsafe Vector128 MaskLoad(double* address, Vector128 mask) { throw new PlatformNotSupportedException(); } /// /// __m256 _mm256_maskload_ps (float const * mem_addr, __m256i mask) /// VMASKMOVPS ymm, ymm, m256 /// - public static unsafe Vector256 MaskLoad(float* address, Vector256 mask) { throw new PlatformNotSupportedException(); } + public static unsafe Vector256 MaskLoad(float* address, Vector256 mask) { throw new PlatformNotSupportedException(); } /// /// __m256d _mm256_maskload_pd (double const * mem_addr, __m256i mask) /// VMASKMOVPD ymm, ymm, m256 /// - public static unsafe Vector256 MaskLoad(double* address, Vector256 mask) { throw new PlatformNotSupportedException(); } + public static unsafe Vector256 MaskLoad(double* address, Vector256 mask) { throw new PlatformNotSupportedException(); } /// /// void _mm_maskstore_ps (float * mem_addr, __m128i mask, __m128 a) /// VMASKMOVPS m128, xmm, xmm /// - public static unsafe void MaskStore(float* address, Vector128 mask, Vector128 source) { throw new PlatformNotSupportedException(); } + public static unsafe void MaskStore(float* address, Vector128 mask, Vector128 source) { throw new PlatformNotSupportedException(); } /// /// void _mm_maskstore_pd (double * mem_addr, __m128i mask, __m128d a) /// VMASKMOVPD m128, xmm, xmm /// - public static unsafe void MaskStore(double* address, Vector128 mask, Vector128 source) { throw new PlatformNotSupportedException(); } + public static unsafe void MaskStore(double* address, Vector128 mask, Vector128 source) { throw new PlatformNotSupportedException(); } /// /// void _mm256_maskstore_ps (float * mem_addr, __m256i mask, __m256 a) /// VMASKMOVPS m256, ymm, ymm /// - public static unsafe void MaskStore(float* address, Vector256 mask, Vector256 source) { throw new PlatformNotSupportedException(); } + public static unsafe void MaskStore(float* address, Vector256 mask, Vector256 source) { throw new PlatformNotSupportedException(); } /// /// void _mm256_maskstore_pd (double * mem_addr, __m256i mask, __m256d a) /// VMASKMOVPD m256, ymm, ymm /// - public static unsafe void MaskStore(double* address, Vector256 mask, Vector256 source) { throw new PlatformNotSupportedException(); } + public static unsafe void MaskStore(double* address, Vector256 mask, Vector256 source) { throw new PlatformNotSupportedException(); } /// /// __m256 _mm256_max_ps (__m256 a, __m256 b) diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs index fdb349b120ee..63e0e29efd0c 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs @@ -4,7 +4,7 @@ using System; using System.Runtime.Intrinsics; -using System.Runtime.CompilerServices; +using Internal.Runtime.CompilerServices; namespace System.Runtime.Intrinsics.X86 { @@ -235,50 +235,15 @@ public static class Avx /// public static Vector256 DuplicateOddIndexed(Vector256 value) => DuplicateOddIndexed(value); - /// - /// __int8 _mm256_extract_epi8 (__m256i a, const int index) - /// HELPER - /// - public static sbyte Extract(Vector256 value, byte index) - { - unsafe - { - index &= 0x1F; - sbyte* buffer = stackalloc sbyte[32]; - Store(buffer, value); - return buffer[index]; - } - } - /// /// __int8 _mm256_extract_epi8 (__m256i a, const int index) /// HELPER /// public static byte Extract(Vector256 value, byte index) { - unsafe - { - index &= 0x1F; - byte* buffer = stackalloc byte[32]; - Store(buffer, value); - return buffer[index]; - } + return Unsafe.Add(ref Unsafe.As, byte>(ref value), index & 0x1F); } - /// - /// __int16 _mm256_extract_epi16 (__m256i a, const int index) - /// HELPER - /// - public static short Extract(Vector256 value, byte index) - { - unsafe - { - index &= 0xF; - short* buffer = stackalloc short[16]; - Store(buffer, value); - return buffer[index]; - } - } /// /// __int16 _mm256_extract_epi16 (__m256i a, const int index) @@ -286,13 +251,7 @@ public static short Extract(Vector256 value, byte index) /// public static ushort Extract(Vector256 value, byte index) { - unsafe - { - index &= 0xF; - ushort* buffer = stackalloc ushort[16]; - Store(buffer, value); - return buffer[index]; - } + return Unsafe.Add(ref Unsafe.As, ushort>(ref value), index & 0xF); } /// @@ -301,13 +260,7 @@ public static ushort Extract(Vector256 value, byte index) /// public static int Extract(Vector256 value, byte index) { - unsafe - { - index &= 0x7; - int* buffer = stackalloc int[8]; - Store(buffer, value); - return buffer[index]; - } + return Unsafe.Add(ref Unsafe.As, int>(ref value), index & 0x7); } /// @@ -316,13 +269,7 @@ public static int Extract(Vector256 value, byte index) /// public static uint Extract(Vector256 value, byte index) { - unsafe - { - index &= 0x7; - uint* buffer = stackalloc uint[8]; - Store(buffer, value); - return buffer[index]; - } + return Unsafe.Add(ref Unsafe.As, uint>(ref value), index & 0x7); } /// @@ -335,13 +282,7 @@ public static long Extract(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - unsafe - { - index &= 0x3; - long* buffer = stackalloc long[4]; - Store(buffer, value); - return buffer[index]; - } + return Unsafe.Add(ref Unsafe.As, long>(ref value), index & 0x3); } /// @@ -354,13 +295,7 @@ public static ulong Extract(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - unsafe - { - index &= 0x3; - ulong* buffer = stackalloc ulong[4]; - Store(buffer, value); - return buffer[index]; - } + return Unsafe.Add(ref Unsafe.As, ulong>(ref value), index & 0x3); } /// @@ -825,45 +760,45 @@ public static Vector256 InsertVector128(Vector256 value, Vector128 d /// __m128 _mm_maskload_ps (float const * mem_addr, __m128i mask) /// VMASKMOVPS xmm, xmm, m128 /// - public static unsafe Vector128 MaskLoad(float* address, Vector128 mask) => MaskLoad(address, mask); + public static unsafe Vector128 MaskLoad(float* address, Vector128 mask) => MaskLoad(address, mask); /// /// __m128d _mm_maskload_pd (double const * mem_addr, __m128i mask) /// VMASKMOVPD xmm, xmm, m128 /// - public static unsafe Vector128 MaskLoad(double* address, Vector128 mask) => MaskLoad(address, mask); + public static unsafe Vector128 MaskLoad(double* address, Vector128 mask) => MaskLoad(address, mask); /// /// __m256 _mm256_maskload_ps (float const * mem_addr, __m256i mask) /// VMASKMOVPS ymm, ymm, m256 /// - public static unsafe Vector256 MaskLoad(float* address, Vector256 mask) => MaskLoad(address, mask); + public static unsafe Vector256 MaskLoad(float* address, Vector256 mask) => MaskLoad(address, mask); /// /// __m256d _mm256_maskload_pd (double const * mem_addr, __m256i mask) /// VMASKMOVPD ymm, ymm, m256 /// - public static unsafe Vector256 MaskLoad(double* address, Vector256 mask) => MaskLoad(address, mask); + public static unsafe Vector256 MaskLoad(double* address, Vector256 mask) => MaskLoad(address, mask); /// /// void _mm_maskstore_ps (float * mem_addr, __m128i mask, __m128 a) /// VMASKMOVPS m128, xmm, xmm /// - public static unsafe void MaskStore(float* address, Vector128 mask, Vector128 source) => MaskStore(address, mask, source); + public static unsafe void MaskStore(float* address, Vector128 mask, Vector128 source) => MaskStore(address, mask, source); /// /// void _mm_maskstore_pd (double * mem_addr, __m128i mask, __m128d a) /// VMASKMOVPD m128, xmm, xmm /// - public static unsafe void MaskStore(double* address, Vector128 mask, Vector128 source) => MaskStore(address, mask, source); + public static unsafe void MaskStore(double* address, Vector128 mask, Vector128 source) => MaskStore(address, mask, source); /// /// void _mm256_maskstore_ps (float * mem_addr, __m256i mask, __m256 a) /// VMASKMOVPS m256, ymm, ymm /// - public static unsafe void MaskStore(float* address, Vector256 mask, Vector256 source) => MaskStore(address, mask, source); + public static unsafe void MaskStore(float* address, Vector256 mask, Vector256 source) => MaskStore(address, mask, source); /// /// void _mm256_maskstore_pd (double * mem_addr, __m256i mask, __m256d a) /// VMASKMOVPD m256, ymm, ymm /// - public static unsafe void MaskStore(double* address, Vector256 mask, Vector256 source) => MaskStore(address, mask, source); + public static unsafe void MaskStore(double* address, Vector256 mask, Vector256 source) => MaskStore(address, mask, source); /// /// __m256 _mm256_max_ps (__m256 a, __m256 b) diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs index 8aaa454eebca..0e2bb5d48b71 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs @@ -609,11 +609,6 @@ public static class Sse2 /// public static Vector128 DivideScalar(Vector128 left, Vector128 right) { throw new PlatformNotSupportedException(); } - /// - /// int _mm_extract_epi16 (__m128i a, int immediate) - /// PEXTRW reg, xmm, imm8 - /// - public static short Extract(Vector128 value, byte index) { throw new PlatformNotSupportedException(); } /// /// int _mm_extract_epi16 (__m128i a, int immediate) /// PEXTRW reg, xmm, imm8 diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.cs index d0eb9ef4da9b..332bd7b8c936 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.cs @@ -610,11 +610,6 @@ public static class Sse2 /// public static Vector128 DivideScalar(Vector128 left, Vector128 right) => DivideScalar(left, right); - /// - /// int _mm_extract_epi16 (__m128i a, int immediate) - /// PEXTRW reg, xmm, imm8 - /// - public static short Extract(Vector128 value, byte index) => Extract(value, index); /// /// int _mm_extract_epi16 (__m128i a, int immediate) /// PEXTRW reg, xmm, imm8 diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs index 063b8dc2cbf7..8ba73931c02d 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs @@ -178,11 +178,6 @@ public static class Sse41 /// public static Vector128 DotProduct(Vector128 left, Vector128 right, byte control) { throw new PlatformNotSupportedException(); } - /// - /// int _mm_extract_epi8 (__m128i a, const int imm8) - /// PEXTRB reg/m8, xmm, imm8 - /// - public static sbyte Extract(Vector128 value, byte index) { throw new PlatformNotSupportedException(); } /// /// int _mm_extract_epi8 (__m128i a, const int imm8) /// PEXTRB reg/m8, xmm, imm8 @@ -283,7 +278,7 @@ public static class Sse41 /// __m128 _mm_insert_ps (__m128 a, __m128 b, const int imm8) /// INSERTPS xmm, xmm/m32, imm8 /// - public static Vector128 Insert(Vector128 value, float data, byte index) { throw new PlatformNotSupportedException(); } + public static Vector128 Insert(Vector128 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm_max_epi8 (__m128i a, __m128i b) diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.cs index dd81168a2450..c3d9dcb1cd86 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.cs @@ -178,11 +178,6 @@ public static class Sse41 /// public static Vector128 DotProduct(Vector128 left, Vector128 right, byte control) => DotProduct(left, right, control); - /// - /// int _mm_extract_epi8 (__m128i a, const int imm8) - /// PEXTRB reg/m8, xmm, imm8 - /// - public static sbyte Extract(Vector128 value, byte index) => Extract(value, index); /// /// int _mm_extract_epi8 (__m128i a, const int imm8) /// PEXTRB reg/m8, xmm, imm8 @@ -283,7 +278,7 @@ public static class Sse41 /// __m128 _mm_insert_ps (__m128 a, __m128 b, const int imm8) /// INSERTPS xmm, xmm/m32, imm8 /// - public static Vector128 Insert(Vector128 value, float data, byte index) => Insert(value, data, index); + public static Vector128 Insert(Vector128 value, Vector128 data, byte index) => Insert(value, data, index); /// /// __m128i _mm_max_epi8 (__m128i a, __m128i b) diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj index 7f89b8944017..5a4658cb1311 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj @@ -45,12 +45,8 @@ - - - - @@ -61,8 +57,6 @@ - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj index 66eb86a7e156..5ff97f7892b2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj @@ -45,12 +45,8 @@ - - - - @@ -61,8 +57,6 @@ - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.1.cs deleted file mode 100644 index 157ae1696f33..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.1.cs +++ /dev/null @@ -1,309 +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 ExtractInt161() - { - var test = new SimpleUnaryOpTest__ExtractInt161(); - - try - { - 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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractInt161 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractInt161() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractInt161() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(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.Extract(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.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractInt161(); - var result = Avx.Extract(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.11.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.11.cs deleted file mode 100644 index ba511b820092..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.11.cs +++ /dev/null @@ -1,309 +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 ExtractInt1611() - { - var test = new SimpleUnaryOpTest__ExtractInt1611(); - - try - { - 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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractInt1611 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractInt1611() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractInt1611() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 11 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - 11 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - 11 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)11 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)11 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)11 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 11 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(firstOp, 11); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 11); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 11); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractInt1611(); - var result = Avx.Extract(test._fld, 11); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 11); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[11])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.27.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.27.cs deleted file mode 100644 index 83d73dacf628..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.27.cs +++ /dev/null @@ -1,309 +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 ExtractInt1627() - { - var test = new SimpleUnaryOpTest__ExtractInt1627(); - - try - { - 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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractInt1627 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractInt1627() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractInt1627() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 27 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - 27 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - 27 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)27 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)27 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)27 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 27 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(firstOp, 27); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 27); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 27); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractInt1627(); - var result = Avx.Extract(test._fld, 27); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 27); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[11])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.1.cs deleted file mode 100644 index 387e00b548ea..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.1.cs +++ /dev/null @@ -1,309 +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 ExtractSByte1() - { - var test = new SimpleUnaryOpTest__ExtractSByte1(); - - try - { - 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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractSByte1 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractSByte1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractSByte1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(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.Extract(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.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractSByte1(); - var result = Avx.Extract(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.20.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.20.cs deleted file mode 100644 index 4fb463acd804..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.20.cs +++ /dev/null @@ -1,309 +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 ExtractSByte20() - { - var test = new SimpleUnaryOpTest__ExtractSByte20(); - - try - { - 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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractSByte20 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractSByte20() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractSByte20() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 20 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - 20 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - 20 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)20 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)20 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)20 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 20 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(firstOp, 20); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 20); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 20); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractSByte20(); - var result = Avx.Extract(test._fld, 20); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 20); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[20])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.52.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.52.cs deleted file mode 100644 index 391703f2d9aa..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.52.cs +++ /dev/null @@ -1,309 +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 ExtractSByte52() - { - var test = new SimpleUnaryOpTest__ExtractSByte52(); - - try - { - 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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractSByte52 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractSByte52() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractSByte52() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 52 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - 52 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - 52 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)52 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)52 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)52 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 52 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(firstOp, 52); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 52); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 52); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractSByte52(); - var result = Avx.Extract(test._fld, 52); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 52); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[20])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_r.csproj deleted file mode 100644 index a35fbf8f8af8..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_r.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - true - - - - - - - False - - - - None - - - - - - - - - - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_ro.csproj deleted file mode 100644 index d0a0a9c518c5..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_ro.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - true - - - - - - - False - - - - None - True - - - - - - - - - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs index 9c52458bfab2..0b40b214f166 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs @@ -30,16 +30,10 @@ static Program() ["DuplicateEvenIndexed.Single"] = DuplicateEvenIndexedSingle, ["DuplicateOddIndexed.Single"] = DuplicateOddIndexedSingle, ["Extract.Byte.1"] = ExtractByte1, - ["Extract.SByte.1"] = ExtractSByte1, ["Extract.Byte.20"] = ExtractByte20, - ["Extract.SByte.20"] = ExtractSByte20, ["Extract.Byte.52"] = ExtractByte52, - ["Extract.SByte.52"] = ExtractSByte52, - ["Extract.Int16.1"] = ExtractInt161, ["Extract.UInt16.1"] = ExtractUInt161, - ["Extract.Int16.11"] = ExtractInt1611, ["Extract.UInt16.11"] = ExtractUInt1611, - ["Extract.Int16.27"] = ExtractInt1627, ["Extract.UInt16.27"] = ExtractUInt1627, ["Extract.Int32.1"] = ExtractInt321, ["Extract.UInt32.1"] = ExtractUInt321, diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx index e8f44cde1889..13c621f0f123 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx @@ -137,9 +137,7 @@ private static readonly (string templateFileName, Dictionary tem ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareUnordered", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((double.IsNaN(left[0]) || double.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((double.IsNaN(left[i]) || double.IsNaN(right[i])) ? -1 : 0)"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Divide", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "DivideScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), @@ -284,14 +282,12 @@ private static readonly (string templateFileName, Dictionary tem ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((long)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0)"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((ulong)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0)"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[1]))"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Byte", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), @@ -301,30 +297,18 @@ private static readonly (string templateFileName, Dictionary tem ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Floor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "FloorScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "FloorScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "0", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Byte", ["Data"] = "(byte)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Data"] = "(sbyte)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Data"] = "(int)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt32", ["Data"] = "(uint)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int64", ["Data"] = "(long)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt64", ["Data"] = "(ulong)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "2", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "4", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "8", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "48", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "128", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Byte", ["Data"] = "(byte)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Data"] = "(sbyte)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Data"] = "(int)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt32", ["Data"] = "(uint)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int64", ["Data"] = "(long)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt64", ["Data"] = "(ulong)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "192", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != Math.Max(left[0], right[0])", ["ValidateRemainingResults"] = "result[i] != Math.Max(left[i], right[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != Math.Max(left[0], right[0])", ["ValidateRemainingResults"] = "result[i] != Math.Max(left[i], right[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != Math.Max(left[0], right[0])", ["ValidateRemainingResults"] = "result[i] != Math.Max(left[i], right[i])"}), @@ -430,16 +414,10 @@ private static readonly (string templateFileName, Dictionary tem ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "DuplicateEvenIndexed", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i - 1]) != BitConverter.SingleToInt32Bits(result[i]))"}), ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "DuplicateOddIndexed", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[1]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i + 1]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "20", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[20])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "20", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[20])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "52", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[20])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "52", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[20])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "11", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[11])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "11", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[11])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "27", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[11])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "27", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[11])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.1.cs deleted file mode 100644 index f2f11953fffc..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.1.cs +++ /dev/null @@ -1,309 +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 ExtractInt161() - { - var test = new SimpleUnaryOpTest__ExtractInt161(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse2.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 (Sse2.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 (Sse2.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractInt161 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractInt161() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractInt161() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse2.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse2.Extract( - Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse2.Extract( - Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse2.Extract( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse2.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)); - var result = Sse2.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)); - var result = Sse2.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractInt161(); - var result = Sse2.Extract(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse2.Extract(_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(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Extract)}(Vector128<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/Sse2/Extract.Int16.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.129.cs deleted file mode 100644 index e2d3a0013509..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.129.cs +++ /dev/null @@ -1,309 +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 ExtractInt16129() - { - var test = new SimpleUnaryOpTest__ExtractInt16129(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse2.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 (Sse2.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 (Sse2.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractInt16129 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractInt16129() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractInt16129() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse2.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse2.Extract( - Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse2.Extract( - Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse2.Extract( - _clsVar, - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse2.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)); - var result = Sse2.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)); - var result = Sse2.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractInt16129(); - var result = Sse2.Extract(test._fld, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse2.Extract(_fld, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Extract)}(Vector128<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/Sse2/Program.Sse2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs index 10782bcced44..e2ab97d7f122 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs @@ -72,9 +72,7 @@ static Program() ["CompareUnordered.Double"] = CompareUnorderedDouble, ["Divide.Double"] = DivideDouble, ["DivideScalar.Double"] = DivideScalarDouble, - ["Extract.Int16.1"] = ExtractInt161, ["Extract.UInt16.1"] = ExtractUInt161, - ["Extract.Int16.129"] = ExtractInt16129, ["Extract.UInt16.129"] = ExtractUInt16129, ["Insert.Int16.1"] = InsertInt161, ["Insert.UInt16.1"] = InsertUInt161, diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj index fec034cb5168..0769a9d4d1b9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj @@ -87,9 +87,7 @@ - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj index 8c82568c0c9a..cdf3e718b3d2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj @@ -87,9 +87,7 @@ - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.1.cs deleted file mode 100644 index 82650303230e..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.1.cs +++ /dev/null @@ -1,309 +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 ExtractSByte1() - { - var test = new SimpleUnaryOpTest__ExtractSByte1(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse2.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 (Sse2.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 (Sse2.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractSByte1 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractSByte1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractSByte1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Extract( - Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Extract( - Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Extract( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)); - var result = Sse41.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)); - var result = Sse41.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractSByte1(); - var result = Sse41.Extract(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Extract(_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(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Extract)}(Vector128<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/Sse41/Extract.SByte.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.129.cs deleted file mode 100644 index f4c2258f66ec..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.129.cs +++ /dev/null @@ -1,309 +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 ExtractSByte129() - { - var test = new SimpleUnaryOpTest__ExtractSByte129(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse2.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 (Sse2.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 (Sse2.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractSByte129 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractSByte129() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractSByte129() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Extract( - Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Extract( - Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Extract( - _clsVar, - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)); - var result = Sse41.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)); - var result = Sse41.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractSByte129(); - var result = Sse41.Extract(test._fld, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Extract(_fld, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Extract)}(Vector128<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/Sse41/Insert.Single.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.1.cs deleted file mode 100644 index 537fe667027c..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.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.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 InsertSingle1() - { - var test = new SimpleUnaryOpTest__InsertSingle1(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle1 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle1(); - var result = Sse41.Insert(test._fld, (float)2, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 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(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.128.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.128.cs deleted file mode 100644 index 0ca49317765a..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.128.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.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 InsertSingle128() - { - var test = new SimpleUnaryOpTest__InsertSingle128(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle128 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle128() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle128() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 128 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 128 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 128 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)128 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)128 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)128 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 128 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 128); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 128); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 128); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle128(); - var result = Sse41.Insert(test._fld, (float)2, 128); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 128); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.129.cs deleted file mode 100644 index 8b30e9f31936..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.129.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.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 InsertSingle129() - { - var test = new SimpleUnaryOpTest__InsertSingle129(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle129 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle129() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle129() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle129(); - var result = Sse41.Insert(test._fld, (float)2, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.16.cs deleted file mode 100644 index a491c1029193..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.16.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.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 InsertSingle16() - { - var test = new SimpleUnaryOpTest__InsertSingle16(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle16 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle16() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle16() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 16 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 16 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 16 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)16 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)16 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)16 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 16 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 16); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 16); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 16); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle16(); - var result = Sse41.Insert(test._fld, (float)2, 16); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 16); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.192.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.192.cs deleted file mode 100644 index f8908e3588f8..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.192.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.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 InsertSingle192() - { - var test = new SimpleUnaryOpTest__InsertSingle192(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle192 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle192() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle192() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 192 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 192 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 192 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)192 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)192 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)192 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 192 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 192); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 192); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 192); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle192(); - var result = Sse41.Insert(test._fld, (float)2, 192); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 192); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.2.cs deleted file mode 100644 index 44ead60aec3d..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.2.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.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 InsertSingle2() - { - var test = new SimpleUnaryOpTest__InsertSingle2(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle2 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle2() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle2() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)2 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 2 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle2(); - var result = Sse41.Insert(test._fld, (float)2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 2); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.217.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.217.cs deleted file mode 100644 index 64872177fdff..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.217.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.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 InsertSingle217() - { - var test = new SimpleUnaryOpTest__InsertSingle217(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle217 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle217() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle217() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 217 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 217 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 217 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)217 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)217 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)217 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 217 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 217); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 217); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 217); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle217(); - var result = Sse41.Insert(test._fld, (float)2, 217); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 217); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits((float)0))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.32.cs deleted file mode 100644 index 6d647afde19c..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.32.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.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 InsertSingle32() - { - var test = new SimpleUnaryOpTest__InsertSingle32(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle32 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle32() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle32() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 32 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 32 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 32 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)32 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)32 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)32 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 32 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 32); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 32); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 32); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle32(); - var result = Sse41.Insert(test._fld, (float)2, 32); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 32); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.4.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.4.cs deleted file mode 100644 index c47c9d28e934..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.4.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.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 InsertSingle4() - { - var test = new SimpleUnaryOpTest__InsertSingle4(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle4 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle4() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle4() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 4 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 4 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 4 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)4 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)4 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)4 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 4 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 4); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 4); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 4); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle4(); - var result = Sse41.Insert(test._fld, (float)2, 4); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 4); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.48.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.48.cs deleted file mode 100644 index 4a8eef9c61e6..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.48.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.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 InsertSingle48() - { - var test = new SimpleUnaryOpTest__InsertSingle48(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle48 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle48() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle48() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 48 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 48 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 48 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)48 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)48 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)48 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 48 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 48); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 48); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 48); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle48(); - var result = Sse41.Insert(test._fld, (float)2, 48); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 48); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.64.cs deleted file mode 100644 index feddaad2e68f..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.64.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.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 InsertSingle64() - { - var test = new SimpleUnaryOpTest__InsertSingle64(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle64 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle64() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle64() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 64 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 64 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 64 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)64 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)64 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)64 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 64 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 64); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 64); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 64); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle64(); - var result = Sse41.Insert(test._fld, (float)2, 64); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 64); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Insert.Single.8.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.8.cs deleted file mode 100644 index b81444ccb044..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.8.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.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 InsertSingle8() - { - var test = new SimpleUnaryOpTest__InsertSingle8(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.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 (Sse.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 (Sse.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(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle8 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle8() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle8() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 8 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 8 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 8 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)8 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)8 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)8 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 8 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 8); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 8); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 8); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle8(); - var result = Sse41.Insert(test._fld, (float)2, 8); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 8); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<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/Sse41/Program.Sse41.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Program.Sse41.cs index 195e1865b2b4..92fd2acd8c7d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Program.Sse41.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Program.Sse41.cs @@ -23,14 +23,12 @@ static Program() ["CompareEqual.Int64"] = CompareEqualInt64, ["CompareEqual.UInt64"] = CompareEqualUInt64, ["Extract.Byte.1"] = ExtractByte1, - ["Extract.SByte.1"] = ExtractSByte1, ["Extract.Int32.1"] = ExtractInt321, ["Extract.UInt32.1"] = ExtractUInt321, ["Extract.Int64.1"] = ExtractInt641, ["Extract.UInt64.1"] = ExtractUInt641, ["Extract.Single.1"] = ExtractSingle1, ["Extract.Byte.129"] = ExtractByte129, - ["Extract.SByte.129"] = ExtractSByte129, ["Extract.Int32.129"] = ExtractInt32129, ["Extract.UInt32.129"] = ExtractUInt32129, ["Extract.Int64.129"] = ExtractInt64129, @@ -40,30 +38,18 @@ static Program() ["Floor.Single"] = FloorSingle, ["FloorScalar.Double"] = FloorScalarDouble, ["FloorScalar.Single"] = FloorScalarSingle, - ["Insert.Single.0"] = InsertSingle0, ["Insert.Byte.1"] = InsertByte1, ["Insert.SByte.1"] = InsertSByte1, ["Insert.Int32.1"] = InsertInt321, ["Insert.UInt32.1"] = InsertUInt321, ["Insert.Int64.1"] = InsertInt641, ["Insert.UInt64.1"] = InsertUInt641, - ["Insert.Single.1"] = InsertSingle1, - ["Insert.Single.2"] = InsertSingle2, - ["Insert.Single.4"] = InsertSingle4, - ["Insert.Single.8"] = InsertSingle8, - ["Insert.Single.16"] = InsertSingle16, - ["Insert.Single.32"] = InsertSingle32, - ["Insert.Single.48"] = InsertSingle48, - ["Insert.Single.64"] = InsertSingle64, - ["Insert.Single.128"] = InsertSingle128, ["Insert.Byte.129"] = InsertByte129, ["Insert.SByte.129"] = InsertSByte129, ["Insert.Int32.129"] = InsertInt32129, ["Insert.UInt32.129"] = InsertUInt32129, ["Insert.Int64.129"] = InsertInt64129, ["Insert.UInt64.129"] = InsertUInt64129, - ["Insert.Single.129"] = InsertSingle129, - ["Insert.Single.192"] = InsertSingle192, ["Max.Int32"] = MaxInt32, ["Max.SByte"] = MaxSByte, ["Max.UInt16"] = MaxUInt16, diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_r.csproj index e98e0c2acba7..b6d3523a2176 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_r.csproj @@ -120,43 +120,29 @@ - - - - - - - - - - - - - - diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_ro.csproj index 171f917b8625..424f767169d2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_ro.csproj @@ -120,43 +120,29 @@ - - - - - - - - - - - - - -