annotate test/test_arith.h @ 46:31cee67540b5

f32/f64: add floor, ceil, round, and trunc operations we also need saturated add sub mul etc
author Paper <paper@tflc.us>
date Sat, 09 Aug 2025 15:55:59 -0400
parents 7955bed1d169
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
1 #define CREATE_TEST_EX(type, ctype, print, bits, size, op, equiv, secondtype, secondctype) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
2 static int test_arith_v##type##bits##x##size##_##op(v##type##bits##x##size a, v##secondtype##bits##x##size b) \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
3 { \
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
4 V##ctype##bits##x##size##_ALIGNED_ARRAY(orig_a); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
5 V##secondctype##bits##x##size##_ALIGNED_ARRAY(orig_b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
6 V##ctype##bits##x##size##_ALIGNED_ARRAY(orig_c); \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
7 \
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
8 v##type##bits##x##size c = v##type##bits##x##size##_##op(a, b); \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
9 \
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
10 v##type##bits##x##size##_store_aligned(a, orig_a); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
11 v##secondtype##bits##x##size##_store_aligned(b, orig_b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
12 v##type##bits##x##size##_store_aligned(c, orig_c); \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
13 \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
14 for (int i = 0; i < size; i++) { \
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
15 if ((vec_##type##bits)(equiv) != orig_c[i]) { \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
16 fprintf(stderr, "v" #type #bits "x" #size "_" #op " test FAILED at index %d: (%s) [%" print "] does not equal result [%" print "]!\n", i, #equiv, (vec_##type##bits)(equiv), orig_c[i]); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
17 print_v##type##bits##x##size(stderr,a); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
18 print_v##secondtype##bits##x##size(stderr,b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
19 print_v##type##bits##x##size(stderr,c); \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
20 fprintf(stderr, "\n"); \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
21 return 1; \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
22 } \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
23 } \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
24 \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
25 return 0; \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
26 }
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
27
46
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
28 #define CREATE_TEST_ONEPARAM(type, ctype, print, bits, size, op, equiv) \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
29 static int test_arith_v##type##bits##x##size##_##op(v##type##bits##x##size a) \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
30 { \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
31 V##ctype##bits##x##size##_ALIGNED_ARRAY(orig_a); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
32 V##ctype##bits##x##size##_ALIGNED_ARRAY(orig_c); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
33 \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
34 v##type##bits##x##size c = v##type##bits##x##size##_##op(a); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
35 \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
36 v##type##bits##x##size##_store_aligned(a, orig_a); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
37 v##type##bits##x##size##_store_aligned(c, orig_c); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
38 \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
39 for (int i = 0; i < size; i++) { \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
40 if ((vec_##type##bits)(equiv) != orig_c[i]) { \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
41 fprintf(stderr, "v" #type #bits "x" #size "_" #op " test FAILED at index %d: (%s) [%" print "] does not equal result [%" print "]!\n", i, #equiv, (vec_##type##bits)(equiv), orig_c[i]); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
42 print_v##type##bits##x##size(stderr,a); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
43 print_v##type##bits##x##size(stderr,c); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
44 fprintf(stderr, "\n"); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
45 return 1; \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
46 } \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
47 } \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
48 \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
49 return 0; \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
50 }
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
51
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
52 #define CREATE_TEST(type, ctype, print, bits, size, op, equiv) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
53 CREATE_TEST_EX(type, ctype, print, bits, size, op, equiv, type, ctype)
40
55cadb1fac4b *: add mod operation, add GCC vector backend
Paper <paper@tflc.us>
parents: 37
diff changeset
54
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
55 #define CREATE_TEST_SHIFT(type, ctype, print, bits, size, op, equiv) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
56 CREATE_TEST_EX(type, ctype, print, bits, size, op, equiv, uint, UINT)
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
57
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
58 #define CREATE_TESTS_INT(type, ctype, sign, print, bits, size) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
59 CREATE_TEST(type, ctype, print, bits, size, add, orig_a[i] + orig_b[i]) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
60 CREATE_TEST(type, ctype, print, bits, size, sub, orig_a[i] - orig_b[i]) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
61 CREATE_TEST(type, ctype, print, bits, size, mul, orig_a[i] * orig_b[i]) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
62 CREATE_TEST(type, ctype, print, bits, size, div, (orig_b[i]) ? (orig_a[i] / orig_b[i]) : 0) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
63 CREATE_TEST(type, ctype, print, bits, size, mod, (orig_b[i]) ? (orig_a[i] % orig_b[i]) : 0) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
64 CREATE_TEST(type, ctype, print, bits, size, and, orig_a[i] & orig_b[i]) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
65 CREATE_TEST(type, ctype, print, bits, size, or, orig_a[i] | orig_b[i]) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
66 CREATE_TEST(type, ctype, print, bits, size, xor, orig_a[i] ^ orig_b[i]) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
67 CREATE_TEST(type, ctype, print, bits, size, avg, (vec_##type##bits)vec_im##sign##avg(orig_a[i], orig_b[i])) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
68 CREATE_TEST_SHIFT(type, ctype, print, bits, size, rshift, vec_##sign##rshift(orig_a[i], orig_b[i])) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
69 CREATE_TEST_SHIFT(type, ctype, print, bits, size, lshift, vec_##sign##lshift(orig_a[i], orig_b[i])) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
70 CREATE_TEST_SHIFT(type, ctype, print, bits, size, lrshift, vec_urshift((vec_uint##bits)orig_a[i], orig_b[i])) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
71 CREATE_TEST(type, ctype, print, bits, size, min, (orig_a[i] < orig_b[i]) ? orig_a[i] : orig_b[i]) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
72 CREATE_TEST(type, ctype, print, bits, size, max, (orig_a[i] > orig_b[i]) ? orig_a[i] : orig_b[i])
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
73
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
74 #define CREATE_TESTS_FLOAT(bits, size) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
75 CREATE_TEST(f, F, "f", bits, size, add, orig_a[i] + orig_b[i]) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
76 CREATE_TEST(f, F, "f", bits, size, sub, orig_a[i] - orig_b[i]) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
77 CREATE_TEST(f, F, "f", bits, size, mul, orig_a[i] * orig_b[i]) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
78 CREATE_TEST(f, F, "f", bits, size, div, (orig_b[i]) ? (orig_a[i] / orig_b[i]) : 0) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
79 CREATE_TEST(f, F, "f", bits, size, mod, (orig_b[i]) ? (fmod(orig_a[i], orig_b[i])) : 0) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
80 CREATE_TEST(f, F, "f", bits, size, avg, (orig_a[i] + orig_b[i]) / 2) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
81 CREATE_TEST(f, F, "f", bits, size, min, (orig_a[i] < orig_b[i]) ? orig_a[i] : orig_b[i]) \
46
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
82 CREATE_TEST(f, F, "f", bits, size, max, (orig_a[i] > orig_b[i]) ? orig_a[i] : orig_b[i]) \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
83 CREATE_TEST_ONEPARAM(f, F, "f", bits, size, round, round(orig_a[i])) \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
84 CREATE_TEST_ONEPARAM(f, F, "f", bits, size, ceil, ceil(orig_a[i])) \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
85 CREATE_TEST_ONEPARAM(f, F, "f", bits, size, floor, floor(orig_a[i])) \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
86 CREATE_TEST_ONEPARAM(f, F, "f", bits, size, trunc, trunc(orig_a[i]))
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
87
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
88 #define CREATE_TESTS(bits, size) \
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
89 CREATE_TESTS_INT(int, INT, /* nothing */, PRI##d##bits, bits, size) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
90 CREATE_TESTS_INT(uint, UINT, u, PRI##u##bits, bits, size)
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
91
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
92 CREATE_TESTS(8, 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
93
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
94 CREATE_TESTS(8, 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
95 CREATE_TESTS(16, 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
96
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
97 CREATE_TESTS(8, 8)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
98 CREATE_TESTS(16, 4)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
99 CREATE_TESTS(32, 2)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
100
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
101 CREATE_TESTS(8, 16)
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
102 CREATE_TESTS(16, 8)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
103 CREATE_TESTS(32, 4)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
104 CREATE_TESTS(64, 2)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
105
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
106 CREATE_TESTS(8, 32)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
107 CREATE_TESTS(16, 16)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
108 CREATE_TESTS(32, 8)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
109 CREATE_TESTS(64, 4)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
110
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
111 CREATE_TESTS(8, 64)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
112 CREATE_TESTS(16, 32)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
113 CREATE_TESTS(32, 16)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
114 CREATE_TESTS(64, 8)
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
115
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
116 CREATE_TESTS_FLOAT(32, 2)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
117 CREATE_TESTS_FLOAT(32, 4)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
118 CREATE_TESTS_FLOAT(32, 8)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
119 CREATE_TESTS_FLOAT(32, 16)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
120
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
121 CREATE_TESTS_FLOAT(64, 2)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
122 CREATE_TESTS_FLOAT(64, 4)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
123 CREATE_TESTS_FLOAT(64, 8)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
124
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
125 #undef CREATE_TESTS_INT
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
126 #undef CREATE_TESTS_FLOAT
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
127 #undef CREATE_TESTS
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
128 #undef CREATE_TEST
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
129 #undef CREATE_TEST_SHIFT
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
130
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
131 static int test_arith(void)
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
132 {
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
133 int ret = 0;
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
134
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
135 #define RUN_TESTS_SIGN(shorttype, type, bits, size) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
136 for (size_t i = 0U; i < ARRAY_SIZE(testval##shorttype##bits); i++) { \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
137 const v##type##bits##x##size a = vtest##shorttype##bits##x##size(i); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
138 for (size_t j = 0U; j < ARRAY_SIZE(testval##shorttype##bits); j++) { \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
139 const v##type##bits##x##size b = vtest##shorttype##bits##x##size(j); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
140 ret |= test_arith_v##type##bits##x##size##_add(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
141 ret |= test_arith_v##type##bits##x##size##_sub(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
142 ret |= test_arith_v##type##bits##x##size##_mul(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
143 ret |= test_arith_v##type##bits##x##size##_div(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
144 ret |= test_arith_v##type##bits##x##size##_mod(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
145 ret |= test_arith_v##type##bits##x##size##_and(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
146 ret |= test_arith_v##type##bits##x##size##_or(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
147 ret |= test_arith_v##type##bits##x##size##_xor(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
148 ret |= test_arith_v##type##bits##x##size##_avg(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
149 ret |= test_arith_v##type##bits##x##size##_min(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
150 ret |= test_arith_v##type##bits##x##size##_max(a, b); \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
151 } \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
152 } \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
153 \
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
154 for (size_t i = 0U; i < ARRAY_SIZE(testval##shorttype##bits); i++) { \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
155 const v##type##bits##x##size a = vtest##shorttype##bits##x##size(i); \
4
75ab77f874e2 *: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents: 3
diff changeset
156 for (uint32_t j = 0U; j < bits; j++) { \
75ab77f874e2 *: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents: 3
diff changeset
157 const vuint##bits##x##size b = vuint##bits##x##size##_splat(j); \
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
158 ret |= test_arith_v##type##bits##x##size##_rshift(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
159 ret |= test_arith_v##type##bits##x##size##_lshift(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
160 ret |= test_arith_v##type##bits##x##size##_lrshift(a, b); \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
161 } \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
162 }
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
163
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
164 #define RUN_TESTS(bits, size) \
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
165 RUN_TESTS_SIGN( , int, bits, size) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
166 RUN_TESTS_SIGN(u, uint, bits, size)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
167
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
168 #define RUN_TESTS_FLOAT(shorttype, type, bits, size) \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
169 for (size_t i = 0U; i < ARRAY_SIZE(testval##shorttype##bits); i++) { \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
170 const v##type##bits##x##size a = vtest##shorttype##bits##x##size(i); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
171 for (size_t j = 0U; j < ARRAY_SIZE(testval##shorttype##bits); j++) { \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
172 const v##type##bits##x##size b = vtest##shorttype##bits##x##size(j); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
173 ret |= test_arith_v##type##bits##x##size##_add(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
174 ret |= test_arith_v##type##bits##x##size##_sub(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
175 ret |= test_arith_v##type##bits##x##size##_mul(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
176 ret |= test_arith_v##type##bits##x##size##_div(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
177 ret |= test_arith_v##type##bits##x##size##_mod(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
178 ret |= test_arith_v##type##bits##x##size##_avg(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
179 ret |= test_arith_v##type##bits##x##size##_min(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
180 ret |= test_arith_v##type##bits##x##size##_max(a, b); \
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
181 } \
46
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
182 ret |= test_arith_v##type##bits##x##size##_floor(a); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
183 ret |= test_arith_v##type##bits##x##size##_ceil(a); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
184 ret |= test_arith_v##type##bits##x##size##_round(a); \
31cee67540b5 f32/f64: add floor, ceil, round, and trunc operations
Paper <paper@tflc.us>
parents: 45
diff changeset
185 ret |= test_arith_v##type##bits##x##size##_trunc(a); \
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
186 }
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
187
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
188 RUN_TESTS(8, 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
189
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
190 RUN_TESTS(8, 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
191 RUN_TESTS(16, 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
192
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
193 RUN_TESTS(8, 8)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
194 RUN_TESTS(16, 4)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
195 RUN_TESTS(32, 2)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
196
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
197 RUN_TESTS(8, 16)
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
198 RUN_TESTS(16, 8)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
199 RUN_TESTS(32, 4)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
200 RUN_TESTS(64, 2)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
201
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
202 RUN_TESTS(8, 32)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
203 RUN_TESTS(16, 16)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
204 RUN_TESTS(32, 8)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
205 RUN_TESTS(64, 4)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
206
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
207 RUN_TESTS(8, 64)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
208 RUN_TESTS(16, 32)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
209 RUN_TESTS(32, 16)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 13
diff changeset
210 RUN_TESTS(64, 8)
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
211
45
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
212 RUN_TESTS_FLOAT(f, f, 32, 2)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
213 RUN_TESTS_FLOAT(f, f, 32, 4)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
214 RUN_TESTS_FLOAT(f, f, 32, 8)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
215 RUN_TESTS_FLOAT(f, f, 32, 16)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
216
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
217 RUN_TESTS_FLOAT(f, f, 64, 2)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
218 RUN_TESTS_FLOAT(f, f, 64, 4)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
219 RUN_TESTS_FLOAT(f, f, 64, 8)
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
220
7955bed1d169 *: add preliminary floating point support
Paper <paper@tflc.us>
parents: 41
diff changeset
221 #undef RUN_TESTS_FLOAT
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
222 #undef RUN_TESTS_SIGN
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
223 #undef RUN_TESTS
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
224
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
225 return ret;
3
3c5545b1568f *: much better alignment support & tests
Paper <paper@tflc.us>
parents: 2
diff changeset
226 }