Expand Vector128 testing to 5 elements
authorBrian Sullivan <briansul@microsoft.com>
Thu, 21 Mar 2019 01:15:14 +0000 (18:15 -0700)
committerBrian Sullivan <briansul@microsoft.com>
Thu, 21 Mar 2019 01:15:14 +0000 (18:15 -0700)
tests/src/JIT/Directed/VectorABI/VectorMgdMgd.cs

index 6073c9d..e241dc7 100644 (file)
@@ -12,10 +12,16 @@ using System.Runtime.InteropServices;
 // as well as passing various numbers of them (so that we exceed the available registers),
 // and mixing the HVA parameters with non-HVA parameters.
 
-// This is a skeleton version. Remaining to do:
-// - Add more HVA types: using Vector64 and with varying numbers of vectors.
+// This Test case covers all cases for
+//   Methods that take one HVA argument with between 1 and 9 Vectror64 or Vector128 elements
+//   - Called normally or by using reflection
+//   Methods that return an HVA with between 1 and 9 Vectror64 or Vector128 elements
+//   - Called normally or by using reflection
+
+// Remaining Test cases to do:
+// - Add tests that have one than one HVA argument
 // - Add types that are *not* HVA types (e.g. too many vectors, or using Vector256).
-// - Add diagnostic info so that it is easier to see what has failed.
+// - Add tests that use a mix of HVA and non-HVA arguments
 
 public static class VectorMgdMgd
 {
@@ -96,13 +102,13 @@ public static class VectorMgdMgd
 
     public unsafe class HVATests<T> where T : struct
     {
-        // We can have up to 4 vectors in an HVA, and we'll test structs with up to 6 (3x2) of them
+        // An HVA can contain up to 4 vectors, so we'll test structs with up to 5 of them
         // (to ensure that even those that are too large are handled consistently).
-        // So we need 6 * the element count in the largest (128-bit) vector with the smallest
+        // So we need 5 * the element count in the largest (128-bit) vector with the smallest
         // element type (byte).
         static T[] values;
         static T[] check;
-        private int ElementCount = (Unsafe.SizeOf<Vector128<T>>() / sizeof(byte)) * 6;
+        private int ElementCount = (Unsafe.SizeOf<Vector128<T>>() / sizeof(byte)) * 5;
         public bool isPassing = true;
         public bool isReflection = false;
 
@@ -173,9 +179,28 @@ public static class VectorMgdMgd
             public Vector128<T> v2;
         }
 
+        public struct HVA128_04
+        {
+            public Vector128<T> v0;
+            public Vector128<T> v1;
+            public Vector128<T> v2;
+            public Vector128<T> v3;
+        }
+
+        public struct HVA128_05
+        {
+            public Vector128<T> v0;
+            public Vector128<T> v1;
+            public Vector128<T> v2;
+            public Vector128<T> v3;
+            public Vector128<T> v4;
+       }
+
         private HVA128_01 hva128_01;
         private HVA128_02 hva128_02;
         private HVA128_03 hva128_03;
+        private HVA128_04 hva128_04;
+        private HVA128_05 hva128_05;
 
         ////////////////////////////////////////
 
@@ -234,7 +259,27 @@ public static class VectorMgdMgd
             hva128_03.v1 = Unsafe.As<T, Vector128<T>>(ref values[i]);
             i += Vector128<T>.Count;
             hva128_03.v2 = Unsafe.As<T, Vector128<T>>(ref values[i]);
-        }
+
+            i = 0;
+            hva128_04.v0 = Unsafe.As<T, Vector128<T>>(ref values[i]);
+            i += Vector128<T>.Count;
+            hva128_04.v1 = Unsafe.As<T, Vector128<T>>(ref values[i]);
+            i += Vector128<T>.Count;
+            hva128_04.v2 = Unsafe.As<T, Vector128<T>>(ref values[i]);
+            i += Vector128<T>.Count;
+            hva128_04.v3 = Unsafe.As<T, Vector128<T>>(ref values[i]);
+            i = 0;
+            hva128_05.v0 = Unsafe.As<T, Vector128<T>>(ref values[i]);
+            i += Vector128<T>.Count;
+            hva128_05.v1 = Unsafe.As<T, Vector128<T>>(ref values[i]);
+            i += Vector128<T>.Count;
+            hva128_05.v2 = Unsafe.As<T, Vector128<T>>(ref values[i]);
+            i += Vector128<T>.Count;
+            hva128_05.v3 = Unsafe.As<T, Vector128<T>>(ref values[i]);
+            i += Vector128<T>.Count;
+            hva128_05.v4 = Unsafe.As<T, Vector128<T>>(ref values[i]);
+       }
 
         public HVATests()
         {
@@ -398,7 +443,7 @@ public static class VectorMgdMgd
             reflectionInvokeArgs = new object[] { hva64_05 };
         }
 
