2008-12-08 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 8 Dec 2008 22:22:55 +0000 (22:22 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 8 Dec 2008 22:22:55 +0000 (22:22 -0000)
* VectorOperations.cs: Move methods from Vector8us.

* Vector8us.cs: Same.

svn path=/trunk/mcs/; revision=121052

mcs/class/Mono.Simd/Mono.Simd/Changelog
mcs/class/Mono.Simd/Mono.Simd/Vector8us.cs
mcs/class/Mono.Simd/Mono.Simd/VectorOperations.cs

index 5bc800c4469d10bac035036f7919f09032fe298b..fbf6290a920238e6e84fb333b0becd6129a4fae9 100644 (file)
@@ -1,3 +1,9 @@
+2008-12-08  Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * VectorOperations.cs: Move methods from Vector8us.
+
+       * Vector8us.cs: Same.
+
 2008-12-08  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * VectorOperations.cs: Move methods from Vector8s.
index 35cf414ecdbc9cbd2a1ff7b6d6974b4e93558e79..498224f2bb30afc072999e033e7bcb7bc384887e 100644 (file)
@@ -33,7 +33,7 @@ namespace Mono.Simd
        [CLSCompliant(false)]
        public struct Vector8us
        {
-               private ushort v0, v1, v2, v3, v4, v5, v6, v7;
+               internal ushort v0, v1, v2, v3, v4, v5, v6, v7;
                public Vector8us (ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7)
                {
                        this.v0 = v0;
@@ -200,150 +200,6 @@ namespace Mono.Simd
                        return false;
                }
 
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector8us UnpackLow (Vector8us va, Vector8us vb)
-               {
-                       return new Vector8us (va.v0, vb.v0, va.v1, vb.v1, va.v2, vb.v2, va.v3, vb.v3);
-               }
-
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector8us UnpackHigh (Vector8us va, Vector8us vb)
-               {
-                       return new Vector8us (va.v4, vb.v4, va.v5, vb.v5, va.v6, vb.v6, va.v7, vb.v7);
-               }
-
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector8us ArithmeticRightShift (Vector8us va, int amount)
-               {
-                       Vector8us res = new Vector8us ();
-                       ushort *a = &va.v0;
-                       ushort *b = &res.v0;
-                       for (int i = 0; i < 8; ++i)
-                               *b++ = (ushort)((short)(*a++) >> amount);
-                       return res;
-               }
-
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector8us AddWithSaturation (Vector8us va, Vector8us vb) {
-                       Vector8us res = new Vector8us ();
-                       ushort *a = &va.v0;
-                       ushort *b = &vb.v0;
-                       ushort *c = &res.v0;
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (ushort) System.Math.Min (*a++ + *b++, ushort.MaxValue);
-                       return res;
-               }
-
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector8us SubtractWithSaturation (Vector8us va, Vector8us vb) {
-                       Vector8us res = new Vector8us ();
-                       ushort *a = &va.v0;
-                       ushort *b = &vb.v0;
-                       ushort *c = &res.v0;
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (ushort) System.Math.Max (*a++ - *b++, 0);
-                       return res;
-               }
-
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector8us Average (Vector8us va, Vector8us vb) {
-                       Vector8us res = new Vector8us ();
-                       ushort *a = &va.v0;
-                       ushort *b = &vb.v0;
-                       ushort *c = &res.v0;
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (ushort) ((*a++ + *b++ + 1) >> 1);
-                       return res;
-               }
-
-               [Acceleration (AccelMode.SSE41)]
-               public static unsafe Vector8us Max (Vector8us va, Vector8us vb) {
-                       Vector8us res = new Vector8us ();
-                       ushort *a = &va.v0;
-                       ushort *b = &vb.v0;
-                       ushort *c = &res.v0;
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (ushort) System.Math.Max (*a++, *b++);
-                       return res;
-               }
-
-               [Acceleration (AccelMode.SSE41)]
-               public static unsafe Vector8us Min (Vector8us va, Vector8us vb) {
-                       Vector8us res = new Vector8us ();
-                       ushort *a = &va.v0;
-                       ushort *b = &vb.v0;
-                       ushort *c = &res.v0;
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (ushort) System.Math.Min (*a++, *b++);
-                       return res;
-               }
-
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector8us ShuffleHigh (Vector8us va, ShuffleSel sel)
-               {
-                       ushort *ptr = ((ushort*)&va) + 4;
-                       int idx = (int)sel;
-                       return new Vector8us (va.v0, va.v1, va.v2, va.v3, *(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)));
-               }
-
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector8us ShuffleLow (Vector8us va, ShuffleSel sel)
-               {
-                       ushort *ptr = ((ushort*)&va);
-                       int idx = (int)sel;
-                       return new Vector8us (*(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)), va.v4, va.v5, va.v6, va.v7);
-               }
-
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector8us CompareEqual (Vector8us va, Vector8us vb) {
-                       Vector8us res = new Vector8us ();
-                       ushort *a = &va.v0;
-                       ushort *b = &vb.v0;
-                       ushort *c = &res.v0;
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (ushort) (*a++ == *b++ ? -1 : 0);
-                       return res;
-               }
-
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector8us MultiplyStoreHigh (Vector8us va, Vector8us vb) {
-                       Vector8us res = new Vector8us ();
-                       ushort *a = &va.v0;
-                       ushort *b = &vb.v0;
-                       ushort *c = &res.v0;
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (ushort)((uint)*a++ * (uint)*b++ >> 16);
-                       return res;
-               }
-
-               /*This function performs a packuswb, which treats the source as a signed value */
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector16b SignedPackWithUnsignedSaturation (Vector8us va, Vector8us vb) {
-                       Vector16b res = new Vector16b ();
-                       short *a = (short*)&va;
-                       short *b = (short*)&vb;
-                       byte *c = (byte*)&res;
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (byte)System.Math.Max (0, System.Math.Min ((int)*a++, byte.MaxValue));
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (byte)System.Math.Max (0, System.Math.Min ((int)*b++, byte.MaxValue));
-                       return res;
-               }
-
-               /*This function performs a packsswb, which treats the source as a signed value */
-               [Acceleration (AccelMode.SSE2)]
-               public static unsafe Vector16sb SignedPackWithSignedSaturation (Vector8us va, Vector8us vb) {
-                       Vector16sb res = new Vector16sb ();
-                       short *a = (short*)&va;
-                       short *b = (short*)&vb;
-                       sbyte *c = (sbyte*)&res;
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (sbyte)System.Math.Max (System.Math.Min ((int)*a++, sbyte.MaxValue), sbyte.MinValue);
-                       for (int i = 0; i < 8; ++i)
-                               *c++ = (sbyte)System.Math.Max (System.Math.Min ((int)*b++, sbyte.MaxValue), sbyte.MinValue);
-                       return res;
-               }
-
                [Acceleration (AccelMode.SSE1)]
                public static unsafe explicit operator Vector2d (Vector8us v)
                {
index a399b21d3c86ea426766349e71252a0202071b00..2848cbc3816de98b5472a69befb9f53cddc76fb3 100644 (file)
@@ -71,6 +71,17 @@ namespace Mono.Simd
                        return res;
                }
 
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector8us ArithmeticRightShift (this Vector8us va, int amount)
+               {
+                       Vector8us res = new Vector8us ();
+                       ushort *a = &va.v0;
+                       ushort *b = &res.v0;
+                       for (int i = 0; i < 8; ++i)
+                               *b++ = (ushort)((short)(*a++) >> amount);
+                       return res;
+               }
+
                [Acceleration (AccelMode.SSE2)]
                public static unsafe Vector2l LogicalRightShift (this Vector2l v1, int amount)
                {
@@ -113,6 +124,17 @@ namespace Mono.Simd
                        return res;
                }
 
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector8us AddWithSaturation (this Vector8us va, Vector8us vb) {
+                       Vector8us res = new Vector8us ();
+                       ushort *a = &va.v0;
+                       ushort *b = &vb.v0;
+                       ushort *c = &res.v0;
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (ushort) System.Math.Min (*a++ + *b++, ushort.MaxValue);
+                       return res;
+               }
+
                [Acceleration (AccelMode.SSE2)]
                public static unsafe Vector8s SubtractWithSaturation (this Vector8s va, Vector8s vb) {
                        Vector8s res = new Vector8s ();
@@ -124,6 +146,17 @@ namespace Mono.Simd
                        return res;
                }
 
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector8us SubtractWithSaturation (this Vector8us va, Vector8us vb) {
+                       Vector8us res = new Vector8us ();
+                       ushort *a = &va.v0;
+                       ushort *b = &vb.v0;
+                       ushort *c = &res.v0;
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (ushort) System.Math.Max (*a++ - *b++, 0);
+                       return res;
+               }
+
                [Acceleration (AccelMode.SSE2)]
                public static unsafe Vector8s MultiplyStoreHigh (this Vector8s va, Vector8s vb) {
                        Vector8s res = new Vector8s ();
@@ -135,6 +168,17 @@ namespace Mono.Simd
                        return res;
                }
 
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector8us MultiplyStoreHigh (this Vector8us va, Vector8us vb) {
+                       Vector8us res = new Vector8us ();
+                       ushort *a = &va.v0;
+                       ushort *b = &vb.v0;
+                       ushort *c = &res.v0;
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (ushort)((uint)*a++ * (uint)*b++ >> 16);
+                       return res;
+               }
+
                [Acceleration (AccelMode.SSE1)]
                public static Vector4f Sqrt (this Vector4f v1)
                {
@@ -159,6 +203,17 @@ namespace Mono.Simd
                        return new Vector4f (1.0f / v1.x, 1.0f / v1.y, 1.0f / v1.z, 1.0f / v1.w);
                }
 
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector8us Average (this Vector8us va, Vector8us vb) {
+                       Vector8us res = new Vector8us ();
+                       ushort *a = &va.v0;
+                       ushort *b = &vb.v0;
+                       ushort *c = &res.v0;
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (ushort) ((*a++ + *b++ + 1) >> 1);
+                       return res;
+               }
+
                [Acceleration (AccelMode.SSE1)]
                public static Vector4f Max (this Vector4f v1, Vector4f v2)
                {
@@ -198,6 +253,17 @@ namespace Mono.Simd
                        return res;
                }
 
