Add SSE2 StoreNonTemporal HW intrinsic tests
authorJacek Blaszczynski <biosciencenow@outlook.com>
Thu, 8 Mar 2018 07:28:06 +0000 (08:28 +0100)
committerJacek Blaszczynski <biosciencenow@outlook.com>
Tue, 13 Mar 2018 21:40:14 +0000 (22:40 +0100)
tests/src/JIT/HardwareIntrinsics/X86/Sse2/StoreNonTemporal.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/StoreNonTemporal_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/StoreNonTemporal_ro.csproj [new file with mode: 0644]

diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/StoreNonTemporal.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/StoreNonTemporal.cs
new file mode 100644 (file)
index 0000000..76b468e
--- /dev/null
@@ -0,0 +1,171 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics.X86;
+using System.Runtime.Intrinsics;
+
+namespace IntelHardwareIntrinsicTest
+{
+    class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+
+            if (Sse2.IsSupported)
+            {
+                if (Environment.Is64BitProcess)
+                {
+                    {
+                        long* inArray = stackalloc long[2];
+                        inArray[0] = 0xffffffff01l;
+                        long* outBuffer = stackalloc long[2];
+
+                        Sse2.StoreNonTemporal(outBuffer, inArray[0]);
+
+                        for (var i = 0; i < 2; i++)
+                        {
+                            if (inArray[i] != outBuffer[i])
+                            {
+                                Console.WriteLine("Sse2 StoreNonTemporal failed on long:");
+                                for (var n = 0; n < 2; n++)
+                                {
+                                    Console.Write(outBuffer[n] + ", ");
+                                }
+                                Console.WriteLine();
+
+                                testResult = Fail;
+                                break;
+                            }
+                        }
+                    }
+
+                    {
+                        ulong* inArray = stackalloc ulong[2];
+                        inArray[0] = 0xffffffffff01ul;
+                        ulong* outBuffer = stackalloc ulong[2];
+
+                        Sse2.StoreNonTemporal(outBuffer, inArray[0]);
+
+                        for (var i = 0; i < 2; i++)
+                        {
+                            if (inArray[i] != outBuffer[i])
+                            {
+                                Console.WriteLine("Sse2 StoreNonTemporal failed on ulong:");
+                                for (var n = 0; n < 2; n++)
+                                {
+                                    Console.Write(outBuffer[n] + ", ");
+                                }
+                                Console.WriteLine();
+
+                                testResult = Fail;
+                                break;
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    try
+                    {
+                        long* inArray = stackalloc long[2];
+                        inArray[0] = 0xffffffff01l;
+                        long* outBuffer = stackalloc long[2];
+
+                        Sse2.StoreNonTemporal(outBuffer, inArray[0]);
+                        testResult = Fail;
+                        Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.StoreNonTemporal)} failed on long: expected PlatformNotSupportedException exception.");
+                    }
+                    catch (PlatformNotSupportedException)
+                    {
+
+                    }
+                    catch(Exception ex)
+                    {
+                        testResult = Fail;
+                        Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.StoreNonTemporal)}-{ex} failed on long: expected PlatformNotSupportedException exception.");
+                    }
+
+                    try
+                    {
+                        ulong* inArray = stackalloc ulong[2];
+                        inArray[0] = 0xffffffffff01ul;
+                        ulong* outBuffer = stackalloc ulong[2];
+
+                        Sse2.StoreNonTemporal(outBuffer, inArray[0]);
+                        testResult = Fail;
+                        Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.StoreNonTemporal)} failed on ulong: expected PlatformNotSupportedException exception.");
+                    }
+                    catch (PlatformNotSupportedException)
+                    {
+
+                    }
+                    catch(Exception ex)
+                    {
+                        testResult = Fail;
+                        Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.StoreNonTemporal)}-{ex} failed on ulong: expected PlatformNotSupportedException exception.");                            
+                    }                    
+                }
+
+                {
+                    int* inArray = stackalloc int[4];
+                    inArray[0] = -784561;
+                    int* outBuffer = stackalloc int[4];
+
+                    Sse2.StoreNonTemporal(outBuffer, inArray[0]);
+
+                    for (var i = 0; i < 4; i++)
+                    {
+                        if (inArray[i] != outBuffer[i])
+                        {
+                            Console.WriteLine("Sse2 StoreNonTemporal failed on int:");
+                            for (var n = 0; n < 4; n++)
+                            {
+                                Console.Write(outBuffer[n] + ", ");
+                            }
+                            Console.WriteLine();
+
+                            testResult = Fail;
+                            break;
+                        }
+                    }
+                }
+
+                {
+                    uint* inArray = stackalloc uint[4];
+                    inArray[0] = 0xffffff02u;
+                    uint* outBuffer = stackalloc uint[4];
+
+                    Sse2.StoreNonTemporal(outBuffer, inArray[0]);
+
+                    for (var i = 0; i < 4; i++)
+                    {
+                        if (inArray[i] != outBuffer[i])
+                        {
+                            Console.WriteLine("Sse2 StoreNonTemporal failed on uint:");
+                            for (var n = 0; n < 4; n++)
+                            {
+                                Console.Write(outBuffer[n] + ", ");
+                            }
+                            Console.WriteLine();
+
+                            testResult = Fail;
+                            break;
+                        }
+                    }
+                }
+            }
+
+            return testResult;
+        }
+    }
+}
+
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/StoreNonTemporal_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/StoreNonTemporal_r.csproj
new file mode 100644 (file)
index 0000000..8ca2a26
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize></Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="StoreNonTemporal.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/StoreNonTemporal_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/StoreNonTemporal_ro.csproj
new file mode 100644 (file)
index 0000000..4f00c2b
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="StoreNonTemporal.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>
\ No newline at end of file