1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <sys/time.h>
25#include <stdint.h>
26
27#include "../../../../include/wrappers_msa.h"
28#include "../../../../include/test_inputs_128.h"
29#include "../../../../include/test_utils_128.h"
30
31#define TEST_COUNT_TOTAL ( \
32 (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \
33 3 * (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT))
34
35
36int32_t main(void)
37{
38 char *isa_ase_name = "MSA";
39 char *group_name = "Fixed Multiply";
40 char *instruction_name = "MADD_Q.W";
41 int32_t ret;
42 uint32_t i, j;
43 struct timeval start, end;
44 double elapsed_time;
45
46 uint64_t b128_result[TEST_COUNT_TOTAL][2];
47 uint64_t b128_expect[TEST_COUNT_TOTAL][2] = {
48 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
49 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
50 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
51 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
52 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
53 { 0xfffffffefffffffeULL, 0xfffffffefffffffeULL, },
54 { 0xfffffffefffffffeULL, 0xfffffffdfffffffeULL, },
55 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
56 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
57 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
58 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
59 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
60 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
61 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
62 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
63 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
64 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
65 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, },
66 { 0x38e38e3638e38e36ULL, 0x38e38e3638e38e36ULL, },
67 { 0xfffffffcfffffffcULL, 0xfffffffcfffffffcULL, },
68 { 0x2222221e2222221eULL, 0x2222221e2222221eULL, },
69 { 0xfffffffbfffffffbULL, 0xfffffffbfffffffbULL, },
70 { 0x12f684b94bda12f2ULL, 0xda12f68012f684b9ULL, },
71 { 0xfffffffbfffffffbULL, 0xfffffffbfffffffbULL, },
72 { 0xfffffffafffffffaULL, 0xfffffffafffffffaULL, },
73 { 0xfffffffafffffffaULL, 0xfffffffafffffffaULL, },
74 { 0xc71c71c0c71c71c0ULL, 0xc71c71c0c71c71c0ULL, },
75 { 0xfffffff8fffffff8ULL, 0xfffffff8fffffff8ULL, },
76 { 0xddddddd5ddddddd5ULL, 0xddddddd5ddddddd5ULL, },
77 { 0xfffffff6fffffff6ULL, 0xfffffff6fffffff6ULL, },
78 { 0xed097b38b425ecffULL, 0x25ed0970ed097b38ULL, },
79 { 0xfffffff5fffffff4ULL, 0xfffffff4fffffff5ULL, },
80 { 0xfffffff5fffffff4ULL, 0xfffffff4fffffff5ULL, },
81 { 0xfffffff5fffffff4ULL, 0xfffffff4fffffff5ULL, },
82 { 0x2222221722222216ULL, 0x2222221622222217ULL, },
83 { 0xfffffff4fffffff3ULL, 0xfffffff3fffffff4ULL, },
84 { 0x147ae13c147ae13bULL, 0x147ae13b147ae13cULL, },
85 { 0xfffffff4fffffff3ULL, 0xfffffff3fffffff4ULL, },
86 { 0x0b60b5ff2d82d821ULL, 0xe93e93dc0b60b5ffULL, },
87 { 0xfffffff3fffffff3ULL, 0xfffffff3fffffff3ULL, },
88 { 0xfffffff2fffffff2ULL, 0xfffffff2fffffff2ULL, },
89 { 0xfffffff2fffffff2ULL, 0xfffffff2fffffff2ULL, },
90 { 0xddddddcfddddddcfULL, 0xddddddcfddddddcfULL, },
91 { 0xfffffff0fffffff0ULL, 0xfffffff0fffffff0ULL, },
92 { 0xeb851ea8eb851ea8ULL, 0xeb851ea8eb851ea8ULL, },
93 { 0xffffffefffffffefULL, 0xffffffefffffffefULL, },
94 { 0xf49f49e3d27d27c1ULL, 0x16c16c05f49f49e3ULL, },
95 { 0xffffffeeffffffeeULL, 0xffffffeeffffffeeULL, },
96 { 0xffffffeeffffffeeULL, 0xffffffedffffffeeULL, },
97 { 0xffffffeeffffffeeULL, 0xffffffedffffffeeULL, },
98 { 0x12f684ac4bda12e5ULL, 0xda12f67212f684acULL, },
99 { 0xffffffeeffffffeeULL, 0xffffffecffffffeeULL, },
100 { 0x0b60b5f92d82d81cULL, 0xe93e93d50b60b5f9ULL, },
101 { 0xffffffedffffffeeULL, 0xffffffebffffffedULL, },
102 { 0x06522c2c6522c3e1ULL, 0x1948b0e706522c2cULL, },
103 { 0xffffffecffffffeeULL, 0xffffffeaffffffecULL, },
104 { 0xffffffebffffffedULL, 0xffffffeaffffffebULL, },
105 { 0xffffffebffffffedULL, 0xffffffeaffffffebULL, },
106 { 0xed097b2db425ecf6ULL, 0x25ed0965ed097b2dULL, },
107 { 0xffffffeaffffffebULL, 0xffffffe9ffffffeaULL, },
108 { 0xf49f49ded27d27bdULL, 0x16c16c00f49f49deULL, },
109 { 0xffffffe9ffffffeaULL, 0xffffffe9ffffffe9ULL, },
110 { 0xf9add3a99add3bf7ULL, 0xe6b74eecf9add3a9ULL, },
111 { 0xffffffe8ffffffe8ULL, 0xffffffe8ffffffe8ULL, },
112 { 0x6fb7e8710cbdc0baULL, 0x2c6b142e000499ecULL, },
113 { 0x73b239bf253787bbULL, 0x379780d7ffc424b2ULL, },
114 { 0x7fffffff0f12777aULL, 0x4f10996a00c57ee6ULL, },
115 { 0x1713a7162cca6b1fULL, 0x0be04dd301cca255ULL, },
116 { 0x1b0df86445443220ULL, 0x170cba7c018c2d1bULL, },
117 { 0x1b323a657448a831ULL, 0x19dc4690051313a9ULL, },
118 { 0x1dfa85ec49be7952ULL, 0x1fc3e11af6fe2ffbULL, },
119 { 0x1a3e24c87fffffffULL, 0x0edd19b6e8983fd8ULL, },
120 { 0x6863454e69daefbeULL, 0x26563249e9999a0cULL, },
121 { 0x6b2b90d53f50c0dfULL, 0x2c3dccd3db84b65eULL, },
122 { 0x7fffffff65cdd2a2ULL, 0x38a5553713bd77aaULL, },
123 { 0x369baa383226e26fULL, 0x1523c32e4d39d083ULL, },
124 { 0xcdaf514f4fded614ULL, 0xd1f377974e40f3f2ULL, },
125 { 0xc9f2f02b7fffffffULL, 0xc10cb0333fdb03cfULL, },
126 { 0x808e9a644c590fccULL, 0x9d8b1e2a79575ca8ULL, },
127 { 0xe31932487fffffffULL, 0x032ce40b7fffffffULL, },
128 { 0xfe196fe57fffffffULL, 0x050bc0117e7bb00bULL, },
129 { 0xfe299f467fffffffULL, 0x05cb2b207fffffffULL, },
130 { 0xff5d018239cf8b7fULL, 0x0798e21e2b2b2513ULL, },
131 { 0xfecdfe1e645a7d99ULL, 0x00d3dcf00dea608dULL, },
132 { 0xffebe0507fffffffULL, 0x0150aaf30dc02967ULL, },
133 { 0xffec8bad7fffffffULL, 0x01828e9310087db0ULL, },
134 { 0xfff9423b39cf8b7fULL, 0x01fae4ad056841b8ULL, },
135 { 0xfff35804645a7d99ULL, 0x003737ba01be3861ULL, },
136 { 0xffff2aee7fffffffULL, 0x0057bed401b8eeafULL, },
137 { 0xffff32047fffffffULL, 0x0064bf7c02021ffbULL, },
138 { 0xffffb89f39cf8b7fULL, 0x00841c7300ad6409ULL, },
139 { 0xffff79fe645a7d99ULL, 0x000e642e0037e4a5ULL, },
140 { 0xfffff72f7fffffffULL, 0x0016de7600373b15ULL, },
141 { 0xfffff77a7fffffffULL, 0x001a420100406619ULL, },
142 { 0xfffffd0b39cf8b7fULL, 0x00226e950015b801ULL, },
143 { 0xfffffa72645a7d99ULL, 0x0003c03400070049ULL, },
144 { 0xffffffa27fffffffULL, 0x0005f5d70006eb0bULL, },
145 { 0xfffffff97fffffffULL, 0x000978af0006d60eULL, },
146 { 0xffffffff7fffffffULL, 0x000f0d050006c150ULL, },
147 { 0xffffffff7fffffffULL, 0x0017eac30006acd1ULL, },
148 { 0xffffffff7fffffffULL, 0x001b76100007c878ULL, },
149 { 0xffffffff7fffffffULL, 0x001f87d000091335ULL, },
150 { 0xffffffff7fffffffULL, 0x002433ef000a94d9ULL, },
151 { 0xffffffff7fffffffULL, 0x0029914d000c5680ULL, },
152 { 0xffffffff39cf8b7fULL, 0x003681f800042937ULL, },
153 { 0xffffffff1a1c28c3ULL, 0x004779e10001673fULL, },
154 { 0xffffffff0bcae025ULL, 0x005dba1000007928ULL, },
155 { 0xffffffff055376c1ULL, 0x007ae77c000028dcULL, },
156 { 0xfffffffe093ed554ULL, 0x000d636d00000d2bULL, },
157 { 0xfffffffc100c9463ULL, 0x0001755c0000043eULL, },
158 { 0xfffffff81bdc128cULL, 0x000028ab0000015eULL, },
159 { 0xfffffff0305c8babULL, 0x0000046e00000070ULL, },
160};
161
162 reset_msa_registers();
163
164 gettimeofday(&start, NULL);
165
166 for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) {
167 for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) {
168 do_msa_MADD_Q_W(b128_pattern[i], b128_pattern[j],
169 b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]);
170 }
171 }
172
173 for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) {
174 for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) {
175 do_msa_MADD_Q_W(b128_random[i], b128_random[j],
176 b128_result[((PATTERN_INPUTS_SHORT_COUNT) *
177 (PATTERN_INPUTS_SHORT_COUNT)) +
178 RANDOM_INPUTS_SHORT_COUNT * i + j]);
179 }
180 }
181
182 for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) {
183 for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) {
184 do_msa_MADD_Q_W__DDT(b128_random[i], b128_random[j],
185 b128_result[
186 ((PATTERN_INPUTS_SHORT_COUNT) *
187 (PATTERN_INPUTS_SHORT_COUNT)) +
188 ((RANDOM_INPUTS_SHORT_COUNT) *
189 (RANDOM_INPUTS_SHORT_COUNT)) +
190 RANDOM_INPUTS_SHORT_COUNT * i + j]);
191 }
192 }
193
194 for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) {
195 for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) {
196 do_msa_MADD_Q_W__DSD(b128_random[i], b128_random[j],
197 b128_result[
198 ((PATTERN_INPUTS_SHORT_COUNT) *
199 (PATTERN_INPUTS_SHORT_COUNT)) +
200 (2 * (RANDOM_INPUTS_SHORT_COUNT) *
201 (RANDOM_INPUTS_SHORT_COUNT)) +
202 RANDOM_INPUTS_SHORT_COUNT * i + j]);
203 }
204 }
205
206 gettimeofday(&end, NULL);
207
208 elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
209 elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
210
211 ret = check_results_128(isa_ase_name, group_name, instruction_name,
212 TEST_COUNT_TOTAL, elapsed_time,
213 &b128_result[0][0], &b128_expect[0][0]);
214
215 return ret;
216}
217