Mercurial > vec
comparison test/test_arith.h @ 7:945d410803f8
*: fix clang & gcc warnings, add avg test, etc
author | Paper <paper@tflc.us> |
---|---|
date | Wed, 23 Oct 2024 20:07:08 -0400 |
parents | 75ab77f874e2 |
children | d1d5d767004c |
comparison
equal
deleted
inserted
replaced
6:978c167dcceb | 7:945d410803f8 |
---|---|
38 vuint##bits##x##size##_store_aligned(b, orig_b); \ | 38 vuint##bits##x##size##_store_aligned(b, orig_b); \ |
39 v##sign##int##bits##x##size##_store_aligned(c, orig_c); \ | 39 v##sign##int##bits##x##size##_store_aligned(c, orig_c); \ |
40 \ | 40 \ |
41 for (int i = 0; i < size; i++) { \ | 41 for (int i = 0; i < size; i++) { \ |
42 if ((sign##int##bits##_t)(equiv) != orig_c[i]) { \ | 42 if ((sign##int##bits##_t)(equiv) != orig_c[i]) { \ |
43 fprintf(stderr, "v" #sign "int" #bits "x" #size "_" #op " test FAILED at index %d: (" #equiv ") [%" PRI ## psign ## bits "] does not equal result [%" PRI ## psign ## bits "]!\n", i, equiv, orig_c[i]); \ | 43 fprintf(stderr, "v" #sign "int" #bits "x" #size "_" #op " test FAILED at index %d: (" #equiv ") [%" PRI ## psign ## bits "] does not equal result [%" PRI ## psign ## bits "]!\n", i, (sign##int##bits##_t)(equiv), orig_c[i]); \ |
44 print_v##sign##int##bits##x##size(stderr,a); \ | 44 print_v##sign##int##bits##x##size(stderr,a); \ |
45 print_vuint##bits##x##size(stderr,b); \ | 45 print_vuint##bits##x##size(stderr,b); \ |
46 print_v##sign##int##bits##x##size(stderr,c); \ | 46 print_v##sign##int##bits##x##size(stderr,c); \ |
47 fprintf(stderr, "\n"); \ | 47 fprintf(stderr, "\n"); \ |
48 return 1; \ | 48 return 1; \ |
58 CREATE_TEST(sign, psign, csign, bits, size, mul, orig_a[i] * orig_b[i]) \ | 58 CREATE_TEST(sign, psign, csign, bits, size, mul, orig_a[i] * orig_b[i]) \ |
59 CREATE_TEST(sign, psign, csign, bits, size, div, (orig_b[i]) ? (orig_a[i] / orig_b[i]) : 0) \ | 59 CREATE_TEST(sign, psign, csign, bits, size, div, (orig_b[i]) ? (orig_a[i] / orig_b[i]) : 0) \ |
60 CREATE_TEST(sign, psign, csign, bits, size, and, orig_a[i] & orig_b[i]) \ | 60 CREATE_TEST(sign, psign, csign, bits, size, and, orig_a[i] & orig_b[i]) \ |
61 CREATE_TEST(sign, psign, csign, bits, size, or, orig_a[i] | orig_b[i]) \ | 61 CREATE_TEST(sign, psign, csign, bits, size, or, orig_a[i] | orig_b[i]) \ |
62 CREATE_TEST(sign, psign, csign, bits, size, xor, orig_a[i] ^ orig_b[i]) \ | 62 CREATE_TEST(sign, psign, csign, bits, size, xor, orig_a[i] ^ orig_b[i]) \ |
63 CREATE_TEST(sign, psign, csign, bits, size, avg, (orig_a[i] * orig_b[i]) / 2) \ | 63 CREATE_TEST(sign, psign, csign, bits, size, avg, (sign##int##bits##_t)(orig_a[i] + orig_b[i]) / 2) \ |
64 CREATE_TEST_SHIFT(sign, psign, csign, bits, size, rshift, vec_##sign##rshift(orig_a[i], orig_b[i])) \ | 64 CREATE_TEST_SHIFT(sign, psign, csign, bits, size, rshift, vec_##sign##rshift(orig_a[i], orig_b[i])) \ |
65 CREATE_TEST_SHIFT(sign, psign, csign, bits, size, lshift, vec_##sign##lshift(orig_a[i], orig_b[i])) \ | 65 CREATE_TEST_SHIFT(sign, psign, csign, bits, size, lshift, vec_##sign##lshift(orig_a[i], orig_b[i])) \ |
66 CREATE_TEST_SHIFT(sign, psign, csign, bits, size, lrshift, vec_##sign##lrshift(orig_a[i], orig_b[i])) | 66 CREATE_TEST_SHIFT(sign, psign, csign, bits, size, lrshift, vec_##sign##lrshift(orig_a[i], orig_b[i])) |
67 | 67 |
68 #define CREATE_TESTS_2(bits, size) \ | 68 #define CREATE_TESTS_2(bits, size) \ |
92 ret |= test_arith_v##sign##int##bits##x##size##_mul(a, b); \ | 92 ret |= test_arith_v##sign##int##bits##x##size##_mul(a, b); \ |
93 ret |= test_arith_v##sign##int##bits##x##size##_div(a, b); \ | 93 ret |= test_arith_v##sign##int##bits##x##size##_div(a, b); \ |
94 ret |= test_arith_v##sign##int##bits##x##size##_and(a, b); \ | 94 ret |= test_arith_v##sign##int##bits##x##size##_and(a, b); \ |
95 ret |= test_arith_v##sign##int##bits##x##size##_or(a, b); \ | 95 ret |= test_arith_v##sign##int##bits##x##size##_or(a, b); \ |
96 ret |= test_arith_v##sign##int##bits##x##size##_xor(a, b); \ | 96 ret |= test_arith_v##sign##int##bits##x##size##_xor(a, b); \ |
97 ret |= test_arith_v##sign##int##bits##x##size##_avg(a, b); \ | |
97 } \ | 98 } \ |
98 } \ | 99 } \ |
99 \ | 100 \ |
100 for (size_t i = 0U; i < ARRAY_SIZE(testval##sign##bits); i++) { \ | 101 for (size_t i = 0U; i < ARRAY_SIZE(testval##sign##bits); i++) { \ |
101 const v##sign##int##bits##x##size a = vtest##sign##bits##x##size(i); \ | 102 const v##sign##int##bits##x##size a = vtest##sign##bits##x##size(i); \ |