4 public class SimdTests {
6 public static int test_accessors () {
7 Vector4f a = new Vector4f (1, 2, 3, 4);
19 public static int test_packed_add_with_stack_tmp () {
20 Vector4f a = new Vector4f (1, 2, 3, 4);
21 Vector4f b = new Vector4f (5, 6, 7, 8);
22 Vector4f c = new Vector4f (-1, -3, -4, -5);
23 Vector4f d = a + b + c;
35 public static int test_simple_packed_add () {
36 Vector4f a = new Vector4f (1, 2, 3, 4);
37 Vector4f b = new Vector4f (5, 6, 7, 8);
51 public static int test_simple_packed_sub () {
52 Vector4f a = new Vector4f (1, 2, 3, 4);
53 Vector4f b = new Vector4f (5, 6, 7, 8);
66 public static int test_simple_packed_mul () {
67 Vector4f a = new Vector4f (1, 2, 3, 4);
68 Vector4f b = new Vector4f (5, 6, 7, 8);
81 public static int test_simple_packed_div () {
82 Vector4f a = new Vector4f (2, 2, 3, 4);
83 Vector4f b = new Vector4f (20, 10, 33, 12);
96 public static int test_simple_packed_sqrt () {
97 Vector4f a = new Vector4f (16, 4, 9, 25);
98 a = Vector4f.Sqrt (a);
110 public static int test_simple_packed_invsqrt () {
111 Vector4f a = new Vector4f (16, 4, 100, 25);
112 //this function has VERY low precision
113 a = Vector4f.InvSqrt (a);
114 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
116 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
118 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
120 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
125 public static int test_simple_packed_min () {
126 Vector4f a = new Vector4f (16, -4, 9, 25);
127 Vector4f b = new Vector4f (5, 3, 9, 0);
128 Vector4f c = Vector4f.Min (a, b);
140 public static int test_simple_packed_max () {
141 Vector4f a = new Vector4f (16, -4, 9, 25);
142 Vector4f b = new Vector4f (5, 3, 9, 0);
143 Vector4f c = Vector4f.Max (a, b);
155 public static int test_simple_packed_hadd () {
156 Vector4f a = new Vector4f (5, 5, 6, 6);
157 Vector4f b = new Vector4f (7, 7, 8, 8);
158 Vector4f c = Vector4f.HorizontalAdd (a, b);
170 public static int test_simple_packed_hsub () {
171 Vector4f a = new Vector4f (5, 2, 6, 1);
172 Vector4f b = new Vector4f (7, 0, 8, 3);
173 Vector4f c = Vector4f.HorizontalSub (a, b);
185 public static int test_simple_packed_addsub () {
186 Vector4f a = new Vector4f (5, 2, 6, 1);
187 Vector4f b = new Vector4f (7, 0, 8, 3);
188 Vector4f c = Vector4f.AddSub (a, b);
200 public static int test_simple_packed_shuffle () {
201 Vector4f a = new Vector4f (1, 2, 3, 4);
202 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
214 public static int test_0_packed_shuffle_with_reg_pressure () {
215 Vector4f v = new Vector4f (1, 2, 3, 4);
216 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
217 if (ff) v = v + v -v ;
219 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
220 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
221 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
222 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
223 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
231 Vector4f result = r0 + r1 + r2 + r3;
241 if (result.Y != result.Y)
246 public static int test_24_regs_pressure_a () {
247 Vector4f a = new Vector4f (1, 2, 3, 4);
255 public static int test_54_regs_pressure_b () {
256 Vector4f a = new Vector4f (1, 2, 3, 4);
260 Vector4f e = a + b + c;
261 Vector4f f = d - b + a - c;
262 Vector4f g = a - d * f - c + b;
263 Vector4f h = a * b - c + e;
264 Vector4f i = h - g - f - e - d - c - b - a;
265 Vector4f j = a + b + c + d + e + f + g + h + i;
270 public static int test_3_single_block_var_is_properly_promoted () {
271 Vector4f a = new Vector4f (4, 5, 6, 7);
275 Vector4f b = new Vector4f (1, 2, 3, 4);
286 static float float_val = 45f;
288 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
289 Vector4f v = new Vector4f (1, 2, 3, 4);
299 public static int Main () {
300 return TestDriver.RunTests (typeof (SimdTests));