From: Fei Peng Date: Mon, 18 Jun 2018 20:17:41 +0000 (-0700) Subject: Improve Intel hardware intrinsic APIs (#17637) X-Git-Tag: accepted/tizen/unified/20190422.045933~1882 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ea58e86b476c7a596b43b12f31b5bccfdbbeca67;p=platform%2Fupstream%2Fcoreclr.git Improve Intel hardware intrinsic APIs (#17637) * Improve Intel hardware intrinsic APIs * Simplify Avx.Extract non-const fallback --- 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 1fd61ec..03a3313 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 @@ -238,21 +238,11 @@ namespace System.Runtime.Intrinsics.X86 /// __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 - /// public static byte Extract(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __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 @@ namespace System.Runtime.Intrinsics.X86 /// __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 fdb349b..63e0e29 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 { @@ -239,46 +239,11 @@ namespace System.Runtime.Intrinsics.X86 /// __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 @@ namespace System.Runtime.Intrinsics.X86 /// 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 @@ namespace System.Runtime.Intrinsics.X86 /// 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 @@ namespace System.Runtime.Intrinsics.X86 /// 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 @@ namespace System.Runtime.Intrinsics.X86 { 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 @@ namespace System.Runtime.Intrinsics.X86 { 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 @@ namespace System.Runtime.Intrinsics.X86 /// __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 8aaa454..0e2bb5d 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 @@ -613,11 +613,6 @@ namespace System.Runtime.Intrinsics.X86 /// 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 - /// public static ushort Extract(Vector128 value, byte index) { throw new PlatformNotSupportedException(); } /// 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 d0eb9ef..332bd7b 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 @@ -614,11 +614,6 @@ namespace System.Runtime.Intrinsics.X86 /// 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 - /// public static ushort Extract(Vector128 value, byte index) => Extract(value, index); /// 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 063b8dc..8ba7393 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 @@ -182,11 +182,6 @@ namespace System.Runtime.Intrinsics.X86 /// 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 - /// public static byte Extract(Vector128 value, byte index) { throw new PlatformNotSupportedException(); } /// /// int _mm_extract_epi32 (__m128i a, const int imm8) @@ -283,7 +278,7 @@ namespace System.Runtime.Intrinsics.X86 /// __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 dd81168..c3d9dcb 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 @@ -182,11 +182,6 @@ namespace System.Runtime.Intrinsics.X86 /// 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 - /// public static byte Extract(Vector128 value, byte index) => Extract(value, index); /// /// int _mm_extract_epi32 (__m128i a, const int imm8) @@ -283,7 +278,7 @@ namespace System.Runtime.Intrinsics.X86 /// __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 7f89b89..5a4658c 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 66eb86a..5ff97f7 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 157ae16..0000000 --- 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 ba511b8..0000000 --- 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 83d73da..0000000 --- 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 387e00b..0000000 --- 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 4fb463a..0000000 --- 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 391703f..0000000 --- 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 a35fbf8..0000000 --- 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 d0a0a9c..0000000 --- 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 9c52458..0b40b21 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 @@ namespace JIT.HardwareIntrinsics.X86 ["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 e8f44cd..13c621f 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 f2f1195..0000000 --- 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 e2d3a00..0000000 --- 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 10782bc..e2ab97d 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 @@ namespace JIT.HardwareIntrinsics.X86 ["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 fec034c..0769a9d 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 8c82568..cdf3e71 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 8265030..0000000 --- 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 f4c2258..0000000 --- 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 537fe66..0000000 --- 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 0ca4931..0000000 --- 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 8b30e9f..0000000 --- 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 a491c10..0000000 --- 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 f8908e3..0000000 --- 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 44ead60..0000000 --- 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 6487217..0000000 --- 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 6d647af..0000000 --- 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 c47c9d2..0000000 --- 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 4a8eef9..0000000 --- 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 feddaad..0000000 --- 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 b81444c..0000000 --- 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 195e186..92fd2ac 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 @@ namespace JIT.HardwareIntrinsics.X86 ["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 @@ namespace JIT.HardwareIntrinsics.X86 ["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 e98e0c2..b6d3523 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 171f917..424f767 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 @@ - - - - - - - - - - - - - -