-        //===============   Tests for return values if HFA64
+        //===============   Tests for return values if HVA64
 
         //====================   Tests for return values of HVA64_01
 
@@ -409,7 +454,7 @@ public static class VectorMgdMgd
             return hva64_01;
         }
 
-        public void testReturn_HFA64_01()
+        public void testReturn_HVA64_01()
         {
             HVA64_01 result = returnTest_HVA64_01();
             checkValues("testReturn_HVA64_01(result.v0)",result.v0, 0);
@@ -423,7 +468,7 @@ public static class VectorMgdMgd
             reflectionInvokeArgs = new object[] { };
         }
 
-        public void testReflectionReturn_HFA64_01()
+        public void testReflectionReturn_HVA64_01()
         {
             Init_Reflection_Return_HVA64_01();
 
@@ -445,7 +490,7 @@ public static class VectorMgdMgd
             return hva64_02;
         }
 
-        public void testReturn_HFA64_02()
+        public void testReturn_HVA64_02()
         {
             HVA64_02 result = returnTest_HVA64_02();
             checkValues("testReturn_HVA64_02(result.v0)",result.v0, 0);
@@ -460,7 +505,7 @@ public static class VectorMgdMgd
             reflectionInvokeArgs = new object[] { };
         }
 
-        public void testReflectionReturn_HFA64_02()
+        public void testReflectionReturn_HVA64_02()
         {
             Init_Reflection_Return_HVA64_02();
 
@@ -483,7 +528,7 @@ public static class VectorMgdMgd
             return hva64_03;
         }
 
-        public void testReturn_HFA64_03()
+        public void testReturn_HVA64_03()
         {
             HVA64_03 result = returnTest_HVA64_03();
             checkValues("testReturn_HVA64_03(result.v0)",result.v0, 0);
@@ -499,7 +544,7 @@ public static class VectorMgdMgd
             reflectionInvokeArgs = new object[] { };
         }
 
-        public void testReflectionReturn_HFA64_03()
+        public void testReflectionReturn_HVA64_03()
         {
             Init_Reflection_Return_HVA64_03();
 
@@ -523,7 +568,7 @@ public static class VectorMgdMgd
             return hva64_04;
         }
 
-        public void testReturn_HFA64_04()
+        public void testReturn_HVA64_04()
         {
             HVA64_04 result = returnTest_HVA64_04();
             checkValues("testReturn_HVA64_04(result.v0)",result.v0, 0);
@@ -540,7 +585,7 @@ public static class VectorMgdMgd
             reflectionInvokeArgs = new object[] { };
         }
 
-        public void testReflectionReturn_HFA64_04()
+        public void testReflectionReturn_HVA64_04()
         {
             Init_Reflection_Return_HVA64_04();
 
@@ -565,7 +610,7 @@ public static class VectorMgdMgd
             return hva64_05;
         }
 
-        public void testReturn_HFA64_05()
+        public void testReturn_HVA64_05()
         {
             HVA64_05 result = returnTest_HVA64_05();
             checkValues("testReturn_HVA64_05(result.v0)",result.v0, 0);
@@ -583,7 +628,7 @@ public static class VectorMgdMgd
             reflectionInvokeArgs = new object[] { };
         }
 
