Mercurial > vec
annotate test/test_align.h @ 15:e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
ALSO!! now intrinsics are enabled at runtime, depending on what is
detected. altivec *should* still work but I only tested compiling
it.
the major version has been updated to 2.0 for this...
author | Paper <paper@tflc.us> |
---|---|
date | Wed, 20 Nov 2024 04:10:37 -0500 |
parents | 53197dbf4e8e |
children | 41dd962abdd1 |
rev | line source |
---|---|
3 | 1 static int test_align(void) |
2 { | |
3 int ret = 0; | |
4 | |
5 #define RUN_TEST(sign, csign, bits, size) \ | |
6 do { \ | |
7 /* allocate the aligned array */ \ | |
8 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(vec_arr); \ | |
9 \ | |
10 /* fill the values */ \ | |
13
53197dbf4e8e
vec.h: initial refactor for runtime SSE and stuff
Paper <paper@tflc.us>
parents:
9
diff
changeset
|
11 for (int i = 0; i < size; i++) \ |
3 | 12 vec_arr[i] = i; \ |
13 \ | |
14 /* try to load it */ \ | |
15 v##sign##int##bits##x##size vec = v##sign##int##bits##x##size##_load_aligned(vec_arr); \ | |
16 \ | |
17 /* now allocate an output array */ \ | |
18 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(vec_arr_out); \ | |
19 \ | |
20 /* try storing it */ \ | |
21 v##sign##int##bits##x##size##_store_aligned(vec, vec_arr_out); \ | |
22 \ | |
23 /* mark success or failure */ \ | |
13
53197dbf4e8e
vec.h: initial refactor for runtime SSE and stuff
Paper <paper@tflc.us>
parents:
9
diff
changeset
|
24 ret |= !!memcmp(vec_arr, vec_arr_out, size * sizeof(*vec_arr)); \ |
4
75ab77f874e2
*: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents:
3
diff
changeset
|
25 \ |
75ab77f874e2
*: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents:
3
diff
changeset
|
26 ret |= !V##csign##INT##bits##x##size##_PTR_ALIGNED(vec_arr); \ |
75ab77f874e2
*: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents:
3
diff
changeset
|
27 ret |= !V##csign##INT##bits##x##size##_PTR_ALIGNED(vec_arr_out); \ |
3 | 28 } while (0); |
29 | |
30 #define RUN_TESTS(bits, size) \ | |
31 RUN_TEST( , , bits, size) \ | |
32 RUN_TEST(u, U, bits, size) | |
33 | |
15
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
34 RUN_TESTS(8, 8) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
35 RUN_TESTS(16, 4) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
36 RUN_TESTS(32, 2) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
37 |
3 | 38 RUN_TESTS(8, 16) |
15
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
39 RUN_TESTS(16, 8) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
40 RUN_TESTS(32, 4) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
41 RUN_TESTS(64, 2) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
42 |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
43 RUN_TESTS(8, 32) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
44 RUN_TESTS(16, 16) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
45 RUN_TESTS(32, 8) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
46 RUN_TESTS(64, 4) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
47 |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
48 RUN_TESTS(8, 64) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
49 RUN_TESTS(16, 32) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
50 RUN_TESTS(32, 16) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
13
diff
changeset
|
51 RUN_TESTS(64, 8) |
9
6ff0b7a44bb6
generic: add initial support for 256-bit and 512-bit types
Paper <paper@tflc.us>
parents:
4
diff
changeset
|
52 |
3 | 53 #undef RUN_TESTS |
54 #undef RUN_TEST | |
55 | |
56 return ret; | |
57 } |