comparison test/main.c @ 4:75ab77f874e2

*: aligned generics, fixed altivec, aligned tests...
author Paper <paper@tflc.us>
date Wed, 23 Oct 2024 10:13:25 -0400
parents 3c5545b1568f
children 945d410803f8 6ff0b7a44bb6
comparison
equal deleted inserted replaced
3:3c5545b1568f 4:75ab77f874e2
45 static const uint64_t testvalu64[] = { 45 static const uint64_t testvalu64[] = {
46 UINT64_MAX, UINT64_C(0x44354365), UINT64_C(0x00000000), UINT64_C(0xFFFFFFFFF), 46 UINT64_MAX, UINT64_C(0x44354365), UINT64_C(0x00000000), UINT64_C(0xFFFFFFFFF),
47 UINT64_C(0xff), UINT64_C(645366), UINT64_C(0x12345ABCDE), UINT64_C(0xF00000FFF), 47 UINT64_C(0xff), UINT64_C(645366), UINT64_C(0x12345ABCDE), UINT64_C(0xF00000FFF),
48 }; 48 };
49 49
50 #define VTEST(sign, bits, size) \ 50 #define VTEST(sign, csign, bits, size) \
51 static inline v##sign##int##bits##x##size vtest##sign##bits##x##size(const size_t start) \ 51 static inline v##sign##int##bits##x##size vtest##sign##bits##x##size(const size_t start) \
52 { \ 52 { \
53 sign##int##bits##_t x[size]; \ 53 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(x); \
54 for (size_t i = 0; i < size; i++) \ 54 for (size_t i = 0; i < size; i++) \
55 x[i] = testval##sign##bits[(start + i) % ARRAY_SIZE(testval##sign##bits)]; \ 55 x[i] = testval##sign##bits[(start + i) % ARRAY_SIZE(testval##sign##bits)]; \
56 return v##sign##int##bits##x##size##_load(x); \ 56 return v##sign##int##bits##x##size##_load_aligned(x); \
57 } 57 }
58 58
59 #define VTEST_SIGN(bits, size) VTEST(, bits, size) VTEST(u, bits, size) 59 #define VTEST_SIGN(bits, size) VTEST(, , bits, size) VTEST(u, U, bits, size)
60 60
61 VTEST_SIGN(8, 16) 61 VTEST_SIGN(8, 16)
62 VTEST_SIGN(16, 8) 62 VTEST_SIGN(16, 8)
63 VTEST_SIGN(32, 4) 63 VTEST_SIGN(32, 4)
64 VTEST_SIGN(64, 2) 64 VTEST_SIGN(64, 2)
65 65
66 #define DEFINE_PRINT_VECTOR(sign, psign, bits, size) \ 66 #define DEFINE_PRINT_VECTOR(sign, csign, psign, bits, size) \
67 static inline void print_v##sign##int##bits##x##size(FILE *file, v##sign##int##bits##x##size vec) \ 67 static inline void print_v##sign##int##bits##x##size(FILE *file, v##sign##int##bits##x##size vec) \
68 { \ 68 { \
69 fputs("vector: ", file); \ 69 fputs("vector: ", file); \
70 \ 70 \
71 int##bits##_t v[size]; \ 71 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(v); \
72 \ 72 \
73 v##sign##int##bits##x##size##_store(vec, v); \ 73 v##sign##int##bits##x##size##_store_aligned(vec, v); \
74 \ 74 \
75 fprintf(file, "%" PRI ## psign ## bits, v[0]); \ 75 fprintf(file, "%" PRI ## psign ## bits, v[0]); \
76 \ 76 \
77 for (int i = 1; i < size; i++) \ 77 for (int i = 1; i < size; i++) \
78 fprintf(file, ", %" PRI ## psign ## bits, v[i]); \ 78 fprintf(file, ", %" PRI ## psign ## bits, v[i]); \
79 \ 79 \
80 fputs("\n", file); \ 80 fputs("\n", file); \
81 \ 81 \
82 } 82 }
83 83
84 #define DEFINE_PRINT_VECTOR_2(bits, size) DEFINE_PRINT_VECTOR(, d, bits, size) DEFINE_PRINT_VECTOR(u, u, bits, size) 84 #define DEFINE_PRINT_VECTOR_2(bits, size) DEFINE_PRINT_VECTOR(, , d, bits, size) DEFINE_PRINT_VECTOR(u, U, u, bits, size)
85 85
86 DEFINE_PRINT_VECTOR_2(8, 16) 86 DEFINE_PRINT_VECTOR_2(8, 16)
87 DEFINE_PRINT_VECTOR_2(16, 8) 87 DEFINE_PRINT_VECTOR_2(16, 8)
88 DEFINE_PRINT_VECTOR_2(32, 4) 88 DEFINE_PRINT_VECTOR_2(32, 4)
89 DEFINE_PRINT_VECTOR_2(64, 2) 89 DEFINE_PRINT_VECTOR_2(64, 2)