-        public void testReflectionReturn_HFA64_05()
+        public void testReflectionReturn_HVA64_05()
         {
             Init_Reflection_Return_HVA64_05();
 
@@ -656,6 +701,47 @@ public static class VectorMgdMgd
             reflectionInvokeArgs = new object[] { hva128_03 };
         }
 
+        //====================   Tests for passing 1 argumnet of HVA128_04
+
+        // Test the case where we've passed in a single argument HVA of 2 vectors.
+        [MethodImpl(MethodImplOptions.NoInlining)]
+        public void test1Argument_HVA128_04(HVA128_04 arg1)
+        {
+            checkValues("test1Argument_HVA128_04(arg1.v0)", arg1.v0, 0);
+            checkValues("test1Argument_HVA128_04(arg1.v1)", arg1.v1, 1 * Vector128<T>.Count);
+            checkValues("test1Argument_HVA128_04(arg1.v2)", arg1.v2, 2 * Vector128<T>.Count);
+            checkValues("test1Argument_HVA128_04(arg1.v3)", arg1.v3, 3 * Vector128<T>.Count);
+        }
+
+        public void Init_Reflection_Args_HVA128_04()
+        {
+            isReflection = true;
+            reflectionParameterTypes = new Type[] { typeof(HVA128_04) };
+            reflectionMethodInfo = typeof(HVATests<T>).GetMethod(nameof(HVATests<T>.test1Argument_HVA128_04), reflectionParameterTypes);
+            reflectionInvokeArgs = new object[] { hva128_04 };
+        }
+
+        //====================   Tests for passing 1 argumnet of HVA128_05
+
+        // Test the case where we've passed in a single argument HVA of 2 vectors.
+        [MethodImpl(MethodImplOptions.NoInlining)]
+        public void test1Argument_HVA128_05(HVA128_05 arg1)
+        {
+            checkValues("test1Argument_HVA128_05(arg1.v0)", arg1.v0, 0);
+            checkValues("test1Argument_HVA128_05(arg1.v1)", arg1.v1, 1 * Vector128<T>.Count);
+            checkValues("test1Argument_HVA128_05(arg1.v2)", arg1.v2, 2 * Vector128<T>.Count);
+            checkValues("test1Argument_HVA128_05(arg1.v3)", arg1.v3, 3 * Vector128<T>.Count);
+            checkValues("test1Argument_HVA128_05(arg1.v4)", arg1.v4, 4 * Vector128<T>.Count);
+        }
+
+        public void Init_Reflection_Args_HVA128_05()
+        {
+            isReflection = true;
+            reflectionParameterTypes = new Type[] { typeof(HVA128_05) };
+            reflectionMethodInfo = typeof(HVATests<T>).GetMethod(nameof(HVATests<T>.test1Argument_HVA128_05), reflectionParameterTypes);
+            reflectionInvokeArgs = new object[] { hva128_05 };
+        }
+
         //====================   Tests for return values of HVA128_01
 
         // Return an HVA of 1 vector, with values from the 'values' array.
@@ -665,7 +751,7 @@ public static class VectorMgdMgd
             return hva128_01;
         }
 
-        public void testReturn_HFA128_01()
+        public void testReturn_HVA128_01()
         {
             HVA128_01 result = returnTest_HVA128_01();
             checkValues("testReturn_HVA128_01(result.v0)",result.v0, 0);
@@ -678,7 +764,7 @@ public static class VectorMgdMgd
             reflectionInvokeArgs = new object[] { };
         }
 
-        public void testReflectionReturn_HFA128_01()
+        public void testReflectionReturn_HVA128_01()
         {
             Init_Reflection_Return_HVA128_01();
 
@@ -700,7 +786,7 @@ public static class VectorMgdMgd
             return hva128_02;
         }
 
-        public void testReturn_HFA128_02()
+        public void testReturn_HVA128_02()
         {
             HVA128_02 result = returnTest_HVA128_02();
             checkValues("testReturn_HVA128_02(result.v0)",result.v0, 0);
@@ -715,7 +801,7 @@ public static class VectorMgdMgd
             reflectionInvokeArgs = new object[] { };
         }
 
