| 1 |
#include <arm_neon.h> |
| 2 |
#include "arm-neon-ref.h" |
| 3 |
#include "compute-ref-data.h" |
| 4 |
|
| 5 |
/* Expected results. */ |
| 6 |
VECT_VAR_DECL(expected,int,16,4) [] = { 0xffc0, 0xffc4, 0xffc8, 0xffcc }; |
| 7 |
VECT_VAR_DECL(expected,int,32,2) [] = { 0xfffffde0, 0xfffffe02 }; |
| 8 |
VECT_VAR_DECL(expected,uint,16,4) [] = { 0xbbc0, 0xc004, 0xc448, 0xc88c }; |
| 9 |
VECT_VAR_DECL(expected,uint,32,2) [] = { 0xfffface0, 0xffffb212 }; |
| 10 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 11 |
VECT_VAR_DECL(expected, hfloat, 16, 4) [] = { 0xddb3, 0xdd58, 0xdcfd, 0xdca1 }; |
| 12 |
#endif |
| 13 |
VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0xc3b66666, 0xc3ab0000 }; |
| 14 |
VECT_VAR_DECL(expected,int,16,8) [] = { 0xffc0, 0xffc4, 0xffc8, 0xffcc, |
| 15 |
0xffd0, 0xffd4, 0xffd8, 0xffdc }; |
| 16 |
VECT_VAR_DECL(expected,int,32,4) [] = { 0xfffffde0, 0xfffffe02, |
| 17 |
0xfffffe24, 0xfffffe46 }; |
| 18 |
VECT_VAR_DECL(expected,uint,16,8) [] = { 0xbbc0, 0xc004, 0xc448, 0xc88c, |
| 19 |
0xccd0, 0xd114, 0xd558, 0xd99c }; |
| 20 |
VECT_VAR_DECL(expected,uint,32,4) [] = { 0xfffface0, 0xffffb212, |
| 21 |
0xffffb744, 0xffffbc76 }; |
| 22 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 23 |
VECT_VAR_DECL(expected, hfloat, 16, 8) [] = { 0xddb3, 0xdd58, 0xdcfd, 0xdca1, |
| 24 |
0xdc46, 0xdbd6, 0xdb20, 0xda69 }; |
| 25 |
#endif |
| 26 |
VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0xc3b66666, 0xc3ab0000, |
| 27 |
0xc39f9999, 0xc3943333 }; |
| 28 |
|
| 29 |
#define TEST_MSG "VMUL_LANE" |
| 30 |
void exec_vmul_lane (void) |
| 31 |
{ |
| 32 |
#define DECL_VMUL(VAR) \ |
| 33 |
DECL_VARIABLE(VAR, int, 16, 4); \ |
| 34 |
DECL_VARIABLE(VAR, int, 32, 2); \ |
| 35 |
DECL_VARIABLE(VAR, uint, 16, 4); \ |
| 36 |
DECL_VARIABLE(VAR, uint, 32, 2); \ |
| 37 |
DECL_VARIABLE(VAR, float, 32, 2); \ |
| 38 |
DECL_VARIABLE(VAR, int, 16, 8); \ |
| 39 |
DECL_VARIABLE(VAR, int, 32, 4); \ |
| 40 |
DECL_VARIABLE(VAR, uint, 16, 8); \ |
| 41 |
DECL_VARIABLE(VAR, uint, 32, 4); \ |
| 42 |
DECL_VARIABLE(VAR, float, 32, 4) |
| 43 |
|
| 44 |
/* vector_res = vmul_lane(vector,vector2,lane), then store the result. */ |
| 45 |
#define TEST_VMUL_LANE(Q, T1, T2, W, N, N2, L) \ |
| 46 |
VECT_VAR(vector_res, T1, W, N) = \ |
| 47 |
vmul##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N), \ |
| 48 |
VECT_VAR(vector2, T1, W, N2), \ |
| 49 |
L); \ |
| 50 |
vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \ |
| 51 |
VECT_VAR(vector_res, T1, W, N)) |
| 52 |
|
| 53 |
DECL_VMUL(vector); |
| 54 |
DECL_VMUL(vector_res); |
| 55 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 56 |
DECL_VARIABLE(vector, float, 16, 4); |
| 57 |
DECL_VARIABLE(vector, float, 16, 8); |
| 58 |
DECL_VARIABLE(vector_res, float, 16, 4); |
| 59 |
DECL_VARIABLE(vector_res, float, 16, 8); |
| 60 |
#endif |
| 61 |
|
| 62 |
DECL_VARIABLE(vector2, int, 16, 4); |
| 63 |
DECL_VARIABLE(vector2, int, 32, 2); |
| 64 |
DECL_VARIABLE(vector2, uint, 16, 4); |
| 65 |
DECL_VARIABLE(vector2, uint, 32, 2); |
| 66 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 67 |
DECL_VARIABLE(vector2, float, 16, 4); |
| 68 |
#endif |
| 69 |
DECL_VARIABLE(vector2, float, 32, 2); |
| 70 |
|
| 71 |
clean_results (); |
| 72 |
|
| 73 |
/* Initialize vector from pre-initialized values. */ |
| 74 |
VLOAD(vector, buffer, , int, s, 16, 4); |
| 75 |
VLOAD(vector, buffer, , int, s, 32, 2); |
| 76 |
VLOAD(vector, buffer, , uint, u, 16, 4); |
| 77 |
VLOAD(vector, buffer, , uint, u, 32, 2); |
| 78 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 79 |
VLOAD(vector, buffer, , float, f, 16, 4); |
| 80 |
#endif |
| 81 |
VLOAD(vector, buffer, , float, f, 32, 2); |
| 82 |
VLOAD(vector, buffer, q, int, s, 16, 8); |
| 83 |
VLOAD(vector, buffer, q, int, s, 32, 4); |
| 84 |
VLOAD(vector, buffer, q, uint, u, 16, 8); |
| 85 |
VLOAD(vector, buffer, q, uint, u, 32, 4); |
| 86 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 87 |
VLOAD(vector, buffer, q, float, f, 16, 8); |
| 88 |
#endif |
| 89 |
VLOAD(vector, buffer, q, float, f, 32, 4); |
| 90 |
|
| 91 |
/* Initialize vector2. */ |
| 92 |
VDUP(vector2, , int, s, 16, 4, 0x4); |
| 93 |
VDUP(vector2, , int, s, 32, 2, 0x22); |
| 94 |
VDUP(vector2, , uint, u, 16, 4, 0x444); |
| 95 |
VDUP(vector2, , uint, u, 32, 2, 0x532); |
| 96 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 97 |
VDUP(vector2, , float, f, 16, 4, 22.8f); |
| 98 |
#endif |
| 99 |
VDUP(vector2, , float, f, 32, 2, 22.8f); |
| 100 |
|
| 101 |
/* Choose lane arbitrarily. */ |
| 102 |
TEST_VMUL_LANE(, int, s, 16, 4, 4, 2); |
| 103 |
TEST_VMUL_LANE(, int, s, 32, 2, 2, 1); |
| 104 |
TEST_VMUL_LANE(, uint, u, 16, 4, 4, 2); |
| 105 |
TEST_VMUL_LANE(, uint, u, 32, 2, 2, 1); |
| 106 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 107 |
TEST_VMUL_LANE(, float, f, 16, 4, 4, 1); |
| 108 |
#endif |
| 109 |
TEST_VMUL_LANE(, float, f, 32, 2, 2, 1); |
| 110 |
TEST_VMUL_LANE(q, int, s, 16, 8, 4, 2); |
| 111 |
TEST_VMUL_LANE(q, int, s, 32, 4, 2, 0); |
| 112 |
TEST_VMUL_LANE(q, uint, u, 16, 8, 4, 2); |
| 113 |
TEST_VMUL_LANE(q, uint, u, 32, 4, 2, 1); |
| 114 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 115 |
TEST_VMUL_LANE(q, float, f, 16, 8, 4, 0); |
| 116 |
#endif |
| 117 |
TEST_VMUL_LANE(q, float, f, 32, 4, 2, 0); |
| 118 |
|
| 119 |
CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, ""); |
| 120 |
CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, ""); |
| 121 |
CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected, ""); |
| 122 |
CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, ""); |
| 123 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 124 |
CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected, ""); |
| 125 |
#endif |
| 126 |
CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected, ""); |
| 127 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, ""); |
| 128 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, ""); |
| 129 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, ""); |
| 130 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, ""); |
| 131 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 132 |
CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected, ""); |
| 133 |
#endif |
| 134 |
CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected, ""); |
| 135 |
} |
| 136 |
|
| 137 |
int main (void) |
| 138 |
{ |
| 139 |
exec_vmul_lane (); |
| 140 |
return 0; |
| 141 |
} |