+               [Acceleration (AccelMode.SSE41)]
+               public static unsafe Vector8us Max (this Vector8us va, Vector8us vb) {
+                       Vector8us res = new Vector8us ();
+                       ushort *a = &va.v0;
+                       ushort *b = &vb.v0;
+                       ushort *c = &res.v0;
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (ushort) System.Math.Max (*a++, *b++);
+                       return res;
+               }
+
                [Acceleration (AccelMode.SSE1)]
                public static Vector4f Min (this Vector4f v1, Vector4f v2)
                {
@@ -237,6 +303,16 @@ namespace Mono.Simd
                        return res;
                }
 
+               [Acceleration (AccelMode.SSE41)]
+               public static unsafe Vector8us Min (this Vector8us va, Vector8us vb) {
+                       Vector8us res = new Vector8us ();
+                       ushort *a = &va.v0;
+                       ushort *b = &vb.v0;
+                       ushort *c = &res.v0;
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (ushort) System.Math.Min (*a++, *b++);
+                       return res;
+               }
 
                /* ==== Horizontal operations ==== */
 
@@ -336,6 +412,17 @@ namespace Mono.Simd
                        return res;
                }
 
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector8us CompareEqual (this Vector8us va, Vector8us vb) {
+                       Vector8us res = new Vector8us ();
+                       ushort *a = &va.v0;
+                       ushort *b = &vb.v0;
+                       ushort *c = &res.v0;
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (ushort) (*a++ == *b++ ? -1 : 0);
+                       return res;
+               }
+
                /*Same as a < b. */
                [Acceleration (AccelMode.SSE1)]
                public unsafe static Vector4f CompareLessThan (this Vector4f v1, Vector4f v2)