-        public void testReflectionReturn_HFA128_02()
+        public void testReflectionReturn_HVA128_02()
         {
             Init_Reflection_Return_HVA128_02();
 
@@ -738,7 +824,7 @@ public static class VectorMgdMgd
             return hva128_03;
         }
 
-        public void testReturn_HFA128_03()
+        public void testReturn_HVA128_03()
         {
             HVA128_03 result = returnTest_HVA128_03();
             checkValues("testReturn_HVA128_03(result.v0)",result.v0, 0);
@@ -754,7 +840,7 @@ public static class VectorMgdMgd
             reflectionInvokeArgs = new object[] { };
         }
 
-        public void testReflectionReturn_HFA128_03()
+        public void testReflectionReturn_HVA128_03()
         {
             Init_Reflection_Return_HVA128_03();
 
@@ -769,6 +855,92 @@ public static class VectorMgdMgd
             Done_Reflection();
         }
 
+        //====================   Tests for return values of HVA128_04
+
+        // Return an HVA of 3 vectors, with values from the 'values' array.
+        [MethodImpl(MethodImplOptions.NoInlining)]
+        public HVA128_04 returnTest_HVA128_04()
+        {
+            return hva128_04;
+        }
+
+        public void testReturn_HVA128_04()
+        {
+            HVA128_04 result = returnTest_HVA128_04();
+            checkValues("testReturn_HVA128_04(result.v0)",result.v0, 0);
+            checkValues("testReturn_HVA128_04(result.v1)",result.v1, 1 * Vector128<T>.Count);
+            checkValues("testReturn_HVA128_04(result.v2)",result.v2, 2 * Vector128<T>.Count);
+            checkValues("testReturn_HVA128_04(result.v3)",result.v3, 3 * Vector128<T>.Count);
+        }
+
+        public void Init_Reflection_Return_HVA128_04()
+        {
+            isReflection = true;
+            reflectionParameterTypes = new Type[] { };
+            reflectionMethodInfo = typeof(HVATests<T>).GetMethod(nameof(HVATests<T>.returnTest_HVA128_04), reflectionParameterTypes);
+            reflectionInvokeArgs = new object[] { };
+        }
+
+        public void testReflectionReturn_HVA128_04()
+        {
+            Init_Reflection_Return_HVA128_04();
+
+            object objResult = reflectionMethodInfo.Invoke(this, reflectionInvokeArgs);
+
+            HVA128_04 result = (HVA128_04)objResult;
+
+            checkValues("testReflectionReturn_HVA128_04(result.v0)",result.v0, 0);
+            checkValues("testReflectionReturn_HVA128_04(result.v1)",result.v1, 1 * Vector128<T>.Count);
+            checkValues("testReflectionReturn_HVA128_04(result.v2)",result.v2, 2 * Vector128<T>.Count);
+            checkValues("testReflectionReturn_HVA128_04(result.v3)",result.v3, 3 * Vector128<T>.Count);
+
+            Done_Reflection();
+        }
+
+        //====================   Tests for return values of HVA128_05
+
+        // Return an HVA of 3 vectors, with values from the 'values' array.
+        [MethodImpl(MethodImplOptions.NoInlining)]
+        public HVA128_05 returnTest_HVA128_05()
+        {
+            return hva128_05;
+        }
+
+        public void testReturn_HVA128_05()
+        {
+            HVA128_05 result = returnTest_HVA128_05();
+            checkValues("testReturn_HVA128_05(result.v0)",result.v0, 0);
+            checkValues("testReturn_HVA128_05(result.v1)",result.v1, 1 * Vector128<T>.Count);
+            checkValues("testReturn_HVA128_05(result.v2)",result.v2, 2 * Vector128<T>.Count);
+            checkValues("testReturn_HVA128_05(result.v3)",result.v3, 3 * Vector128<T>.Count);
+            checkValues("testReturn_HVA128_05(result.v4)",result.v4, 4 * Vector128<T>.Count);
+        }
+
+        public void Init_Reflection_Return_HVA128_05()
+        {
+            isReflection = true;
+            reflectionParameterTypes = new Type[] { };
+            reflectionMethodInfo = typeof(HVATests<T>).GetMethod(nameof(HVATests<T>.returnTest_HVA128_05), reflectionParameterTypes);
+            reflectionInvokeArgs = new object[] { };
+        }
+
+        public void testReflectionReturn_HVA128_05()
+        {
+            Init_Reflection_Return_HVA128_05();
+
+            object objResult = reflectionMethodInfo.Invoke(this, reflectionInvokeArgs);
+
+            HVA128_05 result = (HVA128_05)objResult;
+
+            checkValues("testReflectionReturn_HVA128_05(result.v0)",result.v0, 0);
+            checkValues("testReflectionReturn_HVA128_05(result.v1)",result.v1, 1 * Vector128<T>.Count);
+            checkValues("testReflectionReturn_HVA128_05(result.v2)",result.v2, 2 * Vector128<T>.Count);
+            checkValues("testReflectionReturn_HVA128_05(result.v3)",result.v3, 3 * Vector128<T>.Count);
+            checkValues("testReflectionReturn_HVA128_05(result.v4)",result.v4, 4 * Vector128<T>.Count);
+
+            Done_Reflection();
+        }
+
         //////////////////////////////////////////////////
 
         public void doTests()
