コード例 #1
0
ファイル: VectorOperations.cs プロジェクト: REALTOBIZ/mono
		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;
		}
コード例 #2
0
ファイル: Vector8us.cs プロジェクト: kasertim/sentience
		public static unsafe Vector8us operator - (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++);
			return res;
		}
コード例 #3
0
ファイル: Vector8us.cs プロジェクト: Tsalex71/mono-1
        public static unsafe Vector8us operator &(Vector8us va, Vector8us vb)
        {
            Vector8us res = new Vector8us();
            uint *    a   = (uint *)&va.v0;
            uint *    b   = (uint *)&vb.v0;
            uint *    c   = (uint *)&res.v0;

            *c++ = *a++ & *b++;
            *c++ = *a++ & *b++;
            *c++ = *a++ & *b++;
            *c   = *a & *b;
            return(res);
        }
コード例 #4
0
ファイル: Vector8us.cs プロジェクト: Tsalex71/mono-1
        public static unsafe Vector8us operator *(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++));
            }
            return(res);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
ファイル: Vector4ui.cs プロジェクト: williammc/sentience
        public static unsafe Vector8us SignedPackWithUnsignedSaturation(Vector4ui va, Vector4ui vb)
        {
            Vector8us res = new Vector8us();
            int *     a   = (int *)&va;
            int *     b   = (int *)&vb;
            ushort *  c   = (ushort *)&res;

            for (int i = 0; i < 4; ++i)
            {
                *c++ = (ushort)System.Math.Max(0, System.Math.Min(*a++, ushort.MaxValue));
            }
            for (int i = 0; i < 4; ++i)
            {
                *c++ = (ushort)System.Math.Max(0, System.Math.Min(*b++, ushort.MaxValue));
            }
            return(res);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        public static unsafe Vector8us SumOfAbsoluteDifferences(Vector16b va, Vector16sb vb)
        {
            Vector8us res = new Vector8us();
            byte *    a   = &va.v0;
            sbyte *   b   = (sbyte *)&vb;

            int tmp = 0;

            for (int i = 0; i < 8; ++i)
            {
                tmp += System.Math.Abs((int)*a++ - (int)*b++);
            }
            res.V0 = (ushort)tmp;

            tmp = 0;
            for (int i = 0; i < 8; ++i)
            {
                tmp += System.Math.Abs((int)*a++ - (int)*b++);
            }
            res.V4 = (ushort)tmp;

            return(res);
        }
コード例 #15
0
 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));
 }
コード例 #16
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_one_element_ctor () {
		Vector8us a = new Vector8us (99);

		if (a.V0 != 99)
			return 1;
		if (a.V1 != 99)
			return 2;
		if (a.V2 != 99)
			return 3;
		if (a.V3 != 99)
			return 4;
		if (a.V4 != 99)
			return 5;
		if (a.V5 != 99)
			return 6;
		if (a.V6 != 99)
			return 7;
		if (a.V7 != 99)
			return 8;
		return 0;
	}
コード例 #17
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_accessors () {
		Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);

		if (a.V0 != 0)
			return 1;
		if (a.V1 != 1)
			return 2;
		if (a.V2 != 2)
			return 3;
		if (a.V3 != 3)
			return 4;
		if (a.V4 != 4)
			return 5;
		if (a.V5 != 5)
			return 6;
		if (a.V6 != 6)
			return 7;
		if (a.V7 != 7)
			return 8;
		a.V0 = 10;
		a.V1 = 20;
		a.V2 = 30;
		a.V3 = 40;
		a.V4 = 50;
		a.V5 = 60;
		a.V6 = 70;
		a.V7 = 80;

		if (a.V0 != 10)
			return 17;
		if (a.V1 != 20)
			return 18;
		if (a.V2 != 30)
			return 19;
		if (a.V3 != 40)
			return 20;
		if (a.V4 != 50)
			return 21;
		if (a.V5 != 60)
			return 22;
		if (a.V6 != 70)
			return 23;
		if (a.V7 != 80)
			return 24;

		return 0;
	}
コード例 #18
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_add () {
		Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
		Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);

		Vector8us c = a + b;
		if (c.V0 != 34696)
			return 1;
		if (c.V1 != 5)
			return 2;
		if (c.V7 != 18)
			return 3;
		return 0;
	}
コード例 #19
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_shr_constant () {
		Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
		Vector8us c = a >> 2;

		if (c.V0 != 0x3C00)
			return 1;
		if (c.V1 != 0)
			return 2;
		if (c.V7 != 1)
			return 3;
		return 0;
	}
コード例 #20
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_shift_variable_offset () {
		int off = 2;
		Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
		Vector8us b = a;
		Vector8us c = b >> off;
		a = b + b;

		if (c.V0 != 0x3C00)
			return 1;
		if (c.V1 != 0)
			return 2;
		if (c.V7 != 1)
			return 3;
		if (a.V1 != 2)
			return 4;
		if (a.V7 != 14)
			return 5;
		return 0;
	}
