Mercurial > vec
annotate test/test_compare.h @ 8:6e0eb3aa12ab
build: add files to build vec as an external library
this is most definitely a double-edged sword, but you can
do it now if you *really* want to
author | Paper <paper@tflc.us> |
---|---|
date | Wed, 23 Oct 2024 20:44:30 -0400 |
parents | 945d410803f8 |
children | d1d5d767004c |
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 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
26 #define CREATE_TESTS(sign, psign, bits, size) \ |
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 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
33 #define CREATE_TESTS_2(bits, size) CREATE_TESTS(, d, bits, size) CREATE_TESTS(u, u, bits, size) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
34 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
35 CREATE_TESTS_2(8, 16) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
36 CREATE_TESTS_2(16, 8) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
37 CREATE_TESTS_2(32, 4) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
38 CREATE_TESTS_2(64, 2) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
39 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
40 #undef CREATE_TESTS_2 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
41 #undef CREATE_TESTS |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
42 #undef CREATE_TEST |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
43 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
44 static int test_compare(void) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
45 { |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
46 int ret = 0; |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
47 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
48 #define RUN_TESTS(sign, bits, size) \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 } \ |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
59 } |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
60 |
4
75ab77f874e2
*: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents:
2
diff
changeset
|
61 #define RUN_TESTS_2(bits, size) \ |
75ab77f874e2
*: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents:
2
diff
changeset
|
62 RUN_TESTS( , bits, size) \ |
75ab77f874e2
*: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents:
2
diff
changeset
|
63 RUN_TESTS(u, bits, size) |
2
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 RUN_TESTS_2(8, 16) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
66 RUN_TESTS_2(16, 8) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
67 RUN_TESTS_2(32, 4) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
68 RUN_TESTS_2(64, 2) |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
69 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
70 #undef RUN_TESTS_2 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
71 #undef RUN_TESTS |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
72 |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
73 return ret; |
f12b5dd4e18c
*: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff
changeset
|
74 } |