@@ -602,6 +689,12 @@ namespace Mono.Simd
                        return new Vector8s (va.v0, vb.v0, va.v1, vb.v1, va.v2, vb.v2, va.v3, vb.v3);
                }
 
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector8us UnpackLow (this Vector8us va, Vector8us vb)
+               {
+                       return new Vector8us (va.v0, vb.v0, va.v1, vb.v1, va.v2, vb.v2, va.v3, vb.v3);
+               }
+       
                [Acceleration (AccelMode.SSE2)]
                public static Vector2l UnpackHigh (this Vector2l v1, Vector2l v2)
                {
@@ -632,6 +725,12 @@ namespace Mono.Simd
                        return new Vector8s (va.v4, vb.v4, va.v5, vb.v5, va.v6, vb.v6, va.v7, vb.v7);
                }
 
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector8us UnpackHigh (this Vector8us va, Vector8us vb)
+               {
+                       return new Vector8us (va.v4, vb.v4, va.v5, vb.v5, va.v6, vb.v6, va.v7, vb.v7);
+               }
+
                [Acceleration (AccelMode.SSE2)]
                public static unsafe Vector4f Shuffle (this Vector4f v1, ShuffleSel sel)
                {
@@ -664,6 +763,14 @@ namespace Mono.Simd
                        return new Vector8s (va.v0, va.v1, va.v2, va.v3, *(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)));
                }
 
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector8us ShuffleHigh (this Vector8us va, ShuffleSel sel)
+               {
+                       ushort *ptr = ((ushort*)&va) + 4;
+                       int idx = (int)sel;
+                       return new Vector8us (va.v0, va.v1, va.v2, va.v3, *(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)));
+               }
+
                [Acceleration (AccelMode.SSE2)]
                public static unsafe Vector8s ShuffleLow (this Vector8s va, ShuffleSel sel)
                {
@@ -672,6 +779,14 @@ namespace Mono.Simd
                        return new Vector8s (*(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)), va.v4, va.v5, va.v6, va.v7);
                }
 
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector8us ShuffleLow (this Vector8us va, ShuffleSel sel)
+               {
+                       ushort *ptr = ((ushort*)&va);
+                       int idx = (int)sel;
+                       return new Vector8us (*(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)), va.v4, va.v5, va.v6, va.v7);
+               }
+
                [CLSCompliant(false)]
                [Acceleration (AccelMode.SSE41)]
                public static unsafe Vector8us PackWithUnsignedSaturation (this Vector4i va, Vector4i vb) {
@@ -741,6 +856,20 @@ namespace Mono.Simd
                        return res;
                }
 