コード例 #21
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_shift_left () {
		Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
		int amt = 2;
		Vector8us c = a << amt;
	
		if (c.V0 != 0xFC00)
			return 1;
		if (c.V1 != 4)
			return 2;
		if (c.V7 != 28)
			return 3;
		return 0;
	}
コード例 #22
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	public static int test_0_vector8us_cmpeq () {
		Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
		Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
		Vector8us c = a.CompareEqual (b);

		if (c.V0 != 0)
			return 1;
		if (c.V1 != 0xFFFF)
			return 2;
		if (c.V2 != 0)
			return 3;
		if (c.V3 != 0)
			return 4;
		if (c.V4 != 0)
			return 5;
		if (c.V5 != 0xFFFF)
			return 6;
		if (c.V6 != 0xFFFF)
			return 7;
		if (c.V7 != 0)
			return 8;
		return 0;
	}
コード例 #23
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	public static int test_0_vector8us_mul_high () {
		Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
		Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
		Vector8us c = a.MultiplyStoreHigh (b);

		if (c.V0 != 0xFE01)
			return 1;
		if (c.V1 != 0)
			return 2;
		if (c.V2 != 0)
			return 3;
		if (c.V3 != 0)
			return 4;
		if (c.V4 != 0)
			return 5;
		if (c.V5 != 0)
			return 6;
		if (c.V6 != 0)
			return 7;
		if (c.V7 != 0)
			return 8;
		return 0;
	}
コード例 #24
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	public static int test_0_vector8us_pack_with_sat () {
		Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
		Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
		Vector16b c = a.SignedPackWithUnsignedSaturation (b);

		if (c.V0 != 0)
			return 1;
		if (c.V1 != 1)
			return 2;
		if (c.V2 != 2)
			return 3;
		if (c.V8 != 3)
			return 4;
		if (c.V15 != 10)
			return 5;
		return 0;
	}
コード例 #25
0
ファイル: Vector8us.cs プロジェクト: kasertim/sentience
		public static unsafe Vector8us operator >> (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)(*a++ >> amount);
			return res;
		}
コード例 #26
0
ファイル: Vector8us.cs プロジェクト: kasertim/sentience
		public static void PrefetchNonTemporal (ref Vector8us res)
		{
		}
コード例 #27
0
ファイル: Vector8us.cs プロジェクト: kasertim/sentience
		public static unsafe void PrefetchNonTemporal (Vector8us *res)
		{
		}
コード例 #28
0
ファイル: Vector8us.cs プロジェクト: kasertim/sentience
		public static unsafe void PrefetchTemporal2ndLevelCache (Vector8us *res)
		{
		}
コード例 #29
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_unpack_low () {
		Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
		Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
		Vector8us c = a.UnpackLow (b);

		if (c.V0 != 0)
			return 1;
		if (c.V1 != 3)
			return 2;
		if (c.V2 != 1)
			return 3;
		if (c.V3 != 4)
			return 4;
		if (c.V4 != 2)
			return 5;
		if (c.V5 != 5)
			return 6;
		if (c.V6 != 3)
			return 7;
		if (c.V7 != 6)
			return 8;
		return 0;
	}
コード例 #30
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
		Vector8us res = new Vector8us ();
		byte *a = (byte*)&va;
		byte *b = (byte*)&vb;

		int tmp = 0;
		for (int i = 0; i < 8; ++i)
			tmp += System.Math.Abs ((int)*a++ - (int)*b++);
		res.V0 = (ushort)tmp;

		tmp = 0;
		for (int i = 0; i < 8; ++i)
			tmp += System.Math.Abs ((int)*a++ - (int)*b++);
		res.V4 = (ushort)tmp;
		return res;
	}
コード例 #31
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_shift_right_arithmetic () {
		Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
		int amt = 2;
		Vector8us c = a.ArithmeticRightShift (amt);
	
		if (c.V0 != 0xFFC0)
			return 1;
		if (c.V1 != 0)
			return 2;
		if (c.V7 != 1)
			return 3;
		return 0;
	}
コード例 #32
0
 public static Vector8us LoadAligned(ref Vector8us v)
 {
     return(v);
 }
コード例 #33
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_shift_operand_is_live_after_op () {
		Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
		Vector8us b = a;
		Vector8us c = b >> 2;
		a = b + b;

		if (c.V0 != 0x3C00)
			return 1;
		if (c.V1 != 0)
			return 2;
		if (c.V7 != 1)
			return 3;
		if (a.V1 != 2)
			return 4;
		if (a.V7 != 14)
			return 5;
		return 0;
	}
コード例 #34
0
 public static unsafe void StoreAligned(Vector8us *res, Vector8us val)
 {
     *res = val;
 }
コード例 #35
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_mul () {
		Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
		Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);

		Vector8us c = a * b;
		if (c.V0 != 63488)
			return 1;
		if (c.V1 != 4)
			return 2;
		if (c.V7 != 80)
			return 3;
		return 0;
	}
