annotate test/main.c @ 10:d1d5d767004c

chore: merge diverging branches
author Paper <paper@tflc.us>
date Mon, 18 Nov 2024 15:44:09 -0500
parents 6ff0b7a44bb6 945d410803f8
children 53197dbf4e8e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
945d410803f8 *: fix clang & gcc warnings, add avg test, etc
Paper <paper@tflc.us>
parents: 4
diff changeset
1 #define VEC_EXTERN
945d410803f8 *: fix clang & gcc warnings, add avg test, etc
Paper <paper@tflc.us>
parents: 4
diff changeset
2 #define VEC_EXTERN_DEFINE
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
3 #include "vec/vec.h"
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
4
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
5 #include <stdio.h>
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
6 #include <inttypes.h>
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 #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
9
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
10 static const int8_t testval8[] = {
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
11 INT8_C(-80), INT8_C(-3), INT8_C(25), INT8_C(0x7F),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
12 INT8_C(-42), INT8_C(27), INT8_C(24), INT8_C(0x40),
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
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
15 static const uint8_t testvalu8[] = {
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
16 UINT8_C(0x00), UINT8_C(0xFF), UINT8_C(0xFE), UINT8_C(0x7F),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
17 UINT8_C(0xC0), UINT8_C(0x80), UINT8_C(0x20), UINT8_C(0x50),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
18 };
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
19
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
20 static const int16_t testval16[] = {
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
21 INT16_C(-8000), INT16_C(-30), INT16_MAX, INT16_C(0x4000),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
22 INT16_C(-42), INT16_C(250), INT16_MIN, INT16_C(0x500),
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 static const uint16_t testvalu16[] = {
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
26 UINT16_C(0x0000), UINT16_C(0xFFFF), UINT16_C(0xFEA), UINT16_C(0x7FF),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
27 UINT16_C(0x7FFF), UINT16_C(0x8000), UINT16_C(0x20B), UINT16_C(0x50C),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
28 };
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
29
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
30 static const int32_t testval32[] = {
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
31 INT32_C(-1000000), INT32_C(-3), INT32_C(0x00000000), INT32_C(0xFFFFFFFF),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
32 INT32_C( -42), INT32_C(27), INT32_C(0xABCDEF03), INT32_C(0x00000FFF),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
33 INT32_C(0xFFFFFFFF), INT32_C( 0), INT32_C(0xFFFFFFFE), INT32_C( 1),
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
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
36 static const uint32_t testvalu32[] = {
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
37 UINT32_C(0x00000000), UINT32_C(0xDEADBEEF), UINT32_C(42), UINT32_C(0x12340000),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
38 UINT32_C(0xFFFFFFFF), UINT32_C(0xFEDCBA98), UINT32_C(17), UINT32_C(0x00012345),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
39 UINT32_C(0xFFFFFFFF), UINT32_C(0xFFFFFFFE), UINT32_C( 0), UINT32_C( 1),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
40 };
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
41
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
42 static const int64_t testval64[] = {
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
43 INT64_MAX, INT64_C(-3), INT64_C(0x00000000), INT64_C(0xFFFFFFFFF),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
44 INT64_MIN, INT64_C(645366), INT64_C(0x12345ABCDE), INT64_C(0xF00000FFF),
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
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
47 static const uint64_t testvalu64[] = {
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
48 UINT64_MAX, UINT64_C(0x44354365), UINT64_C(0x00000000), UINT64_C(0xFFFFFFFFF),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
49 UINT64_C(0xff), UINT64_C(645366), UINT64_C(0x12345ABCDE), UINT64_C(0xF00000FFF),
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
50 };
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
51
4
75ab77f874e2 *: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents: 3
diff changeset
52 #define VTEST(sign, csign, bits, size) \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
53 static inline v##sign##int##bits##x##size vtest##sign##bits##x##size(const size_t start) \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
54 { \
4
75ab77f874e2 *: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents: 3
diff changeset
55 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(x); \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
56 for (size_t i = 0; i < size; i++) \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
57 x[i] = testval##sign##bits[(start + i) % ARRAY_SIZE(testval##sign##bits)]; \
4
75ab77f874e2 *: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents: 3
diff changeset
58 return v##sign##int##bits##x##size##_load_aligned(x); \
2
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
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
61 #define VPRINT(sign, csign, psign, bits, size) \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
62 static inline void print_v##sign##int##bits##x##size(FILE *file, v##sign##int##bits##x##size vec) \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
63 { \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
64 fputs("vector: ", file); \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
65 \
4
75ab77f874e2 *: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents: 3
diff changeset
66 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(v); \
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
67 \
4
75ab77f874e2 *: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents: 3
diff changeset
68 v##sign##int##bits##x##size##_store_aligned(vec, v); \
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 fprintf(file, "%" PRI ## psign ## bits, v[0]); \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
71 \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
72 for (int i = 1; i < size; i++) \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
73 fprintf(file, ", %" PRI ## psign ## bits, v[i]); \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
74 \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
75 fputs("\n", file); \
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
76 \
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
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
79 #define DEF_VEC_TEST_FUNCS(bits, size) \
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
80 VTEST(, , bits, size) VTEST(u, U, bits, size) \
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
81 VPRINT(, , d, bits, size) VPRINT(u, U, u, bits, size)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
82
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
83 DEF_VEC_TEST_FUNCS(8, 16)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
84 DEF_VEC_TEST_FUNCS(16, 8)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
85 DEF_VEC_TEST_FUNCS(32, 4)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
86 DEF_VEC_TEST_FUNCS(64, 2)
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 DEF_VEC_TEST_FUNCS(8, 32)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
89 DEF_VEC_TEST_FUNCS(16, 16)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
90 DEF_VEC_TEST_FUNCS(32, 8)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
91 DEF_VEC_TEST_FUNCS(64, 4)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
92
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
93 DEF_VEC_TEST_FUNCS(8, 64)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
94 DEF_VEC_TEST_FUNCS(16, 32)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
95 DEF_VEC_TEST_FUNCS(32, 16)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
96 DEF_VEC_TEST_FUNCS(64, 8)
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
97
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
98 #undef DEF_VEC_TEST_FUNCS
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
99 #undef VPRINT
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
100 #undef VTEST
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
101
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
102 // ------------------------------------------------------------
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
103
3
3c5545b1568f *: much better alignment support & tests
Paper <paper@tflc.us>
parents: 2
diff changeset
104 #include "test_align.h"
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
105 #include "test_arith.h"
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
106 #include "test_compare.h"
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
107
9
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
108 // ------------------------------------------------------------
6ff0b7a44bb6 generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents: 4
diff changeset
109
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
110 int main(void)
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
111 {
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
112 int ret = 0;
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
113
3
3c5545b1568f *: much better alignment support & tests
Paper <paper@tflc.us>
parents: 2
diff changeset
114 ret |= test_align();
2
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
115 ret |= test_arith();
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
116 ret |= test_compare();
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
117
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
118 return ret;
f12b5dd4e18c *: many new operations and a real test suite
Paper <paper@tflc.us>
parents:
diff changeset
119 }