+               /*This function performs a packuswb, which treats the source as a signed value */
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector16b SignedPackWithUnsignedSaturation (this Vector8us va, Vector8us vb) {
+                       Vector16b res = new Vector16b ();
+                       short *a = (short*)&va;
+                       short *b = (short*)&vb;
+                       byte *c = (byte*)&res;
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (byte)System.Math.Max (0, System.Math.Min ((int)*a++, byte.MaxValue));
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (byte)System.Math.Max (0, System.Math.Min ((int)*b++, byte.MaxValue));
+                       return res;
+               }
+               
                /* This function performs a packssdw, which treats the source as a signed value*/
                [Acceleration (AccelMode.SSE2)]
                public static unsafe Vector8s SignedPackWithSignedSaturation (this Vector4ui va, Vector4ui vb) {
@@ -754,5 +883,19 @@ namespace Mono.Simd
                                *c++ = (short)System.Math.Max (System.Math.Min ((int)*b++, short.MaxValue), short.MinValue);
                        return res;
                }
+
+               /*This function performs a packsswb, which treats the source as a signed value */
+               [Acceleration (AccelMode.SSE2)]
+               public static unsafe Vector16sb SignedPackWithSignedSaturation (this Vector8us va, Vector8us vb) {
+                       Vector16sb res = new Vector16sb ();
+                       short *a = (short*)&va;
+                       short *b = (short*)&vb;
+                       sbyte *c = (sbyte*)&res;
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (sbyte)System.Math.Max (System.Math.Min ((int)*a++, sbyte.MaxValue), sbyte.MinValue);
+                       for (int i = 0; i < 8; ++i)
+                               *c++ = (sbyte)System.Math.Max (System.Math.Min ((int)*b++, sbyte.MaxValue), sbyte.MinValue);
+                       return res;
+               }
        }
 }
\ No newline at end of file