コード例 #36
0
 public static void PrefetchTemporal2ndLevelCache(ref Vector8us res)
 {
 }
コード例 #37
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_sub () {
		Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
		Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);

		Vector8us c = a - b;

		if (c.V0 != 65529)
			return 1;
		if (c.V1 != 3)
			return 2;
		if (c.V7 != 2)
			return 3;
		return 0;
	}
コード例 #38
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	public static int test_0_vecto8us_avg () {
		Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
		Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
		Vector8us c = a.Average (b);

		if (c.V0 != 5)
			return 1;
		if (c.V1 != 2)
			return 2;
		if (c.V2 != 2)
			return 3;
		if (c.V3 != 3)
			return 4;
		if (c.V4 != 4)
			return 5;
		if (c.V5 != 5)
			return 6;
		if (c.V6 != 6)
			return 7;
		if (c.V7 != 7)
			return 8;
		return 0;
	}
コード例 #39
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	public static int test_0_vector8us_operator_eq () {
		Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
		Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
		if (!(a == b))
			return 1;
		b.V0 = 99;
		if (a == b)
			return 2;
		return 0;
	}
コード例 #40
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_sub_sat () {
		Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
		Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
		Vector8us c = a.SubtractWithSaturation (b);

		if (c.V0 != 0)
			return 1;
		if (c.V1 != 0)
			return 2;
		if (c.V2 != 15)
			return 3;
		if (c.V3 != 0)
			return 4;
		if (c.V4 != 0)
			return 5;
		if (c.V5 != 0)
			return 6;
		if (c.V6 != 0)
			return 7;
		if (c.V7 != 0)
			return 8;
		return 0;
	}
コード例 #41
0
 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));
 }
コード例 #42
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static int test_0_vector8us_add_sat () {
		Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
		Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
		Vector8us c = a.AddWithSaturation (b);

		if (c.V0 != 0xFFFF)
			return 1;
		if (c.V1 != 5)
			return 2;
		if (c.V2 != 7)
			return 3;
		if (c.V3 != 9)
			return 4;
		if (c.V4 != 11)
			return 5;
		if (c.V5 != 13)
			return 6;
		if (c.V6 != 15)
			return 7;
		if (c.V7 != 17)
			return 8;
		return 0;
	}
コード例 #43
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
		Vector8us res = new Vector8us ();
		byte *a = (byte*)&va;
		byte *b = (byte*)&vb;
		*((ushort*)&res) = 10;

		int tmp = 0;
		if (*b != 0)
			tmp++;

		Vector8us dd = res;
		dd = dd + dd - dd;
		return dd;
	}
コード例 #44
0
ファイル: Vector8us.cs プロジェクト: kasertim/sentience
		public static unsafe void PrefetchTemporalAllCacheLevels (Vector8us *res)
		{
		}
コード例 #45
0
 public static void StoreAligned(ref Vector8us res, Vector8us val)
 {
     res = val;
 }
コード例 #46
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	public static int test_0_vecto8us_shuffle_high () {
		Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
		Vector8us c = a.ShuffleHigh (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);

		if (c.V0 != 1)
			return 1;
		if (c.V1 != 2)
			return 2;
		if (c.V2 != 3)
			return 3;
		if (c.V3 != 4)
			return 4;
		if (c.V4 != 6)
			return 5;
		if (c.V5 != 8)
			return 6;
		if (c.V6 != 5)
			return 7;
		if (c.V7 != 7)
			return 8;

		return 0;
	}
コード例 #47
0
 public static void PrefetchTemporalAllCacheLevels(ref Vector8us res)
 {
 }
コード例 #48
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	public static int test_0_vecto8us_max () {
		Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
		Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
		Vector8us c = a.Max (b);

		if (c.V0 != 9)
			return 1;
		if (c.V1 != 2)
			return 2;
		if (c.V2 != 3)
			return 3;
		if (c.V3 != 4)
			return 4;
		if (c.V4 != 9)
			return 5;
		if (c.V5 != 6)
			return 6;
		if (c.V6 != 7)
			return 7;
		if (c.V7 != 1000)
			return 0;

		return 0;
	}
コード例 #49
0
 public static void PrefetchNonTemporal(ref Vector8us res)
 {
 }
コード例 #50
0
ファイル: basic-simd.cs プロジェクト: Zman0169/mono
	public static int test_0_vecto8us_min () {
		Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
		Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
		Vector8us c = a.Min (b);

		if (c.V0 != 1)
			return 1;
		if (c.V1 != 1)
			return 2;
		if (c.V2 != 1)
			return 3;
		if (c.V3 != 0)
			return 4;
		if (c.V4 != 3)
			return 5;
		if (c.V5 != 4)
			return 6;
		if (c.V6 != 5)
			return 7;
		if (c.V7 != 4)
			return 8;
		return 0;
	}