Mercurial > vec
annotate test/test_compare.h @ 25:92156fe32755
impl/ppc/altivec: update to new implementation
the signed average function is wrong; it needs to round up the number
when only one of them is odd, but that doesn't necessarily seem to be
true because altivec is weird, and that's what we need to emulate the
quirks for. ugh.
also the altivec backend uses the generic functions instead of fallbacks
because it does indeed use the exact same memory structure as the generic
implementation...
author | Paper <paper@tflc.us> |
---|---|
date | Sun, 24 Nov 2024 11:15:59 +0000 |
parents | 627d548b23c8 |
children |
rev | line source |
---|---|
2
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
1 #define CREATE_TEST(sign, psign, bits, size, op, equiv) \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
2 static int test_compare_v##sign##int##bits##x##size##_##op(v##sign##int##bits##x##size a, v##sign##int##bits##x##size b) \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
3 { \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
4 sign##int##bits##_t orig_a[size], orig_b[size], orig_c[size]; \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
5 \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
6 v##sign##int##bits##x##size c = v##sign##int##bits##x##size##_##op(a, b); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
7 \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
8 v##sign##int##bits##x##size##_store(a, orig_a); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
9 v##sign##int##bits##x##size##_store(b, orig_b); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
10 v##sign##int##bits##x##size##_store(c, orig_c); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
11 \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
12 for (int i = 0; i < size; i++) { \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
13 if ((sign##int##bits##_t)(((equiv) ? UINT##bits##_MAX : 0)) != orig_c[i]) { \ |
7
945d410803f8
*: fix clang & gcc warnings, add avg test, etc
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
14 fprintf(stderr, "v" #sign "int" #bits "x" #size "_" #op " test FAILED at index %d: (" #equiv ") [%d] does not equal result [%" PRI ## psign ## bits "]!\n", i, equiv, orig_c[i]); \ |
2
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
15 print_v##sign##int##bits##x##size(stderr,a); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
16 print_v##sign##int##bits##x##size(stderr,b); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
17 print_v##sign##int##bits##x##size(stderr,c); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
18 fprintf(stderr, "\n"); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
19 return 1; \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
20 } \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
21 } \ |
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 return 0; \ |
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 |
9
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
26 #define CREATE_TESTS_SIGN(sign, psign, bits, size) \ |
2
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
27 CREATE_TEST(sign, psign, bits, size, cmplt, orig_a[i] < orig_b[i]) \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
28 CREATE_TEST(sign, psign, bits, size, cmpgt, orig_a[i] > orig_b[i]) \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
29 CREATE_TEST(sign, psign, bits, size, cmpeq, orig_a[i] == orig_b[i]) \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
30 CREATE_TEST(sign, psign, bits, size, cmple, orig_a[i] <= orig_b[i]) \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
31 CREATE_TEST(sign, psign, bits, size, cmpge, orig_a[i] >= orig_b[i]) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
32 |
9
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
33 #define CREATE_TESTS(bits, size) CREATE_TESTS_SIGN(, d, bits, size) CREATE_TESTS_SIGN(u, u, bits, size) |
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
34 |
17
41dd962abdd1
*: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
15
diff
changeset
|
35 CREATE_TESTS(8, 2) |
41dd962abdd1
*: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
15
diff
changeset
|
36 |
41dd962abdd1
*: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
15
diff
changeset
|
37 CREATE_TESTS(8, 4) |
41dd962abdd1
*: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
15
diff
changeset
|
38 CREATE_TESTS(16, 2) |
41dd962abdd1
*: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
15
diff
changeset
|
39 |
15
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
40 CREATE_TESTS(8, 8) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
41 CREATE_TESTS(16, 4) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
42 CREATE_TESTS(32, 2) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
43 |
9
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
44 CREATE_TESTS(8, 16) |
15
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
45 CREATE_TESTS(16, 8) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
46 CREATE_TESTS(32, 4) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
47 CREATE_TESTS(64, 2) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
48 |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
49 CREATE_TESTS(8, 32) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
50 CREATE_TESTS(16, 16) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
51 CREATE_TESTS(32, 8) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
52 CREATE_TESTS(64, 4) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
53 |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
54 CREATE_TESTS(8, 64) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
55 CREATE_TESTS(16, 32) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
56 CREATE_TESTS(32, 16) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
57 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
|
58 |
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
59 #undef CREATE_TESTS_SIGN |
2
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
60 #undef CREATE_TESTS |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
61 #undef CREATE_TEST |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
62 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
63 static int test_compare(void) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
64 { |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
65 int ret = 0; |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
66 |
9
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
67 #define RUN_TESTS_SIGN(sign, bits, size) \ |
2
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
68 for (size_t i = 0U; i < ARRAY_SIZE(testval##sign##bits); i++) { \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
69 const v##sign##int##bits##x##size a = vtest##sign##bits##x##size(i); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
70 for (size_t j = 0U; j < ARRAY_SIZE(testval##sign##bits); j++) { \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
71 const v##sign##int##bits##x##size b = vtest##sign##bits##x##size(j); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
72 ret |= test_compare_v##sign##int##bits##x##size##_cmplt(a, b); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
73 ret |= test_compare_v##sign##int##bits##x##size##_cmpgt(a, b); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
74 ret |= test_compare_v##sign##int##bits##x##size##_cmpeq(a, b); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
75 ret |= test_compare_v##sign##int##bits##x##size##_cmple(a, b); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
76 ret |= test_compare_v##sign##int##bits##x##size##_cmpge(a, b); \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
77 } \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
78 } |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
79 |
9
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
80 #define RUN_TESTS(bits, size) \ |
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
81 RUN_TESTS_SIGN( , bits, size) \ |
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
82 RUN_TESTS_SIGN(u, bits, size) |
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
83 |
17
41dd962abdd1
*: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
15
diff
changeset
|
84 RUN_TESTS(8, 2) |
41dd962abdd1
*: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
15
diff
changeset
|
85 |
41dd962abdd1
*: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
15
diff
changeset
|
86 RUN_TESTS(8, 4) |
41dd962abdd1
*: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
15
diff
changeset
|
87 RUN_TESTS(16, 2) |
41dd962abdd1
*: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
15
diff
changeset
|
88 |
15
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
89 RUN_TESTS(8, 8) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
90 RUN_TESTS(16, 4) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
91 RUN_TESTS(32, 2) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
92 |
9
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
93 RUN_TESTS(8, 16) |
15
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
94 RUN_TESTS(16, 8) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
95 RUN_TESTS(32, 4) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
96 RUN_TESTS(64, 2) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
97 |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
98 RUN_TESTS(8, 32) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
99 RUN_TESTS(16, 16) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
100 RUN_TESTS(32, 8) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
101 RUN_TESTS(64, 4) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
102 |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
103 RUN_TESTS(8, 64) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
104 RUN_TESTS(16, 32) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
105 RUN_TESTS(32, 16) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
106 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
|
107 |
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
108 #undef RUN_TESTS_SIGN |
2
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
109 #undef RUN_TESTS |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
110 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
111 return ret; |
20
627d548b23c8
impl/generic: fix load and store implementations
Paper <paper@tflc.us>
parents:
17
diff
changeset
|
112 } |