@@ -814,29 +986,29 @@ public static class VectorMgdMgd
 
             // Test HVA Vector64<T> Return values
 
-            testReturn_HFA64_01();
+            testReturn_HVA64_01();
 
-            testReflectionReturn_HFA64_01();
+            testReflectionReturn_HVA64_01();
 
 
-            testReturn_HFA64_02();
+            testReturn_HVA64_02();
 
-            testReflectionReturn_HFA64_02();
+            testReflectionReturn_HVA64_02();
 
 
-            testReturn_HFA64_03();
+            testReturn_HVA64_03();
 
-            testReflectionReturn_HFA64_03();
+            testReflectionReturn_HVA64_03();
 
 
-            testReturn_HFA64_04();
+            testReturn_HVA64_04();
 
-            testReflectionReturn_HFA64_04();
+            testReflectionReturn_HVA64_04();
 
 
-            testReturn_HFA64_05();
+            testReturn_HVA64_05();
 
-            testReflectionReturn_HFA64_05();
+            testReflectionReturn_HVA64_05();
 
 
             //////  Vector128<T> tests
@@ -864,21 +1036,36 @@ public static class VectorMgdMgd
             Done_Reflection();
 
 
-            // Test HVA Vector128<T> Return values
+            test1Argument_HVA128_04(hva128_04);
+
+            Init_Reflection_Args_HVA128_04();
+            reflectionMethodInfo.Invoke(this, reflectionInvokeArgs);
+            Done_Reflection();
+
+
+            test1Argument_HVA128_05(hva128_05);
 
-            testReturn_HFA128_01();
+            Init_Reflection_Args_HVA128_05();
+            reflectionMethodInfo.Invoke(this, reflectionInvokeArgs);
+            Done_Reflection();
 
-            testReflectionReturn_HFA128_01();
 
+            // Test HVA Vector128<T> Return values
 
-            testReturn_HFA128_02();
+            testReturn_HVA128_01();
+            testReflectionReturn_HVA128_01();
 
-            testReflectionReturn_HFA128_02();
+            testReturn_HVA128_02();
+            testReflectionReturn_HVA128_02();
 
+            testReturn_HVA128_03();
+            testReflectionReturn_HVA128_03();
 
-            testReturn_HFA128_03();
+            testReturn_HVA128_04();
+            testReflectionReturn_HVA128_04();
 
-            testReflectionReturn_HFA128_03();
+            testReturn_HVA128_05();
+            testReflectionReturn_HVA128_05();
         }
     }