Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/jdk/incubator/vector/Long256VectorTests.java
42588 views
1
/*
2
* Copyright (c) 2018, 2021, 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
* @test
26
* @modules jdk.incubator.vector
27
* @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Long256VectorTests
28
*/
29
30
// -- This file was mechanically generated: Do not edit! -- //
31
32
import jdk.incubator.vector.VectorShape;
33
import jdk.incubator.vector.VectorSpecies;
34
import jdk.incubator.vector.VectorShuffle;
35
import jdk.incubator.vector.VectorMask;
36
import jdk.incubator.vector.VectorOperators;
37
import jdk.incubator.vector.Vector;
38
39
import jdk.incubator.vector.LongVector;
40
41
import org.testng.Assert;
42
import org.testng.annotations.DataProvider;
43
import org.testng.annotations.Test;
44
45
import java.lang.Integer;
46
import java.util.List;
47
import java.util.Arrays;
48
import java.util.function.BiFunction;
49
import java.util.function.IntFunction;
50
import java.util.Objects;
51
import java.util.stream.Collectors;
52
import java.util.stream.Stream;
53
54
@Test
55
public class Long256VectorTests extends AbstractVectorTest {
56
57
static final VectorSpecies<Long> SPECIES =
58
LongVector.SPECIES_256;
59
60
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
61
62
63
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
64
65
static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));
66
67
interface FUnOp {
68
long apply(long a);
69
}
70
71
static void assertArraysEquals(long[] r, long[] a, FUnOp f) {
72
int i = 0;
73
try {
74
for (; i < a.length; i++) {
75
Assert.assertEquals(r[i], f.apply(a[i]));
76
}
77
} catch (AssertionError e) {
78
Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
79
}
80
}
81
82
interface FUnArrayOp {
83
long[] apply(long a);
84
}
85
86
static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) {
87
int i = 0;
88
try {
89
for (; i < a.length; i += SPECIES.length()) {
90
Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
91
f.apply(a[i]));
92
}
93
} catch (AssertionError e) {
94
long[] ref = f.apply(a[i]);
95
long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
96
Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
97
+ ", res: " + Arrays.toString(res)
98
+ "), at index #" + i);
99
}
100
}
101
102
static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) {
103
int i = 0;
104
try {
105
for (; i < a.length; i++) {
106
Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
107
}
108
} catch (AssertionError e) {
109
Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]);
110
}
111
}
112
113
interface FReductionOp {
114
long apply(long[] a, int idx);
115
}
116
117
interface FReductionAllOp {
118
long apply(long[] a);
119
}
120
121
static void assertReductionArraysEquals(long[] r, long rc, long[] a,
122
FReductionOp f, FReductionAllOp fa) {
123
int i = 0;
124
try {
125
Assert.assertEquals(rc, fa.apply(a));
126
for (; i < a.length; i += SPECIES.length()) {
127
Assert.assertEquals(r[i], f.apply(a, i));
128
}
129
} catch (AssertionError e) {
130
Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
131
Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
132
}
133
}
134
135
interface FReductionMaskedOp {
136
long apply(long[] a, int idx, boolean[] mask);
137
}
138
139
interface FReductionAllMaskedOp {
140
long apply(long[] a, boolean[] mask);
141
}
142
143
static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask,
144
FReductionMaskedOp f, FReductionAllMaskedOp fa) {
145
int i = 0;
146
try {
147
Assert.assertEquals(rc, fa.apply(a, mask));
148
for (; i < a.length; i += SPECIES.length()) {
149
Assert.assertEquals(r[i], f.apply(a, i, mask));
150
}
151
} catch (AssertionError e) {
152
Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
153
Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
154
}
155
}
156
157
158
interface FBoolReductionOp {
159
boolean apply(boolean[] a, int idx);
160
}
161
162
static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) {
163
int i = 0;
164
try {
165
for (; i < a.length; i += SPECIES.length()) {
166
Assert.assertEquals(r[i], f.apply(a, i));
167
}
168
} catch (AssertionError e) {
169
Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
170
}
171
}
172
173
static void assertInsertArraysEquals(long[] r, long[] a, long element, int index) {
174
int i = 0;
175
try {
176
for (; i < a.length; i += 1) {
177
if(i%SPECIES.length() == index) {
178
Assert.assertEquals(r[i], element);
179
} else {
180
Assert.assertEquals(r[i], a[i]);
181
}
182
}
183
} catch (AssertionError e) {
184
if (i%SPECIES.length() == index) {
185
Assert.assertEquals(r[i], element, "at index #" + i);
186
} else {
187
Assert.assertEquals(r[i], a[i], "at index #" + i);
188
}
189
}
190
}
191
192
static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) {
193
int i = 0, j = 0;
194
try {
195
for (; i < a.length; i += vector_len) {
196
for (j = 0; j < vector_len; j++) {
197
Assert.assertEquals(r[i+j], a[i+order[i+j]]);
198
}
199
}
200
} catch (AssertionError e) {
201
int idx = i + j;
202
Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
203
}
204
}
205
206
static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) {
207
int i = 0, j = 0;
208
try {
209
for (; i < a.length; i += vector_len) {
210
for (j = 0; j < vector_len; j++) {
211
Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
212
}
213
}
214
} catch (AssertionError e) {
215
int idx = i + j;
216
Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
217
}
218
}
219
220
static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean[] mask, int vector_len) {
221
int i = 0, j = 0;
222
try {
223
for (; i < a.length; i += vector_len) {
224
for (j = 0; j < vector_len; j++) {
225
if (mask[j % SPECIES.length()])
226
Assert.assertEquals(r[i+j], a[i+order[i+j]]);
227
else
228
Assert.assertEquals(r[i+j], (long)0);
229
}
230
}
231
} catch (AssertionError e) {
232
int idx = i + j;
233
if (mask[j % SPECIES.length()])
234
Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
235
else
236
Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
237
}
238
}
239
240
static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) {
241
int i = 0, j = 0;
242
try {
243
for (; i < a.length; i += vector_len) {
244
for (j = 0; j < vector_len; j++) {
245
if (mask[j % SPECIES.length()])
246
Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
247
else
248
Assert.assertEquals(r[i+j], (long)0);
249
}
250
}
251
} catch (AssertionError e) {
252
int idx = i + j;
253
if (mask[j % SPECIES.length()])
254
Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
255
else
256
Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
257
}
258
}
259
260
static void assertBroadcastArraysEquals(long[] r, long[] a) {
261
int i = 0;
262
for (; i < a.length; i += SPECIES.length()) {
263
int idx = i;
264
for (int j = idx; j < (idx + SPECIES.length()); j++)
265
a[j]=a[idx];
266
}
267
268
try {
269
for (i = 0; i < a.length; i++) {
270
Assert.assertEquals(r[i], a[i]);
271
}
272
} catch (AssertionError e) {
273
Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);
274
}
275
}
276
277
interface FBinOp {
278
long apply(long a, long b);
279
}
280
281
interface FBinMaskOp {
282
long apply(long a, long b, boolean m);
283
284
static FBinMaskOp lift(FBinOp f) {
285
return (a, b, m) -> m ? f.apply(a, b) : a;
286
}
287
}
288
289
static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {
290
int i = 0;
291
try {
292
for (; i < a.length; i++) {
293
Assert.assertEquals(r[i], f.apply(a[i], b[i]));
294
}
295
} catch (AssertionError e) {
296
Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
297
}
298
}
299
300
static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {
301
int i = 0;
302
try {
303
for (; i < a.length; i++) {
304
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
305
}
306
} catch (AssertionError e) {
307
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
308
"(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
309
}
310
}
311
312
static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {
313
int i = 0;
314
try {
315
for (; i < a.length; i++) {
316
Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])));
317
}
318
} catch (AssertionError e) {
319
Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])),
320
"(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
321
}
322
}
323
324
static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {
325
assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
326
}
327
328
static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {
329
int i = 0;
330
try {
331
for (; i < a.length; i++) {
332
Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
333
}
334
} catch (AssertionError err) {
335
Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
336
}
337
}
338
339
static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {
340
assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
341
}
342
343
static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {
344
int i = 0;
345
try {
346
for (; i < a.length; i++) {
347
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
348
}
349
} catch (AssertionError err) {
350
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
351
mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
352
", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
353
mask[i % SPECIES.length()]);
354
}
355
}
356
357
static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {
358
assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
359
}
360
361
static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {
362
int i = 0;
363
try {
364
for (; i < a.length; i++) {
365
Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]));
366
}
367
} catch (AssertionError err) {
368
Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]),
369
mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
370
", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
371
mask[i % SPECIES.length()]);
372
}
373
}
374
375
static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {
376
int i = 0;
377
int j = 0;
378
try {
379
for (; j < a.length; j += SPECIES.length()) {
380
for (i = 0; i < SPECIES.length(); i++) {
381
Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
382
}
383
}
384
} catch (AssertionError e) {
385
Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
386
}
387
}
388
389
static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {
390
assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
391
}
392
393
static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {
394
int i = 0;
395
int j = 0;
396
try {
397
for (; j < a.length; j += SPECIES.length()) {
398
for (i = 0; i < SPECIES.length(); i++) {
399
Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
400
}
401
}
402
} catch (AssertionError err) {
403
Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]);
404
}
405
}
406
407
interface FTernOp {
408
long apply(long a, long b, long c);
409
}
410
411
interface FTernMaskOp {
412
long apply(long a, long b, long c, boolean m);
413
414
static FTernMaskOp lift(FTernOp f) {
415
return (a, b, c, m) -> m ? f.apply(a, b, c) : a;
416
}
417
}
418
419
static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {
420
int i = 0;
421
try {
422
for (; i < a.length; i++) {
423
Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));
424
}
425
} catch (AssertionError e) {
426
Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
427
}
428
}
429
430
static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) {
431
assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
432
}
433
434
static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) {
435
int i = 0;
436
try {
437
for (; i < a.length; i++) {
438
Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));
439
}
440
} catch (AssertionError err) {
441
Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "
442
+ b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
443
}
444
}
445
446
static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {
447
int i = 0;
448
try {
449
for (; i < a.length; i++) {
450
Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]));
451
}
452
} catch (AssertionError e) {
453
Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" +
454
i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " +
455
c[(i / SPECIES.length()) * SPECIES.length()]);
456
}
457
}
458
459
static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {
460
int i = 0;
461
try {
462
for (; i < a.length; i++) {
463
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]));
464
}
465
} catch (AssertionError e) {
466
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" +
467
i + ", input1 = " + a[i] + ", input2 = " +
468
b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]);
469
}
470
}
471
472
static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
473
FTernOp f) {
474
assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
475
}
476
477
static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
478
FTernMaskOp f) {
479
int i = 0;
480
try {
481
for (; i < a.length; i++) {
482
Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
483
mask[i % SPECIES.length()]));
484
}
485
} catch (AssertionError err) {
486
Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
487
mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " +
488
b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
489
mask[i % SPECIES.length()]);
490
}
491
}
492
493
static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
494
FTernOp f) {
495
assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
496
}
497
498
static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
499
FTernMaskOp f) {
500
int i = 0;
501
try {
502
for (; i < a.length; i++) {
503
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
504
mask[i % SPECIES.length()]));
505
}
506
} catch (AssertionError err) {
507
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
508
mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
509
", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
510
", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
511
}
512
}
513
514
static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {
515
int i = 0;
516
try {
517
for (; i < a.length; i++) {
518
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
519
c[(i / SPECIES.length()) * SPECIES.length()]));
520
}
521
} catch (AssertionError e) {
522
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
523
c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i]
524
+ ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " +
525
c[(i / SPECIES.length()) * SPECIES.length()]);
526
}
527
}
528
529
static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
530
FTernOp f) {
531
assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
532
}
533
534
static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
535
FTernMaskOp f) {
536
int i = 0;
537
try {
538
for (; i < a.length; i++) {
539
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
540
c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
541
}
542
} catch (AssertionError err) {
543
Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
544
c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #"
545
+ i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
546
", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
547
mask[i % SPECIES.length()]);
548
}
549
}
550
551
552
553
interface FBinArrayOp {
554
long apply(long[] a, int b);
555
}
556
557
static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) {
558
int i = 0;
559
try {
560
for (; i < a.length; i++) {
561
Assert.assertEquals(r[i], f.apply(a, i));
562
}
563
} catch (AssertionError e) {
564
Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i);
565
}
566
}
567
568
interface FGatherScatterOp {
569
long[] apply(long[] a, int ix, int[] b, int iy);
570
}
571
572
static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) {
573
int i = 0;
574
try {
575
for (; i < a.length; i += SPECIES.length()) {
576
Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
577
f.apply(a, i, b, i));
578
}
579
} catch (AssertionError e) {
580
long[] ref = f.apply(a, i, b, i);
581
long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
582
Assert.assertEquals(res, ref,
583
"(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
584
+ Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
585
+ ", b: "
586
+ Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
587
+ " at index #" + i);
588
}
589
}
590
591
interface FGatherMaskedOp {
592
long[] apply(long[] a, int ix, boolean[] mask, int[] b, int iy);
593
}
594
595
interface FScatterMaskedOp {
596
long[] apply(long[] r, long[] a, int ix, boolean[] mask, int[] b, int iy);
597
}
598
599
static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGatherMaskedOp f) {
600
int i = 0;
601
try {
602
for (; i < a.length; i += SPECIES.length()) {
603
Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
604
f.apply(a, i, mask, b, i));
605
}
606
} catch (AssertionError e) {
607
long[] ref = f.apply(a, i, mask, b, i);
608
long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
609
Assert.assertEquals(res, ref,
610
"(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
611
+ Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
612
+ ", b: "
613
+ Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
614
+ ", mask: "
615
+ Arrays.toString(mask)
616
+ " at index #" + i);
617
}
618
}
619
620
static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FScatterMaskedOp f) {
621
int i = 0;
622
try {
623
for (; i < a.length; i += SPECIES.length()) {
624
Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
625
f.apply(r, a, i, mask, b, i));
626
}
627
} catch (AssertionError e) {
628
long[] ref = f.apply(r, a, i, mask, b, i);
629
long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
630
Assert.assertEquals(res, ref,
631
"(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
632
+ Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
633
+ ", b: "
634
+ Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
635
+ ", r: "
636
+ Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length()))
637
+ ", mask: "
638
+ Arrays.toString(mask)
639
+ " at index #" + i);
640
}
641
}
642
643
interface FLaneOp {
644
long[] apply(long[] a, int origin, int idx);
645
}
646
647
static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) {
648
int i = 0;
649
try {
650
for (; i < a.length; i += SPECIES.length()) {
651
Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
652
f.apply(a, origin, i));
653
}
654
} catch (AssertionError e) {
655
long[] ref = f.apply(a, origin, i);
656
long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
657
Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
658
+ ", res: " + Arrays.toString(res)
659
+ "), at index #" + i);
660
}
661
}
662
663
interface FLaneBop {
664
long[] apply(long[] a, long[] b, int origin, int idx);
665
}
666
667
static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBop f) {
668
int i = 0;
669
try {
670
for (; i < a.length; i += SPECIES.length()) {
671
Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
672
f.apply(a, b, origin, i));
673
}
674
} catch (AssertionError e) {
675
long[] ref = f.apply(a, b, origin, i);
676
long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
677
Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
678
+ ", res: " + Arrays.toString(res)
679
+ "), at index #" + i
680
+ ", at origin #" + origin);
681
}
682
}
683
684
interface FLaneMaskedBop {
685
long[] apply(long[] a, long[] b, int origin, boolean[] mask, int idx);
686
}
687
688
static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean[] mask, FLaneMaskedBop f) {
689
int i = 0;
690
try {
691
for (; i < a.length; i += SPECIES.length()) {
692
Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
693
f.apply(a, b, origin, mask, i));
694
}
695
} catch (AssertionError e) {
696
long[] ref = f.apply(a, b, origin, mask, i);
697
long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
698
Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
699
+ ", res: " + Arrays.toString(res)
700
+ "), at index #" + i
701
+ ", at origin #" + origin);
702
}
703
}
704
705
interface FLanePartBop {
706
long[] apply(long[] a, long[] b, int origin, int part, int idx);
707
}
708
709
static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, FLanePartBop f) {
710
int i = 0;
711
try {
712
for (; i < a.length; i += SPECIES.length()) {
713
Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
714
f.apply(a, b, origin, part, i));
715
}
716
} catch (AssertionError e) {
717
long[] ref = f.apply(a, b, origin, part, i);
718
long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
719
Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
720
+ ", res: " + Arrays.toString(res)
721
+ "), at index #" + i
722
+ ", at origin #" + origin
723
+ ", with part #" + part);
724
}
725
}
726
727
interface FLanePartMaskedBop {
728
long[] apply(long[] a, long[] b, int origin, int part, boolean[] mask, int idx);
729
}
730
731
static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) {
732
int i = 0;
733
try {
734
for (; i < a.length; i += SPECIES.length()) {
735
Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
736
f.apply(a, b, origin, part, mask, i));
737
}
738
} catch (AssertionError e) {
739
long[] ref = f.apply(a, b, origin, part, mask, i);
740
long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
741
Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
742
+ ", res: " + Arrays.toString(res)
743
+ "), at index #" + i
744
+ ", at origin #" + origin
745
+ ", with part #" + part);
746
}
747
}
748
749
static int intCornerCaseValue(int i) {
750
switch(i % 5) {
751
case 0:
752
return Integer.MAX_VALUE;
753
case 1:
754
return Integer.MIN_VALUE;
755
case 2:
756
return Integer.MIN_VALUE;
757
case 3:
758
return Integer.MAX_VALUE;
759
default:
760
return (int)0;
761
}
762
}
763
764
static final List<IntFunction<long[]>> INT_LONG_GENERATORS = List.of(
765
withToString("long[-i * 5]", (int s) -> {
766
return fill(s * BUFFER_REPS,
767
i -> (long)(-i * 5));
768
}),
769
withToString("long[i * 5]", (int s) -> {
770
return fill(s * BUFFER_REPS,
771
i -> (long)(i * 5));
772
}),
773
withToString("long[i + 1]", (int s) -> {
774
return fill(s * BUFFER_REPS,
775
i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1)));
776
}),
777
withToString("long[intCornerCaseValue(i)]", (int s) -> {
778
return fill(s * BUFFER_REPS,
779
i -> (long)intCornerCaseValue(i));
780
})
781
);
782
783
static void assertArraysEquals(int[] r, long[] a, int offs) {
784
int i = 0;
785
try {
786
for (; i < r.length; i++) {
787
Assert.assertEquals(r[i], (int)(a[i+offs]));
788
}
789
} catch (AssertionError e) {
790
Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
791
}
792
}
793
794
795
796
static void assertArraysEquals(long[] r, long[] a, int offs) {
797
int i = 0;
798
try {
799
for (; i < r.length; i++) {
800
Assert.assertEquals(r[i], (long)(a[i+offs]));
801
}
802
} catch (AssertionError e) {
803
Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
804
}
805
}
806
807
static void assertArraysEquals(double[] r, long[] a, int offs) {
808
int i = 0;
809
try {
810
for (; i < r.length; i++) {
811
Assert.assertEquals(r[i], (double)(a[i+offs]));
812
}
813
} catch (AssertionError e) {
814
Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
815
}
816
}
817
818
819
static long bits(long e) {
820
return e;
821
}
822
823
static final List<IntFunction<long[]>> LONG_GENERATORS = List.of(
824
withToString("long[-i * 5]", (int s) -> {
825
return fill(s * BUFFER_REPS,
826
i -> (long)(-i * 5));
827
}),
828
withToString("long[i * 5]", (int s) -> {
829
return fill(s * BUFFER_REPS,
830
i -> (long)(i * 5));
831
}),
832
withToString("long[i + 1]", (int s) -> {
833
return fill(s * BUFFER_REPS,
834
i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1)));
835
}),
836
withToString("long[cornerCaseValue(i)]", (int s) -> {
837
return fill(s * BUFFER_REPS,
838
i -> cornerCaseValue(i));
839
})
840
);
841
842
// Create combinations of pairs
843
// @@@ Might be sensitive to order e.g. div by 0
844
static final List<List<IntFunction<long[]>>> LONG_GENERATOR_PAIRS =
845
Stream.of(LONG_GENERATORS.get(0)).
846
flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
847
collect(Collectors.toList());
848
849
@DataProvider
850
public Object[][] boolUnaryOpProvider() {
851
return BOOL_ARRAY_GENERATORS.stream().
852
map(f -> new Object[]{f}).
853
toArray(Object[][]::new);
854
}
855
856
static final List<List<IntFunction<long[]>>> LONG_GENERATOR_TRIPLES =
857
LONG_GENERATOR_PAIRS.stream().
858
flatMap(pair -> LONG_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
859
collect(Collectors.toList());
860
861
@DataProvider
862
public Object[][] longBinaryOpProvider() {
863
return LONG_GENERATOR_PAIRS.stream().map(List::toArray).
864
toArray(Object[][]::new);
865
}
866
867
@DataProvider
868
public Object[][] longIndexedOpProvider() {
869
return LONG_GENERATOR_PAIRS.stream().map(List::toArray).
870
toArray(Object[][]::new);
871
}
872
873
@DataProvider
874
public Object[][] longBinaryOpMaskProvider() {
875
return BOOLEAN_MASK_GENERATORS.stream().
876
flatMap(fm -> LONG_GENERATOR_PAIRS.stream().map(lfa -> {
877
return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
878
})).
879
toArray(Object[][]::new);
880
}
881
882
@DataProvider
883
public Object[][] longTernaryOpProvider() {
884
return LONG_GENERATOR_TRIPLES.stream().map(List::toArray).
885
toArray(Object[][]::new);
886
}
887
888
@DataProvider
889
public Object[][] longTernaryOpMaskProvider() {
890
return BOOLEAN_MASK_GENERATORS.stream().
891
flatMap(fm -> LONG_GENERATOR_TRIPLES.stream().map(lfa -> {
892
return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
893
})).
894
toArray(Object[][]::new);
895
}
896
897
@DataProvider
898
public Object[][] longUnaryOpProvider() {
899
return LONG_GENERATORS.stream().
900
map(f -> new Object[]{f}).
901
toArray(Object[][]::new);
902
}
903
904
@DataProvider
905
public Object[][] longUnaryOpMaskProvider() {
906
return BOOLEAN_MASK_GENERATORS.stream().
907
flatMap(fm -> LONG_GENERATORS.stream().map(fa -> {
908
return new Object[] {fa, fm};
909
})).
910
toArray(Object[][]::new);
911
}
912
913
@DataProvider
914
public Object[][] longtoIntUnaryOpProvider() {
915
return INT_LONG_GENERATORS.stream().
916
map(f -> new Object[]{f}).
917
toArray(Object[][]::new);
918
}
919
920
921
@DataProvider
922
public Object[][] maskProvider() {
923
return BOOLEAN_MASK_GENERATORS.stream().
924
map(f -> new Object[]{f}).
925
toArray(Object[][]::new);
926
}
927
928
@DataProvider
929
public Object[][] maskCompareOpProvider() {
930
return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
931
toArray(Object[][]::new);
932
}
933
934
@DataProvider
935
public Object[][] shuffleProvider() {
936
return INT_SHUFFLE_GENERATORS.stream().
937
map(f -> new Object[]{f}).
938
toArray(Object[][]::new);
939
}
940
941
@DataProvider
942
public Object[][] shuffleCompareOpProvider() {
943
return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
944
toArray(Object[][]::new);
945
}
946
947
@DataProvider
948
public Object[][] longUnaryOpShuffleProvider() {
949
return INT_SHUFFLE_GENERATORS.stream().
950
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
951
return new Object[] {fa, fs};
952
})).
953
toArray(Object[][]::new);
954
}
955
956
@DataProvider
957
public Object[][] longUnaryOpShuffleMaskProvider() {
958
return BOOLEAN_MASK_GENERATORS.stream().
959
flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().
960
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
961
return new Object[] {fa, fs, fm};
962
}))).
963
toArray(Object[][]::new);
964
}
965
966
static final List<BiFunction<Integer,Integer,long[]>> LONG_SHUFFLE_GENERATORS = List.of(
967
withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
968
long[] a = new long[l];
969
int upper = m;
970
for (int i = 0; i < 1; i++) {
971
a[i] = (long)RAND.nextInt(upper);
972
}
973
return a;
974
})
975
);
976
977
@DataProvider
978
public Object[][] longUnaryOpSelectFromProvider() {
979
return LONG_SHUFFLE_GENERATORS.stream().
980
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
981
return new Object[] {fa, fs};
982
})).
983
toArray(Object[][]::new);
984
}
985
986
@DataProvider
987
public Object[][] longUnaryOpSelectFromMaskProvider() {
988
return BOOLEAN_MASK_GENERATORS.stream().
989
flatMap(fm -> LONG_SHUFFLE_GENERATORS.stream().
990
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
991
return new Object[] {fa, fs, fm};
992
}))).
993
toArray(Object[][]::new);
994
}
995
996
997
@DataProvider
998
public Object[][] longUnaryOpIndexProvider() {
999
return INT_INDEX_GENERATORS.stream().
1000
flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
1001
return new Object[] {fa, fs};
1002
})).
1003
toArray(Object[][]::new);
1004
}
1005
1006
@DataProvider
1007
public Object[][] longUnaryMaskedOpIndexProvider() {
1008
return BOOLEAN_MASK_GENERATORS.stream().
1009
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
1010
LONG_GENERATORS.stream().map(fa -> {
1011
return new Object[] {fa, fm, fs};
1012
}))).
1013
toArray(Object[][]::new);
1014
}
1015
1016
@DataProvider
1017
public Object[][] scatterMaskedOpIndexProvider() {
1018
return BOOLEAN_MASK_GENERATORS.stream().
1019
flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->
1020
LONG_GENERATORS.stream().flatMap(fn ->
1021
LONG_GENERATORS.stream().map(fa -> {
1022
return new Object[] {fa, fn, fm, fs};
1023
})))).
1024
toArray(Object[][]::new);
1025
}
1026
1027
static final List<IntFunction<long[]>> LONG_COMPARE_GENERATORS = List.of(
1028
withToString("long[i]", (int s) -> {
1029
return fill(s * BUFFER_REPS,
1030
i -> (long)i);
1031
}),
1032
withToString("long[i - length / 2]", (int s) -> {
1033
return fill(s * BUFFER_REPS,
1034
i -> (long)(i - (s * BUFFER_REPS / 2)));
1035
}),
1036
withToString("long[i + 1]", (int s) -> {
1037
return fill(s * BUFFER_REPS,
1038
i -> (long)(i + 1));
1039
}),
1040
withToString("long[i - 2]", (int s) -> {
1041
return fill(s * BUFFER_REPS,
1042
i -> (long)(i - 2));
1043
}),
1044
withToString("long[zigZag(i)]", (int s) -> {
1045
return fill(s * BUFFER_REPS,
1046
i -> i%3 == 0 ? (long)i : (i%3 == 1 ? (long)(i + 1) : (long)(i - 2)));
1047
}),
1048
withToString("long[cornerCaseValue(i)]", (int s) -> {
1049
return fill(s * BUFFER_REPS,
1050
i -> cornerCaseValue(i));
1051
})
1052
);
1053
1054
static final List<List<IntFunction<long[]>>> LONG_TEST_GENERATOR_ARGS =
1055
LONG_COMPARE_GENERATORS.stream().
1056
map(fa -> List.of(fa)).
1057
collect(Collectors.toList());
1058
1059
@DataProvider
1060
public Object[][] longTestOpProvider() {
1061
return LONG_TEST_GENERATOR_ARGS.stream().map(List::toArray).
1062
toArray(Object[][]::new);
1063
}
1064
1065
@DataProvider
1066
public Object[][] longTestOpMaskProvider() {
1067
return BOOLEAN_MASK_GENERATORS.stream().
1068
flatMap(fm -> LONG_TEST_GENERATOR_ARGS.stream().map(lfa -> {
1069
return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1070
})).
1071
toArray(Object[][]::new);
1072
}
1073
1074
static final List<List<IntFunction<long[]>>> LONG_COMPARE_GENERATOR_PAIRS =
1075
LONG_COMPARE_GENERATORS.stream().
1076
flatMap(fa -> LONG_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
1077
collect(Collectors.toList());
1078
1079
@DataProvider
1080
public Object[][] longCompareOpProvider() {
1081
return LONG_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1082
toArray(Object[][]::new);
1083
}
1084
1085
@DataProvider
1086
public Object[][] longCompareOpMaskProvider() {
1087
return BOOLEAN_MASK_GENERATORS.stream().
1088
flatMap(fm -> LONG_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> {
1089
return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1090
})).
1091
toArray(Object[][]::new);
1092
}
1093
1094
interface ToLongF {
1095
long apply(int i);
1096
}
1097
1098
static long[] fill(int s , ToLongF f) {
1099
return fill(new long[s], f);
1100
}
1101
1102
static long[] fill(long[] a, ToLongF f) {
1103
for (int i = 0; i < a.length; i++) {
1104
a[i] = f.apply(i);
1105
}
1106
return a;
1107
}
1108
1109
static long cornerCaseValue(int i) {
1110
switch(i % 5) {
1111
case 0:
1112
return Long.MAX_VALUE;
1113
case 1:
1114
return Long.MIN_VALUE;
1115
case 2:
1116
return Long.MIN_VALUE;
1117
case 3:
1118
return Long.MAX_VALUE;
1119
default:
1120
return (long)0;
1121
}
1122
}
1123
1124
static long get(long[] a, int i) {
1125
return (long) a[i];
1126
}
1127
1128
static final IntFunction<long[]> fr = (vl) -> {
1129
int length = BUFFER_REPS * vl;
1130
return new long[length];
1131
};
1132
1133
static final IntFunction<boolean[]> fmr = (vl) -> {
1134
int length = BUFFER_REPS * vl;
1135
return new boolean[length];
1136
};
1137
1138
1139
static void replaceZero(long[] a, long v) {
1140
for (int i = 0; i < a.length; i++) {
1141
if (a[i] == 0) {
1142
a[i] = v;
1143
}
1144
}
1145
}
1146
1147
static void replaceZero(long[] a, boolean[] mask, long v) {
1148
for (int i = 0; i < a.length; i++) {
1149
if (mask[i % mask.length] && a[i] == 0) {
1150
a[i] = v;
1151
}
1152
}
1153
}
1154
1155
static boolean eq(long a, long b) {
1156
return a == b;
1157
}
1158
1159
static boolean neq(long a, long b) {
1160
return a != b;
1161
}
1162
1163
static boolean lt(long a, long b) {
1164
return a < b;
1165
}
1166
1167
static boolean le(long a, long b) {
1168
return a <= b;
1169
}
1170
1171
static boolean gt(long a, long b) {
1172
return a > b;
1173
}
1174
1175
static boolean ge(long a, long b) {
1176
return a >= b;
1177
}
1178
1179
static boolean ult(long a, long b) {
1180
return Long.compareUnsigned(a, b) < 0;
1181
}
1182
1183
static boolean ule(long a, long b) {
1184
return Long.compareUnsigned(a, b) <= 0;
1185
}
1186
1187
static boolean ugt(long a, long b) {
1188
return Long.compareUnsigned(a, b) > 0;
1189
}
1190
1191
static boolean uge(long a, long b) {
1192
return Long.compareUnsigned(a, b) >= 0;
1193
}
1194
1195
@Test
1196
static void smokeTest1() {
1197
LongVector three = LongVector.broadcast(SPECIES, (byte)-3);
1198
LongVector three2 = (LongVector) SPECIES.broadcast(-3);
1199
assert(three.eq(three2).allTrue());
1200
LongVector three3 = three2.broadcast(1).broadcast(-3);
1201
assert(three.eq(three3).allTrue());
1202
int scale = 2;
1203
Class<?> ETYPE = long.class;
1204
if (ETYPE == double.class || ETYPE == long.class)
1205
scale = 1000000;
1206
else if (ETYPE == byte.class && SPECIES.length() >= 64)
1207
scale = 1;
1208
LongVector higher = three.addIndex(scale);
1209
VectorMask<Long> m = three.compare(VectorOperators.LE, higher);
1210
assert(m.allTrue());
1211
m = higher.min((long)-1).test(VectorOperators.IS_NEGATIVE);
1212
assert(m.allTrue());
1213
long max = higher.reduceLanes(VectorOperators.MAX);
1214
assert(max == -3 + scale * (SPECIES.length()-1));
1215
}
1216
1217
private static long[]
1218
bothToArray(LongVector a, LongVector b) {
1219
long[] r = new long[a.length() + b.length()];
1220
a.intoArray(r, 0);
1221
b.intoArray(r, a.length());
1222
return r;
1223
}
1224
1225
@Test
1226
static void smokeTest2() {
1227
// Do some zipping and shuffling.
1228
LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1);
1229
LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();
1230
Assert.assertEquals(io, io2);
1231
LongVector a = io.add((long)1); //[1,2]
1232
LongVector b = a.neg(); //[-1,-2]
1233
long[] abValues = bothToArray(a,b); //[1,2,-1,-2]
1234
VectorShuffle<Long> zip0 = VectorShuffle.makeZip(SPECIES, 0);
1235
VectorShuffle<Long> zip1 = VectorShuffle.makeZip(SPECIES, 1);
1236
LongVector zab0 = a.rearrange(zip0,b); //[1,-1]
1237
LongVector zab1 = a.rearrange(zip1,b); //[2,-2]
1238
long[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]
1239
// manually zip
1240
long[] manual = new long[zabValues.length];
1241
for (int i = 0; i < manual.length; i += 2) {
1242
manual[i+0] = abValues[i/2];
1243
manual[i+1] = abValues[a.length() + i/2];
1244
}
1245
Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));
1246
VectorShuffle<Long> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);
1247
VectorShuffle<Long> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);
1248
LongVector uab0 = zab0.rearrange(unz0,zab1);
1249
LongVector uab1 = zab0.rearrange(unz1,zab1);
1250
long[] abValues1 = bothToArray(uab0, uab1);
1251
Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));
1252
}
1253
1254
static void iotaShuffle() {
1255
LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1);
1256
LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();
1257
Assert.assertEquals(io, io2);
1258
}
1259
1260
@Test
1261
// Test all shuffle related operations.
1262
static void shuffleTest() {
1263
// To test backend instructions, make sure that C2 is used.
1264
for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {
1265
iotaShuffle();
1266
}
1267
}
1268
1269
@Test
1270
void viewAsIntegeralLanesTest() {
1271
Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();
1272
Assert.assertEquals(asIntegral.species(), SPECIES);
1273
}
1274
1275
@Test
1276
void viewAsFloatingLanesTest() {
1277
Vector<?> asFloating = SPECIES.zero().viewAsFloatingLanes();
1278
VectorSpecies<?> asFloatingSpecies = asFloating.species();
1279
Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType());
1280
Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape());
1281
Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length());
1282
Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES);
1283
}
1284
1285
@Test
1286
// Test div by 0.
1287
static void bitwiseDivByZeroSmokeTest() {
1288
try {
1289
LongVector a = (LongVector) SPECIES.broadcast(0).addIndex(1);
1290
LongVector b = (LongVector) SPECIES.broadcast(0);
1291
a.div(b);
1292
Assert.fail();
1293
} catch (ArithmeticException e) {
1294
}
1295
1296
try {
1297
LongVector a = (LongVector) SPECIES.broadcast(0).addIndex(1);
1298
LongVector b = (LongVector) SPECIES.broadcast(0);
1299
VectorMask<Long> m = a.lt((long) 1);
1300
a.div(b, m);
1301
Assert.fail();
1302
} catch (ArithmeticException e) {
1303
}
1304
}
1305
static long ADD(long a, long b) {
1306
return (long)(a + b);
1307
}
1308
1309
@Test(dataProvider = "longBinaryOpProvider")
1310
static void ADDLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1311
long[] a = fa.apply(SPECIES.length());
1312
long[] b = fb.apply(SPECIES.length());
1313
long[] r = fr.apply(SPECIES.length());
1314
1315
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1316
for (int i = 0; i < a.length; i += SPECIES.length()) {
1317
LongVector av = LongVector.fromArray(SPECIES, a, i);
1318
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1319
av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1320
}
1321
}
1322
1323
assertArraysEquals(r, a, b, Long256VectorTests::ADD);
1324
}
1325
static long add(long a, long b) {
1326
return (long)(a + b);
1327
}
1328
1329
@Test(dataProvider = "longBinaryOpProvider")
1330
static void addLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1331
long[] a = fa.apply(SPECIES.length());
1332
long[] b = fb.apply(SPECIES.length());
1333
long[] r = fr.apply(SPECIES.length());
1334
1335
for (int i = 0; i < a.length; i += SPECIES.length()) {
1336
LongVector av = LongVector.fromArray(SPECIES, a, i);
1337
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1338
av.add(bv).intoArray(r, i);
1339
}
1340
1341
assertArraysEquals(r, a, b, Long256VectorTests::add);
1342
}
1343
1344
@Test(dataProvider = "longBinaryOpMaskProvider")
1345
static void ADDLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1346
IntFunction<boolean[]> fm) {
1347
long[] a = fa.apply(SPECIES.length());
1348
long[] b = fb.apply(SPECIES.length());
1349
long[] r = fr.apply(SPECIES.length());
1350
boolean[] mask = fm.apply(SPECIES.length());
1351
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1352
1353
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1354
for (int i = 0; i < a.length; i += SPECIES.length()) {
1355
LongVector av = LongVector.fromArray(SPECIES, a, i);
1356
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1357
av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);
1358
}
1359
}
1360
1361
assertArraysEquals(r, a, b, mask, Long256VectorTests::ADD);
1362
}
1363
1364
@Test(dataProvider = "longBinaryOpMaskProvider")
1365
static void addLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1366
IntFunction<boolean[]> fm) {
1367
long[] a = fa.apply(SPECIES.length());
1368
long[] b = fb.apply(SPECIES.length());
1369
long[] r = fr.apply(SPECIES.length());
1370
boolean[] mask = fm.apply(SPECIES.length());
1371
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1372
1373
for (int i = 0; i < a.length; i += SPECIES.length()) {
1374
LongVector av = LongVector.fromArray(SPECIES, a, i);
1375
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1376
av.add(bv, vmask).intoArray(r, i);
1377
}
1378
1379
assertArraysEquals(r, a, b, mask, Long256VectorTests::add);
1380
}
1381
static long SUB(long a, long b) {
1382
return (long)(a - b);
1383
}
1384
1385
@Test(dataProvider = "longBinaryOpProvider")
1386
static void SUBLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1387
long[] a = fa.apply(SPECIES.length());
1388
long[] b = fb.apply(SPECIES.length());
1389
long[] r = fr.apply(SPECIES.length());
1390
1391
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1392
for (int i = 0; i < a.length; i += SPECIES.length()) {
1393
LongVector av = LongVector.fromArray(SPECIES, a, i);
1394
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1395
av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1396
}
1397
}
1398
1399
assertArraysEquals(r, a, b, Long256VectorTests::SUB);
1400
}
1401
static long sub(long a, long b) {
1402
return (long)(a - b);
1403
}
1404
1405
@Test(dataProvider = "longBinaryOpProvider")
1406
static void subLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1407
long[] a = fa.apply(SPECIES.length());
1408
long[] b = fb.apply(SPECIES.length());
1409
long[] r = fr.apply(SPECIES.length());
1410
1411
for (int i = 0; i < a.length; i += SPECIES.length()) {
1412
LongVector av = LongVector.fromArray(SPECIES, a, i);
1413
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1414
av.sub(bv).intoArray(r, i);
1415
}
1416
1417
assertArraysEquals(r, a, b, Long256VectorTests::sub);
1418
}
1419
1420
@Test(dataProvider = "longBinaryOpMaskProvider")
1421
static void SUBLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1422
IntFunction<boolean[]> fm) {
1423
long[] a = fa.apply(SPECIES.length());
1424
long[] b = fb.apply(SPECIES.length());
1425
long[] r = fr.apply(SPECIES.length());
1426
boolean[] mask = fm.apply(SPECIES.length());
1427
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1428
1429
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1430
for (int i = 0; i < a.length; i += SPECIES.length()) {
1431
LongVector av = LongVector.fromArray(SPECIES, a, i);
1432
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1433
av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);
1434
}
1435
}
1436
1437
assertArraysEquals(r, a, b, mask, Long256VectorTests::SUB);
1438
}
1439
1440
@Test(dataProvider = "longBinaryOpMaskProvider")
1441
static void subLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1442
IntFunction<boolean[]> fm) {
1443
long[] a = fa.apply(SPECIES.length());
1444
long[] b = fb.apply(SPECIES.length());
1445
long[] r = fr.apply(SPECIES.length());
1446
boolean[] mask = fm.apply(SPECIES.length());
1447
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1448
1449
for (int i = 0; i < a.length; i += SPECIES.length()) {
1450
LongVector av = LongVector.fromArray(SPECIES, a, i);
1451
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1452
av.sub(bv, vmask).intoArray(r, i);
1453
}
1454
1455
assertArraysEquals(r, a, b, mask, Long256VectorTests::sub);
1456
}
1457
static long MUL(long a, long b) {
1458
return (long)(a * b);
1459
}
1460
1461
@Test(dataProvider = "longBinaryOpProvider")
1462
static void MULLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1463
long[] a = fa.apply(SPECIES.length());
1464
long[] b = fb.apply(SPECIES.length());
1465
long[] r = fr.apply(SPECIES.length());
1466
1467
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1468
for (int i = 0; i < a.length; i += SPECIES.length()) {
1469
LongVector av = LongVector.fromArray(SPECIES, a, i);
1470
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1471
av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1472
}
1473
}
1474
1475
assertArraysEquals(r, a, b, Long256VectorTests::MUL);
1476
}
1477
static long mul(long a, long b) {
1478
return (long)(a * b);
1479
}
1480
1481
@Test(dataProvider = "longBinaryOpProvider")
1482
static void mulLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1483
long[] a = fa.apply(SPECIES.length());
1484
long[] b = fb.apply(SPECIES.length());
1485
long[] r = fr.apply(SPECIES.length());
1486
1487
for (int i = 0; i < a.length; i += SPECIES.length()) {
1488
LongVector av = LongVector.fromArray(SPECIES, a, i);
1489
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1490
av.mul(bv).intoArray(r, i);
1491
}
1492
1493
assertArraysEquals(r, a, b, Long256VectorTests::mul);
1494
}
1495
1496
@Test(dataProvider = "longBinaryOpMaskProvider")
1497
static void MULLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1498
IntFunction<boolean[]> fm) {
1499
long[] a = fa.apply(SPECIES.length());
1500
long[] b = fb.apply(SPECIES.length());
1501
long[] r = fr.apply(SPECIES.length());
1502
boolean[] mask = fm.apply(SPECIES.length());
1503
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1504
1505
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1506
for (int i = 0; i < a.length; i += SPECIES.length()) {
1507
LongVector av = LongVector.fromArray(SPECIES, a, i);
1508
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1509
av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);
1510
}
1511
}
1512
1513
assertArraysEquals(r, a, b, mask, Long256VectorTests::MUL);
1514
}
1515
1516
@Test(dataProvider = "longBinaryOpMaskProvider")
1517
static void mulLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1518
IntFunction<boolean[]> fm) {
1519
long[] a = fa.apply(SPECIES.length());
1520
long[] b = fb.apply(SPECIES.length());
1521
long[] r = fr.apply(SPECIES.length());
1522
boolean[] mask = fm.apply(SPECIES.length());
1523
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1524
1525
for (int i = 0; i < a.length; i += SPECIES.length()) {
1526
LongVector av = LongVector.fromArray(SPECIES, a, i);
1527
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1528
av.mul(bv, vmask).intoArray(r, i);
1529
}
1530
1531
assertArraysEquals(r, a, b, mask, Long256VectorTests::mul);
1532
}
1533
1534
1535
1536
static long DIV(long a, long b) {
1537
return (long)(a / b);
1538
}
1539
1540
@Test(dataProvider = "longBinaryOpProvider")
1541
static void DIVLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1542
long[] a = fa.apply(SPECIES.length());
1543
long[] b = fb.apply(SPECIES.length());
1544
long[] r = fr.apply(SPECIES.length());
1545
1546
replaceZero(b, (long) 1);
1547
1548
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1549
for (int i = 0; i < a.length; i += SPECIES.length()) {
1550
LongVector av = LongVector.fromArray(SPECIES, a, i);
1551
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1552
av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1553
}
1554
}
1555
1556
assertArraysEquals(r, a, b, Long256VectorTests::DIV);
1557
}
1558
static long div(long a, long b) {
1559
return (long)(a / b);
1560
}
1561
1562
@Test(dataProvider = "longBinaryOpProvider")
1563
static void divLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1564
long[] a = fa.apply(SPECIES.length());
1565
long[] b = fb.apply(SPECIES.length());
1566
long[] r = fr.apply(SPECIES.length());
1567
1568
replaceZero(b, (long) 1);
1569
1570
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1571
for (int i = 0; i < a.length; i += SPECIES.length()) {
1572
LongVector av = LongVector.fromArray(SPECIES, a, i);
1573
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1574
av.div(bv).intoArray(r, i);
1575
}
1576
}
1577
1578
assertArraysEquals(r, a, b, Long256VectorTests::div);
1579
}
1580
1581
1582
1583
@Test(dataProvider = "longBinaryOpMaskProvider")
1584
static void DIVLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1585
IntFunction<boolean[]> fm) {
1586
long[] a = fa.apply(SPECIES.length());
1587
long[] b = fb.apply(SPECIES.length());
1588
long[] r = fr.apply(SPECIES.length());
1589
boolean[] mask = fm.apply(SPECIES.length());
1590
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1591
1592
replaceZero(b, mask, (long) 1);
1593
1594
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1595
for (int i = 0; i < a.length; i += SPECIES.length()) {
1596
LongVector av = LongVector.fromArray(SPECIES, a, i);
1597
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1598
av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1599
}
1600
}
1601
1602
assertArraysEquals(r, a, b, mask, Long256VectorTests::DIV);
1603
}
1604
1605
@Test(dataProvider = "longBinaryOpMaskProvider")
1606
static void divLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1607
IntFunction<boolean[]> fm) {
1608
long[] a = fa.apply(SPECIES.length());
1609
long[] b = fb.apply(SPECIES.length());
1610
long[] r = fr.apply(SPECIES.length());
1611
boolean[] mask = fm.apply(SPECIES.length());
1612
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1613
1614
replaceZero(b, mask, (long) 1);
1615
1616
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1617
for (int i = 0; i < a.length; i += SPECIES.length()) {
1618
LongVector av = LongVector.fromArray(SPECIES, a, i);
1619
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1620
av.div(bv, vmask).intoArray(r, i);
1621
}
1622
}
1623
1624
assertArraysEquals(r, a, b, mask, Long256VectorTests::div);
1625
}
1626
1627
static long FIRST_NONZERO(long a, long b) {
1628
return (long)((a)!=0?a:b);
1629
}
1630
1631
@Test(dataProvider = "longBinaryOpProvider")
1632
static void FIRST_NONZEROLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1633
long[] a = fa.apply(SPECIES.length());
1634
long[] b = fb.apply(SPECIES.length());
1635
long[] r = fr.apply(SPECIES.length());
1636
1637
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1638
for (int i = 0; i < a.length; i += SPECIES.length()) {
1639
LongVector av = LongVector.fromArray(SPECIES, a, i);
1640
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1641
av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1642
}
1643
}
1644
1645
assertArraysEquals(r, a, b, Long256VectorTests::FIRST_NONZERO);
1646
}
1647
1648
@Test(dataProvider = "longBinaryOpMaskProvider")
1649
static void FIRST_NONZEROLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1650
IntFunction<boolean[]> fm) {
1651
long[] a = fa.apply(SPECIES.length());
1652
long[] b = fb.apply(SPECIES.length());
1653
long[] r = fr.apply(SPECIES.length());
1654
boolean[] mask = fm.apply(SPECIES.length());
1655
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1656
1657
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1658
for (int i = 0; i < a.length; i += SPECIES.length()) {
1659
LongVector av = LongVector.fromArray(SPECIES, a, i);
1660
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1661
av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1662
}
1663
}
1664
1665
assertArraysEquals(r, a, b, mask, Long256VectorTests::FIRST_NONZERO);
1666
}
1667
1668
static long AND(long a, long b) {
1669
return (long)(a & b);
1670
}
1671
1672
@Test(dataProvider = "longBinaryOpProvider")
1673
static void ANDLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1674
long[] a = fa.apply(SPECIES.length());
1675
long[] b = fb.apply(SPECIES.length());
1676
long[] r = fr.apply(SPECIES.length());
1677
1678
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1679
for (int i = 0; i < a.length; i += SPECIES.length()) {
1680
LongVector av = LongVector.fromArray(SPECIES, a, i);
1681
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1682
av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1683
}
1684
}
1685
1686
assertArraysEquals(r, a, b, Long256VectorTests::AND);
1687
}
1688
static long and(long a, long b) {
1689
return (long)(a & b);
1690
}
1691
1692
@Test(dataProvider = "longBinaryOpProvider")
1693
static void andLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1694
long[] a = fa.apply(SPECIES.length());
1695
long[] b = fb.apply(SPECIES.length());
1696
long[] r = fr.apply(SPECIES.length());
1697
1698
for (int i = 0; i < a.length; i += SPECIES.length()) {
1699
LongVector av = LongVector.fromArray(SPECIES, a, i);
1700
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1701
av.and(bv).intoArray(r, i);
1702
}
1703
1704
assertArraysEquals(r, a, b, Long256VectorTests::and);
1705
}
1706
1707
1708
1709
@Test(dataProvider = "longBinaryOpMaskProvider")
1710
static void ANDLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1711
IntFunction<boolean[]> fm) {
1712
long[] a = fa.apply(SPECIES.length());
1713
long[] b = fb.apply(SPECIES.length());
1714
long[] r = fr.apply(SPECIES.length());
1715
boolean[] mask = fm.apply(SPECIES.length());
1716
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1717
1718
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1719
for (int i = 0; i < a.length; i += SPECIES.length()) {
1720
LongVector av = LongVector.fromArray(SPECIES, a, i);
1721
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1722
av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
1723
}
1724
}
1725
1726
assertArraysEquals(r, a, b, mask, Long256VectorTests::AND);
1727
}
1728
1729
1730
static long AND_NOT(long a, long b) {
1731
return (long)(a & ~b);
1732
}
1733
1734
@Test(dataProvider = "longBinaryOpProvider")
1735
static void AND_NOTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1736
long[] a = fa.apply(SPECIES.length());
1737
long[] b = fb.apply(SPECIES.length());
1738
long[] r = fr.apply(SPECIES.length());
1739
1740
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1741
for (int i = 0; i < a.length; i += SPECIES.length()) {
1742
LongVector av = LongVector.fromArray(SPECIES, a, i);
1743
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1744
av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
1745
}
1746
}
1747
1748
assertArraysEquals(r, a, b, Long256VectorTests::AND_NOT);
1749
}
1750
1751
1752
1753
@Test(dataProvider = "longBinaryOpMaskProvider")
1754
static void AND_NOTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1755
IntFunction<boolean[]> fm) {
1756
long[] a = fa.apply(SPECIES.length());
1757
long[] b = fb.apply(SPECIES.length());
1758
long[] r = fr.apply(SPECIES.length());
1759
boolean[] mask = fm.apply(SPECIES.length());
1760
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1761
1762
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1763
for (int i = 0; i < a.length; i += SPECIES.length()) {
1764
LongVector av = LongVector.fromArray(SPECIES, a, i);
1765
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1766
av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
1767
}
1768
}
1769
1770
assertArraysEquals(r, a, b, mask, Long256VectorTests::AND_NOT);
1771
}
1772
1773
1774
static long OR(long a, long b) {
1775
return (long)(a | b);
1776
}
1777
1778
@Test(dataProvider = "longBinaryOpProvider")
1779
static void ORLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1780
long[] a = fa.apply(SPECIES.length());
1781
long[] b = fb.apply(SPECIES.length());
1782
long[] r = fr.apply(SPECIES.length());
1783
1784
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1785
for (int i = 0; i < a.length; i += SPECIES.length()) {
1786
LongVector av = LongVector.fromArray(SPECIES, a, i);
1787
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1788
av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1789
}
1790
}
1791
1792
assertArraysEquals(r, a, b, Long256VectorTests::OR);
1793
}
1794
static long or(long a, long b) {
1795
return (long)(a | b);
1796
}
1797
1798
@Test(dataProvider = "longBinaryOpProvider")
1799
static void orLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1800
long[] a = fa.apply(SPECIES.length());
1801
long[] b = fb.apply(SPECIES.length());
1802
long[] r = fr.apply(SPECIES.length());
1803
1804
for (int i = 0; i < a.length; i += SPECIES.length()) {
1805
LongVector av = LongVector.fromArray(SPECIES, a, i);
1806
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1807
av.or(bv).intoArray(r, i);
1808
}
1809
1810
assertArraysEquals(r, a, b, Long256VectorTests::or);
1811
}
1812
1813
1814
1815
@Test(dataProvider = "longBinaryOpMaskProvider")
1816
static void ORLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1817
IntFunction<boolean[]> fm) {
1818
long[] a = fa.apply(SPECIES.length());
1819
long[] b = fb.apply(SPECIES.length());
1820
long[] r = fr.apply(SPECIES.length());
1821
boolean[] mask = fm.apply(SPECIES.length());
1822
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1823
1824
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1825
for (int i = 0; i < a.length; i += SPECIES.length()) {
1826
LongVector av = LongVector.fromArray(SPECIES, a, i);
1827
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1828
av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1829
}
1830
}
1831
1832
assertArraysEquals(r, a, b, mask, Long256VectorTests::OR);
1833
}
1834
1835
1836
static long XOR(long a, long b) {
1837
return (long)(a ^ b);
1838
}
1839
1840
@Test(dataProvider = "longBinaryOpProvider")
1841
static void XORLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1842
long[] a = fa.apply(SPECIES.length());
1843
long[] b = fb.apply(SPECIES.length());
1844
long[] r = fr.apply(SPECIES.length());
1845
1846
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1847
for (int i = 0; i < a.length; i += SPECIES.length()) {
1848
LongVector av = LongVector.fromArray(SPECIES, a, i);
1849
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1850
av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
1851
}
1852
}
1853
1854
assertArraysEquals(r, a, b, Long256VectorTests::XOR);
1855
}
1856
1857
1858
1859
@Test(dataProvider = "longBinaryOpMaskProvider")
1860
static void XORLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1861
IntFunction<boolean[]> fm) {
1862
long[] a = fa.apply(SPECIES.length());
1863
long[] b = fb.apply(SPECIES.length());
1864
long[] r = fr.apply(SPECIES.length());
1865
boolean[] mask = fm.apply(SPECIES.length());
1866
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1867
1868
for (int ic = 0; ic < INVOC_COUNT; ic++) {
1869
for (int i = 0; i < a.length; i += SPECIES.length()) {
1870
LongVector av = LongVector.fromArray(SPECIES, a, i);
1871
LongVector bv = LongVector.fromArray(SPECIES, b, i);
1872
av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1873
}
1874
}
1875
1876
assertArraysEquals(r, a, b, mask, Long256VectorTests::XOR);
1877
}
1878
1879
1880
@Test(dataProvider = "longBinaryOpProvider")
1881
static void addLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1882
long[] a = fa.apply(SPECIES.length());
1883
long[] b = fb.apply(SPECIES.length());
1884
long[] r = fr.apply(SPECIES.length());
1885
1886
for (int i = 0; i < a.length; i += SPECIES.length()) {
1887
LongVector av = LongVector.fromArray(SPECIES, a, i);
1888
av.add(b[i]).intoArray(r, i);
1889
}
1890
1891
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::add);
1892
}
1893
1894
@Test(dataProvider = "longBinaryOpMaskProvider")
1895
static void addLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
1896
IntFunction<boolean[]> fm) {
1897
long[] a = fa.apply(SPECIES.length());
1898
long[] b = fb.apply(SPECIES.length());
1899
long[] r = fr.apply(SPECIES.length());
1900
boolean[] mask = fm.apply(SPECIES.length());
1901
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1902
1903
for (int i = 0; i < a.length; i += SPECIES.length()) {
1904
LongVector av = LongVector.fromArray(SPECIES, a, i);
1905
av.add(b[i], vmask).intoArray(r, i);
1906
}
1907
1908
assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::add);
1909
}
1910
1911
@Test(dataProvider = "longBinaryOpProvider")
1912
static void subLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1913
long[] a = fa.apply(SPECIES.length());
1914
long[] b = fb.apply(SPECIES.length());
1915
long[] r = fr.apply(SPECIES.length());
1916
1917
for (int i = 0; i < a.length; i += SPECIES.length()) {
1918
LongVector av = LongVector.fromArray(SPECIES, a, i);
1919
av.sub(b[i]).intoArray(r, i);
1920
}
1921
1922
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::sub);
1923
}
1924
1925
@Test(dataProvider = "longBinaryOpMaskProvider")
1926
static void subLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
1927
IntFunction<boolean[]> fm) {
1928
long[] a = fa.apply(SPECIES.length());
1929
long[] b = fb.apply(SPECIES.length());
1930
long[] r = fr.apply(SPECIES.length());
1931
boolean[] mask = fm.apply(SPECIES.length());
1932
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1933
1934
for (int i = 0; i < a.length; i += SPECIES.length()) {
1935
LongVector av = LongVector.fromArray(SPECIES, a, i);
1936
av.sub(b[i], vmask).intoArray(r, i);
1937
}
1938
1939
assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::sub);
1940
}
1941
1942
@Test(dataProvider = "longBinaryOpProvider")
1943
static void mulLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1944
long[] a = fa.apply(SPECIES.length());
1945
long[] b = fb.apply(SPECIES.length());
1946
long[] r = fr.apply(SPECIES.length());
1947
1948
for (int i = 0; i < a.length; i += SPECIES.length()) {
1949
LongVector av = LongVector.fromArray(SPECIES, a, i);
1950
av.mul(b[i]).intoArray(r, i);
1951
}
1952
1953
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::mul);
1954
}
1955
1956
@Test(dataProvider = "longBinaryOpMaskProvider")
1957
static void mulLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
1958
IntFunction<boolean[]> fm) {
1959
long[] a = fa.apply(SPECIES.length());
1960
long[] b = fb.apply(SPECIES.length());
1961
long[] r = fr.apply(SPECIES.length());
1962
boolean[] mask = fm.apply(SPECIES.length());
1963
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1964
1965
for (int i = 0; i < a.length; i += SPECIES.length()) {
1966
LongVector av = LongVector.fromArray(SPECIES, a, i);
1967
av.mul(b[i], vmask).intoArray(r, i);
1968
}
1969
1970
assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::mul);
1971
}
1972
1973
1974
1975
1976
@Test(dataProvider = "longBinaryOpProvider")
1977
static void divLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1978
long[] a = fa.apply(SPECIES.length());
1979
long[] b = fb.apply(SPECIES.length());
1980
long[] r = fr.apply(SPECIES.length());
1981
1982
replaceZero(b, (long) 1);
1983
1984
for (int i = 0; i < a.length; i += SPECIES.length()) {
1985
LongVector av = LongVector.fromArray(SPECIES, a, i);
1986
av.div(b[i]).intoArray(r, i);
1987
}
1988
1989
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::div);
1990
}
1991
1992
1993
1994
@Test(dataProvider = "longBinaryOpMaskProvider")
1995
static void divLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
1996
IntFunction<boolean[]> fm) {
1997
long[] a = fa.apply(SPECIES.length());
1998
long[] b = fb.apply(SPECIES.length());
1999
long[] r = fr.apply(SPECIES.length());
2000
boolean[] mask = fm.apply(SPECIES.length());
2001
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2002
2003
replaceZero(b, (long) 1);
2004
2005
for (int i = 0; i < a.length; i += SPECIES.length()) {
2006
LongVector av = LongVector.fromArray(SPECIES, a, i);
2007
av.div(b[i], vmask).intoArray(r, i);
2008
}
2009
2010
assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::div);
2011
}
2012
2013
2014
2015
@Test(dataProvider = "longBinaryOpProvider")
2016
static void ORLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2017
long[] a = fa.apply(SPECIES.length());
2018
long[] b = fb.apply(SPECIES.length());
2019
long[] r = fr.apply(SPECIES.length());
2020
2021
for (int i = 0; i < a.length; i += SPECIES.length()) {
2022
LongVector av = LongVector.fromArray(SPECIES, a, i);
2023
av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2024
}
2025
2026
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::OR);
2027
}
2028
2029
@Test(dataProvider = "longBinaryOpProvider")
2030
static void orLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2031
long[] a = fa.apply(SPECIES.length());
2032
long[] b = fb.apply(SPECIES.length());
2033
long[] r = fr.apply(SPECIES.length());
2034
2035
for (int i = 0; i < a.length; i += SPECIES.length()) {
2036
LongVector av = LongVector.fromArray(SPECIES, a, i);
2037
av.or(b[i]).intoArray(r, i);
2038
}
2039
2040
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::or);
2041
}
2042
2043
2044
2045
@Test(dataProvider = "longBinaryOpMaskProvider")
2046
static void ORLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2047
IntFunction<boolean[]> fm) {
2048
long[] a = fa.apply(SPECIES.length());
2049
long[] b = fb.apply(SPECIES.length());
2050
long[] r = fr.apply(SPECIES.length());
2051
boolean[] mask = fm.apply(SPECIES.length());
2052
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2053
2054
for (int i = 0; i < a.length; i += SPECIES.length()) {
2055
LongVector av = LongVector.fromArray(SPECIES, a, i);
2056
av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2057
}
2058
2059
assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::OR);
2060
}
2061
2062
2063
2064
@Test(dataProvider = "longBinaryOpProvider")
2065
static void ANDLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2066
long[] a = fa.apply(SPECIES.length());
2067
long[] b = fb.apply(SPECIES.length());
2068
long[] r = fr.apply(SPECIES.length());
2069
2070
for (int i = 0; i < a.length; i += SPECIES.length()) {
2071
LongVector av = LongVector.fromArray(SPECIES, a, i);
2072
av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2073
}
2074
2075
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::AND);
2076
}
2077
2078
@Test(dataProvider = "longBinaryOpProvider")
2079
static void andLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2080
long[] a = fa.apply(SPECIES.length());
2081
long[] b = fb.apply(SPECIES.length());
2082
long[] r = fr.apply(SPECIES.length());
2083
2084
for (int i = 0; i < a.length; i += SPECIES.length()) {
2085
LongVector av = LongVector.fromArray(SPECIES, a, i);
2086
av.and(b[i]).intoArray(r, i);
2087
}
2088
2089
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::and);
2090
}
2091
2092
2093
2094
@Test(dataProvider = "longBinaryOpMaskProvider")
2095
static void ANDLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2096
IntFunction<boolean[]> fm) {
2097
long[] a = fa.apply(SPECIES.length());
2098
long[] b = fb.apply(SPECIES.length());
2099
long[] r = fr.apply(SPECIES.length());
2100
boolean[] mask = fm.apply(SPECIES.length());
2101
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2102
2103
for (int i = 0; i < a.length; i += SPECIES.length()) {
2104
LongVector av = LongVector.fromArray(SPECIES, a, i);
2105
av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2106
}
2107
2108
assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::AND);
2109
}
2110
2111
2112
2113
@Test(dataProvider = "longBinaryOpProvider")
2114
static void ORLong256VectorTestsBroadcastLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2115
long[] a = fa.apply(SPECIES.length());
2116
long[] b = fb.apply(SPECIES.length());
2117
long[] r = fr.apply(SPECIES.length());
2118
2119
for (int i = 0; i < a.length; i += SPECIES.length()) {
2120
LongVector av = LongVector.fromArray(SPECIES, a, i);
2121
av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2122
}
2123
2124
assertBroadcastLongArraysEquals(r, a, b, Long256VectorTests::OR);
2125
}
2126
2127
2128
2129
@Test(dataProvider = "longBinaryOpMaskProvider")
2130
static void ORLong256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2131
IntFunction<boolean[]> fm) {
2132
long[] a = fa.apply(SPECIES.length());
2133
long[] b = fb.apply(SPECIES.length());
2134
long[] r = fr.apply(SPECIES.length());
2135
boolean[] mask = fm.apply(SPECIES.length());
2136
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2137
2138
for (int i = 0; i < a.length; i += SPECIES.length()) {
2139
LongVector av = LongVector.fromArray(SPECIES, a, i);
2140
av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2141
}
2142
2143
assertBroadcastLongArraysEquals(r, a, b, mask, Long256VectorTests::OR);
2144
}
2145
2146
2147
@Test(dataProvider = "longBinaryOpProvider")
2148
static void ADDLong256VectorTestsBroadcastLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2149
long[] a = fa.apply(SPECIES.length());
2150
long[] b = fb.apply(SPECIES.length());
2151
long[] r = fr.apply(SPECIES.length());
2152
2153
for (int i = 0; i < a.length; i += SPECIES.length()) {
2154
LongVector av = LongVector.fromArray(SPECIES, a, i);
2155
av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2156
}
2157
2158
assertBroadcastLongArraysEquals(r, a, b, Long256VectorTests::ADD);
2159
}
2160
2161
@Test(dataProvider = "longBinaryOpMaskProvider")
2162
static void ADDLong256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2163
IntFunction<boolean[]> fm) {
2164
long[] a = fa.apply(SPECIES.length());
2165
long[] b = fb.apply(SPECIES.length());
2166
long[] r = fr.apply(SPECIES.length());
2167
boolean[] mask = fm.apply(SPECIES.length());
2168
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2169
2170
for (int i = 0; i < a.length; i += SPECIES.length()) {
2171
LongVector av = LongVector.fromArray(SPECIES, a, i);
2172
av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2173
}
2174
2175
assertBroadcastLongArraysEquals(r, a, b, mask, Long256VectorTests::ADD);
2176
}
2177
2178
static long LSHL(long a, long b) {
2179
return (long)((a << b));
2180
}
2181
2182
@Test(dataProvider = "longBinaryOpProvider")
2183
static void LSHLLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2184
long[] a = fa.apply(SPECIES.length());
2185
long[] b = fb.apply(SPECIES.length());
2186
long[] r = fr.apply(SPECIES.length());
2187
2188
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2189
for (int i = 0; i < a.length; i += SPECIES.length()) {
2190
LongVector av = LongVector.fromArray(SPECIES, a, i);
2191
LongVector bv = LongVector.fromArray(SPECIES, b, i);
2192
av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2193
}
2194
}
2195
2196
assertArraysEquals(r, a, b, Long256VectorTests::LSHL);
2197
}
2198
2199
2200
2201
@Test(dataProvider = "longBinaryOpMaskProvider")
2202
static void LSHLLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2203
IntFunction<boolean[]> fm) {
2204
long[] a = fa.apply(SPECIES.length());
2205
long[] b = fb.apply(SPECIES.length());
2206
long[] r = fr.apply(SPECIES.length());
2207
boolean[] mask = fm.apply(SPECIES.length());
2208
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2209
2210
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2211
for (int i = 0; i < a.length; i += SPECIES.length()) {
2212
LongVector av = LongVector.fromArray(SPECIES, a, i);
2213
LongVector bv = LongVector.fromArray(SPECIES, b, i);
2214
av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2215
}
2216
}
2217
2218
assertArraysEquals(r, a, b, mask, Long256VectorTests::LSHL);
2219
}
2220
2221
2222
2223
2224
2225
2226
static long ASHR(long a, long b) {
2227
return (long)((a >> b));
2228
}
2229
2230
@Test(dataProvider = "longBinaryOpProvider")
2231
static void ASHRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2232
long[] a = fa.apply(SPECIES.length());
2233
long[] b = fb.apply(SPECIES.length());
2234
long[] r = fr.apply(SPECIES.length());
2235
2236
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2237
for (int i = 0; i < a.length; i += SPECIES.length()) {
2238
LongVector av = LongVector.fromArray(SPECIES, a, i);
2239
LongVector bv = LongVector.fromArray(SPECIES, b, i);
2240
av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2241
}
2242
}
2243
2244
assertArraysEquals(r, a, b, Long256VectorTests::ASHR);
2245
}
2246
2247
2248
2249
@Test(dataProvider = "longBinaryOpMaskProvider")
2250
static void ASHRLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2251
IntFunction<boolean[]> fm) {
2252
long[] a = fa.apply(SPECIES.length());
2253
long[] b = fb.apply(SPECIES.length());
2254
long[] r = fr.apply(SPECIES.length());
2255
boolean[] mask = fm.apply(SPECIES.length());
2256
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2257
2258
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2259
for (int i = 0; i < a.length; i += SPECIES.length()) {
2260
LongVector av = LongVector.fromArray(SPECIES, a, i);
2261
LongVector bv = LongVector.fromArray(SPECIES, b, i);
2262
av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2263
}
2264
}
2265
2266
assertArraysEquals(r, a, b, mask, Long256VectorTests::ASHR);
2267
}
2268
2269
2270
2271
2272
2273
2274
static long LSHR(long a, long b) {
2275
return (long)((a >>> b));
2276
}
2277
2278
@Test(dataProvider = "longBinaryOpProvider")
2279
static void LSHRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2280
long[] a = fa.apply(SPECIES.length());
2281
long[] b = fb.apply(SPECIES.length());
2282
long[] r = fr.apply(SPECIES.length());
2283
2284
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2285
for (int i = 0; i < a.length; i += SPECIES.length()) {
2286
LongVector av = LongVector.fromArray(SPECIES, a, i);
2287
LongVector bv = LongVector.fromArray(SPECIES, b, i);
2288
av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2289
}
2290
}
2291
2292
assertArraysEquals(r, a, b, Long256VectorTests::LSHR);
2293
}
2294
2295
2296
2297
@Test(dataProvider = "longBinaryOpMaskProvider")
2298
static void LSHRLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2299
IntFunction<boolean[]> fm) {
2300
long[] a = fa.apply(SPECIES.length());
2301
long[] b = fb.apply(SPECIES.length());
2302
long[] r = fr.apply(SPECIES.length());
2303
boolean[] mask = fm.apply(SPECIES.length());
2304
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2305
2306
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2307
for (int i = 0; i < a.length; i += SPECIES.length()) {
2308
LongVector av = LongVector.fromArray(SPECIES, a, i);
2309
LongVector bv = LongVector.fromArray(SPECIES, b, i);
2310
av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2311
}
2312
}
2313
2314
assertArraysEquals(r, a, b, mask, Long256VectorTests::LSHR);
2315
}
2316
2317
2318
2319
2320
2321
2322
static long LSHL_unary(long a, long b) {
2323
return (long)((a << b));
2324
}
2325
2326
@Test(dataProvider = "longBinaryOpProvider")
2327
static void LSHLLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2328
long[] a = fa.apply(SPECIES.length());
2329
long[] b = fb.apply(SPECIES.length());
2330
long[] r = fr.apply(SPECIES.length());
2331
2332
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2333
for (int i = 0; i < a.length; i += SPECIES.length()) {
2334
LongVector av = LongVector.fromArray(SPECIES, a, i);
2335
av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2336
}
2337
}
2338
2339
assertShiftArraysEquals(r, a, b, Long256VectorTests::LSHL_unary);
2340
}
2341
2342
2343
2344
@Test(dataProvider = "longBinaryOpMaskProvider")
2345
static void LSHLLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
2346
IntFunction<boolean[]> fm) {
2347
long[] a = fa.apply(SPECIES.length());
2348
long[] b = fb.apply(SPECIES.length());
2349
long[] r = fr.apply(SPECIES.length());
2350
boolean[] mask = fm.apply(SPECIES.length());
2351
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2352
2353
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2354
for (int i = 0; i < a.length; i += SPECIES.length()) {
2355
LongVector av = LongVector.fromArray(SPECIES, a, i);
2356
av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2357
}
2358
}
2359
2360
assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::LSHL_unary);
2361
}
2362
2363
2364
2365
2366
2367
2368
static long LSHR_unary(long a, long b) {
2369
return (long)((a >>> b));
2370
}
2371
2372
@Test(dataProvider = "longBinaryOpProvider")
2373
static void LSHRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2374
long[] a = fa.apply(SPECIES.length());
2375
long[] b = fb.apply(SPECIES.length());
2376
long[] r = fr.apply(SPECIES.length());
2377
2378
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2379
for (int i = 0; i < a.length; i += SPECIES.length()) {
2380
LongVector av = LongVector.fromArray(SPECIES, a, i);
2381
av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2382
}
2383
}
2384
2385
assertShiftArraysEquals(r, a, b, Long256VectorTests::LSHR_unary);
2386
}
2387
2388
2389
2390
@Test(dataProvider = "longBinaryOpMaskProvider")
2391
static void LSHRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
2392
IntFunction<boolean[]> fm) {
2393
long[] a = fa.apply(SPECIES.length());
2394
long[] b = fb.apply(SPECIES.length());
2395
long[] r = fr.apply(SPECIES.length());
2396
boolean[] mask = fm.apply(SPECIES.length());
2397
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2398
2399
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2400
for (int i = 0; i < a.length; i += SPECIES.length()) {
2401
LongVector av = LongVector.fromArray(SPECIES, a, i);
2402
av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2403
}
2404
}
2405
2406
assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::LSHR_unary);
2407
}
2408
2409
2410
2411
2412
2413
2414
static long ASHR_unary(long a, long b) {
2415
return (long)((a >> b));
2416
}
2417
2418
@Test(dataProvider = "longBinaryOpProvider")
2419
static void ASHRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2420
long[] a = fa.apply(SPECIES.length());
2421
long[] b = fb.apply(SPECIES.length());
2422
long[] r = fr.apply(SPECIES.length());
2423
2424
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2425
for (int i = 0; i < a.length; i += SPECIES.length()) {
2426
LongVector av = LongVector.fromArray(SPECIES, a, i);
2427
av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2428
}
2429
}
2430
2431
assertShiftArraysEquals(r, a, b, Long256VectorTests::ASHR_unary);
2432
}
2433
2434
2435
2436
@Test(dataProvider = "longBinaryOpMaskProvider")
2437
static void ASHRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
2438
IntFunction<boolean[]> fm) {
2439
long[] a = fa.apply(SPECIES.length());
2440
long[] b = fb.apply(SPECIES.length());
2441
long[] r = fr.apply(SPECIES.length());
2442
boolean[] mask = fm.apply(SPECIES.length());
2443
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2444
2445
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2446
for (int i = 0; i < a.length; i += SPECIES.length()) {
2447
LongVector av = LongVector.fromArray(SPECIES, a, i);
2448
av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2449
}
2450
}
2451
2452
assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::ASHR_unary);
2453
}
2454
2455
2456
2457
2458
2459
static long MIN(long a, long b) {
2460
return (long)(Math.min(a, b));
2461
}
2462
2463
@Test(dataProvider = "longBinaryOpProvider")
2464
static void MINLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2465
long[] a = fa.apply(SPECIES.length());
2466
long[] b = fb.apply(SPECIES.length());
2467
long[] r = fr.apply(SPECIES.length());
2468
2469
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2470
for (int i = 0; i < a.length; i += SPECIES.length()) {
2471
LongVector av = LongVector.fromArray(SPECIES, a, i);
2472
LongVector bv = LongVector.fromArray(SPECIES, b, i);
2473
av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2474
}
2475
}
2476
2477
assertArraysEquals(r, a, b, Long256VectorTests::MIN);
2478
}
2479
static long min(long a, long b) {
2480
return (long)(Math.min(a, b));
2481
}
2482
2483
@Test(dataProvider = "longBinaryOpProvider")
2484
static void minLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2485
long[] a = fa.apply(SPECIES.length());
2486
long[] b = fb.apply(SPECIES.length());
2487
long[] r = fr.apply(SPECIES.length());
2488
2489
for (int i = 0; i < a.length; i += SPECIES.length()) {
2490
LongVector av = LongVector.fromArray(SPECIES, a, i);
2491
LongVector bv = LongVector.fromArray(SPECIES, b, i);
2492
av.min(bv).intoArray(r, i);
2493
}
2494
2495
assertArraysEquals(r, a, b, Long256VectorTests::min);
2496
}
2497
static long MAX(long a, long b) {
2498
return (long)(Math.max(a, b));
2499
}
2500
2501
@Test(dataProvider = "longBinaryOpProvider")
2502
static void MAXLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2503
long[] a = fa.apply(SPECIES.length());
2504
long[] b = fb.apply(SPECIES.length());
2505
long[] r = fr.apply(SPECIES.length());
2506
2507
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2508
for (int i = 0; i < a.length; i += SPECIES.length()) {
2509
LongVector av = LongVector.fromArray(SPECIES, a, i);
2510
LongVector bv = LongVector.fromArray(SPECIES, b, i);
2511
av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2512
}
2513
}
2514
2515
assertArraysEquals(r, a, b, Long256VectorTests::MAX);
2516
}
2517
static long max(long a, long b) {
2518
return (long)(Math.max(a, b));
2519
}
2520
2521
@Test(dataProvider = "longBinaryOpProvider")
2522
static void maxLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2523
long[] a = fa.apply(SPECIES.length());
2524
long[] b = fb.apply(SPECIES.length());
2525
long[] r = fr.apply(SPECIES.length());
2526
2527
for (int i = 0; i < a.length; i += SPECIES.length()) {
2528
LongVector av = LongVector.fromArray(SPECIES, a, i);
2529
LongVector bv = LongVector.fromArray(SPECIES, b, i);
2530
av.max(bv).intoArray(r, i);
2531
}
2532
2533
assertArraysEquals(r, a, b, Long256VectorTests::max);
2534
}
2535
2536
@Test(dataProvider = "longBinaryOpProvider")
2537
static void MINLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2538
long[] a = fa.apply(SPECIES.length());
2539
long[] b = fb.apply(SPECIES.length());
2540
long[] r = fr.apply(SPECIES.length());
2541
2542
for (int i = 0; i < a.length; i += SPECIES.length()) {
2543
LongVector av = LongVector.fromArray(SPECIES, a, i);
2544
av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
2545
}
2546
2547
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::MIN);
2548
}
2549
2550
@Test(dataProvider = "longBinaryOpProvider")
2551
static void minLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2552
long[] a = fa.apply(SPECIES.length());
2553
long[] b = fb.apply(SPECIES.length());
2554
long[] r = fr.apply(SPECIES.length());
2555
2556
for (int i = 0; i < a.length; i += SPECIES.length()) {
2557
LongVector av = LongVector.fromArray(SPECIES, a, i);
2558
av.min(b[i]).intoArray(r, i);
2559
}
2560
2561
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::min);
2562
}
2563
2564
@Test(dataProvider = "longBinaryOpProvider")
2565
static void MAXLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2566
long[] a = fa.apply(SPECIES.length());
2567
long[] b = fb.apply(SPECIES.length());
2568
long[] r = fr.apply(SPECIES.length());
2569
2570
for (int i = 0; i < a.length; i += SPECIES.length()) {
2571
LongVector av = LongVector.fromArray(SPECIES, a, i);
2572
av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
2573
}
2574
2575
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::MAX);
2576
}
2577
2578
@Test(dataProvider = "longBinaryOpProvider")
2579
static void maxLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2580
long[] a = fa.apply(SPECIES.length());
2581
long[] b = fb.apply(SPECIES.length());
2582
long[] r = fr.apply(SPECIES.length());
2583
2584
for (int i = 0; i < a.length; i += SPECIES.length()) {
2585
LongVector av = LongVector.fromArray(SPECIES, a, i);
2586
av.max(b[i]).intoArray(r, i);
2587
}
2588
2589
assertBroadcastArraysEquals(r, a, b, Long256VectorTests::max);
2590
}
2591
2592
static long ANDReduce(long[] a, int idx) {
2593
long res = -1;
2594
for (int i = idx; i < (idx + SPECIES.length()); i++) {
2595
res &= a[i];
2596
}
2597
2598
return res;
2599
}
2600
2601
static long ANDReduceAll(long[] a) {
2602
long res = -1;
2603
for (int i = 0; i < a.length; i += SPECIES.length()) {
2604
res &= ANDReduce(a, i);
2605
}
2606
2607
return res;
2608
}
2609
2610
2611
@Test(dataProvider = "longUnaryOpProvider")
2612
static void ANDReduceLong256VectorTests(IntFunction<long[]> fa) {
2613
long[] a = fa.apply(SPECIES.length());
2614
long[] r = fr.apply(SPECIES.length());
2615
long ra = -1;
2616
2617
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2618
for (int i = 0; i < a.length; i += SPECIES.length()) {
2619
LongVector av = LongVector.fromArray(SPECIES, a, i);
2620
r[i] = av.reduceLanes(VectorOperators.AND);
2621
}
2622
}
2623
2624
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2625
ra = -1;
2626
for (int i = 0; i < a.length; i += SPECIES.length()) {
2627
LongVector av = LongVector.fromArray(SPECIES, a, i);
2628
ra &= av.reduceLanes(VectorOperators.AND);
2629
}
2630
}
2631
2632
assertReductionArraysEquals(r, ra, a,
2633
Long256VectorTests::ANDReduce, Long256VectorTests::ANDReduceAll);
2634
}
2635
2636
2637
static long ANDReduceMasked(long[] a, int idx, boolean[] mask) {
2638
long res = -1;
2639
for (int i = idx; i < (idx + SPECIES.length()); i++) {
2640
if (mask[i % SPECIES.length()])
2641
res &= a[i];
2642
}
2643
2644
return res;
2645
}
2646
2647
static long ANDReduceAllMasked(long[] a, boolean[] mask) {
2648
long res = -1;
2649
for (int i = 0; i < a.length; i += SPECIES.length()) {
2650
res &= ANDReduceMasked(a, i, mask);
2651
}
2652
2653
return res;
2654
}
2655
2656
2657
@Test(dataProvider = "longUnaryOpMaskProvider")
2658
static void ANDReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
2659
long[] a = fa.apply(SPECIES.length());
2660
long[] r = fr.apply(SPECIES.length());
2661
boolean[] mask = fm.apply(SPECIES.length());
2662
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2663
long ra = -1;
2664
2665
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2666
for (int i = 0; i < a.length; i += SPECIES.length()) {
2667
LongVector av = LongVector.fromArray(SPECIES, a, i);
2668
r[i] = av.reduceLanes(VectorOperators.AND, vmask);
2669
}
2670
}
2671
2672
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2673
ra = -1;
2674
for (int i = 0; i < a.length; i += SPECIES.length()) {
2675
LongVector av = LongVector.fromArray(SPECIES, a, i);
2676
ra &= av.reduceLanes(VectorOperators.AND, vmask);
2677
}
2678
}
2679
2680
assertReductionArraysEqualsMasked(r, ra, a, mask,
2681
Long256VectorTests::ANDReduceMasked, Long256VectorTests::ANDReduceAllMasked);
2682
}
2683
2684
2685
static long ORReduce(long[] a, int idx) {
2686
long res = 0;
2687
for (int i = idx; i < (idx + SPECIES.length()); i++) {
2688
res |= a[i];
2689
}
2690
2691
return res;
2692
}
2693
2694
static long ORReduceAll(long[] a) {
2695
long res = 0;
2696
for (int i = 0; i < a.length; i += SPECIES.length()) {
2697
res |= ORReduce(a, i);
2698
}
2699
2700
return res;
2701
}
2702
2703
2704
@Test(dataProvider = "longUnaryOpProvider")
2705
static void ORReduceLong256VectorTests(IntFunction<long[]> fa) {
2706
long[] a = fa.apply(SPECIES.length());
2707
long[] r = fr.apply(SPECIES.length());
2708
long ra = 0;
2709
2710
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2711
for (int i = 0; i < a.length; i += SPECIES.length()) {
2712
LongVector av = LongVector.fromArray(SPECIES, a, i);
2713
r[i] = av.reduceLanes(VectorOperators.OR);
2714
}
2715
}
2716
2717
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2718
ra = 0;
2719
for (int i = 0; i < a.length; i += SPECIES.length()) {
2720
LongVector av = LongVector.fromArray(SPECIES, a, i);
2721
ra |= av.reduceLanes(VectorOperators.OR);
2722
}
2723
}
2724
2725
assertReductionArraysEquals(r, ra, a,
2726
Long256VectorTests::ORReduce, Long256VectorTests::ORReduceAll);
2727
}
2728
2729
2730
static long ORReduceMasked(long[] a, int idx, boolean[] mask) {
2731
long res = 0;
2732
for (int i = idx; i < (idx + SPECIES.length()); i++) {
2733
if (mask[i % SPECIES.length()])
2734
res |= a[i];
2735
}
2736
2737
return res;
2738
}
2739
2740
static long ORReduceAllMasked(long[] a, boolean[] mask) {
2741
long res = 0;
2742
for (int i = 0; i < a.length; i += SPECIES.length()) {
2743
res |= ORReduceMasked(a, i, mask);
2744
}
2745
2746
return res;
2747
}
2748
2749
2750
@Test(dataProvider = "longUnaryOpMaskProvider")
2751
static void ORReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
2752
long[] a = fa.apply(SPECIES.length());
2753
long[] r = fr.apply(SPECIES.length());
2754
boolean[] mask = fm.apply(SPECIES.length());
2755
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2756
long ra = 0;
2757
2758
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2759
for (int i = 0; i < a.length; i += SPECIES.length()) {
2760
LongVector av = LongVector.fromArray(SPECIES, a, i);
2761
r[i] = av.reduceLanes(VectorOperators.OR, vmask);
2762
}
2763
}
2764
2765
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2766
ra = 0;
2767
for (int i = 0; i < a.length; i += SPECIES.length()) {
2768
LongVector av = LongVector.fromArray(SPECIES, a, i);
2769
ra |= av.reduceLanes(VectorOperators.OR, vmask);
2770
}
2771
}
2772
2773
assertReductionArraysEqualsMasked(r, ra, a, mask,
2774
Long256VectorTests::ORReduceMasked, Long256VectorTests::ORReduceAllMasked);
2775
}
2776
2777
2778
static long XORReduce(long[] a, int idx) {
2779
long res = 0;
2780
for (int i = idx; i < (idx + SPECIES.length()); i++) {
2781
res ^= a[i];
2782
}
2783
2784
return res;
2785
}
2786
2787
static long XORReduceAll(long[] a) {
2788
long res = 0;
2789
for (int i = 0; i < a.length; i += SPECIES.length()) {
2790
res ^= XORReduce(a, i);
2791
}
2792
2793
return res;
2794
}
2795
2796
2797
@Test(dataProvider = "longUnaryOpProvider")
2798
static void XORReduceLong256VectorTests(IntFunction<long[]> fa) {
2799
long[] a = fa.apply(SPECIES.length());
2800
long[] r = fr.apply(SPECIES.length());
2801
long ra = 0;
2802
2803
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2804
for (int i = 0; i < a.length; i += SPECIES.length()) {
2805
LongVector av = LongVector.fromArray(SPECIES, a, i);
2806
r[i] = av.reduceLanes(VectorOperators.XOR);
2807
}
2808
}
2809
2810
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2811
ra = 0;
2812
for (int i = 0; i < a.length; i += SPECIES.length()) {
2813
LongVector av = LongVector.fromArray(SPECIES, a, i);
2814
ra ^= av.reduceLanes(VectorOperators.XOR);
2815
}
2816
}
2817
2818
assertReductionArraysEquals(r, ra, a,
2819
Long256VectorTests::XORReduce, Long256VectorTests::XORReduceAll);
2820
}
2821
2822
2823
static long XORReduceMasked(long[] a, int idx, boolean[] mask) {
2824
long res = 0;
2825
for (int i = idx; i < (idx + SPECIES.length()); i++) {
2826
if (mask[i % SPECIES.length()])
2827
res ^= a[i];
2828
}
2829
2830
return res;
2831
}
2832
2833
static long XORReduceAllMasked(long[] a, boolean[] mask) {
2834
long res = 0;
2835
for (int i = 0; i < a.length; i += SPECIES.length()) {
2836
res ^= XORReduceMasked(a, i, mask);
2837
}
2838
2839
return res;
2840
}
2841
2842
2843
@Test(dataProvider = "longUnaryOpMaskProvider")
2844
static void XORReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
2845
long[] a = fa.apply(SPECIES.length());
2846
long[] r = fr.apply(SPECIES.length());
2847
boolean[] mask = fm.apply(SPECIES.length());
2848
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2849
long ra = 0;
2850
2851
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2852
for (int i = 0; i < a.length; i += SPECIES.length()) {
2853
LongVector av = LongVector.fromArray(SPECIES, a, i);
2854
r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
2855
}
2856
}
2857
2858
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2859
ra = 0;
2860
for (int i = 0; i < a.length; i += SPECIES.length()) {
2861
LongVector av = LongVector.fromArray(SPECIES, a, i);
2862
ra ^= av.reduceLanes(VectorOperators.XOR, vmask);
2863
}
2864
}
2865
2866
assertReductionArraysEqualsMasked(r, ra, a, mask,
2867
Long256VectorTests::XORReduceMasked, Long256VectorTests::XORReduceAllMasked);
2868
}
2869
2870
static long ADDReduce(long[] a, int idx) {
2871
long res = 0;
2872
for (int i = idx; i < (idx + SPECIES.length()); i++) {
2873
res += a[i];
2874
}
2875
2876
return res;
2877
}
2878
2879
static long ADDReduceAll(long[] a) {
2880
long res = 0;
2881
for (int i = 0; i < a.length; i += SPECIES.length()) {
2882
res += ADDReduce(a, i);
2883
}
2884
2885
return res;
2886
}
2887
@Test(dataProvider = "longUnaryOpProvider")
2888
static void ADDReduceLong256VectorTests(IntFunction<long[]> fa) {
2889
long[] a = fa.apply(SPECIES.length());
2890
long[] r = fr.apply(SPECIES.length());
2891
long ra = 0;
2892
2893
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2894
for (int i = 0; i < a.length; i += SPECIES.length()) {
2895
LongVector av = LongVector.fromArray(SPECIES, a, i);
2896
r[i] = av.reduceLanes(VectorOperators.ADD);
2897
}
2898
}
2899
2900
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2901
ra = 0;
2902
for (int i = 0; i < a.length; i += SPECIES.length()) {
2903
LongVector av = LongVector.fromArray(SPECIES, a, i);
2904
ra += av.reduceLanes(VectorOperators.ADD);
2905
}
2906
}
2907
2908
assertReductionArraysEquals(r, ra, a,
2909
Long256VectorTests::ADDReduce, Long256VectorTests::ADDReduceAll);
2910
}
2911
static long ADDReduceMasked(long[] a, int idx, boolean[] mask) {
2912
long res = 0;
2913
for (int i = idx; i < (idx + SPECIES.length()); i++) {
2914
if (mask[i % SPECIES.length()])
2915
res += a[i];
2916
}
2917
2918
return res;
2919
}
2920
2921
static long ADDReduceAllMasked(long[] a, boolean[] mask) {
2922
long res = 0;
2923
for (int i = 0; i < a.length; i += SPECIES.length()) {
2924
res += ADDReduceMasked(a, i, mask);
2925
}
2926
2927
return res;
2928
}
2929
@Test(dataProvider = "longUnaryOpMaskProvider")
2930
static void ADDReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
2931
long[] a = fa.apply(SPECIES.length());
2932
long[] r = fr.apply(SPECIES.length());
2933
boolean[] mask = fm.apply(SPECIES.length());
2934
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2935
long ra = 0;
2936
2937
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2938
for (int i = 0; i < a.length; i += SPECIES.length()) {
2939
LongVector av = LongVector.fromArray(SPECIES, a, i);
2940
r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
2941
}
2942
}
2943
2944
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2945
ra = 0;
2946
for (int i = 0; i < a.length; i += SPECIES.length()) {
2947
LongVector av = LongVector.fromArray(SPECIES, a, i);
2948
ra += av.reduceLanes(VectorOperators.ADD, vmask);
2949
}
2950
}
2951
2952
assertReductionArraysEqualsMasked(r, ra, a, mask,
2953
Long256VectorTests::ADDReduceMasked, Long256VectorTests::ADDReduceAllMasked);
2954
}
2955
static long MULReduce(long[] a, int idx) {
2956
long res = 1;
2957
for (int i = idx; i < (idx + SPECIES.length()); i++) {
2958
res *= a[i];
2959
}
2960
2961
return res;
2962
}
2963
2964
static long MULReduceAll(long[] a) {
2965
long res = 1;
2966
for (int i = 0; i < a.length; i += SPECIES.length()) {
2967
res *= MULReduce(a, i);
2968
}
2969
2970
return res;
2971
}
2972
@Test(dataProvider = "longUnaryOpProvider")
2973
static void MULReduceLong256VectorTests(IntFunction<long[]> fa) {
2974
long[] a = fa.apply(SPECIES.length());
2975
long[] r = fr.apply(SPECIES.length());
2976
long ra = 1;
2977
2978
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2979
for (int i = 0; i < a.length; i += SPECIES.length()) {
2980
LongVector av = LongVector.fromArray(SPECIES, a, i);
2981
r[i] = av.reduceLanes(VectorOperators.MUL);
2982
}
2983
}
2984
2985
for (int ic = 0; ic < INVOC_COUNT; ic++) {
2986
ra = 1;
2987
for (int i = 0; i < a.length; i += SPECIES.length()) {
2988
LongVector av = LongVector.fromArray(SPECIES, a, i);
2989
ra *= av.reduceLanes(VectorOperators.MUL);
2990
}
2991
}
2992
2993
assertReductionArraysEquals(r, ra, a,
2994
Long256VectorTests::MULReduce, Long256VectorTests::MULReduceAll);
2995
}
2996
static long MULReduceMasked(long[] a, int idx, boolean[] mask) {
2997
long res = 1;
2998
for (int i = idx; i < (idx + SPECIES.length()); i++) {
2999
if (mask[i % SPECIES.length()])
3000
res *= a[i];
3001
}
3002
3003
return res;
3004
}
3005
3006
static long MULReduceAllMasked(long[] a, boolean[] mask) {
3007
long res = 1;
3008
for (int i = 0; i < a.length; i += SPECIES.length()) {
3009
res *= MULReduceMasked(a, i, mask);
3010
}
3011
3012
return res;
3013
}
3014
@Test(dataProvider = "longUnaryOpMaskProvider")
3015
static void MULReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3016
long[] a = fa.apply(SPECIES.length());
3017
long[] r = fr.apply(SPECIES.length());
3018
boolean[] mask = fm.apply(SPECIES.length());
3019
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3020
long ra = 1;
3021
3022
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3023
for (int i = 0; i < a.length; i += SPECIES.length()) {
3024
LongVector av = LongVector.fromArray(SPECIES, a, i);
3025
r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3026
}
3027
}
3028
3029
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3030
ra = 1;
3031
for (int i = 0; i < a.length; i += SPECIES.length()) {
3032
LongVector av = LongVector.fromArray(SPECIES, a, i);
3033
ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3034
}
3035
}
3036
3037
assertReductionArraysEqualsMasked(r, ra, a, mask,
3038
Long256VectorTests::MULReduceMasked, Long256VectorTests::MULReduceAllMasked);
3039
}
3040
static long MINReduce(long[] a, int idx) {
3041
long res = Long.MAX_VALUE;
3042
for (int i = idx; i < (idx + SPECIES.length()); i++) {
3043
res = (long)Math.min(res, a[i]);
3044
}
3045
3046
return res;
3047
}
3048
3049
static long MINReduceAll(long[] a) {
3050
long res = Long.MAX_VALUE;
3051
for (int i = 0; i < a.length; i++) {
3052
res = (long)Math.min(res, a[i]);
3053
}
3054
3055
return res;
3056
}
3057
@Test(dataProvider = "longUnaryOpProvider")
3058
static void MINReduceLong256VectorTests(IntFunction<long[]> fa) {
3059
long[] a = fa.apply(SPECIES.length());
3060
long[] r = fr.apply(SPECIES.length());
3061
long ra = Long.MAX_VALUE;
3062
3063
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3064
for (int i = 0; i < a.length; i += SPECIES.length()) {
3065
LongVector av = LongVector.fromArray(SPECIES, a, i);
3066
r[i] = av.reduceLanes(VectorOperators.MIN);
3067
}
3068
}
3069
3070
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3071
ra = Long.MAX_VALUE;
3072
for (int i = 0; i < a.length; i += SPECIES.length()) {
3073
LongVector av = LongVector.fromArray(SPECIES, a, i);
3074
ra = (long)Math.min(ra, av.reduceLanes(VectorOperators.MIN));
3075
}
3076
}
3077
3078
assertReductionArraysEquals(r, ra, a,
3079
Long256VectorTests::MINReduce, Long256VectorTests::MINReduceAll);
3080
}
3081
static long MINReduceMasked(long[] a, int idx, boolean[] mask) {
3082
long res = Long.MAX_VALUE;
3083
for (int i = idx; i < (idx + SPECIES.length()); i++) {
3084
if(mask[i % SPECIES.length()])
3085
res = (long)Math.min(res, a[i]);
3086
}
3087
3088
return res;
3089
}
3090
3091
static long MINReduceAllMasked(long[] a, boolean[] mask) {
3092
long res = Long.MAX_VALUE;
3093
for (int i = 0; i < a.length; i++) {
3094
if(mask[i % SPECIES.length()])
3095
res = (long)Math.min(res, a[i]);
3096
}
3097
3098
return res;
3099
}
3100
@Test(dataProvider = "longUnaryOpMaskProvider")
3101
static void MINReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3102
long[] a = fa.apply(SPECIES.length());
3103
long[] r = fr.apply(SPECIES.length());
3104
boolean[] mask = fm.apply(SPECIES.length());
3105
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3106
long ra = Long.MAX_VALUE;
3107
3108
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3109
for (int i = 0; i < a.length; i += SPECIES.length()) {
3110
LongVector av = LongVector.fromArray(SPECIES, a, i);
3111
r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
3112
}
3113
}
3114
3115
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3116
ra = Long.MAX_VALUE;
3117
for (int i = 0; i < a.length; i += SPECIES.length()) {
3118
LongVector av = LongVector.fromArray(SPECIES, a, i);
3119
ra = (long)Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
3120
}
3121
}
3122
3123
assertReductionArraysEqualsMasked(r, ra, a, mask,
3124
Long256VectorTests::MINReduceMasked, Long256VectorTests::MINReduceAllMasked);
3125
}
3126
static long MAXReduce(long[] a, int idx) {
3127
long res = Long.MIN_VALUE;
3128
for (int i = idx; i < (idx + SPECIES.length()); i++) {
3129
res = (long)Math.max(res, a[i]);
3130
}
3131
3132
return res;
3133
}
3134
3135
static long MAXReduceAll(long[] a) {
3136
long res = Long.MIN_VALUE;
3137
for (int i = 0; i < a.length; i++) {
3138
res = (long)Math.max(res, a[i]);
3139
}
3140
3141
return res;
3142
}
3143
@Test(dataProvider = "longUnaryOpProvider")
3144
static void MAXReduceLong256VectorTests(IntFunction<long[]> fa) {
3145
long[] a = fa.apply(SPECIES.length());
3146
long[] r = fr.apply(SPECIES.length());
3147
long ra = Long.MIN_VALUE;
3148
3149
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3150
for (int i = 0; i < a.length; i += SPECIES.length()) {
3151
LongVector av = LongVector.fromArray(SPECIES, a, i);
3152
r[i] = av.reduceLanes(VectorOperators.MAX);
3153
}
3154
}
3155
3156
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3157
ra = Long.MIN_VALUE;
3158
for (int i = 0; i < a.length; i += SPECIES.length()) {
3159
LongVector av = LongVector.fromArray(SPECIES, a, i);
3160
ra = (long)Math.max(ra, av.reduceLanes(VectorOperators.MAX));
3161
}
3162
}
3163
3164
assertReductionArraysEquals(r, ra, a,
3165
Long256VectorTests::MAXReduce, Long256VectorTests::MAXReduceAll);
3166
}
3167
static long MAXReduceMasked(long[] a, int idx, boolean[] mask) {
3168
long res = Long.MIN_VALUE;
3169
for (int i = idx; i < (idx + SPECIES.length()); i++) {
3170
if(mask[i % SPECIES.length()])
3171
res = (long)Math.max(res, a[i]);
3172
}
3173
3174
return res;
3175
}
3176
3177
static long MAXReduceAllMasked(long[] a, boolean[] mask) {
3178
long res = Long.MIN_VALUE;
3179
for (int i = 0; i < a.length; i++) {
3180
if(mask[i % SPECIES.length()])
3181
res = (long)Math.max(res, a[i]);
3182
}
3183
3184
return res;
3185
}
3186
@Test(dataProvider = "longUnaryOpMaskProvider")
3187
static void MAXReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3188
long[] a = fa.apply(SPECIES.length());
3189
long[] r = fr.apply(SPECIES.length());
3190
boolean[] mask = fm.apply(SPECIES.length());
3191
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3192
long ra = Long.MIN_VALUE;
3193
3194
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3195
for (int i = 0; i < a.length; i += SPECIES.length()) {
3196
LongVector av = LongVector.fromArray(SPECIES, a, i);
3197
r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
3198
}
3199
}
3200
3201
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3202
ra = Long.MIN_VALUE;
3203
for (int i = 0; i < a.length; i += SPECIES.length()) {
3204
LongVector av = LongVector.fromArray(SPECIES, a, i);
3205
ra = (long)Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
3206
}
3207
}
3208
3209
assertReductionArraysEqualsMasked(r, ra, a, mask,
3210
Long256VectorTests::MAXReduceMasked, Long256VectorTests::MAXReduceAllMasked);
3211
}
3212
3213
static boolean anyTrue(boolean[] a, int idx) {
3214
boolean res = false;
3215
for (int i = idx; i < (idx + SPECIES.length()); i++) {
3216
res |= a[i];
3217
}
3218
3219
return res;
3220
}
3221
3222
3223
@Test(dataProvider = "boolUnaryOpProvider")
3224
static void anyTrueLong256VectorTests(IntFunction<boolean[]> fm) {
3225
boolean[] mask = fm.apply(SPECIES.length());
3226
boolean[] r = fmr.apply(SPECIES.length());
3227
3228
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3229
for (int i = 0; i < mask.length; i += SPECIES.length()) {
3230
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);
3231
r[i] = vmask.anyTrue();
3232
}
3233
}
3234
3235
assertReductionBoolArraysEquals(r, mask, Long256VectorTests::anyTrue);
3236
}
3237
3238
3239
static boolean allTrue(boolean[] a, int idx) {
3240
boolean res = true;
3241
for (int i = idx; i < (idx + SPECIES.length()); i++) {
3242
res &= a[i];
3243
}
3244
3245
return res;
3246
}
3247
3248
3249
@Test(dataProvider = "boolUnaryOpProvider")
3250
static void allTrueLong256VectorTests(IntFunction<boolean[]> fm) {
3251
boolean[] mask = fm.apply(SPECIES.length());
3252
boolean[] r = fmr.apply(SPECIES.length());
3253
3254
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3255
for (int i = 0; i < mask.length; i += SPECIES.length()) {
3256
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);
3257
r[i] = vmask.allTrue();
3258
}
3259
}
3260
3261
assertReductionBoolArraysEquals(r, mask, Long256VectorTests::allTrue);
3262
}
3263
3264
3265
@Test(dataProvider = "longUnaryOpProvider")
3266
static void withLong256VectorTests(IntFunction<long []> fa) {
3267
long[] a = fa.apply(SPECIES.length());
3268
long[] r = fr.apply(SPECIES.length());
3269
3270
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3271
for (int i = 0; i < a.length; i += SPECIES.length()) {
3272
LongVector av = LongVector.fromArray(SPECIES, a, i);
3273
av.withLane(0, (long)4).intoArray(r, i);
3274
}
3275
}
3276
3277
assertInsertArraysEquals(r, a, (long)4, 0);
3278
}
3279
static boolean testIS_DEFAULT(long a) {
3280
return bits(a)==0;
3281
}
3282
3283
@Test(dataProvider = "longTestOpProvider")
3284
static void IS_DEFAULTLong256VectorTests(IntFunction<long[]> fa) {
3285
long[] a = fa.apply(SPECIES.length());
3286
3287
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3288
for (int i = 0; i < a.length; i += SPECIES.length()) {
3289
LongVector av = LongVector.fromArray(SPECIES, a, i);
3290
VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT);
3291
3292
// Check results as part of computation.
3293
for (int j = 0; j < SPECIES.length(); j++) {
3294
Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3295
}
3296
}
3297
}
3298
}
3299
3300
@Test(dataProvider = "longTestOpMaskProvider")
3301
static void IS_DEFAULTMaskedLong256VectorTestsSmokeTest(IntFunction<long[]> fa,
3302
IntFunction<boolean[]> fm) {
3303
long[] a = fa.apply(SPECIES.length());
3304
boolean[] mask = fm.apply(SPECIES.length());
3305
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3306
3307
for (int i = 0; i < a.length; i += SPECIES.length()) {
3308
LongVector av = LongVector.fromArray(SPECIES, a, i);
3309
VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3310
3311
// Check results as part of computation.
3312
for (int j = 0; j < SPECIES.length(); j++) {
3313
Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3314
}
3315
}
3316
}
3317
static boolean testIS_NEGATIVE(long a) {
3318
return bits(a)<0;
3319
}
3320
3321
@Test(dataProvider = "longTestOpProvider")
3322
static void IS_NEGATIVELong256VectorTests(IntFunction<long[]> fa) {
3323
long[] a = fa.apply(SPECIES.length());
3324
3325
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3326
for (int i = 0; i < a.length; i += SPECIES.length()) {
3327
LongVector av = LongVector.fromArray(SPECIES, a, i);
3328
VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE);
3329
3330
// Check results as part of computation.
3331
for (int j = 0; j < SPECIES.length(); j++) {
3332
Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3333
}
3334
}
3335
}
3336
}
3337
3338
@Test(dataProvider = "longTestOpMaskProvider")
3339
static void IS_NEGATIVEMaskedLong256VectorTestsSmokeTest(IntFunction<long[]> fa,
3340
IntFunction<boolean[]> fm) {
3341
long[] a = fa.apply(SPECIES.length());
3342
boolean[] mask = fm.apply(SPECIES.length());
3343
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3344
3345
for (int i = 0; i < a.length; i += SPECIES.length()) {
3346
LongVector av = LongVector.fromArray(SPECIES, a, i);
3347
VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3348
3349
// Check results as part of computation.
3350
for (int j = 0; j < SPECIES.length(); j++) {
3351
Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3352
}
3353
}
3354
}
3355
3356
3357
3358
3359
@Test(dataProvider = "longCompareOpProvider")
3360
static void LTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3361
long[] a = fa.apply(SPECIES.length());
3362
long[] b = fb.apply(SPECIES.length());
3363
3364
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3365
for (int i = 0; i < a.length; i += SPECIES.length()) {
3366
LongVector av = LongVector.fromArray(SPECIES, a, i);
3367
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3368
VectorMask<Long> mv = av.compare(VectorOperators.LT, bv);
3369
3370
// Check results as part of computation.
3371
for (int j = 0; j < SPECIES.length(); j++) {
3372
Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3373
}
3374
}
3375
}
3376
}
3377
3378
3379
@Test(dataProvider = "longCompareOpProvider")
3380
static void ltLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3381
long[] a = fa.apply(SPECIES.length());
3382
long[] b = fb.apply(SPECIES.length());
3383
3384
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3385
for (int i = 0; i < a.length; i += SPECIES.length()) {
3386
LongVector av = LongVector.fromArray(SPECIES, a, i);
3387
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3388
VectorMask<Long> mv = av.lt(bv);
3389
3390
// Check results as part of computation.
3391
for (int j = 0; j < SPECIES.length(); j++) {
3392
Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3393
}
3394
}
3395
}
3396
}
3397
3398
@Test(dataProvider = "longCompareOpMaskProvider")
3399
static void LTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3400
IntFunction<boolean[]> fm) {
3401
long[] a = fa.apply(SPECIES.length());
3402
long[] b = fb.apply(SPECIES.length());
3403
boolean[] mask = fm.apply(SPECIES.length());
3404
3405
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3406
3407
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3408
for (int i = 0; i < a.length; i += SPECIES.length()) {
3409
LongVector av = LongVector.fromArray(SPECIES, a, i);
3410
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3411
VectorMask<Long> mv = av.compare(VectorOperators.LT, bv, vmask);
3412
3413
// Check results as part of computation.
3414
for (int j = 0; j < SPECIES.length(); j++) {
3415
Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3416
}
3417
}
3418
}
3419
}
3420
3421
3422
@Test(dataProvider = "longCompareOpProvider")
3423
static void GTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3424
long[] a = fa.apply(SPECIES.length());
3425
long[] b = fb.apply(SPECIES.length());
3426
3427
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3428
for (int i = 0; i < a.length; i += SPECIES.length()) {
3429
LongVector av = LongVector.fromArray(SPECIES, a, i);
3430
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3431
VectorMask<Long> mv = av.compare(VectorOperators.GT, bv);
3432
3433
// Check results as part of computation.
3434
for (int j = 0; j < SPECIES.length(); j++) {
3435
Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3436
}
3437
}
3438
}
3439
}
3440
3441
@Test(dataProvider = "longCompareOpMaskProvider")
3442
static void GTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3443
IntFunction<boolean[]> fm) {
3444
long[] a = fa.apply(SPECIES.length());
3445
long[] b = fb.apply(SPECIES.length());
3446
boolean[] mask = fm.apply(SPECIES.length());
3447
3448
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3449
3450
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3451
for (int i = 0; i < a.length; i += SPECIES.length()) {
3452
LongVector av = LongVector.fromArray(SPECIES, a, i);
3453
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3454
VectorMask<Long> mv = av.compare(VectorOperators.GT, bv, vmask);
3455
3456
// Check results as part of computation.
3457
for (int j = 0; j < SPECIES.length(); j++) {
3458
Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
3459
}
3460
}
3461
}
3462
}
3463
3464
3465
@Test(dataProvider = "longCompareOpProvider")
3466
static void EQLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3467
long[] a = fa.apply(SPECIES.length());
3468
long[] b = fb.apply(SPECIES.length());
3469
3470
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3471
for (int i = 0; i < a.length; i += SPECIES.length()) {
3472
LongVector av = LongVector.fromArray(SPECIES, a, i);
3473
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3474
VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv);
3475
3476
// Check results as part of computation.
3477
for (int j = 0; j < SPECIES.length(); j++) {
3478
Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3479
}
3480
}
3481
}
3482
}
3483
3484
3485
@Test(dataProvider = "longCompareOpProvider")
3486
static void eqLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3487
long[] a = fa.apply(SPECIES.length());
3488
long[] b = fb.apply(SPECIES.length());
3489
3490
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3491
for (int i = 0; i < a.length; i += SPECIES.length()) {
3492
LongVector av = LongVector.fromArray(SPECIES, a, i);
3493
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3494
VectorMask<Long> mv = av.eq(bv);
3495
3496
// Check results as part of computation.
3497
for (int j = 0; j < SPECIES.length(); j++) {
3498
Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3499
}
3500
}
3501
}
3502
}
3503
3504
@Test(dataProvider = "longCompareOpMaskProvider")
3505
static void EQLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3506
IntFunction<boolean[]> fm) {
3507
long[] a = fa.apply(SPECIES.length());
3508
long[] b = fb.apply(SPECIES.length());
3509
boolean[] mask = fm.apply(SPECIES.length());
3510
3511
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3512
3513
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3514
for (int i = 0; i < a.length; i += SPECIES.length()) {
3515
LongVector av = LongVector.fromArray(SPECIES, a, i);
3516
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3517
VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv, vmask);
3518
3519
// Check results as part of computation.
3520
for (int j = 0; j < SPECIES.length(); j++) {
3521
Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
3522
}
3523
}
3524
}
3525
}
3526
3527
3528
@Test(dataProvider = "longCompareOpProvider")
3529
static void NELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3530
long[] a = fa.apply(SPECIES.length());
3531
long[] b = fb.apply(SPECIES.length());
3532
3533
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3534
for (int i = 0; i < a.length; i += SPECIES.length()) {
3535
LongVector av = LongVector.fromArray(SPECIES, a, i);
3536
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3537
VectorMask<Long> mv = av.compare(VectorOperators.NE, bv);
3538
3539
// Check results as part of computation.
3540
for (int j = 0; j < SPECIES.length(); j++) {
3541
Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
3542
}
3543
}
3544
}
3545
}
3546
3547
@Test(dataProvider = "longCompareOpMaskProvider")
3548
static void NELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3549
IntFunction<boolean[]> fm) {
3550
long[] a = fa.apply(SPECIES.length());
3551
long[] b = fb.apply(SPECIES.length());
3552
boolean[] mask = fm.apply(SPECIES.length());
3553
3554
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3555
3556
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3557
for (int i = 0; i < a.length; i += SPECIES.length()) {
3558
LongVector av = LongVector.fromArray(SPECIES, a, i);
3559
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3560
VectorMask<Long> mv = av.compare(VectorOperators.NE, bv, vmask);
3561
3562
// Check results as part of computation.
3563
for (int j = 0; j < SPECIES.length(); j++) {
3564
Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
3565
}
3566
}
3567
}
3568
}
3569
3570
3571
@Test(dataProvider = "longCompareOpProvider")
3572
static void LELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3573
long[] a = fa.apply(SPECIES.length());
3574
long[] b = fb.apply(SPECIES.length());
3575
3576
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3577
for (int i = 0; i < a.length; i += SPECIES.length()) {
3578
LongVector av = LongVector.fromArray(SPECIES, a, i);
3579
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3580
VectorMask<Long> mv = av.compare(VectorOperators.LE, bv);
3581
3582
// Check results as part of computation.
3583
for (int j = 0; j < SPECIES.length(); j++) {
3584
Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
3585
}
3586
}
3587
}
3588
}
3589
3590
@Test(dataProvider = "longCompareOpMaskProvider")
3591
static void LELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3592
IntFunction<boolean[]> fm) {
3593
long[] a = fa.apply(SPECIES.length());
3594
long[] b = fb.apply(SPECIES.length());
3595
boolean[] mask = fm.apply(SPECIES.length());
3596
3597
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3598
3599
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3600
for (int i = 0; i < a.length; i += SPECIES.length()) {
3601
LongVector av = LongVector.fromArray(SPECIES, a, i);
3602
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3603
VectorMask<Long> mv = av.compare(VectorOperators.LE, bv, vmask);
3604
3605
// Check results as part of computation.
3606
for (int j = 0; j < SPECIES.length(); j++) {
3607
Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
3608
}
3609
}
3610
}
3611
}
3612
3613
3614
@Test(dataProvider = "longCompareOpProvider")
3615
static void GELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3616
long[] a = fa.apply(SPECIES.length());
3617
long[] b = fb.apply(SPECIES.length());
3618
3619
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3620
for (int i = 0; i < a.length; i += SPECIES.length()) {
3621
LongVector av = LongVector.fromArray(SPECIES, a, i);
3622
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3623
VectorMask<Long> mv = av.compare(VectorOperators.GE, bv);
3624
3625
// Check results as part of computation.
3626
for (int j = 0; j < SPECIES.length(); j++) {
3627
Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
3628
}
3629
}
3630
}
3631
}
3632
3633
@Test(dataProvider = "longCompareOpMaskProvider")
3634
static void GELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3635
IntFunction<boolean[]> fm) {
3636
long[] a = fa.apply(SPECIES.length());
3637
long[] b = fb.apply(SPECIES.length());
3638
boolean[] mask = fm.apply(SPECIES.length());
3639
3640
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3641
3642
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3643
for (int i = 0; i < a.length; i += SPECIES.length()) {
3644
LongVector av = LongVector.fromArray(SPECIES, a, i);
3645
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3646
VectorMask<Long> mv = av.compare(VectorOperators.GE, bv, vmask);
3647
3648
// Check results as part of computation.
3649
for (int j = 0; j < SPECIES.length(); j++) {
3650
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
3651
}
3652
}
3653
}
3654
}
3655
3656
3657
3658
@Test(dataProvider = "longCompareOpProvider")
3659
static void UNSIGNED_LTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3660
long[] a = fa.apply(SPECIES.length());
3661
long[] b = fb.apply(SPECIES.length());
3662
3663
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3664
for (int i = 0; i < a.length; i += SPECIES.length()) {
3665
LongVector av = LongVector.fromArray(SPECIES, a, i);
3666
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3667
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
3668
3669
// Check results as part of computation.
3670
for (int j = 0; j < SPECIES.length(); j++) {
3671
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
3672
}
3673
}
3674
}
3675
}
3676
3677
3678
3679
@Test(dataProvider = "longCompareOpMaskProvider")
3680
static void UNSIGNED_LTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3681
IntFunction<boolean[]> fm) {
3682
long[] a = fa.apply(SPECIES.length());
3683
long[] b = fb.apply(SPECIES.length());
3684
boolean[] mask = fm.apply(SPECIES.length());
3685
3686
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3687
3688
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3689
for (int i = 0; i < a.length; i += SPECIES.length()) {
3690
LongVector av = LongVector.fromArray(SPECIES, a, i);
3691
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3692
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
3693
3694
// Check results as part of computation.
3695
for (int j = 0; j < SPECIES.length(); j++) {
3696
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
3697
}
3698
}
3699
}
3700
}
3701
3702
3703
3704
3705
@Test(dataProvider = "longCompareOpProvider")
3706
static void UNSIGNED_GTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3707
long[] a = fa.apply(SPECIES.length());
3708
long[] b = fb.apply(SPECIES.length());
3709
3710
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3711
for (int i = 0; i < a.length; i += SPECIES.length()) {
3712
LongVector av = LongVector.fromArray(SPECIES, a, i);
3713
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3714
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
3715
3716
// Check results as part of computation.
3717
for (int j = 0; j < SPECIES.length(); j++) {
3718
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
3719
}
3720
}
3721
}
3722
}
3723
3724
3725
3726
@Test(dataProvider = "longCompareOpMaskProvider")
3727
static void UNSIGNED_GTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3728
IntFunction<boolean[]> fm) {
3729
long[] a = fa.apply(SPECIES.length());
3730
long[] b = fb.apply(SPECIES.length());
3731
boolean[] mask = fm.apply(SPECIES.length());
3732
3733
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3734
3735
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3736
for (int i = 0; i < a.length; i += SPECIES.length()) {
3737
LongVector av = LongVector.fromArray(SPECIES, a, i);
3738
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3739
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
3740
3741
// Check results as part of computation.
3742
for (int j = 0; j < SPECIES.length(); j++) {
3743
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
3744
}
3745
}
3746
}
3747
}
3748
3749
3750
3751
3752
@Test(dataProvider = "longCompareOpProvider")
3753
static void UNSIGNED_LELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3754
long[] a = fa.apply(SPECIES.length());
3755
long[] b = fb.apply(SPECIES.length());
3756
3757
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3758
for (int i = 0; i < a.length; i += SPECIES.length()) {
3759
LongVector av = LongVector.fromArray(SPECIES, a, i);
3760
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3761
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
3762
3763
// Check results as part of computation.
3764
for (int j = 0; j < SPECIES.length(); j++) {
3765
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
3766
}
3767
}
3768
}
3769
}
3770
3771
3772
3773
@Test(dataProvider = "longCompareOpMaskProvider")
3774
static void UNSIGNED_LELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3775
IntFunction<boolean[]> fm) {
3776
long[] a = fa.apply(SPECIES.length());
3777
long[] b = fb.apply(SPECIES.length());
3778
boolean[] mask = fm.apply(SPECIES.length());
3779
3780
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3781
3782
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3783
for (int i = 0; i < a.length; i += SPECIES.length()) {
3784
LongVector av = LongVector.fromArray(SPECIES, a, i);
3785
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3786
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
3787
3788
// Check results as part of computation.
3789
for (int j = 0; j < SPECIES.length(); j++) {
3790
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
3791
}
3792
}
3793
}
3794
}
3795
3796
3797
3798
3799
@Test(dataProvider = "longCompareOpProvider")
3800
static void UNSIGNED_GELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3801
long[] a = fa.apply(SPECIES.length());
3802
long[] b = fb.apply(SPECIES.length());
3803
3804
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3805
for (int i = 0; i < a.length; i += SPECIES.length()) {
3806
LongVector av = LongVector.fromArray(SPECIES, a, i);
3807
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3808
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
3809
3810
// Check results as part of computation.
3811
for (int j = 0; j < SPECIES.length(); j++) {
3812
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
3813
}
3814
}
3815
}
3816
}
3817
3818
3819
3820
@Test(dataProvider = "longCompareOpMaskProvider")
3821
static void UNSIGNED_GELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3822
IntFunction<boolean[]> fm) {
3823
long[] a = fa.apply(SPECIES.length());
3824
long[] b = fb.apply(SPECIES.length());
3825
boolean[] mask = fm.apply(SPECIES.length());
3826
3827
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3828
3829
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3830
for (int i = 0; i < a.length; i += SPECIES.length()) {
3831
LongVector av = LongVector.fromArray(SPECIES, a, i);
3832
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3833
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
3834
3835
// Check results as part of computation.
3836
for (int j = 0; j < SPECIES.length(); j++) {
3837
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
3838
}
3839
}
3840
}
3841
}
3842
3843
3844
3845
@Test(dataProvider = "longCompareOpProvider")
3846
static void LTLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3847
long[] a = fa.apply(SPECIES.length());
3848
long[] b = fb.apply(SPECIES.length());
3849
3850
for (int i = 0; i < a.length; i += SPECIES.length()) {
3851
LongVector av = LongVector.fromArray(SPECIES, a, i);
3852
VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i]);
3853
3854
// Check results as part of computation.
3855
for (int j = 0; j < SPECIES.length(); j++) {
3856
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
3857
}
3858
}
3859
}
3860
3861
3862
@Test(dataProvider = "longCompareOpMaskProvider")
3863
static void LTLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa,
3864
IntFunction<long[]> fb, IntFunction<boolean[]> fm) {
3865
long[] a = fa.apply(SPECIES.length());
3866
long[] b = fb.apply(SPECIES.length());
3867
boolean[] mask = fm.apply(SPECIES.length());
3868
3869
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3870
3871
for (int i = 0; i < a.length; i += SPECIES.length()) {
3872
LongVector av = LongVector.fromArray(SPECIES, a, i);
3873
VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i], vmask);
3874
3875
// Check results as part of computation.
3876
for (int j = 0; j < SPECIES.length(); j++) {
3877
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
3878
}
3879
}
3880
}
3881
3882
3883
@Test(dataProvider = "longCompareOpProvider")
3884
static void EQLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3885
long[] a = fa.apply(SPECIES.length());
3886
long[] b = fb.apply(SPECIES.length());
3887
3888
for (int i = 0; i < a.length; i += SPECIES.length()) {
3889
LongVector av = LongVector.fromArray(SPECIES, a, i);
3890
VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i]);
3891
3892
// Check results as part of computation.
3893
for (int j = 0; j < SPECIES.length(); j++) {
3894
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
3895
}
3896
}
3897
}
3898
3899
3900
@Test(dataProvider = "longCompareOpMaskProvider")
3901
static void EQLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa,
3902
IntFunction<long[]> fb, IntFunction<boolean[]> fm) {
3903
long[] a = fa.apply(SPECIES.length());
3904
long[] b = fb.apply(SPECIES.length());
3905
boolean[] mask = fm.apply(SPECIES.length());
3906
3907
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3908
3909
for (int i = 0; i < a.length; i += SPECIES.length()) {
3910
LongVector av = LongVector.fromArray(SPECIES, a, i);
3911
VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i], vmask);
3912
3913
// Check results as part of computation.
3914
for (int j = 0; j < SPECIES.length(); j++) {
3915
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
3916
}
3917
}
3918
}
3919
3920
3921
static long blend(long a, long b, boolean mask) {
3922
return mask ? b : a;
3923
}
3924
3925
@Test(dataProvider = "longBinaryOpMaskProvider")
3926
static void blendLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
3927
IntFunction<boolean[]> fm) {
3928
long[] a = fa.apply(SPECIES.length());
3929
long[] b = fb.apply(SPECIES.length());
3930
long[] r = fr.apply(SPECIES.length());
3931
boolean[] mask = fm.apply(SPECIES.length());
3932
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3933
3934
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3935
for (int i = 0; i < a.length; i += SPECIES.length()) {
3936
LongVector av = LongVector.fromArray(SPECIES, a, i);
3937
LongVector bv = LongVector.fromArray(SPECIES, b, i);
3938
av.blend(bv, vmask).intoArray(r, i);
3939
}
3940
}
3941
3942
assertArraysEquals(r, a, b, mask, Long256VectorTests::blend);
3943
}
3944
3945
@Test(dataProvider = "longUnaryOpShuffleProvider")
3946
static void RearrangeLong256VectorTests(IntFunction<long[]> fa,
3947
BiFunction<Integer,Integer,int[]> fs) {
3948
long[] a = fa.apply(SPECIES.length());
3949
int[] order = fs.apply(a.length, SPECIES.length());
3950
long[] r = fr.apply(SPECIES.length());
3951
3952
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3953
for (int i = 0; i < a.length; i += SPECIES.length()) {
3954
LongVector av = LongVector.fromArray(SPECIES, a, i);
3955
av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
3956
}
3957
}
3958
3959
assertRearrangeArraysEquals(r, a, order, SPECIES.length());
3960
}
3961
3962
@Test(dataProvider = "longUnaryOpShuffleMaskProvider")
3963
static void RearrangeLong256VectorTestsMaskedSmokeTest(IntFunction<long[]> fa,
3964
BiFunction<Integer,Integer,int[]> fs,
3965
IntFunction<boolean[]> fm) {
3966
long[] a = fa.apply(SPECIES.length());
3967
int[] order = fs.apply(a.length, SPECIES.length());
3968
long[] r = fr.apply(SPECIES.length());
3969
boolean[] mask = fm.apply(SPECIES.length());
3970
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3971
3972
for (int i = 0; i < a.length; i += SPECIES.length()) {
3973
LongVector av = LongVector.fromArray(SPECIES, a, i);
3974
av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
3975
}
3976
3977
assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
3978
}
3979
@Test(dataProvider = "longUnaryOpProvider")
3980
static void getLong256VectorTests(IntFunction<long[]> fa) {
3981
long[] a = fa.apply(SPECIES.length());
3982
long[] r = fr.apply(SPECIES.length());
3983
3984
for (int ic = 0; ic < INVOC_COUNT; ic++) {
3985
for (int i = 0; i < a.length; i += SPECIES.length()) {
3986
LongVector av = LongVector.fromArray(SPECIES, a, i);
3987
int num_lanes = SPECIES.length();
3988
// Manually unroll because full unroll happens after intrinsification.
3989
// Unroll is needed because get intrinsic requires for index to be a known constant.
3990
if (num_lanes == 1) {
3991
r[i]=av.lane(0);
3992
} else if (num_lanes == 2) {
3993
r[i]=av.lane(0);
3994
r[i+1]=av.lane(1);
3995
} else if (num_lanes == 4) {
3996
r[i]=av.lane(0);
3997
r[i+1]=av.lane(1);
3998
r[i+2]=av.lane(2);
3999
r[i+3]=av.lane(3);
4000
} else if (num_lanes == 8) {
4001
r[i]=av.lane(0);
4002
r[i+1]=av.lane(1);
4003
r[i+2]=av.lane(2);
4004
r[i+3]=av.lane(3);
4005
r[i+4]=av.lane(4);
4006
r[i+5]=av.lane(5);
4007
r[i+6]=av.lane(6);
4008
r[i+7]=av.lane(7);
4009
} else if (num_lanes == 16) {
4010
r[i]=av.lane(0);
4011
r[i+1]=av.lane(1);
4012
r[i+2]=av.lane(2);
4013
r[i+3]=av.lane(3);
4014
r[i+4]=av.lane(4);
4015
r[i+5]=av.lane(5);
4016
r[i+6]=av.lane(6);
4017
r[i+7]=av.lane(7);
4018
r[i+8]=av.lane(8);
4019
r[i+9]=av.lane(9);
4020
r[i+10]=av.lane(10);
4021
r[i+11]=av.lane(11);
4022
r[i+12]=av.lane(12);
4023
r[i+13]=av.lane(13);
4024
r[i+14]=av.lane(14);
4025
r[i+15]=av.lane(15);
4026
} else if (num_lanes == 32) {
4027
r[i]=av.lane(0);
4028
r[i+1]=av.lane(1);
4029
r[i+2]=av.lane(2);
4030
r[i+3]=av.lane(3);
4031
r[i+4]=av.lane(4);
4032
r[i+5]=av.lane(5);
4033
r[i+6]=av.lane(6);
4034
r[i+7]=av.lane(7);
4035
r[i+8]=av.lane(8);
4036
r[i+9]=av.lane(9);
4037
r[i+10]=av.lane(10);
4038
r[i+11]=av.lane(11);
4039
r[i+12]=av.lane(12);
4040
r[i+13]=av.lane(13);
4041
r[i+14]=av.lane(14);
4042
r[i+15]=av.lane(15);
4043
r[i+16]=av.lane(16);
4044
r[i+17]=av.lane(17);
4045
r[i+18]=av.lane(18);
4046
r[i+19]=av.lane(19);
4047
r[i+20]=av.lane(20);
4048
r[i+21]=av.lane(21);
4049
r[i+22]=av.lane(22);
4050
r[i+23]=av.lane(23);
4051
r[i+24]=av.lane(24);
4052
r[i+25]=av.lane(25);
4053
r[i+26]=av.lane(26);
4054
r[i+27]=av.lane(27);
4055
r[i+28]=av.lane(28);
4056
r[i+29]=av.lane(29);
4057
r[i+30]=av.lane(30);
4058
r[i+31]=av.lane(31);
4059
} else if (num_lanes == 64) {
4060
r[i]=av.lane(0);
4061
r[i+1]=av.lane(1);
4062
r[i+2]=av.lane(2);
4063
r[i+3]=av.lane(3);
4064
r[i+4]=av.lane(4);
4065
r[i+5]=av.lane(5);
4066
r[i+6]=av.lane(6);
4067
r[i+7]=av.lane(7);
4068
r[i+8]=av.lane(8);
4069
r[i+9]=av.lane(9);
4070
r[i+10]=av.lane(10);
4071
r[i+11]=av.lane(11);
4072
r[i+12]=av.lane(12);
4073
r[i+13]=av.lane(13);
4074
r[i+14]=av.lane(14);
4075
r[i+15]=av.lane(15);
4076
r[i+16]=av.lane(16);
4077
r[i+17]=av.lane(17);
4078
r[i+18]=av.lane(18);
4079
r[i+19]=av.lane(19);
4080
r[i+20]=av.lane(20);
4081
r[i+21]=av.lane(21);
4082
r[i+22]=av.lane(22);
4083
r[i+23]=av.lane(23);
4084
r[i+24]=av.lane(24);
4085
r[i+25]=av.lane(25);
4086
r[i+26]=av.lane(26);
4087
r[i+27]=av.lane(27);
4088
r[i+28]=av.lane(28);
4089
r[i+29]=av.lane(29);
4090
r[i+30]=av.lane(30);
4091
r[i+31]=av.lane(31);
4092
r[i+32]=av.lane(32);
4093
r[i+33]=av.lane(33);
4094
r[i+34]=av.lane(34);
4095
r[i+35]=av.lane(35);
4096
r[i+36]=av.lane(36);
4097
r[i+37]=av.lane(37);
4098
r[i+38]=av.lane(38);
4099
r[i+39]=av.lane(39);
4100
r[i+40]=av.lane(40);
4101
r[i+41]=av.lane(41);
4102
r[i+42]=av.lane(42);
4103
r[i+43]=av.lane(43);
4104
r[i+44]=av.lane(44);
4105
r[i+45]=av.lane(45);
4106
r[i+46]=av.lane(46);
4107
r[i+47]=av.lane(47);
4108
r[i+48]=av.lane(48);
4109
r[i+49]=av.lane(49);
4110
r[i+50]=av.lane(50);
4111
r[i+51]=av.lane(51);
4112
r[i+52]=av.lane(52);
4113
r[i+53]=av.lane(53);
4114
r[i+54]=av.lane(54);
4115
r[i+55]=av.lane(55);
4116
r[i+56]=av.lane(56);
4117
r[i+57]=av.lane(57);
4118
r[i+58]=av.lane(58);
4119
r[i+59]=av.lane(59);
4120
r[i+60]=av.lane(60);
4121
r[i+61]=av.lane(61);
4122
r[i+62]=av.lane(62);
4123
r[i+63]=av.lane(63);
4124
} else {
4125
for (int j = 0; j < SPECIES.length(); j++) {
4126
r[i+j]=av.lane(j);
4127
}
4128
}
4129
}
4130
}
4131
4132
assertArraysEquals(r, a, Long256VectorTests::get);
4133
}
4134
4135
@Test(dataProvider = "longUnaryOpProvider")
4136
static void BroadcastLong256VectorTests(IntFunction<long[]> fa) {
4137
long[] a = fa.apply(SPECIES.length());
4138
long[] r = new long[a.length];
4139
4140
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4141
for (int i = 0; i < a.length; i += SPECIES.length()) {
4142
LongVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4143
}
4144
}
4145
4146
assertBroadcastArraysEquals(r, a);
4147
}
4148
4149
4150
4151
4152
4153
@Test(dataProvider = "longUnaryOpProvider")
4154
static void ZeroLong256VectorTests(IntFunction<long[]> fa) {
4155
long[] a = fa.apply(SPECIES.length());
4156
long[] r = new long[a.length];
4157
4158
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4159
for (int i = 0; i < a.length; i += SPECIES.length()) {
4160
LongVector.zero(SPECIES).intoArray(a, i);
4161
}
4162
}
4163
4164
Assert.assertEquals(a, r);
4165
}
4166
4167
4168
4169
4170
static long[] sliceUnary(long[] a, int origin, int idx) {
4171
long[] res = new long[SPECIES.length()];
4172
for (int i = 0; i < SPECIES.length(); i++){
4173
if(i+origin < SPECIES.length())
4174
res[i] = a[idx+i+origin];
4175
else
4176
res[i] = (long)0;
4177
}
4178
return res;
4179
}
4180
4181
@Test(dataProvider = "longUnaryOpProvider")
4182
static void sliceUnaryLong256VectorTests(IntFunction<long[]> fa) {
4183
long[] a = fa.apply(SPECIES.length());
4184
long[] r = new long[a.length];
4185
int origin = (new java.util.Random()).nextInt(SPECIES.length());
4186
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4187
for (int i = 0; i < a.length; i += SPECIES.length()) {
4188
LongVector av = LongVector.fromArray(SPECIES, a, i);
4189
av.slice(origin).intoArray(r, i);
4190
}
4191
}
4192
4193
assertArraysEquals(r, a, origin, Long256VectorTests::sliceUnary);
4194
}
4195
static long[] sliceBinary(long[] a, long[] b, int origin, int idx) {
4196
long[] res = new long[SPECIES.length()];
4197
for (int i = 0, j = 0; i < SPECIES.length(); i++){
4198
if(i+origin < SPECIES.length())
4199
res[i] = a[idx+i+origin];
4200
else {
4201
res[i] = b[idx+j];
4202
j++;
4203
}
4204
}
4205
return res;
4206
}
4207
4208
@Test(dataProvider = "longBinaryOpProvider")
4209
static void sliceBinaryLong256VectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4210
long[] a = fa.apply(SPECIES.length());
4211
long[] b = fb.apply(SPECIES.length());
4212
long[] r = new long[a.length];
4213
int origin = (new java.util.Random()).nextInt(SPECIES.length());
4214
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4215
for (int i = 0; i < a.length; i += SPECIES.length()) {
4216
LongVector av = LongVector.fromArray(SPECIES, a, i);
4217
LongVector bv = LongVector.fromArray(SPECIES, b, i);
4218
av.slice(origin, bv).intoArray(r, i);
4219
}
4220
}
4221
4222
assertArraysEquals(r, a, b, origin, Long256VectorTests::sliceBinary);
4223
}
4224
static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) {
4225
long[] res = new long[SPECIES.length()];
4226
for (int i = 0, j = 0; i < SPECIES.length(); i++){
4227
if(i+origin < SPECIES.length())
4228
res[i] = mask[i] ? a[idx+i+origin] : (long)0;
4229
else {
4230
res[i] = mask[i] ? b[idx+j] : (long)0;
4231
j++;
4232
}
4233
}
4234
return res;
4235
}
4236
4237
@Test(dataProvider = "longBinaryOpMaskProvider")
4238
static void sliceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4239
IntFunction<boolean[]> fm) {
4240
long[] a = fa.apply(SPECIES.length());
4241
long[] b = fb.apply(SPECIES.length());
4242
boolean[] mask = fm.apply(SPECIES.length());
4243
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4244
4245
long[] r = new long[a.length];
4246
int origin = (new java.util.Random()).nextInt(SPECIES.length());
4247
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4248
for (int i = 0; i < a.length; i += SPECIES.length()) {
4249
LongVector av = LongVector.fromArray(SPECIES, a, i);
4250
LongVector bv = LongVector.fromArray(SPECIES, b, i);
4251
av.slice(origin, bv, vmask).intoArray(r, i);
4252
}
4253
}
4254
4255
assertArraysEquals(r, a, b, origin, mask, Long256VectorTests::slice);
4256
}
4257
static long[] unsliceUnary(long[] a, int origin, int idx) {
4258
long[] res = new long[SPECIES.length()];
4259
for (int i = 0, j = 0; i < SPECIES.length(); i++){
4260
if(i < origin)
4261
res[i] = (long)0;
4262
else {
4263
res[i] = a[idx+j];
4264
j++;
4265
}
4266
}
4267
return res;
4268
}
4269
4270
@Test(dataProvider = "longUnaryOpProvider")
4271
static void unsliceUnaryLong256VectorTests(IntFunction<long[]> fa) {
4272
long[] a = fa.apply(SPECIES.length());
4273
long[] r = new long[a.length];
4274
int origin = (new java.util.Random()).nextInt(SPECIES.length());
4275
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4276
for (int i = 0; i < a.length; i += SPECIES.length()) {
4277
LongVector av = LongVector.fromArray(SPECIES, a, i);
4278
av.unslice(origin).intoArray(r, i);
4279
}
4280
}
4281
4282
assertArraysEquals(r, a, origin, Long256VectorTests::unsliceUnary);
4283
}
4284
static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) {
4285
long[] res = new long[SPECIES.length()];
4286
for (int i = 0, j = 0; i < SPECIES.length(); i++){
4287
if (part == 0) {
4288
if (i < origin)
4289
res[i] = b[idx+i];
4290
else {
4291
res[i] = a[idx+j];
4292
j++;
4293
}
4294
} else if (part == 1) {
4295
if (i < origin)
4296
res[i] = a[idx+SPECIES.length()-origin+i];
4297
else {
4298
res[i] = b[idx+origin+j];
4299
j++;
4300
}
4301
}
4302
}
4303
return res;
4304
}
4305
4306
@Test(dataProvider = "longBinaryOpProvider")
4307
static void unsliceBinaryLong256VectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4308
long[] a = fa.apply(SPECIES.length());
4309
long[] b = fb.apply(SPECIES.length());
4310
long[] r = new long[a.length];
4311
int origin = (new java.util.Random()).nextInt(SPECIES.length());
4312
int part = (new java.util.Random()).nextInt(2);
4313
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4314
for (int i = 0; i < a.length; i += SPECIES.length()) {
4315
LongVector av = LongVector.fromArray(SPECIES, a, i);
4316
LongVector bv = LongVector.fromArray(SPECIES, b, i);
4317
av.unslice(origin, bv, part).intoArray(r, i);
4318
}
4319
}
4320
4321
assertArraysEquals(r, a, b, origin, part, Long256VectorTests::unsliceBinary);
4322
}
4323
static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) {
4324
long[] res = new long[SPECIES.length()];
4325
for (int i = 0, j = 0; i < SPECIES.length(); i++){
4326
if(i+origin < SPECIES.length())
4327
res[i] = b[idx+i+origin];
4328
else {
4329
res[i] = b[idx+j];
4330
j++;
4331
}
4332
}
4333
for (int i = 0; i < SPECIES.length(); i++){
4334
res[i] = mask[i] ? a[idx+i] : res[i];
4335
}
4336
long[] res1 = new long[SPECIES.length()];
4337
if (part == 0) {
4338
for (int i = 0, j = 0; i < SPECIES.length(); i++){
4339
if (i < origin)
4340
res1[i] = b[idx+i];
4341
else {
4342
res1[i] = res[j];
4343
j++;
4344
}
4345
}
4346
} else if (part == 1) {
4347
for (int i = 0, j = 0; i < SPECIES.length(); i++){
4348
if (i < origin)
4349
res1[i] = res[SPECIES.length()-origin+i];
4350
else {
4351
res1[i] = b[idx+origin+j];
4352
j++;
4353
}
4354
}
4355
}
4356
return res1;
4357
}
4358
4359
@Test(dataProvider = "longBinaryOpMaskProvider")
4360
static void unsliceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4361
IntFunction<boolean[]> fm) {
4362
long[] a = fa.apply(SPECIES.length());
4363
long[] b = fb.apply(SPECIES.length());
4364
boolean[] mask = fm.apply(SPECIES.length());
4365
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4366
long[] r = new long[a.length];
4367
int origin = (new java.util.Random()).nextInt(SPECIES.length());
4368
int part = (new java.util.Random()).nextInt(2);
4369
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4370
for (int i = 0; i < a.length; i += SPECIES.length()) {
4371
LongVector av = LongVector.fromArray(SPECIES, a, i);
4372
LongVector bv = LongVector.fromArray(SPECIES, b, i);
4373
av.unslice(origin, bv, part, vmask).intoArray(r, i);
4374
}
4375
}
4376
4377
assertArraysEquals(r, a, b, origin, part, mask, Long256VectorTests::unslice);
4378
}
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
static long BITWISE_BLEND(long a, long b, long c) {
4403
return (long)((a&~(c))|(b&c));
4404
}
4405
static long bitwiseBlend(long a, long b, long c) {
4406
return (long)((a&~(c))|(b&c));
4407
}
4408
4409
4410
@Test(dataProvider = "longTernaryOpProvider")
4411
static void BITWISE_BLENDLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4412
long[] a = fa.apply(SPECIES.length());
4413
long[] b = fb.apply(SPECIES.length());
4414
long[] c = fc.apply(SPECIES.length());
4415
long[] r = fr.apply(SPECIES.length());
4416
4417
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4418
for (int i = 0; i < a.length; i += SPECIES.length()) {
4419
LongVector av = LongVector.fromArray(SPECIES, a, i);
4420
LongVector bv = LongVector.fromArray(SPECIES, b, i);
4421
LongVector cv = LongVector.fromArray(SPECIES, c, i);
4422
av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
4423
}
4424
}
4425
4426
assertArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND);
4427
}
4428
@Test(dataProvider = "longTernaryOpProvider")
4429
static void bitwiseBlendLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4430
long[] a = fa.apply(SPECIES.length());
4431
long[] b = fb.apply(SPECIES.length());
4432
long[] c = fc.apply(SPECIES.length());
4433
long[] r = fr.apply(SPECIES.length());
4434
4435
for (int i = 0; i < a.length; i += SPECIES.length()) {
4436
LongVector av = LongVector.fromArray(SPECIES, a, i);
4437
LongVector bv = LongVector.fromArray(SPECIES, b, i);
4438
LongVector cv = LongVector.fromArray(SPECIES, c, i);
4439
av.bitwiseBlend(bv, cv).intoArray(r, i);
4440
}
4441
4442
assertArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend);
4443
}
4444
4445
4446
@Test(dataProvider = "longTernaryOpMaskProvider")
4447
static void BITWISE_BLENDLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4448
IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4449
long[] a = fa.apply(SPECIES.length());
4450
long[] b = fb.apply(SPECIES.length());
4451
long[] c = fc.apply(SPECIES.length());
4452
long[] r = fr.apply(SPECIES.length());
4453
boolean[] mask = fm.apply(SPECIES.length());
4454
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4455
4456
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4457
for (int i = 0; i < a.length; i += SPECIES.length()) {
4458
LongVector av = LongVector.fromArray(SPECIES, a, i);
4459
LongVector bv = LongVector.fromArray(SPECIES, b, i);
4460
LongVector cv = LongVector.fromArray(SPECIES, c, i);
4461
av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
4462
}
4463
}
4464
4465
assertArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND);
4466
}
4467
4468
4469
4470
4471
@Test(dataProvider = "longTernaryOpProvider")
4472
static void BITWISE_BLENDLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4473
long[] a = fa.apply(SPECIES.length());
4474
long[] b = fb.apply(SPECIES.length());
4475
long[] c = fc.apply(SPECIES.length());
4476
long[] r = fr.apply(SPECIES.length());
4477
4478
for (int i = 0; i < a.length; i += SPECIES.length()) {
4479
LongVector av = LongVector.fromArray(SPECIES, a, i);
4480
LongVector bv = LongVector.fromArray(SPECIES, b, i);
4481
av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
4482
}
4483
assertBroadcastArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND);
4484
}
4485
4486
@Test(dataProvider = "longTernaryOpProvider")
4487
static void BITWISE_BLENDLong256VectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4488
long[] a = fa.apply(SPECIES.length());
4489
long[] b = fb.apply(SPECIES.length());
4490
long[] c = fc.apply(SPECIES.length());
4491
long[] r = fr.apply(SPECIES.length());
4492
4493
for (int i = 0; i < a.length; i += SPECIES.length()) {
4494
LongVector av = LongVector.fromArray(SPECIES, a, i);
4495
LongVector cv = LongVector.fromArray(SPECIES, c, i);
4496
av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
4497
}
4498
assertAltBroadcastArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND);
4499
}
4500
@Test(dataProvider = "longTernaryOpProvider")
4501
static void bitwiseBlendLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4502
long[] a = fa.apply(SPECIES.length());
4503
long[] b = fb.apply(SPECIES.length());
4504
long[] c = fc.apply(SPECIES.length());
4505
long[] r = fr.apply(SPECIES.length());
4506
4507
for (int i = 0; i < a.length; i += SPECIES.length()) {
4508
LongVector av = LongVector.fromArray(SPECIES, a, i);
4509
LongVector bv = LongVector.fromArray(SPECIES, b, i);
4510
av.bitwiseBlend(bv, c[i]).intoArray(r, i);
4511
}
4512
assertBroadcastArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend);
4513
}
4514
4515
@Test(dataProvider = "longTernaryOpProvider")
4516
static void bitwiseBlendLong256VectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4517
long[] a = fa.apply(SPECIES.length());
4518
long[] b = fb.apply(SPECIES.length());
4519
long[] c = fc.apply(SPECIES.length());
4520
long[] r = fr.apply(SPECIES.length());
4521
4522
for (int i = 0; i < a.length; i += SPECIES.length()) {
4523
LongVector av = LongVector.fromArray(SPECIES, a, i);
4524
LongVector cv = LongVector.fromArray(SPECIES, c, i);
4525
av.bitwiseBlend(b[i], cv).intoArray(r, i);
4526
}
4527
assertAltBroadcastArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend);
4528
}
4529
4530
4531
@Test(dataProvider = "longTernaryOpMaskProvider")
4532
static void BITWISE_BLENDLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
4533
IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4534
long[] a = fa.apply(SPECIES.length());
4535
long[] b = fb.apply(SPECIES.length());
4536
long[] c = fc.apply(SPECIES.length());
4537
long[] r = fr.apply(SPECIES.length());
4538
boolean[] mask = fm.apply(SPECIES.length());
4539
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4540
4541
for (int i = 0; i < a.length; i += SPECIES.length()) {
4542
LongVector av = LongVector.fromArray(SPECIES, a, i);
4543
LongVector bv = LongVector.fromArray(SPECIES, b, i);
4544
av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
4545
}
4546
4547
assertBroadcastArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND);
4548
}
4549
4550
@Test(dataProvider = "longTernaryOpMaskProvider")
4551
static void BITWISE_BLENDLong256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
4552
IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4553
long[] a = fa.apply(SPECIES.length());
4554
long[] b = fb.apply(SPECIES.length());
4555
long[] c = fc.apply(SPECIES.length());
4556
long[] r = fr.apply(SPECIES.length());
4557
boolean[] mask = fm.apply(SPECIES.length());
4558
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4559
4560
for (int i = 0; i < a.length; i += SPECIES.length()) {
4561
LongVector av = LongVector.fromArray(SPECIES, a, i);
4562
LongVector cv = LongVector.fromArray(SPECIES, c, i);
4563
av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
4564
}
4565
4566
assertAltBroadcastArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND);
4567
}
4568
4569
4570
4571
4572
@Test(dataProvider = "longTernaryOpProvider")
4573
static void BITWISE_BLENDLong256VectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4574
long[] a = fa.apply(SPECIES.length());
4575
long[] b = fb.apply(SPECIES.length());
4576
long[] c = fc.apply(SPECIES.length());
4577
long[] r = fr.apply(SPECIES.length());
4578
4579
for (int i = 0; i < a.length; i += SPECIES.length()) {
4580
LongVector av = LongVector.fromArray(SPECIES, a, i);
4581
av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
4582
}
4583
4584
assertDoubleBroadcastArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND);
4585
}
4586
@Test(dataProvider = "longTernaryOpProvider")
4587
static void bitwiseBlendLong256VectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4588
long[] a = fa.apply(SPECIES.length());
4589
long[] b = fb.apply(SPECIES.length());
4590
long[] c = fc.apply(SPECIES.length());
4591
long[] r = fr.apply(SPECIES.length());
4592
4593
for (int i = 0; i < a.length; i += SPECIES.length()) {
4594
LongVector av = LongVector.fromArray(SPECIES, a, i);
4595
av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
4596
}
4597
4598
assertDoubleBroadcastArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend);
4599
}
4600
4601
4602
@Test(dataProvider = "longTernaryOpMaskProvider")
4603
static void BITWISE_BLENDLong256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
4604
IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4605
long[] a = fa.apply(SPECIES.length());
4606
long[] b = fb.apply(SPECIES.length());
4607
long[] c = fc.apply(SPECIES.length());
4608
long[] r = fr.apply(SPECIES.length());
4609
boolean[] mask = fm.apply(SPECIES.length());
4610
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4611
4612
for (int i = 0; i < a.length; i += SPECIES.length()) {
4613
LongVector av = LongVector.fromArray(SPECIES, a, i);
4614
av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
4615
}
4616
4617
assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND);
4618
}
4619
4620
4621
static long NEG(long a) {
4622
return (long)(-((long)a));
4623
}
4624
4625
static long neg(long a) {
4626
return (long)(-((long)a));
4627
}
4628
4629
@Test(dataProvider = "longUnaryOpProvider")
4630
static void NEGLong256VectorTests(IntFunction<long[]> fa) {
4631
long[] a = fa.apply(SPECIES.length());
4632
long[] r = fr.apply(SPECIES.length());
4633
4634
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4635
for (int i = 0; i < a.length; i += SPECIES.length()) {
4636
LongVector av = LongVector.fromArray(SPECIES, a, i);
4637
av.lanewise(VectorOperators.NEG).intoArray(r, i);
4638
}
4639
}
4640
4641
assertArraysEquals(r, a, Long256VectorTests::NEG);
4642
}
4643
4644
@Test(dataProvider = "longUnaryOpProvider")
4645
static void negLong256VectorTests(IntFunction<long[]> fa) {
4646
long[] a = fa.apply(SPECIES.length());
4647
long[] r = fr.apply(SPECIES.length());
4648
4649
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4650
for (int i = 0; i < a.length; i += SPECIES.length()) {
4651
LongVector av = LongVector.fromArray(SPECIES, a, i);
4652
av.neg().intoArray(r, i);
4653
}
4654
}
4655
4656
assertArraysEquals(r, a, Long256VectorTests::neg);
4657
}
4658
4659
@Test(dataProvider = "longUnaryOpMaskProvider")
4660
static void NEGMaskedLong256VectorTests(IntFunction<long[]> fa,
4661
IntFunction<boolean[]> fm) {
4662
long[] a = fa.apply(SPECIES.length());
4663
long[] r = fr.apply(SPECIES.length());
4664
boolean[] mask = fm.apply(SPECIES.length());
4665
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4666
4667
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4668
for (int i = 0; i < a.length; i += SPECIES.length()) {
4669
LongVector av = LongVector.fromArray(SPECIES, a, i);
4670
av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
4671
}
4672
}
4673
4674
assertArraysEquals(r, a, mask, Long256VectorTests::NEG);
4675
}
4676
4677
static long ABS(long a) {
4678
return (long)(Math.abs((long)a));
4679
}
4680
4681
static long abs(long a) {
4682
return (long)(Math.abs((long)a));
4683
}
4684
4685
@Test(dataProvider = "longUnaryOpProvider")
4686
static void ABSLong256VectorTests(IntFunction<long[]> fa) {
4687
long[] a = fa.apply(SPECIES.length());
4688
long[] r = fr.apply(SPECIES.length());
4689
4690
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4691
for (int i = 0; i < a.length; i += SPECIES.length()) {
4692
LongVector av = LongVector.fromArray(SPECIES, a, i);
4693
av.lanewise(VectorOperators.ABS).intoArray(r, i);
4694
}
4695
}
4696
4697
assertArraysEquals(r, a, Long256VectorTests::ABS);
4698
}
4699
4700
@Test(dataProvider = "longUnaryOpProvider")
4701
static void absLong256VectorTests(IntFunction<long[]> fa) {
4702
long[] a = fa.apply(SPECIES.length());
4703
long[] r = fr.apply(SPECIES.length());
4704
4705
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4706
for (int i = 0; i < a.length; i += SPECIES.length()) {
4707
LongVector av = LongVector.fromArray(SPECIES, a, i);
4708
av.abs().intoArray(r, i);
4709
}
4710
}
4711
4712
assertArraysEquals(r, a, Long256VectorTests::abs);
4713
}
4714
4715
@Test(dataProvider = "longUnaryOpMaskProvider")
4716
static void ABSMaskedLong256VectorTests(IntFunction<long[]> fa,
4717
IntFunction<boolean[]> fm) {
4718
long[] a = fa.apply(SPECIES.length());
4719
long[] r = fr.apply(SPECIES.length());
4720
boolean[] mask = fm.apply(SPECIES.length());
4721
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4722
4723
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4724
for (int i = 0; i < a.length; i += SPECIES.length()) {
4725
LongVector av = LongVector.fromArray(SPECIES, a, i);
4726
av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
4727
}
4728
}
4729
4730
assertArraysEquals(r, a, mask, Long256VectorTests::ABS);
4731
}
4732
4733
4734
static long NOT(long a) {
4735
return (long)(~((long)a));
4736
}
4737
4738
static long not(long a) {
4739
return (long)(~((long)a));
4740
}
4741
4742
4743
4744
@Test(dataProvider = "longUnaryOpProvider")
4745
static void NOTLong256VectorTests(IntFunction<long[]> fa) {
4746
long[] a = fa.apply(SPECIES.length());
4747
long[] r = fr.apply(SPECIES.length());
4748
4749
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4750
for (int i = 0; i < a.length; i += SPECIES.length()) {
4751
LongVector av = LongVector.fromArray(SPECIES, a, i);
4752
av.lanewise(VectorOperators.NOT).intoArray(r, i);
4753
}
4754
}
4755
4756
assertArraysEquals(r, a, Long256VectorTests::NOT);
4757
}
4758
4759
@Test(dataProvider = "longUnaryOpProvider")
4760
static void notLong256VectorTests(IntFunction<long[]> fa) {
4761
long[] a = fa.apply(SPECIES.length());
4762
long[] r = fr.apply(SPECIES.length());
4763
4764
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4765
for (int i = 0; i < a.length; i += SPECIES.length()) {
4766
LongVector av = LongVector.fromArray(SPECIES, a, i);
4767
av.not().intoArray(r, i);
4768
}
4769
}
4770
4771
assertArraysEquals(r, a, Long256VectorTests::not);
4772
}
4773
4774
4775
4776
@Test(dataProvider = "longUnaryOpMaskProvider")
4777
static void NOTMaskedLong256VectorTests(IntFunction<long[]> fa,
4778
IntFunction<boolean[]> fm) {
4779
long[] a = fa.apply(SPECIES.length());
4780
long[] r = fr.apply(SPECIES.length());
4781
boolean[] mask = fm.apply(SPECIES.length());
4782
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4783
4784
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4785
for (int i = 0; i < a.length; i += SPECIES.length()) {
4786
LongVector av = LongVector.fromArray(SPECIES, a, i);
4787
av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
4788
}
4789
}
4790
4791
assertArraysEquals(r, a, mask, Long256VectorTests::NOT);
4792
}
4793
4794
4795
4796
static long ZOMO(long a) {
4797
return (long)((a==0?0:-1));
4798
}
4799
4800
4801
4802
@Test(dataProvider = "longUnaryOpProvider")
4803
static void ZOMOLong256VectorTests(IntFunction<long[]> fa) {
4804
long[] a = fa.apply(SPECIES.length());
4805
long[] r = fr.apply(SPECIES.length());
4806
4807
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4808
for (int i = 0; i < a.length; i += SPECIES.length()) {
4809
LongVector av = LongVector.fromArray(SPECIES, a, i);
4810
av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
4811
}
4812
}
4813
4814
assertArraysEquals(r, a, Long256VectorTests::ZOMO);
4815
}
4816
4817
4818
4819
@Test(dataProvider = "longUnaryOpMaskProvider")
4820
static void ZOMOMaskedLong256VectorTests(IntFunction<long[]> fa,
4821
IntFunction<boolean[]> fm) {
4822
long[] a = fa.apply(SPECIES.length());
4823
long[] r = fr.apply(SPECIES.length());
4824
boolean[] mask = fm.apply(SPECIES.length());
4825
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4826
4827
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4828
for (int i = 0; i < a.length; i += SPECIES.length()) {
4829
LongVector av = LongVector.fromArray(SPECIES, a, i);
4830
av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
4831
}
4832
}
4833
4834
assertArraysEquals(r, a, mask, Long256VectorTests::ZOMO);
4835
}
4836
4837
4838
4839
4840
static long[] gather(long a[], int ix, int[] b, int iy) {
4841
long[] res = new long[SPECIES.length()];
4842
for (int i = 0; i < SPECIES.length(); i++) {
4843
int bi = iy + i;
4844
res[i] = a[b[bi] + ix];
4845
}
4846
return res;
4847
}
4848
4849
@Test(dataProvider = "longUnaryOpIndexProvider")
4850
static void gatherLong256VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
4851
long[] a = fa.apply(SPECIES.length());
4852
int[] b = fs.apply(a.length, SPECIES.length());
4853
long[] r = new long[a.length];
4854
4855
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4856
for (int i = 0; i < a.length; i += SPECIES.length()) {
4857
LongVector av = LongVector.fromArray(SPECIES, a, i, b, i);
4858
av.intoArray(r, i);
4859
}
4860
}
4861
4862
assertArraysEquals(r, a, b, Long256VectorTests::gather);
4863
}
4864
static long[] gatherMasked(long a[], int ix, boolean[] mask, int[] b, int iy) {
4865
long[] res = new long[SPECIES.length()];
4866
for (int i = 0; i < SPECIES.length(); i++) {
4867
int bi = iy + i;
4868
if (mask[i]) {
4869
res[i] = a[b[bi] + ix];
4870
}
4871
}
4872
return res;
4873
}
4874
4875
@Test(dataProvider = "longUnaryMaskedOpIndexProvider")
4876
static void gatherMaskedLong256VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
4877
long[] a = fa.apply(SPECIES.length());
4878
int[] b = fs.apply(a.length, SPECIES.length());
4879
long[] r = new long[a.length];
4880
boolean[] mask = fm.apply(SPECIES.length());
4881
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4882
4883
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4884
for (int i = 0; i < a.length; i += SPECIES.length()) {
4885
LongVector av = LongVector.fromArray(SPECIES, a, i, b, i, vmask);
4886
av.intoArray(r, i);
4887
}
4888
}
4889
4890
assertArraysEquals(r, a, b, mask, Long256VectorTests::gatherMasked);
4891
}
4892
4893
static long[] scatter(long a[], int ix, int[] b, int iy) {
4894
long[] res = new long[SPECIES.length()];
4895
for (int i = 0; i < SPECIES.length(); i++) {
4896
int bi = iy + i;
4897
res[b[bi]] = a[i + ix];
4898
}
4899
return res;
4900
}
4901
4902
@Test(dataProvider = "longUnaryOpIndexProvider")
4903
static void scatterLong256VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
4904
long[] a = fa.apply(SPECIES.length());
4905
int[] b = fs.apply(a.length, SPECIES.length());
4906
long[] r = new long[a.length];
4907
4908
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4909
for (int i = 0; i < a.length; i += SPECIES.length()) {
4910
LongVector av = LongVector.fromArray(SPECIES, a, i);
4911
av.intoArray(r, i, b, i);
4912
}
4913
}
4914
4915
assertArraysEquals(r, a, b, Long256VectorTests::scatter);
4916
}
4917
4918
static long[] scatterMasked(long r[], long a[], int ix, boolean[] mask, int[] b, int iy) {
4919
// First, gather r.
4920
long[] oldVal = gather(r, ix, b, iy);
4921
long[] newVal = new long[SPECIES.length()];
4922
4923
// Second, blending it with a.
4924
for (int i = 0; i < SPECIES.length(); i++) {
4925
newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);
4926
}
4927
4928
// Third, scatter: copy old value of r, and scatter it manually.
4929
long[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());
4930
for (int i = 0; i < SPECIES.length(); i++) {
4931
int bi = iy + i;
4932
res[b[bi]] = newVal[i];
4933
}
4934
4935
return res;
4936
}
4937
4938
@Test(dataProvider = "scatterMaskedOpIndexProvider")
4939
static void scatterMaskedLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {
4940
long[] a = fa.apply(SPECIES.length());
4941
int[] b = fs.apply(a.length, SPECIES.length());
4942
long[] r = fb.apply(SPECIES.length());
4943
boolean[] mask = fm.apply(SPECIES.length());
4944
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4945
4946
for (int ic = 0; ic < INVOC_COUNT; ic++) {
4947
for (int i = 0; i < a.length; i += SPECIES.length()) {
4948
LongVector av = LongVector.fromArray(SPECIES, a, i);
4949
av.intoArray(r, i, b, i, vmask);
4950
}
4951
}
4952
4953
assertArraysEquals(r, a, b, mask, Long256VectorTests::scatterMasked);
4954
}
4955
4956
4957
@Test(dataProvider = "longCompareOpProvider")
4958
static void ltLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4959
long[] a = fa.apply(SPECIES.length());
4960
long[] b = fb.apply(SPECIES.length());
4961
4962
for (int i = 0; i < a.length; i += SPECIES.length()) {
4963
LongVector av = LongVector.fromArray(SPECIES, a, i);
4964
VectorMask<Long> mv = av.lt(b[i]);
4965
4966
// Check results as part of computation.
4967
for (int j = 0; j < SPECIES.length(); j++) {
4968
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4969
}
4970
}
4971
}
4972
4973
@Test(dataProvider = "longCompareOpProvider")
4974
static void eqLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4975
long[] a = fa.apply(SPECIES.length());
4976
long[] b = fb.apply(SPECIES.length());
4977
4978
for (int i = 0; i < a.length; i += SPECIES.length()) {
4979
LongVector av = LongVector.fromArray(SPECIES, a, i);
4980
VectorMask<Long> mv = av.eq(b[i]);
4981
4982
// Check results as part of computation.
4983
for (int j = 0; j < SPECIES.length(); j++) {
4984
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4985
}
4986
}
4987
}
4988
4989
@Test(dataProvider = "longtoIntUnaryOpProvider")
4990
static void toIntArrayLong256VectorTestsSmokeTest(IntFunction<long[]> fa) {
4991
long[] a = fa.apply(SPECIES.length());
4992
4993
for (int i = 0; i < a.length; i += SPECIES.length()) {
4994
LongVector av = LongVector.fromArray(SPECIES, a, i);
4995
int[] r = av.toIntArray();
4996
assertArraysEquals(r, a, i);
4997
}
4998
}
4999
5000
@Test(dataProvider = "longUnaryOpProvider")
5001
static void toLongArrayLong256VectorTestsSmokeTest(IntFunction<long[]> fa) {
5002
long[] a = fa.apply(SPECIES.length());
5003
5004
for (int i = 0; i < a.length; i += SPECIES.length()) {
5005
LongVector av = LongVector.fromArray(SPECIES, a, i);
5006
long[] r = av.toLongArray();
5007
assertArraysEquals(r, a, i);
5008
}
5009
}
5010
5011
@Test(dataProvider = "longUnaryOpProvider")
5012
static void toDoubleArrayLong256VectorTestsSmokeTest(IntFunction<long[]> fa) {
5013
long[] a = fa.apply(SPECIES.length());
5014
5015
for (int i = 0; i < a.length; i += SPECIES.length()) {
5016
LongVector av = LongVector.fromArray(SPECIES, a, i);
5017
double[] r = av.toDoubleArray();
5018
assertArraysEquals(r, a, i);
5019
}
5020
}
5021
5022
@Test(dataProvider = "longUnaryOpProvider")
5023
static void toStringLong256VectorTestsSmokeTest(IntFunction<long[]> fa) {
5024
long[] a = fa.apply(SPECIES.length());
5025
5026
for (int i = 0; i < a.length; i += SPECIES.length()) {
5027
LongVector av = LongVector.fromArray(SPECIES, a, i);
5028
String str = av.toString();
5029
5030
long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5031
Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5032
}
5033
}
5034
5035
@Test(dataProvider = "longUnaryOpProvider")
5036
static void hashCodeLong256VectorTestsSmokeTest(IntFunction<long[]> fa) {
5037
long[] a = fa.apply(SPECIES.length());
5038
5039
for (int i = 0; i < a.length; i += SPECIES.length()) {
5040
LongVector av = LongVector.fromArray(SPECIES, a, i);
5041
int hash = av.hashCode();
5042
5043
long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5044
int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5045
Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5046
}
5047
}
5048
5049
5050
5051
@Test(dataProvider = "longUnaryOpProvider")
5052
static void ADDReduceLongLong256VectorTests(IntFunction<long[]> fa) {
5053
long[] a = fa.apply(SPECIES.length());
5054
long[] r = fr.apply(SPECIES.length());
5055
long ra = 0;
5056
5057
for (int i = 0; i < a.length; i += SPECIES.length()) {
5058
LongVector av = LongVector.fromArray(SPECIES, a, i);
5059
r[i] = av.reduceLanesToLong(VectorOperators.ADD);
5060
}
5061
5062
ra = 0;
5063
for (int i = 0; i < a.length; i ++) {
5064
ra += r[i];
5065
}
5066
5067
assertReductionArraysEquals(r, ra, a,
5068
Long256VectorTests::ADDReduce, Long256VectorTests::ADDReduceAll);
5069
}
5070
5071
@Test(dataProvider = "longUnaryOpMaskProvider")
5072
static void ADDReduceLongLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
5073
long[] a = fa.apply(SPECIES.length());
5074
long[] r = fr.apply(SPECIES.length());
5075
boolean[] mask = fm.apply(SPECIES.length());
5076
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5077
long ra = 0;
5078
5079
for (int i = 0; i < a.length; i += SPECIES.length()) {
5080
LongVector av = LongVector.fromArray(SPECIES, a, i);
5081
r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
5082
}
5083
5084
ra = 0;
5085
for (int i = 0; i < a.length; i ++) {
5086
ra += r[i];
5087
}
5088
5089
assertReductionArraysEqualsMasked(r, ra, a, mask,
5090
Long256VectorTests::ADDReduceMasked, Long256VectorTests::ADDReduceAllMasked);
5091
}
5092
5093
@Test(dataProvider = "longUnaryOpSelectFromProvider")
5094
static void SelectFromLong256VectorTests(IntFunction<long[]> fa,
5095
BiFunction<Integer,Integer,long[]> fs) {
5096
long[] a = fa.apply(SPECIES.length());
5097
long[] order = fs.apply(a.length, SPECIES.length());
5098
long[] r = fr.apply(SPECIES.length());
5099
5100
for (int i = 0; i < a.length; i += SPECIES.length()) {
5101
LongVector av = LongVector.fromArray(SPECIES, a, i);
5102
LongVector bv = LongVector.fromArray(SPECIES, order, i);
5103
bv.selectFrom(av).intoArray(r, i);
5104
}
5105
5106
assertSelectFromArraysEquals(r, a, order, SPECIES.length());
5107
}
5108
5109
@Test(dataProvider = "longUnaryOpSelectFromMaskProvider")
5110
static void SelectFromLong256VectorTestsMaskedSmokeTest(IntFunction<long[]> fa,
5111
BiFunction<Integer,Integer,long[]> fs,
5112
IntFunction<boolean[]> fm) {
5113
long[] a = fa.apply(SPECIES.length());
5114
long[] order = fs.apply(a.length, SPECIES.length());
5115
long[] r = fr.apply(SPECIES.length());
5116
boolean[] mask = fm.apply(SPECIES.length());
5117
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5118
5119
for (int i = 0; i < a.length; i += SPECIES.length()) {
5120
LongVector av = LongVector.fromArray(SPECIES, a, i);
5121
LongVector bv = LongVector.fromArray(SPECIES, order, i);
5122
bv.selectFrom(av, vmask).intoArray(r, i);
5123
}
5124
5125
assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
5126
}
5127
5128
@Test(dataProvider = "shuffleProvider")
5129
static void shuffleMiscellaneousLong256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5130
int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5131
5132
for (int i = 0; i < a.length; i += SPECIES.length()) {
5133
var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5134
int hash = shuffle.hashCode();
5135
int length = shuffle.length();
5136
5137
int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5138
int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5139
Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5140
Assert.assertEquals(length, SPECIES.length());
5141
}
5142
}
5143
5144
@Test(dataProvider = "shuffleProvider")
5145
static void shuffleToStringLong256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5146
int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5147
5148
for (int i = 0; i < a.length; i += SPECIES.length()) {
5149
var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5150
String str = shuffle.toString();
5151
5152
int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5153
Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
5154
i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5155
}
5156
}
5157
5158
@Test(dataProvider = "shuffleCompareOpProvider")
5159
static void shuffleEqualsLong256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {
5160
int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5161
int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5162
5163
for (int i = 0; i < a.length; i += SPECIES.length()) {
5164
var av = VectorShuffle.fromArray(SPECIES, a, i);
5165
var bv = VectorShuffle.fromArray(SPECIES, b, i);
5166
boolean eq = av.equals(bv);
5167
int to = i + SPECIES.length();
5168
Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
5169
}
5170
}
5171
5172
@Test(dataProvider = "maskCompareOpProvider")
5173
static void maskEqualsLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5174
boolean[] a = fa.apply(SPECIES.length());
5175
boolean[] b = fb.apply(SPECIES.length());
5176
5177
for (int i = 0; i < a.length; i += SPECIES.length()) {
5178
var av = SPECIES.loadMask(a, i);
5179
var bv = SPECIES.loadMask(b, i);
5180
boolean equals = av.equals(bv);
5181
int to = i + SPECIES.length();
5182
Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
5183
}
5184
}
5185
5186
static boolean beq(boolean a, boolean b) {
5187
return (a == b);
5188
}
5189
5190
@Test(dataProvider = "maskCompareOpProvider")
5191
static void maskEqLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5192
boolean[] a = fa.apply(SPECIES.length());
5193
boolean[] b = fb.apply(SPECIES.length());
5194
boolean[] r = new boolean[a.length];
5195
5196
for (int i = 0; i < a.length; i += SPECIES.length()) {
5197
var av = SPECIES.loadMask(a, i);
5198
var bv = SPECIES.loadMask(b, i);
5199
var cv = av.eq(bv);
5200
cv.intoArray(r, i);
5201
}
5202
assertArraysEquals(r, a, b, Long256VectorTests::beq);
5203
}
5204
5205
@Test(dataProvider = "maskProvider")
5206
static void maskHashCodeLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5207
boolean[] a = fa.apply(SPECIES.length());
5208
5209
for (int i = 0; i < a.length; i += SPECIES.length()) {
5210
var vmask = SPECIES.loadMask(a, i);
5211
int hash = vmask.hashCode();
5212
5213
boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5214
int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5215
Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5216
}
5217
}
5218
5219
@Test(dataProvider = "maskProvider")
5220
static void maskTrueCountLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5221
boolean[] a = fa.apply(SPECIES.length());
5222
5223
for (int i = 0; i < a.length; i += SPECIES.length()) {
5224
var vmask = SPECIES.loadMask(a, i);
5225
int tcount = vmask.trueCount();
5226
int expectedTcount = 0;
5227
for (int j = i; j < i + SPECIES.length(); j++) {
5228
expectedTcount += a[j] ? 1 : 0;
5229
}
5230
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
5231
}
5232
}
5233
5234
@Test(dataProvider = "maskProvider")
5235
static void maskLastTrueLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5236
boolean[] a = fa.apply(SPECIES.length());
5237
5238
for (int i = 0; i < a.length; i += SPECIES.length()) {
5239
var vmask = SPECIES.loadMask(a, i);
5240
int ltrue = vmask.lastTrue();
5241
int j = i + SPECIES.length() - 1;
5242
for (; j >= i; j--) {
5243
if (a[j]) break;
5244
}
5245
int expectedLtrue = j - i;
5246
5247
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
5248
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
5249
}
5250
}
5251
5252
@Test(dataProvider = "maskProvider")
5253
static void maskFirstTrueLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5254
boolean[] a = fa.apply(SPECIES.length());
5255
5256
for (int i = 0; i < a.length; i += SPECIES.length()) {
5257
var vmask = SPECIES.loadMask(a, i);
5258
int ftrue = vmask.firstTrue();
5259
int j = i;
5260
for (; j < i + SPECIES.length() ; j++) {
5261
if (a[j]) break;
5262
}
5263
int expectedFtrue = j - i;
5264
5265
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
5266
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
5267
}
5268
}
5269
5270
@DataProvider
5271
public static Object[][] longMaskProvider() {
5272
return new Object[][]{
5273
{0xFFFFFFFFFFFFFFFFL},
5274
{0x0000000000000000L},
5275
{0x5555555555555555L},
5276
{0x0123456789abcdefL},
5277
};
5278
}
5279
5280
@Test(dataProvider = "longMaskProvider")
5281
static void maskFromToLongLong256VectorTestsSmokeTest(long inputLong) {
5282
var vmask = VectorMask.fromLong(SPECIES, inputLong);
5283
long outputLong = vmask.toLong();
5284
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1));
5285
}
5286
5287
@DataProvider
5288
public static Object[][] offsetProvider() {
5289
return new Object[][]{
5290
{0},
5291
{-1},
5292
{+1},
5293
{+2},
5294
{-2},
5295
};
5296
}
5297
5298
@Test(dataProvider = "offsetProvider")
5299
static void indexInRangeLong256VectorTestsSmokeTest(int offset) {
5300
int limit = SPECIES.length() * BUFFER_REPS;
5301
for (int i = 0; i < limit; i += SPECIES.length()) {
5302
var actualMask = SPECIES.indexInRange(i + offset, limit);
5303
var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5304
assert(actualMask.equals(expectedMask));
5305
for (int j = 0; j < SPECIES.length(); j++) {
5306
int index = i + j + offset;
5307
Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5308
}
5309
}
5310
}
5311
5312
@DataProvider
5313
public static Object[][] lengthProvider() {
5314
return new Object[][]{
5315
{0},
5316
{1},
5317
{32},
5318
{37},
5319
{1024},
5320
{1024+1},
5321
{1024+5},
5322
};
5323
}
5324
5325
@Test(dataProvider = "lengthProvider")
5326
static void loopBoundLong256VectorTestsSmokeTest(int length) {
5327
int actualLoopBound = SPECIES.loopBound(length);
5328
int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5329
Assert.assertEquals(actualLoopBound, expectedLoopBound);
5330
}
5331
5332
@Test
5333
static void ElementSizeLong256VectorTestsSmokeTest() {
5334
LongVector av = LongVector.zero(SPECIES);
5335
int elsize = av.elementSize();
5336
Assert.assertEquals(elsize, Long.SIZE);
5337
}
5338
5339
@Test
5340
static void VectorShapeLong256VectorTestsSmokeTest() {
5341
LongVector av = LongVector.zero(SPECIES);
5342
VectorShape vsh = av.shape();
5343
assert(vsh.equals(VectorShape.S_256_BIT));
5344
}
5345
5346
@Test
5347
static void ShapeWithLanesLong256VectorTestsSmokeTest() {
5348
LongVector av = LongVector.zero(SPECIES);
5349
VectorShape vsh = av.shape();
5350
VectorSpecies species = vsh.withLanes(long.class);
5351
assert(species.equals(SPECIES));
5352
}
5353
5354
@Test
5355
static void ElementTypeLong256VectorTestsSmokeTest() {
5356
LongVector av = LongVector.zero(SPECIES);
5357
assert(av.species().elementType() == long.class);
5358
}
5359
5360
@Test
5361
static void SpeciesElementSizeLong256VectorTestsSmokeTest() {
5362
LongVector av = LongVector.zero(SPECIES);
5363
assert(av.species().elementSize() == Long.SIZE);
5364
}
5365
5366
@Test
5367
static void VectorTypeLong256VectorTestsSmokeTest() {
5368
LongVector av = LongVector.zero(SPECIES);
5369
assert(av.species().vectorType() == av.getClass());
5370
}
5371
5372
@Test
5373
static void WithLanesLong256VectorTestsSmokeTest() {
5374
LongVector av = LongVector.zero(SPECIES);
5375
VectorSpecies species = av.species().withLanes(long.class);
5376
assert(species.equals(SPECIES));
5377
}
5378
5379
@Test
5380
static void WithShapeLong256VectorTestsSmokeTest() {
5381
LongVector av = LongVector.zero(SPECIES);
5382
VectorShape vsh = av.shape();
5383
VectorSpecies species = av.species().withShape(vsh);
5384
assert(species.equals(SPECIES));
5385
}
5386
}
5387
5388
5389