Mercurial > hg > graal-compiler
comparison test/compiler/6340864/TestIntVect.java @ 6614:006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
Summary: Added asm encoding and mach nodes for vector arithmetic instructions on x86.
Reviewed-by: roland
author | kvn |
---|---|
date | Mon, 20 Aug 2012 09:07:21 -0700 |
parents | |
children | b2c669fd8114 |
comparison
equal
deleted
inserted
replaced
6594:d5ec46c7da5c | 6614:006050192a5a |
---|---|
1 /* | |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 /** | |
26 * @test | |
27 * @bug 6340864 | |
28 * @summary Implement vectorization optimizations in hotspot-server | |
29 * | |
30 * @run main/othervm/timeout=400 -Xbatch -Xmx64m TestIntVect | |
31 */ | |
32 | |
33 public class TestIntVect { | |
34 private static final int ARRLEN = 997; | |
35 private static final int ITERS = 11000; | |
36 private static final int ADD_INIT = Integer.MAX_VALUE-500; | |
37 private static final int BIT_MASK = 0xEC80F731; | |
38 private static final int VALUE = 15; | |
39 private static final int SHIFT = 32; | |
40 | |
41 public static void main(String args[]) { | |
42 System.out.println("Testing Integer vectors"); | |
43 int errn = test(); | |
44 if (errn > 0) { | |
45 System.err.println("FAILED: " + errn + " errors"); | |
46 System.exit(97); | |
47 } | |
48 System.out.println("PASSED"); | |
49 } | |
50 | |
51 static int test() { | |
52 int[] a0 = new int[ARRLEN]; | |
53 int[] a1 = new int[ARRLEN]; | |
54 int[] a2 = new int[ARRLEN]; | |
55 int[] a3 = new int[ARRLEN]; | |
56 int[] a4 = new int[ARRLEN]; | |
57 long[] p2 = new long[ARRLEN/2]; | |
58 // Initialize | |
59 int gold_sum = 0; | |
60 for (int i=0; i<ARRLEN; i++) { | |
61 int val = (int)(ADD_INIT+i); | |
62 gold_sum += val; | |
63 a1[i] = val; | |
64 a2[i] = (int)VALUE; | |
65 a3[i] = (int)-VALUE; | |
66 a4[i] = (int)BIT_MASK; | |
67 } | |
68 System.out.println("Warmup"); | |
69 for (int i=0; i<ITERS; i++) { | |
70 test_sum(a1); | |
71 test_addc(a0, a1); | |
72 test_addv(a0, a1, (int)VALUE); | |
73 test_adda(a0, a1, a2); | |
74 test_subc(a0, a1); | |
75 test_subv(a0, a1, (int)VALUE); | |
76 test_suba(a0, a1, a2); | |
77 test_mulc(a0, a1); | |
78 test_mulv(a0, a1, (int)VALUE); | |
79 test_mula(a0, a1, a2); | |
80 test_divc(a0, a1); | |
81 test_divv(a0, a1, (int)VALUE); | |
82 test_diva(a0, a1, a2); | |
83 test_mulc_n(a0, a1); | |
84 test_mulv(a0, a1, (int)-VALUE); | |
85 test_mula(a0, a1, a3); | |
86 test_divc_n(a0, a1); | |
87 test_divv(a0, a1, (int)-VALUE); | |
88 test_diva(a0, a1, a3); | |
89 test_andc(a0, a1); | |
90 test_andv(a0, a1, (int)BIT_MASK); | |
91 test_anda(a0, a1, a4); | |
92 test_orc(a0, a1); | |
93 test_orv(a0, a1, (int)BIT_MASK); | |
94 test_ora(a0, a1, a4); | |
95 test_xorc(a0, a1); | |
96 test_xorv(a0, a1, (int)BIT_MASK); | |
97 test_xora(a0, a1, a4); | |
98 test_sllc(a0, a1); | |
99 test_sllv(a0, a1, VALUE); | |
100 test_srlc(a0, a1); | |
101 test_srlv(a0, a1, VALUE); | |
102 test_srac(a0, a1); | |
103 test_srav(a0, a1, VALUE); | |
104 test_sllc_n(a0, a1); | |
105 test_sllv(a0, a1, -VALUE); | |
106 test_srlc_n(a0, a1); | |
107 test_srlv(a0, a1, -VALUE); | |
108 test_srac_n(a0, a1); | |
109 test_srav(a0, a1, -VALUE); | |
110 test_sllc_o(a0, a1); | |
111 test_sllv(a0, a1, SHIFT); | |
112 test_srlc_o(a0, a1); | |
113 test_srlv(a0, a1, SHIFT); | |
114 test_srac_o(a0, a1); | |
115 test_srav(a0, a1, SHIFT); | |
116 test_sllc_on(a0, a1); | |
117 test_sllv(a0, a1, -SHIFT); | |
118 test_srlc_on(a0, a1); | |
119 test_srlv(a0, a1, -SHIFT); | |
120 test_srac_on(a0, a1); | |
121 test_srav(a0, a1, -SHIFT); | |
122 test_pack2(p2, a1); | |
123 test_unpack2(a0, p2); | |
124 test_pack2_swap(p2, a1); | |
125 test_unpack2_swap(a0, p2); | |
126 } | |
127 // Test and verify results | |
128 System.out.println("Verification"); | |
129 int errn = 0; | |
130 { | |
131 int sum = test_sum(a1); | |
132 if (sum != gold_sum) { | |
133 System.err.println("test_sum: " + sum + " != " + gold_sum); | |
134 errn++; | |
135 } | |
136 | |
137 test_addc(a0, a1); | |
138 for (int i=0; i<ARRLEN; i++) { | |
139 errn += verify("test_addc: ", i, a0[i], (int)((int)(ADD_INIT+i)+VALUE)); | |
140 } | |
141 test_addv(a0, a1, (int)VALUE); | |
142 for (int i=0; i<ARRLEN; i++) { | |
143 errn += verify("test_addv: ", i, a0[i], (int)((int)(ADD_INIT+i)+VALUE)); | |
144 } | |
145 test_adda(a0, a1, a2); | |
146 for (int i=0; i<ARRLEN; i++) { | |
147 errn += verify("test_adda: ", i, a0[i], (int)((int)(ADD_INIT+i)+VALUE)); | |
148 } | |
149 | |
150 test_subc(a0, a1); | |
151 for (int i=0; i<ARRLEN; i++) { | |
152 errn += verify("test_subc: ", i, a0[i], (int)((int)(ADD_INIT+i)-VALUE)); | |
153 } | |
154 test_subv(a0, a1, (int)VALUE); | |
155 for (int i=0; i<ARRLEN; i++) { | |
156 errn += verify("test_subv: ", i, a0[i], (int)((int)(ADD_INIT+i)-VALUE)); | |
157 } | |
158 test_suba(a0, a1, a2); | |
159 for (int i=0; i<ARRLEN; i++) { | |
160 errn += verify("test_suba: ", i, a0[i], (int)((int)(ADD_INIT+i)-VALUE)); | |
161 } | |
162 | |
163 test_mulc(a0, a1); | |
164 for (int i=0; i<ARRLEN; i++) { | |
165 errn += verify("test_mulc: ", i, a0[i], (int)((int)(ADD_INIT+i)*VALUE)); | |
166 } | |
167 test_mulv(a0, a1, (int)VALUE); | |
168 for (int i=0; i<ARRLEN; i++) { | |
169 errn += verify("test_mulv: ", i, a0[i], (int)((int)(ADD_INIT+i)*VALUE)); | |
170 } | |
171 test_mula(a0, a1, a2); | |
172 for (int i=0; i<ARRLEN; i++) { | |
173 errn += verify("test_mula: ", i, a0[i], (int)((int)(ADD_INIT+i)*VALUE)); | |
174 } | |
175 | |
176 test_divc(a0, a1); | |
177 for (int i=0; i<ARRLEN; i++) { | |
178 errn += verify("test_divc: ", i, a0[i], (int)((int)(ADD_INIT+i)/VALUE)); | |
179 } | |
180 test_divv(a0, a1, (int)VALUE); | |
181 for (int i=0; i<ARRLEN; i++) { | |
182 errn += verify("test_divv: ", i, a0[i], (int)((int)(ADD_INIT+i)/VALUE)); | |
183 } | |
184 test_diva(a0, a1, a2); | |
185 for (int i=0; i<ARRLEN; i++) { | |
186 errn += verify("test_diva: ", i, a0[i], (int)((int)(ADD_INIT+i)/VALUE)); | |
187 } | |
188 | |
189 test_mulc_n(a0, a1); | |
190 for (int i=0; i<ARRLEN; i++) { | |
191 errn += verify("test_mulc_n: ", i, a0[i], (int)((int)(ADD_INIT+i)*(-VALUE))); | |
192 } | |
193 test_mulv(a0, a1, (int)-VALUE); | |
194 for (int i=0; i<ARRLEN; i++) { | |
195 errn += verify("test_mulv_n: ", i, a0[i], (int)((int)(ADD_INIT+i)*(-VALUE))); | |
196 } | |
197 test_mula(a0, a1, a3); | |
198 for (int i=0; i<ARRLEN; i++) { | |
199 errn += verify("test_mula_n: ", i, a0[i], (int)((int)(ADD_INIT+i)*(-VALUE))); | |
200 } | |
201 | |
202 test_divc_n(a0, a1); | |
203 for (int i=0; i<ARRLEN; i++) { | |
204 errn += verify("test_divc_n: ", i, a0[i], (int)((int)(ADD_INIT+i)/(-VALUE))); | |
205 } | |
206 test_divv(a0, a1, (int)-VALUE); | |
207 for (int i=0; i<ARRLEN; i++) { | |
208 errn += verify("test_divv_n: ", i, a0[i], (int)((int)(ADD_INIT+i)/(-VALUE))); | |
209 } | |
210 test_diva(a0, a1, a3); | |
211 for (int i=0; i<ARRLEN; i++) { | |
212 errn += verify("test_diva_n: ", i, a0[i], (int)((int)(ADD_INIT+i)/(-VALUE))); | |
213 } | |
214 | |
215 test_andc(a0, a1); | |
216 for (int i=0; i<ARRLEN; i++) { | |
217 errn += verify("test_andc: ", i, a0[i], (int)((int)(ADD_INIT+i)&BIT_MASK)); | |
218 } | |
219 test_andv(a0, a1, (int)BIT_MASK); | |
220 for (int i=0; i<ARRLEN; i++) { | |
221 errn += verify("test_andv: ", i, a0[i], (int)((int)(ADD_INIT+i)&BIT_MASK)); | |
222 } | |
223 test_anda(a0, a1, a4); | |
224 for (int i=0; i<ARRLEN; i++) { | |
225 errn += verify("test_anda: ", i, a0[i], (int)((int)(ADD_INIT+i)&BIT_MASK)); | |
226 } | |
227 | |
228 test_orc(a0, a1); | |
229 for (int i=0; i<ARRLEN; i++) { | |
230 errn += verify("test_orc: ", i, a0[i], (int)((int)(ADD_INIT+i)|BIT_MASK)); | |
231 } | |
232 test_orv(a0, a1, (int)BIT_MASK); | |
233 for (int i=0; i<ARRLEN; i++) { | |
234 errn += verify("test_orv: ", i, a0[i], (int)((int)(ADD_INIT+i)|BIT_MASK)); | |
235 } | |
236 test_ora(a0, a1, a4); | |
237 for (int i=0; i<ARRLEN; i++) { | |
238 errn += verify("test_ora: ", i, a0[i], (int)((int)(ADD_INIT+i)|BIT_MASK)); | |
239 } | |
240 | |
241 test_xorc(a0, a1); | |
242 for (int i=0; i<ARRLEN; i++) { | |
243 errn += verify("test_xorc: ", i, a0[i], (int)((int)(ADD_INIT+i)^BIT_MASK)); | |
244 } | |
245 test_xorv(a0, a1, (int)BIT_MASK); | |
246 for (int i=0; i<ARRLEN; i++) { | |
247 errn += verify("test_xorv: ", i, a0[i], (int)((int)(ADD_INIT+i)^BIT_MASK)); | |
248 } | |
249 test_xora(a0, a1, a4); | |
250 for (int i=0; i<ARRLEN; i++) { | |
251 errn += verify("test_xora: ", i, a0[i], (int)((int)(ADD_INIT+i)^BIT_MASK)); | |
252 } | |
253 | |
254 test_sllc(a0, a1); | |
255 for (int i=0; i<ARRLEN; i++) { | |
256 errn += verify("test_sllc: ", i, a0[i], (int)((int)(ADD_INIT+i)<<VALUE)); | |
257 } | |
258 test_sllv(a0, a1, VALUE); | |
259 for (int i=0; i<ARRLEN; i++) { | |
260 errn += verify("test_sllv: ", i, a0[i], (int)((int)(ADD_INIT+i)<<VALUE)); | |
261 } | |
262 | |
263 test_srlc(a0, a1); | |
264 for (int i=0; i<ARRLEN; i++) { | |
265 errn += verify("test_srlc: ", i, a0[i], (int)((int)(ADD_INIT+i)>>>VALUE)); | |
266 } | |
267 test_srlv(a0, a1, VALUE); | |
268 for (int i=0; i<ARRLEN; i++) { | |
269 errn += verify("test_srlv: ", i, a0[i], (int)((int)(ADD_INIT+i)>>>VALUE)); | |
270 } | |
271 | |
272 test_srac(a0, a1); | |
273 for (int i=0; i<ARRLEN; i++) { | |
274 errn += verify("test_srac: ", i, a0[i], (int)((int)(ADD_INIT+i)>>VALUE)); | |
275 } | |
276 test_srav(a0, a1, VALUE); | |
277 for (int i=0; i<ARRLEN; i++) { | |
278 errn += verify("test_srav: ", i, a0[i], (int)((int)(ADD_INIT+i)>>VALUE)); | |
279 } | |
280 | |
281 test_sllc_n(a0, a1); | |
282 for (int i=0; i<ARRLEN; i++) { | |
283 errn += verify("test_sllc_n: ", i, a0[i], (int)((int)(ADD_INIT+i)<<(-VALUE))); | |
284 } | |
285 test_sllv(a0, a1, -VALUE); | |
286 for (int i=0; i<ARRLEN; i++) { | |
287 errn += verify("test_sllv_n: ", i, a0[i], (int)((int)(ADD_INIT+i)<<(-VALUE))); | |
288 } | |
289 | |
290 test_srlc_n(a0, a1); | |
291 for (int i=0; i<ARRLEN; i++) { | |
292 errn += verify("test_srlc_n: ", i, a0[i], (int)((int)(ADD_INIT+i)>>>(-VALUE))); | |
293 } | |
294 test_srlv(a0, a1, -VALUE); | |
295 for (int i=0; i<ARRLEN; i++) { | |
296 errn += verify("test_srlv_n: ", i, a0[i], (int)((int)(ADD_INIT+i)>>>(-VALUE))); | |
297 } | |
298 | |
299 test_srac_n(a0, a1); | |
300 for (int i=0; i<ARRLEN; i++) { | |
301 errn += verify("test_srac_n: ", i, a0[i], (int)((int)(ADD_INIT+i)>>(-VALUE))); | |
302 } | |
303 test_srav(a0, a1, -VALUE); | |
304 for (int i=0; i<ARRLEN; i++) { | |
305 errn += verify("test_srav_n: ", i, a0[i], (int)((int)(ADD_INIT+i)>>(-VALUE))); | |
306 } | |
307 | |
308 test_sllc_o(a0, a1); | |
309 for (int i=0; i<ARRLEN; i++) { | |
310 errn += verify("test_sllc_o: ", i, a0[i], (int)((int)(ADD_INIT+i)<<SHIFT)); | |
311 } | |
312 test_sllv(a0, a1, SHIFT); | |
313 for (int i=0; i<ARRLEN; i++) { | |
314 errn += verify("test_sllv_o: ", i, a0[i], (int)((int)(ADD_INIT+i)<<SHIFT)); | |
315 } | |
316 | |
317 test_srlc_o(a0, a1); | |
318 for (int i=0; i<ARRLEN; i++) { | |
319 errn += verify("test_srlc_o: ", i, a0[i], (int)((int)(ADD_INIT+i)>>>SHIFT)); | |
320 } | |
321 test_srlv(a0, a1, SHIFT); | |
322 for (int i=0; i<ARRLEN; i++) { | |
323 errn += verify("test_srlv_o: ", i, a0[i], (int)((int)(ADD_INIT+i)>>>SHIFT)); | |
324 } | |
325 | |
326 test_srac_o(a0, a1); | |
327 for (int i=0; i<ARRLEN; i++) { | |
328 errn += verify("test_srac_o: ", i, a0[i], (int)((int)(ADD_INIT+i)>>SHIFT)); | |
329 } | |
330 test_srav(a0, a1, SHIFT); | |
331 for (int i=0; i<ARRLEN; i++) { | |
332 errn += verify("test_srav_o: ", i, a0[i], (int)((int)(ADD_INIT+i)>>SHIFT)); | |
333 } | |
334 | |
335 test_sllc_on(a0, a1); | |
336 for (int i=0; i<ARRLEN; i++) { | |
337 errn += verify("test_sllc_on: ", i, a0[i], (int)((int)(ADD_INIT+i)<<(-SHIFT))); | |
338 } | |
339 test_sllv(a0, a1, -SHIFT); | |
340 for (int i=0; i<ARRLEN; i++) { | |
341 errn += verify("test_sllv_on: ", i, a0[i], (int)((int)(ADD_INIT+i)<<(-SHIFT))); | |
342 } | |
343 | |
344 test_srlc_on(a0, a1); | |
345 for (int i=0; i<ARRLEN; i++) { | |
346 errn += verify("test_srlc_on: ", i, a0[i], (int)((int)(ADD_INIT+i)>>>(-SHIFT))); | |
347 } | |
348 test_srlv(a0, a1, -SHIFT); | |
349 for (int i=0; i<ARRLEN; i++) { | |
350 errn += verify("test_srlv_on: ", i, a0[i], (int)((int)(ADD_INIT+i)>>>(-SHIFT))); | |
351 } | |
352 | |
353 test_srac_on(a0, a1); | |
354 for (int i=0; i<ARRLEN; i++) { | |
355 errn += verify("test_srac_on: ", i, a0[i], (int)((int)(ADD_INIT+i)>>(-SHIFT))); | |
356 } | |
357 test_srav(a0, a1, -SHIFT); | |
358 for (int i=0; i<ARRLEN; i++) { | |
359 errn += verify("test_srav_on: ", i, a0[i], (int)((int)(ADD_INIT+i)>>(-SHIFT))); | |
360 } | |
361 | |
362 test_pack2(p2, a1); | |
363 for (int i=0; i<ARRLEN/2; i++) { | |
364 errn += verify("test_pack2: ", i, p2[i], ((long)(ADD_INIT+2*i) & 0xFFFFFFFFl) | ((long)(ADD_INIT+2*i+1) << 32)); | |
365 } | |
366 for (int i=0; i<ARRLEN; i++) { | |
367 a0[i] = -1; | |
368 } | |
369 test_unpack2(a0, p2); | |
370 for (int i=0; i<(ARRLEN&(-2)); i++) { | |
371 errn += verify("test_unpack2: ", i, a0[i], (ADD_INIT+i)); | |
372 } | |
373 | |
374 test_pack2_swap(p2, a1); | |
375 for (int i=0; i<ARRLEN/2; i++) { | |
376 errn += verify("test_pack2_swap: ", i, p2[i], ((long)(ADD_INIT+2*i+1) & 0xFFFFFFFFl) | ((long)(ADD_INIT+2*i) << 32)); | |
377 } | |
378 for (int i=0; i<ARRLEN; i++) { | |
379 a0[i] = -1; | |
380 } | |
381 test_unpack2_swap(a0, p2); | |
382 for (int i=0; i<(ARRLEN&(-2)); i++) { | |
383 errn += verify("test_unpack2_swap: ", i, a0[i], (ADD_INIT+i)); | |
384 } | |
385 | |
386 } | |
387 | |
388 if (errn > 0) | |
389 return errn; | |
390 | |
391 System.out.println("Time"); | |
392 long start, end; | |
393 | |
394 start = System.currentTimeMillis(); | |
395 for (int i=0; i<ITERS; i++) { | |
396 test_sum(a1); | |
397 } | |
398 end = System.currentTimeMillis(); | |
399 System.out.println("test_sum: " + (end - start)); | |
400 | |
401 start = System.currentTimeMillis(); | |
402 for (int i=0; i<ITERS; i++) { | |
403 test_addc(a0, a1); | |
404 } | |
405 end = System.currentTimeMillis(); | |
406 System.out.println("test_addc: " + (end - start)); | |
407 start = System.currentTimeMillis(); | |
408 for (int i=0; i<ITERS; i++) { | |
409 test_addv(a0, a1, (int)VALUE); | |
410 } | |
411 end = System.currentTimeMillis(); | |
412 System.out.println("test_addv: " + (end - start)); | |
413 start = System.currentTimeMillis(); | |
414 for (int i=0; i<ITERS; i++) { | |
415 test_adda(a0, a1, a2); | |
416 } | |
417 end = System.currentTimeMillis(); | |
418 System.out.println("test_adda: " + (end - start)); | |
419 | |
420 start = System.currentTimeMillis(); | |
421 for (int i=0; i<ITERS; i++) { | |
422 test_subc(a0, a1); | |
423 } | |
424 end = System.currentTimeMillis(); | |
425 System.out.println("test_subc: " + (end - start)); | |
426 start = System.currentTimeMillis(); | |
427 for (int i=0; i<ITERS; i++) { | |
428 test_subv(a0, a1, (int)VALUE); | |
429 } | |
430 end = System.currentTimeMillis(); | |
431 System.out.println("test_subv: " + (end - start)); | |
432 start = System.currentTimeMillis(); | |
433 for (int i=0; i<ITERS; i++) { | |
434 test_suba(a0, a1, a2); | |
435 } | |
436 end = System.currentTimeMillis(); | |
437 System.out.println("test_suba: " + (end - start)); | |
438 | |
439 start = System.currentTimeMillis(); | |
440 for (int i=0; i<ITERS; i++) { | |
441 test_mulc(a0, a1); | |
442 } | |
443 end = System.currentTimeMillis(); | |
444 System.out.println("test_mulc: " + (end - start)); | |
445 start = System.currentTimeMillis(); | |
446 for (int i=0; i<ITERS; i++) { | |
447 test_mulv(a0, a1, (int)VALUE); | |
448 } | |
449 end = System.currentTimeMillis(); | |
450 System.out.println("test_mulv: " + (end - start)); | |
451 start = System.currentTimeMillis(); | |
452 for (int i=0; i<ITERS; i++) { | |
453 test_mula(a0, a1, a2); | |
454 } | |
455 end = System.currentTimeMillis(); | |
456 System.out.println("test_mula: " + (end - start)); | |
457 | |
458 start = System.currentTimeMillis(); | |
459 for (int i=0; i<ITERS; i++) { | |
460 test_divc(a0, a1); | |
461 } | |
462 end = System.currentTimeMillis(); | |
463 System.out.println("test_divc: " + (end - start)); | |
464 start = System.currentTimeMillis(); | |
465 for (int i=0; i<ITERS; i++) { | |
466 test_divv(a0, a1, (int)VALUE); | |
467 } | |
468 end = System.currentTimeMillis(); | |
469 System.out.println("test_divv: " + (end - start)); | |
470 start = System.currentTimeMillis(); | |
471 for (int i=0; i<ITERS; i++) { | |
472 test_diva(a0, a1, a2); | |
473 } | |
474 end = System.currentTimeMillis(); | |
475 System.out.println("test_diva: " + (end - start)); | |
476 | |
477 start = System.currentTimeMillis(); | |
478 for (int i=0; i<ITERS; i++) { | |
479 test_mulc_n(a0, a1); | |
480 } | |
481 end = System.currentTimeMillis(); | |
482 System.out.println("test_mulc_n: " + (end - start)); | |
483 start = System.currentTimeMillis(); | |
484 for (int i=0; i<ITERS; i++) { | |
485 test_mulv(a0, a1, (int)-VALUE); | |
486 } | |
487 end = System.currentTimeMillis(); | |
488 System.out.println("test_mulv_n: " + (end - start)); | |
489 start = System.currentTimeMillis(); | |
490 for (int i=0; i<ITERS; i++) { | |
491 test_mula(a0, a1, a3); | |
492 } | |
493 end = System.currentTimeMillis(); | |
494 System.out.println("test_mula_n: " + (end - start)); | |
495 | |
496 start = System.currentTimeMillis(); | |
497 for (int i=0; i<ITERS; i++) { | |
498 test_divc_n(a0, a1); | |
499 } | |
500 end = System.currentTimeMillis(); | |
501 System.out.println("test_divc_n: " + (end - start)); | |
502 start = System.currentTimeMillis(); | |
503 for (int i=0; i<ITERS; i++) { | |
504 test_divv(a0, a1, (int)-VALUE); | |
505 } | |
506 end = System.currentTimeMillis(); | |
507 System.out.println("test_divv_n: " + (end - start)); | |
508 start = System.currentTimeMillis(); | |
509 for (int i=0; i<ITERS; i++) { | |
510 test_diva(a0, a1, a3); | |
511 } | |
512 end = System.currentTimeMillis(); | |
513 System.out.println("test_diva_n: " + (end - start)); | |
514 | |
515 start = System.currentTimeMillis(); | |
516 for (int i=0; i<ITERS; i++) { | |
517 test_andc(a0, a1); | |
518 } | |
519 end = System.currentTimeMillis(); | |
520 System.out.println("test_andc: " + (end - start)); | |
521 start = System.currentTimeMillis(); | |
522 for (int i=0; i<ITERS; i++) { | |
523 test_andv(a0, a1, (int)BIT_MASK); | |
524 } | |
525 end = System.currentTimeMillis(); | |
526 System.out.println("test_andv: " + (end - start)); | |
527 start = System.currentTimeMillis(); | |
528 for (int i=0; i<ITERS; i++) { | |
529 test_anda(a0, a1, a4); | |
530 } | |
531 end = System.currentTimeMillis(); | |
532 System.out.println("test_anda: " + (end - start)); | |
533 | |
534 start = System.currentTimeMillis(); | |
535 for (int i=0; i<ITERS; i++) { | |
536 test_orc(a0, a1); | |
537 } | |
538 end = System.currentTimeMillis(); | |
539 System.out.println("test_orc: " + (end - start)); | |
540 start = System.currentTimeMillis(); | |
541 for (int i=0; i<ITERS; i++) { | |
542 test_orv(a0, a1, (int)BIT_MASK); | |
543 } | |
544 end = System.currentTimeMillis(); | |
545 System.out.println("test_orv: " + (end - start)); | |
546 start = System.currentTimeMillis(); | |
547 for (int i=0; i<ITERS; i++) { | |
548 test_ora(a0, a1, a4); | |
549 } | |
550 end = System.currentTimeMillis(); | |
551 System.out.println("test_ora: " + (end - start)); | |
552 | |
553 start = System.currentTimeMillis(); | |
554 for (int i=0; i<ITERS; i++) { | |
555 test_xorc(a0, a1); | |
556 } | |
557 end = System.currentTimeMillis(); | |
558 System.out.println("test_xorc: " + (end - start)); | |
559 start = System.currentTimeMillis(); | |
560 for (int i=0; i<ITERS; i++) { | |
561 test_xorv(a0, a1, (int)BIT_MASK); | |
562 } | |
563 end = System.currentTimeMillis(); | |
564 System.out.println("test_xorv: " + (end - start)); | |
565 start = System.currentTimeMillis(); | |
566 for (int i=0; i<ITERS; i++) { | |
567 test_xora(a0, a1, a4); | |
568 } | |
569 end = System.currentTimeMillis(); | |
570 System.out.println("test_xora: " + (end - start)); | |
571 | |
572 start = System.currentTimeMillis(); | |
573 for (int i=0; i<ITERS; i++) { | |
574 test_sllc(a0, a1); | |
575 } | |
576 end = System.currentTimeMillis(); | |
577 System.out.println("test_sllc: " + (end - start)); | |
578 start = System.currentTimeMillis(); | |
579 for (int i=0; i<ITERS; i++) { | |
580 test_sllv(a0, a1, VALUE); | |
581 } | |
582 end = System.currentTimeMillis(); | |
583 System.out.println("test_sllv: " + (end - start)); | |
584 | |
585 start = System.currentTimeMillis(); | |
586 for (int i=0; i<ITERS; i++) { | |
587 test_srlc(a0, a1); | |
588 } | |
589 end = System.currentTimeMillis(); | |
590 System.out.println("test_srlc: " + (end - start)); | |
591 start = System.currentTimeMillis(); | |
592 for (int i=0; i<ITERS; i++) { | |
593 test_srlv(a0, a1, VALUE); | |
594 } | |
595 end = System.currentTimeMillis(); | |
596 System.out.println("test_srlv: " + (end - start)); | |
597 | |
598 start = System.currentTimeMillis(); | |
599 for (int i=0; i<ITERS; i++) { | |
600 test_srac(a0, a1); | |
601 } | |
602 end = System.currentTimeMillis(); | |
603 System.out.println("test_srac: " + (end - start)); | |
604 start = System.currentTimeMillis(); | |
605 for (int i=0; i<ITERS; i++) { | |
606 test_srav(a0, a1, VALUE); | |
607 } | |
608 end = System.currentTimeMillis(); | |
609 System.out.println("test_srav: " + (end - start)); | |
610 | |
611 start = System.currentTimeMillis(); | |
612 for (int i=0; i<ITERS; i++) { | |
613 test_sllc_n(a0, a1); | |
614 } | |
615 end = System.currentTimeMillis(); | |
616 System.out.println("test_sllc_n: " + (end - start)); | |
617 start = System.currentTimeMillis(); | |
618 for (int i=0; i<ITERS; i++) { | |
619 test_sllv(a0, a1, -VALUE); | |
620 } | |
621 end = System.currentTimeMillis(); | |
622 System.out.println("test_sllv_n: " + (end - start)); | |
623 | |
624 start = System.currentTimeMillis(); | |
625 for (int i=0; i<ITERS; i++) { | |
626 test_srlc_n(a0, a1); | |
627 } | |
628 end = System.currentTimeMillis(); | |
629 System.out.println("test_srlc_n: " + (end - start)); | |
630 start = System.currentTimeMillis(); | |
631 for (int i=0; i<ITERS; i++) { | |
632 test_srlv(a0, a1, -VALUE); | |
633 } | |
634 end = System.currentTimeMillis(); | |
635 System.out.println("test_srlv_n: " + (end - start)); | |
636 | |
637 start = System.currentTimeMillis(); | |
638 for (int i=0; i<ITERS; i++) { | |
639 test_srac_n(a0, a1); | |
640 } | |
641 end = System.currentTimeMillis(); | |
642 System.out.println("test_srac_n: " + (end - start)); | |
643 start = System.currentTimeMillis(); | |
644 for (int i=0; i<ITERS; i++) { | |
645 test_srav(a0, a1, -VALUE); | |
646 } | |
647 end = System.currentTimeMillis(); | |
648 System.out.println("test_srav_n: " + (end - start)); | |
649 | |
650 start = System.currentTimeMillis(); | |
651 for (int i=0; i<ITERS; i++) { | |
652 test_sllc_o(a0, a1); | |
653 } | |
654 end = System.currentTimeMillis(); | |
655 System.out.println("test_sllc_o: " + (end - start)); | |
656 start = System.currentTimeMillis(); | |
657 for (int i=0; i<ITERS; i++) { | |
658 test_sllv(a0, a1, SHIFT); | |
659 } | |
660 end = System.currentTimeMillis(); | |
661 System.out.println("test_sllv_o: " + (end - start)); | |
662 | |
663 start = System.currentTimeMillis(); | |
664 for (int i=0; i<ITERS; i++) { | |
665 test_srlc_o(a0, a1); | |
666 } | |
667 end = System.currentTimeMillis(); | |
668 System.out.println("test_srlc_o: " + (end - start)); | |
669 start = System.currentTimeMillis(); | |
670 for (int i=0; i<ITERS; i++) { | |
671 test_srlv(a0, a1, SHIFT); | |
672 } | |
673 end = System.currentTimeMillis(); | |
674 System.out.println("test_srlv_o: " + (end - start)); | |
675 | |
676 start = System.currentTimeMillis(); | |
677 for (int i=0; i<ITERS; i++) { | |
678 test_srac_o(a0, a1); | |
679 } | |
680 end = System.currentTimeMillis(); | |
681 System.out.println("test_srac_o: " + (end - start)); | |
682 start = System.currentTimeMillis(); | |
683 for (int i=0; i<ITERS; i++) { | |
684 test_srav(a0, a1, SHIFT); | |
685 } | |
686 end = System.currentTimeMillis(); | |
687 System.out.println("test_srav_o: " + (end - start)); | |
688 | |
689 start = System.currentTimeMillis(); | |
690 for (int i=0; i<ITERS; i++) { | |
691 test_sllc_on(a0, a1); | |
692 } | |
693 end = System.currentTimeMillis(); | |
694 System.out.println("test_sllc_on: " + (end - start)); | |
695 start = System.currentTimeMillis(); | |
696 for (int i=0; i<ITERS; i++) { | |
697 test_sllv(a0, a1, -SHIFT); | |
698 } | |
699 end = System.currentTimeMillis(); | |
700 System.out.println("test_sllv_on: " + (end - start)); | |
701 | |
702 start = System.currentTimeMillis(); | |
703 for (int i=0; i<ITERS; i++) { | |
704 test_srlc_on(a0, a1); | |
705 } | |
706 end = System.currentTimeMillis(); | |
707 System.out.println("test_srlc_on: " + (end - start)); | |
708 start = System.currentTimeMillis(); | |
709 for (int i=0; i<ITERS; i++) { | |
710 test_srlv(a0, a1, -SHIFT); | |
711 } | |
712 end = System.currentTimeMillis(); | |
713 System.out.println("test_srlv_on: " + (end - start)); | |
714 | |
715 start = System.currentTimeMillis(); | |
716 for (int i=0; i<ITERS; i++) { | |
717 test_srac_on(a0, a1); | |
718 } | |
719 end = System.currentTimeMillis(); | |
720 System.out.println("test_srac_on: " + (end - start)); | |
721 start = System.currentTimeMillis(); | |
722 for (int i=0; i<ITERS; i++) { | |
723 test_srav(a0, a1, -SHIFT); | |
724 } | |
725 end = System.currentTimeMillis(); | |
726 System.out.println("test_srav_on: " + (end - start)); | |
727 | |
728 start = System.currentTimeMillis(); | |
729 for (int i=0; i<ITERS; i++) { | |
730 test_pack2(p2, a1); | |
731 } | |
732 end = System.currentTimeMillis(); | |
733 System.out.println("test_pack2: " + (end - start)); | |
734 start = System.currentTimeMillis(); | |
735 for (int i=0; i<ITERS; i++) { | |
736 test_unpack2(a0, p2); | |
737 } | |
738 end = System.currentTimeMillis(); | |
739 System.out.println("test_unpack2: " + (end - start)); | |
740 start = System.currentTimeMillis(); | |
741 for (int i=0; i<ITERS; i++) { | |
742 test_pack2_swap(p2, a1); | |
743 } | |
744 end = System.currentTimeMillis(); | |
745 System.out.println("test_pack2_swap: " + (end - start)); | |
746 start = System.currentTimeMillis(); | |
747 for (int i=0; i<ITERS; i++) { | |
748 test_unpack2_swap(a0, p2); | |
749 } | |
750 end = System.currentTimeMillis(); | |
751 System.out.println("test_unpack2_swap: " + (end - start)); | |
752 | |
753 return errn; | |
754 } | |
755 | |
756 static int test_sum(int[] a1) { | |
757 int sum = 0; | |
758 for (int i = 0; i < a1.length; i+=1) { | |
759 sum += a1[i]; | |
760 } | |
761 return sum; | |
762 } | |
763 | |
764 static void test_addc(int[] a0, int[] a1) { | |
765 for (int i = 0; i < a0.length; i+=1) { | |
766 a0[i] = (int)(a1[i]+VALUE); | |
767 } | |
768 } | |
769 static void test_addv(int[] a0, int[] a1, int b) { | |
770 for (int i = 0; i < a0.length; i+=1) { | |
771 a0[i] = (int)(a1[i]+b); | |
772 } | |
773 } | |
774 static void test_adda(int[] a0, int[] a1, int[] a2) { | |
775 for (int i = 0; i < a0.length; i+=1) { | |
776 a0[i] = (int)(a1[i]+a2[i]); | |
777 } | |
778 } | |
779 | |
780 static void test_subc(int[] a0, int[] a1) { | |
781 for (int i = 0; i < a0.length; i+=1) { | |
782 a0[i] = (int)(a1[i]-VALUE); | |
783 } | |
784 } | |
785 static void test_subv(int[] a0, int[] a1, int b) { | |
786 for (int i = 0; i < a0.length; i+=1) { | |
787 a0[i] = (int)(a1[i]-b); | |
788 } | |
789 } | |
790 static void test_suba(int[] a0, int[] a1, int[] a2) { | |
791 for (int i = 0; i < a0.length; i+=1) { | |
792 a0[i] = (int)(a1[i]-a2[i]); | |
793 } | |
794 } | |
795 | |
796 static void test_mulc(int[] a0, int[] a1) { | |
797 for (int i = 0; i < a0.length; i+=1) { | |
798 a0[i] = (int)(a1[i]*VALUE); | |
799 } | |
800 } | |
801 static void test_mulc_n(int[] a0, int[] a1) { | |
802 for (int i = 0; i < a0.length; i+=1) { | |
803 a0[i] = (int)(a1[i]*(-VALUE)); | |
804 } | |
805 } | |
806 static void test_mulv(int[] a0, int[] a1, int b) { | |
807 for (int i = 0; i < a0.length; i+=1) { | |
808 a0[i] = (int)(a1[i]*b); | |
809 } | |
810 } | |
811 static void test_mula(int[] a0, int[] a1, int[] a2) { | |
812 for (int i = 0; i < a0.length; i+=1) { | |
813 a0[i] = (int)(a1[i]*a2[i]); | |
814 } | |
815 } | |
816 | |
817 static void test_divc(int[] a0, int[] a1) { | |
818 for (int i = 0; i < a0.length; i+=1) { | |
819 a0[i] = (int)(a1[i]/VALUE); | |
820 } | |
821 } | |
822 static void test_divc_n(int[] a0, int[] a1) { | |
823 for (int i = 0; i < a0.length; i+=1) { | |
824 a0[i] = (int)(a1[i]/(-VALUE)); | |
825 } | |
826 } | |
827 static void test_divv(int[] a0, int[] a1, int b) { | |
828 for (int i = 0; i < a0.length; i+=1) { | |
829 a0[i] = (int)(a1[i]/b); | |
830 } | |
831 } | |
832 static void test_diva(int[] a0, int[] a1, int[] a2) { | |
833 for (int i = 0; i < a0.length; i+=1) { | |
834 a0[i] = (int)(a1[i]/a2[i]); | |
835 } | |
836 } | |
837 | |
838 static void test_andc(int[] a0, int[] a1) { | |
839 for (int i = 0; i < a0.length; i+=1) { | |
840 a0[i] = (int)(a1[i]&BIT_MASK); | |
841 } | |
842 } | |
843 static void test_andv(int[] a0, int[] a1, int b) { | |
844 for (int i = 0; i < a0.length; i+=1) { | |
845 a0[i] = (int)(a1[i]&b); | |
846 } | |
847 } | |
848 static void test_anda(int[] a0, int[] a1, int[] a2) { | |
849 for (int i = 0; i < a0.length; i+=1) { | |
850 a0[i] = (int)(a1[i]&a2[i]); | |
851 } | |
852 } | |
853 | |
854 static void test_orc(int[] a0, int[] a1) { | |
855 for (int i = 0; i < a0.length; i+=1) { | |
856 a0[i] = (int)(a1[i]|BIT_MASK); | |
857 } | |
858 } | |
859 static void test_orv(int[] a0, int[] a1, int b) { | |
860 for (int i = 0; i < a0.length; i+=1) { | |
861 a0[i] = (int)(a1[i]|b); | |
862 } | |
863 } | |
864 static void test_ora(int[] a0, int[] a1, int[] a2) { | |
865 for (int i = 0; i < a0.length; i+=1) { | |
866 a0[i] = (int)(a1[i]|a2[i]); | |
867 } | |
868 } | |
869 | |
870 static void test_xorc(int[] a0, int[] a1) { | |
871 for (int i = 0; i < a0.length; i+=1) { | |
872 a0[i] = (int)(a1[i]^BIT_MASK); | |
873 } | |
874 } | |
875 static void test_xorv(int[] a0, int[] a1, int b) { | |
876 for (int i = 0; i < a0.length; i+=1) { | |
877 a0[i] = (int)(a1[i]^b); | |
878 } | |
879 } | |
880 static void test_xora(int[] a0, int[] a1, int[] a2) { | |
881 for (int i = 0; i < a0.length; i+=1) { | |
882 a0[i] = (int)(a1[i]^a2[i]); | |
883 } | |
884 } | |
885 | |
886 static void test_sllc(int[] a0, int[] a1) { | |
887 for (int i = 0; i < a0.length; i+=1) { | |
888 a0[i] = (int)(a1[i]<<VALUE); | |
889 } | |
890 } | |
891 static void test_sllc_n(int[] a0, int[] a1) { | |
892 for (int i = 0; i < a0.length; i+=1) { | |
893 a0[i] = (int)(a1[i]<<(-VALUE)); | |
894 } | |
895 } | |
896 static void test_sllc_o(int[] a0, int[] a1) { | |
897 for (int i = 0; i < a0.length; i+=1) { | |
898 a0[i] = (int)(a1[i]<<SHIFT); | |
899 } | |
900 } | |
901 static void test_sllc_on(int[] a0, int[] a1) { | |
902 for (int i = 0; i < a0.length; i+=1) { | |
903 a0[i] = (int)(a1[i]<<(-SHIFT)); | |
904 } | |
905 } | |
906 static void test_sllv(int[] a0, int[] a1, int b) { | |
907 for (int i = 0; i < a0.length; i+=1) { | |
908 a0[i] = (int)(a1[i]<<b); | |
909 } | |
910 } | |
911 | |
912 static void test_srlc(int[] a0, int[] a1) { | |
913 for (int i = 0; i < a0.length; i+=1) { | |
914 a0[i] = (int)(a1[i]>>>VALUE); | |
915 } | |
916 } | |
917 static void test_srlc_n(int[] a0, int[] a1) { | |
918 for (int i = 0; i < a0.length; i+=1) { | |
919 a0[i] = (int)(a1[i]>>>(-VALUE)); | |
920 } | |
921 } | |
922 static void test_srlc_o(int[] a0, int[] a1) { | |
923 for (int i = 0; i < a0.length; i+=1) { | |
924 a0[i] = (int)(a1[i]>>>SHIFT); | |
925 } | |
926 } | |
927 static void test_srlc_on(int[] a0, int[] a1) { | |
928 for (int i = 0; i < a0.length; i+=1) { | |
929 a0[i] = (int)(a1[i]>>>(-SHIFT)); | |
930 } | |
931 } | |
932 static void test_srlv(int[] a0, int[] a1, int b) { | |
933 for (int i = 0; i < a0.length; i+=1) { | |
934 a0[i] = (int)(a1[i]>>>b); | |
935 } | |
936 } | |
937 | |
938 static void test_srac(int[] a0, int[] a1) { | |
939 for (int i = 0; i < a0.length; i+=1) { | |
940 a0[i] = (int)(a1[i]>>VALUE); | |
941 } | |
942 } | |
943 static void test_srac_n(int[] a0, int[] a1) { | |
944 for (int i = 0; i < a0.length; i+=1) { | |
945 a0[i] = (int)(a1[i]>>(-VALUE)); | |
946 } | |
947 } | |
948 static void test_srac_o(int[] a0, int[] a1) { | |
949 for (int i = 0; i < a0.length; i+=1) { | |
950 a0[i] = (int)(a1[i]>>SHIFT); | |
951 } | |
952 } | |
953 static void test_srac_on(int[] a0, int[] a1) { | |
954 for (int i = 0; i < a0.length; i+=1) { | |
955 a0[i] = (int)(a1[i]>>(-SHIFT)); | |
956 } | |
957 } | |
958 static void test_srav(int[] a0, int[] a1, int b) { | |
959 for (int i = 0; i < a0.length; i+=1) { | |
960 a0[i] = (int)(a1[i]>>b); | |
961 } | |
962 } | |
963 | |
964 static void test_pack2(long[] p2, int[] a1) { | |
965 if (p2.length*2 > a1.length) return; | |
966 for (int i = 0; i < p2.length; i+=1) { | |
967 long l0 = (long)a1[i*2+0]; | |
968 long l1 = (long)a1[i*2+1]; | |
969 p2[i] = (l1 << 32) | (l0 & 0xFFFFFFFFl); | |
970 } | |
971 } | |
972 static void test_unpack2(int[] a0, long[] p2) { | |
973 if (p2.length*2 > a0.length) return; | |
974 for (int i = 0; i < p2.length; i+=1) { | |
975 long l = p2[i]; | |
976 a0[i*2+0] = (int)(l & 0xFFFFFFFFl); | |
977 a0[i*2+1] = (int)(l >> 32); | |
978 } | |
979 } | |
980 static void test_pack2_swap(long[] p2, int[] a1) { | |
981 if (p2.length*2 > a1.length) return; | |
982 for (int i = 0; i < p2.length; i+=1) { | |
983 long l0 = (long)a1[i*2+0]; | |
984 long l1 = (long)a1[i*2+1]; | |
985 p2[i] = (l0 << 32) | (l1 & 0xFFFFFFFFl); | |
986 } | |
987 } | |
988 static void test_unpack2_swap(int[] a0, long[] p2) { | |
989 if (p2.length*2 > a0.length) return; | |
990 for (int i = 0; i < p2.length; i+=1) { | |
991 long l = p2[i]; | |
992 a0[i*2+0] = (int)(l >> 32); | |
993 a0[i*2+1] = (int)(l & 0xFFFFFFFFl); | |
994 } | |
995 } | |
996 | |
997 static int verify(String text, int i, int elem, int val) { | |
998 if (elem != val) { | |
999 System.err.println(text + "[" + i + "] = " + elem + " != " + val); | |
1000 return 1; | |
1001 } | |
1002 return 0; | |
1003 } | |
1004 | |
1005 static int verify(String text, int i, long elem, long val) { | |
1006 if (elem != val) { | |
1007 System.err.println(text + "[" + i + "] = " + Long.toHexString(elem) + " != " + Long.toHexString(val)); | |
1008 return 1; | |
1009 } | |
1010 return 0; | |
1011 } | |
1012 } |