public static unsafe Vector4ui Shuffle(Vector4ui v1, ShuffleSel sel) { uint *ptr = (uint *)&v1; int idx = (int)sel; return(new Vector4ui(*(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)))); }
public static void SetVectorAligned(this uint[] array, Vector4ui val, int offset) { array [offset + 0] = val.X; array [offset + 1] = val.Y; array [offset + 2] = val.Z; array [offset + 3] = val.W; }
public static unsafe Vector4ui Shuffle(this Vector4ui v1, Vector4ui v2, ShuffleSel sel) { uint *p1 = (uint *)&v1; uint *p2 = (uint *)&v2; int idx = (int)sel; return(new Vector4ui(*(p1 + ((idx >> 0) & 0x3)), *(p1 + ((idx >> 2) & 0x3)), *(p2 + ((idx >> 4) & 0x3)), *(p2 + ((idx >> 6) & 0x3)))); }
public static unsafe Vector4ui ArithmeticRightShift (this Vector4ui v1, int amount) { Vector4ui res = new Vector4ui (); uint *a = &v1.x; uint *b = &res.x; for (int i = 0; i < 4; ++i) *b++ = (uint)((int)(*a++) >> amount); return res; }
public static unsafe int ExtractByteMask(Vector4ui va) { int res = 0; byte *a = (byte *)&va; for (int i = 0; i < 16; ++i) { res |= (*a++ & 0x80) >> 7 << i; } return(res); }
public static unsafe Vector4ui ShiftRightArithmetic(Vector4ui v1, int amount) { Vector4ui res = new Vector4ui(); uint * a = &v1.x; uint * b = &res.x; for (int i = 0; i < 4; ++i) { *b++ = (uint)((int)(*a++) >> amount); } return(res); }
static int test_0_vector4ui_one_element_ctor () { Vector4ui a = new Vector4ui (99); if (a.X != 99) return 1; if (a.Y != 99) return 2; if (a.Z != 99) return 3; if (a.W != 99) return 4; return 0; }
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); }
public static unsafe Vector8s SignedPackWithSignedSaturation(Vector4ui va, Vector4ui vb) { Vector8s res = new Vector8s(); int * a = (int *)&va; int * b = (int *)&vb; short * c = (short *)&res; for (int i = 0; i < 4; ++i) { *c++ = (short)System.Math.Max(System.Math.Min((int)*a++, short.MaxValue), short.MinValue); } for (int i = 0; i < 4; ++i) { *c++ = (short)System.Math.Max(System.Math.Min((int)*b++, short.MaxValue), short.MinValue); } return(res); }
public static int test_0_vector4ui_unpack_high () { Vector4ui a = new Vector4ui (1,2,3,4); Vector4ui b = new Vector4ui (5,6,7,8); Vector4ui c = a.UnpackHigh(b); if (c.X != 3) return 1; if (c.Y != 7) return 2; if (c.Z != 4) return 3; if (c.W != 8) return 4; return 0; }
public static int test_0_vector4ui_max () { Vector4ui a = new Vector4ui (6,1,6,3); Vector4ui b = new Vector4ui (3,4,6,7); Vector4ui c = a.Max (b); if (c.X != 6) return 1; if (c.Y != 4) return 2; if (c.Z != 6) return 3; if (c.W != 7) return 4; return 0; }
public static int test_0_vector4ui_cmpeq () { Vector4ui a = new Vector4ui (6,1,6,3); Vector4ui b = new Vector4ui (3,4,6,7); Vector4ui c = a.CompareEqual (b); if (c.X != 0) return 1; if (c.Y != 0) return 2; if (c.Z != 0xFFFFFFFF) return 3; if (c.W != 0) return 4; return 0; }
public static unsafe void PrefetchNonTemporal (Vector4ui *res) { }
public static unsafe Vector4ui Min(Vector4ui v1, Vector4ui v2) { return(new Vector4ui(System.Math.Min(v1.x, v2.x), System.Math.Min(v1.y, v2.y), System.Math.Min(v1.z, v2.z), System.Math.Min(v1.w, v2.w))); }
public static int test_1_set_vector4ui_operator_eq () { Vector4ui a = new Vector4ui(1, 2, 3, 4); Vector4ui b = new Vector4ui(111, 2, 3, 4); if (a == b) return 0; return 1; }
public static int test_0_vector4ui_mul () { Vector4ui a = new Vector4ui (0x8888,20,3,40); Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4); Vector4ui c = a * b; if (c.X != 0xffff7800) return 1; if (c.Y != 40) return 2; if (c.Z != 9) return 3; if (c.W != 160) return 4; return 0; }
public static Vector4ui LoadAligned(ref Vector4ui v) { return(v); }
public static unsafe Vector4ui CompareEqual(Vector4ui v1, Vector4ui v2) { return(new Vector4ui((uint)(v1.x == v2.x ? -1 : 0), (uint)(v1.y == v2.y ? -1 : 0), (uint)(v1.z == v2.z ? -1 : 0), (uint)(v1.w == v2.w ? -1 : 0))); }
public static Vector4ui Max(this Vector4ui v1, Vector4ui v2) { return(new Vector4ui(System.Math.Max(v1.x, v2.x), System.Math.Max(v1.y, v2.y), System.Math.Max(v1.z, v2.z), System.Math.Max(v1.w, v2.w))); }
public static unsafe Vector4ui UnpackLow(Vector4ui v1, Vector4ui v2) { return(new Vector4ui(v1.x, v2.x, v1.y, v2.y)); }
public static int test_0_vector4ui_xor () { Vector4ui a = new Vector4ui (1,2,3,4); Vector4ui b = new Vector4ui (7,5,3,1); Vector4ui c = a ^ b; if (c.X != 6) return 1; if (c.Y != 7) return 2; if (c.Z != 0) return 3; if (c.W != 5) return 4; return 0; }
public static void StoreAligned(ref Vector4ui res, Vector4ui val) { res = val; }
public static int test_0_vector4ui_shr () { Vector4ui a = new Vector4ui (0xF0000000u,20,3,40); Vector4ui c = a >> 2; if (c.X != 0x3C000000) return 1; if (c.Y != 5) return 2; if (c.Z != 0) return 3; if (c.W != 10) return 4; return 0; }
public static unsafe void StoreAligned(Vector4ui *res, Vector4ui val) { *res = val; }
public static int test_0_vector4ui_add () { Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4); Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4); Vector4ui c = a + b; if (c.X != 0xfe01fe00) return 1; if (c.Y != 4) return 2; if (c.Z != 6) return 3; if (c.W != 8) return 4; return 0; }
public static void PrefetchTemporalAllCacheLevels(ref Vector4ui res) { }
public static int test_0_accessor_vecto4ui () { Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4); if (a.X != 0xF0000000) return 1; if (a.Y != 0xF0000) return 2; if (a.Z != 3) return 3; if (a.W != 4) return 4; a.X = 11; a.Y = 22; a.Z = 33333344; a.W = 44444444; if (a.X != 11) return 5; if (a.Y != 22) return 6; if (a.Z != 33333344) return 7; if (a.W != 44444444) return 8; return 0; }
public static void PrefetchTemporal2ndLevelCache(ref Vector4ui res) { }
public static unsafe void PrefetchTemporal2ndLevelCache (Vector4ui *res) { }
public static void PrefetchNonTemporal(ref Vector4ui res) { }
public static int test_0_vector4ui_pack_with_sat () { Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4); Vector4ui b = new Vector4ui (5,6,7,8); Vector8us c = a.SignedPackWithUnsignedSaturation (b); if (c.V0 != 0) return 1; if (c.V1 != 0xFFFF) return 2; if (c.V2 != 3) return 3; if (c.V3 != 4) return 4; if (c.V4 != 5) return 5; if (c.V5 != 6) return 6; if (c.V6 != 7) return 7; if (c.V7 != 8) return 8; return 0; }
public static Vector4ui UnpackHigh(this Vector4ui v1, Vector4ui v2) { return(new Vector4ui(v1.z, v2.z, v1.w, v2.w)); }
public static int test_0_vector4ui_shuffle () { Vector4ui a = new Vector4ui (1,2,3,4); Vector4ui c = a.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ); if (c.X != 2) return 1; if (c.Y != 4) return 2; if (c.Z != 1) return 3; if (c.W != 3) return 4; return 0; }
public static Vector4ui LoadAligned (ref Vector4ui v) { return v; }
public static int test_0_vector4ui_sar () { Vector4ui a = new Vector4ui (0xF0000000u,20,3,40); Vector4ui c = a.ArithmeticRightShift (2); if (c.X != 0xFC000000) return 1; if (c.Y != 5) return 2; if (c.Z != 0) return 3; if (c.W != 10) return 4; return 0; }
public static void StoreAligned (ref Vector4ui res, Vector4ui val) { res = val; }
public static int test_0_vector4ui_unpack_low () { Vector4ui a = new Vector4ui (1,2,3,4); Vector4ui b = new Vector4ui (5,6,7,8); Vector4ui c = a.UnpackLow (b); if (c.X != 1) return 1; if (c.Y != 5) return 2; if (c.Z != 2) return 3; if (c.W != 6) return 4; return 0; }
public static unsafe Vector4ui LoadAligned (Vector4ui *v) { return *v; }
public static int test_0_vector4ui_and () { Vector4ui a = new Vector4ui (1,2,3,4); Vector4ui b = new Vector4ui (7,5,3,1); Vector4ui c = a & b; if (c.X != 1) return 1; if (c.Y != 0) return 2; if (c.Z != 3) return 3; if (c.W != 0) return 4; return 0; }
public static unsafe void StoreAligned (Vector4ui *res, Vector4ui val) { *res = val; }
public static int test_0_vector4ui_shl () { Vector4ui a = new Vector4ui (10,20,3,40); Vector4ui c = a << 2; if (c.X != 40) return 1; if (c.Y != 80) return 2; if (c.Z != 12) return 3; if (c.W != 160) return 4; return 0; }
public static Vector4ui UnpackLow(this Vector4ui v1, Vector4ui v2) { return(new Vector4ui(v1.x, v2.x, v1.y, v2.y)); }
public static int test_0_vector4ui_sub () { Vector4ui a = new Vector4ui (1,20,3,40); Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4); Vector4ui c = a - b; if (c.X != 0xff0101) return 1; if (c.Y != 18) return 2; if (c.Z != 0) return 3; if (c.W != 36) return 4; return 0; }
public static void PrefetchTemporal2ndLevelCache (ref Vector4ui res) { }
static int test_0_vector4ui_accessors () { Vector4ui a = new Vector4ui (1,2,3,4); if (a.X != 1) return 1; if (a.Y != 2) return 2; if (a.Z != 3) return 3; if (a.W != 4) return 4; a.X = 10; a.Y = 20; a.Z = 30; a.W = 40; if (a.X != 10) return 5; if (a.Y != 20) return 6; if (a.Z != 30) return 7; if (a.W != 40) return 8; return 0; }
public static void PrefetchNonTemporal (ref Vector4ui res) { }
public static int test_0_set_vector () { uint[] array = new uint[10]; Vector4ui a = new Vector4ui (11, 22, 33, 44); array.SetVector (a, 1); if (array [1] != 11) return 1; if (array [2] != 22) return 2; if (array [3] != 33) return 3; if (array [4] != 44) return 4; return 0; }
public static unsafe void PrefetchTemporalAllCacheLevels (Vector4ui *res) { }
public static void PrefetchTemporalAllCacheLevels (ref Vector4ui res) { }
public static unsafe Vector4ui UnpackHigh(Vector4ui v1, Vector4ui v2) { return(new Vector4ui(v1.z, v2.z, v1.w, v2.w)); }