Mercurial > vec
diff test/test_arith.h @ 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 |
line wrap: on
line diff
--- a/test/test_arith.h Tue Oct 22 23:27:15 2024 -0400 +++ b/test/test_arith.h Wed Oct 23 10:13:25 2024 -0400 @@ -1,13 +1,15 @@ -#define CREATE_TEST(sign, psign, bits, size, op, equiv) \ +#define CREATE_TEST(sign, psign, csign, bits, size, op, equiv) \ static int test_arith_v##sign##int##bits##x##size##_##op(v##sign##int##bits##x##size a, v##sign##int##bits##x##size b) \ { \ - sign##int##bits##_t orig_a[size], orig_b[size], orig_c[size]; \ + V##csign##INT##bits##x##size##_ALIGNED_ARRAY(orig_a); \ + V##csign##INT##bits##x##size##_ALIGNED_ARRAY(orig_b); \ + V##csign##INT##bits##x##size##_ALIGNED_ARRAY(orig_c); \ \ v##sign##int##bits##x##size c = v##sign##int##bits##x##size##_##op(a, b); \ \ - v##sign##int##bits##x##size##_store(a, orig_a); \ - v##sign##int##bits##x##size##_store(b, orig_b); \ - v##sign##int##bits##x##size##_store(c, orig_c); \ + v##sign##int##bits##x##size##_store_aligned(a, orig_a); \ + v##sign##int##bits##x##size##_store_aligned(b, orig_b); \ + v##sign##int##bits##x##size##_store_aligned(c, orig_c); \ \ for (int i = 0; i < size; i++) { \ if ((sign##int##bits##_t)(equiv) != orig_c[i]) { \ @@ -23,17 +25,18 @@ return 0; \ } -#define CREATE_TEST_SHIFT(sign, psign, bits, size, op, equiv) \ +#define CREATE_TEST_SHIFT(sign, psign, csign, bits, size, op, equiv) \ static int test_arith_v##sign##int##bits##x##size##_##op(v##sign##int##bits##x##size a, vuint##bits##x##size b) \ { \ - sign##int##bits##_t orig_a[size], orig_c[size]; \ - uint##bits##_t orig_b[size]; \ + V##csign##INT##bits##x##size##_ALIGNED_ARRAY(orig_a); \ + VUINT##bits##x##size##_ALIGNED_ARRAY(orig_b); \ + V##csign##INT##bits##x##size##_ALIGNED_ARRAY(orig_c); \ \ v##sign##int##bits##x##size c = v##sign##int##bits##x##size##_##op(a, b); \ \ - v##sign##int##bits##x##size##_store(a, orig_a); \ - vuint##bits##x##size##_store(b, orig_b); \ - v##sign##int##bits##x##size##_store(c, orig_c); \ + v##sign##int##bits##x##size##_store_aligned(a, orig_a); \ + vuint##bits##x##size##_store_aligned(b, orig_b); \ + v##sign##int##bits##x##size##_store_aligned(c, orig_c); \ \ for (int i = 0; i < size; i++) { \ if ((sign##int##bits##_t)(equiv) != orig_c[i]) { \ @@ -49,22 +52,22 @@ return 0; \ } -#define CREATE_TESTS(sign, psign, bits, size) \ - CREATE_TEST(sign, psign, bits, size, add, orig_a[i] + orig_b[i]) \ - CREATE_TEST(sign, psign, bits, size, sub, orig_a[i] - orig_b[i]) \ - CREATE_TEST(sign, psign, bits, size, mul, orig_a[i] * orig_b[i]) \ - CREATE_TEST(sign, psign, bits, size, div, (orig_b[i]) ? (orig_a[i] / orig_b[i]) : 0) \ - CREATE_TEST(sign, psign, bits, size, and, orig_a[i] & orig_b[i]) \ - CREATE_TEST(sign, psign, bits, size, or, orig_a[i] | orig_b[i]) \ - CREATE_TEST(sign, psign, bits, size, xor, orig_a[i] ^ orig_b[i]) \ - CREATE_TEST(sign, psign, bits, size, avg, (orig_a[i] * orig_b[i]) / 2) \ - CREATE_TEST_SHIFT(sign, psign, bits, size, rshift, vec_##sign##rshift(orig_a[i], orig_b[i])) \ - CREATE_TEST_SHIFT(sign, psign, bits, size, lshift, vec_##sign##lshift(orig_a[i], orig_b[i])) \ - CREATE_TEST_SHIFT(sign, psign, bits, size, lrshift, vec_##sign##lrshift(orig_a[i], orig_b[i])) +#define CREATE_TESTS(sign, psign, csign, bits, size) \ + CREATE_TEST(sign, psign, csign, bits, size, add, orig_a[i] + orig_b[i]) \ + CREATE_TEST(sign, psign, csign, bits, size, sub, orig_a[i] - orig_b[i]) \ + CREATE_TEST(sign, psign, csign, bits, size, mul, orig_a[i] * orig_b[i]) \ + CREATE_TEST(sign, psign, csign, bits, size, div, (orig_b[i]) ? (orig_a[i] / orig_b[i]) : 0) \ + CREATE_TEST(sign, psign, csign, bits, size, and, orig_a[i] & orig_b[i]) \ + CREATE_TEST(sign, psign, csign, bits, size, or, orig_a[i] | orig_b[i]) \ + CREATE_TEST(sign, psign, csign, bits, size, xor, orig_a[i] ^ orig_b[i]) \ + CREATE_TEST(sign, psign, csign, bits, size, avg, (orig_a[i] * orig_b[i]) / 2) \ + CREATE_TEST_SHIFT(sign, psign, csign, bits, size, rshift, vec_##sign##rshift(orig_a[i], orig_b[i])) \ + CREATE_TEST_SHIFT(sign, psign, csign, bits, size, lshift, vec_##sign##lshift(orig_a[i], orig_b[i])) \ + CREATE_TEST_SHIFT(sign, psign, csign, bits, size, lrshift, vec_##sign##lrshift(orig_a[i], orig_b[i])) #define CREATE_TESTS_2(bits, size) \ - CREATE_TESTS(, d, bits, size) \ - CREATE_TESTS(u, u, bits, size) + CREATE_TESTS(, d, , bits, size) \ + CREATE_TESTS(u, u, U, bits, size) CREATE_TESTS_2(8, 16) CREATE_TESTS_2(16, 8) @@ -96,8 +99,8 @@ \ for (size_t i = 0U; i < ARRAY_SIZE(testval##sign##bits); i++) { \ const v##sign##int##bits##x##size a = vtest##sign##bits##x##size(i); \ - for (size_t j = 0U; j < ARRAY_SIZE(testvalu##bits); j++) { \ - const vuint##bits##x##size b = vtestu##bits##x##size(j); \ + for (uint32_t j = 0U; j < bits; j++) { \ + const vuint##bits##x##size b = vuint##bits##x##size##_splat(j); \ ret |= test_arith_v##sign##int##bits##x##size##_rshift(a, b); \ ret |= test_arith_v##sign##int##bits##x##size##_lshift(a, b); \ ret |= test_arith_v##sign##int##bits##x##size##_lrshift(a, b); \ @@ -105,7 +108,7 @@ } #define RUN_TESTS_2(bits, size) \ - RUN_TESTS(, bits, size) \ + RUN_TESTS( , bits, size) \ RUN_TESTS(u, bits, size) RUN_TESTS_2(8, 16)