jdk

Форк
0
/
TestOptionVectorizeIR.java 
803 строки · 21.4 Кб
1
/*
2
 * Copyright (c) 2023, 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
 * @bug 8298935
27
 * @summary Test forced vectorization, and check IR for vector instructions
28
 * @requires vm.compiler2.enabled
29
 * @library /test/lib /
30
 * @run driver compiler.vectorization.TestOptionVectorizeIR
31
 */
32

33
package compiler.vectorization;
34
import compiler.lib.ir_framework.*;
35

36
public class TestOptionVectorizeIR {
37
    static int RANGE = 1024*2;
38
    static int ITER  = 100;
39
    int[] gold1 = new int[RANGE];
40
    int[] gold2 = new int[RANGE];
41
    int[] gold3 = new int[RANGE];
42
    int[] gold4 = new int[RANGE];
43
    int[] gold5 = new int[RANGE];
44
    int[] gold6 = new int[RANGE];
45

46
    long[] gold10 = new long[RANGE];
47
    long[] gold11 = new long[RANGE];
48
    long[] gold12 = new long[RANGE];
49
    long[] gold13 = new long[RANGE];
50

51
    short[] gold20 = new short[RANGE];
52
    short[] gold21 = new short[RANGE];
53
    short[] gold22 = new short[RANGE];
54
    short[] gold23 = new short[RANGE];
55

56
    byte[] gold30 = new byte[RANGE];
57
    byte[] gold31 = new byte[RANGE];
58
    byte[] gold32 = new byte[RANGE];
59
    byte[] gold33 = new byte[RANGE];
60

61
    char[] gold40 = new char[RANGE];
62
    char[] gold41 = new char[RANGE];
63
    char[] gold42 = new char[RANGE];
64
    char[] gold43 = new char[RANGE];
65

66
    float[] gold50 = new float[RANGE];
67
    float[] gold51 = new float[RANGE];
68
    float[] gold52 = new float[RANGE];
69
    float[] gold53 = new float[RANGE];
70

71
    double[] gold60 = new double[RANGE];
72
    double[] gold61 = new double[RANGE];
73
    double[] gold62 = new double[RANGE];
74
    double[] gold63 = new double[RANGE];
75

76
    public static void main(String args[]) {
77
        TestFramework.runWithFlags("-XX:CompileCommand=option,compiler.vectorization.TestOptionVectorizeIR::test*,Vectorize");
78
    }
79

80
    TestOptionVectorizeIR() {
81
        // compute the gold standard in interpreter mode
82
        // test1
83
        test1(gold1);
84
        // test2
85
        test1(gold2);
86
        test2(gold2);
87
        // test3
88
        test1(gold3);
89
        test3(gold3, 2, 3);
90
        // test4
91
        test1(gold4);
92
        test4(gold4);
93
        // test5
94
        test1(gold5);
95
        test5(gold5);
96
        // test6
97
        test1(gold6);
98
        test6(gold6);
99

100
        // long
101
        init(gold10);
102
        test10(gold10);
103
        init(gold11);
104
        test11(gold11);
105
        init(gold12);
106
        test12(gold12);
107
        init(gold13);
108
        test13(gold13);
109

110
        // short
111
        init(gold20);
112
        test20(gold20);
113
        init(gold21);
114
        test21(gold21);
115
        init(gold22);
116
        test22(gold22);
117
        init(gold23);
118
        test23(gold23);
119

120
        // byte
121
        init(gold30);
122
        test30(gold30);
123
        init(gold31);
124
        test31(gold31);
125
        init(gold32);
126
        test32(gold32);
127
        init(gold33);
128
        test33(gold33);
129

130
        // char
131
        init(gold40);
132
        test40(gold40);
133
        init(gold41);
134
        test41(gold41);
135
        init(gold42);
136
        test42(gold42);
137
        init(gold43);
138
        test43(gold43);
139

140
        // float
141
        init(gold50);
142
        test50(gold50);
143
        init(gold51);
144
        test51(gold51);
145
        init(gold52);
146
        test52(gold52);
147
        init(gold53);
148
        test53(gold53);
149

150
        // double
151
        init(gold60);
152
        test60(gold60);
153
        init(gold61);
154
        test61(gold61);
155
        init(gold62);
156
        test62(gold62);
157
        init(gold63);
158
        test63(gold63);
159
    }
160

161
    @Run(test = "test1")
162
    @Warmup(100)
163
    public void runTest1() {
164
        int[] data = new int[RANGE];
165
        test1(data);
166
        verify("test1", data, gold1);
167
    }
168

169
    @Run(test = "test2")
170
    @Warmup(100)
171
    public void runTest2() {
172
        int[] data = new int[RANGE];
173
        test1(data);
174
        test2(data);
175
        verify("test2", data, gold2);
176
    }
177

178
    @Run(test = "test3")
179
    @Warmup(100)
180
    public void runTest3() {
181
        int[] data = new int[RANGE];
182
        test1(data);
183
        test3(data, 2, 3);
184
        verify("test3", data, gold3);
185
    }
186

187
    @Run(test = "test4")
188
    @Warmup(100)
189
    public void runTest4() {
190
        int[] data = new int[RANGE];
191
        test1(data);
192
        test4(data);
193
        verify("test4", data, gold4);
194
    }
195

196
    @Run(test = "test5")
197
    @Warmup(100)
198
    public void runTest5() {
199
        int[] data = new int[RANGE];
200
        test1(data);
201
        test5(data);
202
        verify("test5", data, gold5);
203
    }
204

205
    @Run(test = "test6")
206
    @Warmup(100)
207
    public void runTest6() {
208
        int[] data = new int[RANGE];
209
        test1(data);
210
        test6(data);
211
        verify("test6", data, gold6);
212
    }
213

214
    @Test
215
    static void test1(int[] data) {
216
       for (int j = 0; j < RANGE; j++) {
217
           // Vectorizes even if it is not forced
218
           data[j] = j;
219
       }
220
    }
221

222
    @Test
223
    @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.ADD_VI, "> 0", IRNode.STORE_VECTOR, "> 0"},
224
        applyIf = {"AlignVector", "false"},
225
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
226
    static void test2(int[] data) {
227
       for (int j = 0; j < RANGE - 1; j++) {
228
           // Only vectorizes if forced, because of offset by 1
229
           data[j] = data[j] + data[j + 1];
230
       }
231
    }
232

233
    @Test
234
    @IR(counts = {IRNode.LOAD_VECTOR_I, "> 0", IRNode.REPLICATE_I, "> 0", IRNode.ADD_VI, "> 0", IRNode.MUL_VI, "> 0", IRNode.STORE_VECTOR, "> 0"},
235
        applyIf = {"AlignVector", "false"},
236
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
237
    static void test3(int[] data, int A, int B) {
238
       for (int j = 0; j < RANGE - 1; j++) {
239
           // Only vectorizes if forced, because of offset by 1
240
           data[j] = A * data[j] + B * data[j + 1];
241
       }
242
    }
243

244
    @Test
245
    static void test4(int[] data) {
246
       for (int j = 0; j < RANGE - 1; j++) {
247
           // write forward -> cyclic dependency -> cannot vectorize
248
           // independent(s1, s2) for adjacent loads should detect this
249
           data[j + 1] = data[j];
250
       }
251
    }
252

253
    @Test
254
    static void test5(int[] data) {
255
       for (int j = 0; j < RANGE - 3; j++) {
256
           // write forward -> cyclic dependency -> cannot vectorize
257
           // independent(s1, s2) for adjacent loads cannot detect this
258
           // Checks with memory_alignment are disabled via compile option
259
           data[j + 2] = data[j];
260
       }
261
    }
262

263
    @Test
264
    static void test6(int[] data) {
265
       for (int j = 0; j < RANGE - 3; j++) {
266
           // write forward -> cyclic dependency -> cannot vectorize
267
           // independent(s1, s2) for adjacent loads cannot detect this
268
           // Checks with memory_alignment are disabled via compile option
269
           data[j + 3] = data[j];
270
       }
271
    }
272

273
    // ------------------------- Long -----------------------------
274

275
    @Test
276
    @IR(counts = {IRNode.LOAD_VECTOR_L, "> 0", IRNode.ADD_VL, "> 0", IRNode.STORE_VECTOR, "> 0"},
277
        applyIf = {"AlignVector", "false"},
278
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
279
    static void test10(long[] data) {
280
       for (int j = 2; j < RANGE - 2; j++) {
281
           data[j] += data[j + 2];
282
       }
283
    }
284

285
    @Test
286
    @IR(counts = {IRNode.LOAD_VECTOR_L, "> 0", IRNode.ADD_VL, "> 0", IRNode.STORE_VECTOR, "> 0"},
287
        applyIf = {"AlignVector", "false"},
288
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
289
    static void test11(long[] data) {
290
       for (int j = 2; j < RANGE - 2; j++) {
291
           data[j] += data[j + 1];
292
       }
293
    }
294

295
    @Test
296
    static void test12(long[] data) {
297
       for (int j = 2; j < RANGE - 2; j++) {
298
           data[j] += data[j - 1];
299
       }
300
    }
301

302
    @Test
303
    static void test13(long[] data) {
304
       // 128-bit vectors -> can vectorize because only 2 elements
305
       for (int j = 2; j < RANGE - 2; j++) {
306
           data[j] += data[j - 2];
307
       }
308
    }
309

310
    @Run(test = "test10")
311
    @Warmup(100)
312
    public void runTest10() {
313
        long[] data = new long[RANGE];
314
        init(data);
315
        test10(data);
316
        verify("test10", data, gold10);
317
    }
318

319
    @Run(test = "test11")
320
    @Warmup(100)
321
    public void runTest11() {
322
        long[] data = new long[RANGE];
323
        init(data);
324
        test11(data);
325
        verify("test11", data, gold11);
326
    }
327

328
    @Run(test = "test12")
329
    @Warmup(100)
330
    public void runTest12() {
331
        long[] data = new long[RANGE];
332
        init(data);
333
        test12(data);
334
        verify("test12", data, gold12);
335
    }
336

337
    @Run(test = "test13")
338
    @Warmup(100)
339
    public void runTest13() {
340
        long[] data = new long[RANGE];
341
        init(data);
342
        test13(data);
343
        verify("test13", data, gold13);
344
    }
345

346

347
    // ------------------------- Short -----------------------------
348

349
    @Test
350
    @IR(counts = {IRNode.LOAD_VECTOR_S, "> 0", IRNode.ADD_VS, "> 0", IRNode.STORE_VECTOR, "> 0"},
351
        applyIf = {"AlignVector", "false"},
352
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
353
    static void test20(short[] data) {
354
       for (int j = 2; j < RANGE - 2; j++) {
355
           data[j] += data[j + 2];
356
       }
357
    }
358

359
    @Test
360
    @IR(counts = {IRNode.LOAD_VECTOR_S, "> 0", IRNode.ADD_VS, "> 0", IRNode.STORE_VECTOR, "> 0"},
361
        applyIf = {"AlignVector", "false"},
362
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
363
    static void test21(short[] data) {
364
       for (int j = 2; j < RANGE - 2; j++) {
365
           data[j] += data[j + 1];
366
       }
367
    }
368

369
    @Test
370
    static void test22(short[] data) {
371
       for (int j = 2; j < RANGE - 2; j++) {
372
           data[j] += data[j - 1];
373
       }
374
    }
375

376
    @Test
377
    static void test23(short[] data) {
378
       for (int j = 2; j < RANGE - 2; j++) {
379
           data[j] += data[j - 2];
380
       }
381
    }
382

383
    @Run(test = "test20")
384
    @Warmup(100)
385
    public void runTest20() {
386
        short[] data = new short[RANGE];
387
        init(data);
388
        test20(data);
389
        verify("test20", data, gold20);
390
    }
391

392
    @Run(test = "test21")
393
    @Warmup(100)
394
    public void runTest21() {
395
        short[] data = new short[RANGE];
396
        init(data);
397
        test21(data);
398
        verify("test21", data, gold21);
399
    }
400

401
    @Run(test = "test22")
402
    @Warmup(100)
403
    public void runTest22() {
404
        short[] data = new short[RANGE];
405
        init(data);
406
        test22(data);
407
        verify("test22", data, gold22);
408
    }
409

410
    @Run(test = "test23")
411
    @Warmup(100)
412
    public void runTest23() {
413
        short[] data = new short[RANGE];
414
        init(data);
415
        test23(data);
416
        verify("test23", data, gold23);
417
    }
418

419

420
    // ------------------------- Byte -----------------------------
421

422
    @Test
423
    @IR(counts = {IRNode.LOAD_VECTOR_B, "> 0", IRNode.ADD_VB, "> 0", IRNode.STORE_VECTOR, "> 0"},
424
        applyIf = {"AlignVector", "false"},
425
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
426
    static void test30(byte[] data) {
427
       for (int j = 2; j < RANGE - 2; j++) {
428
           data[j] += data[j + 2];
429
       }
430
    }
431

432
    @Test
433
    @IR(counts = {IRNode.LOAD_VECTOR_B, "> 0", IRNode.ADD_VB, "> 0", IRNode.STORE_VECTOR, "> 0"},
434
        applyIf = {"AlignVector", "false"},
435
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
436
    static void test31(byte[] data) {
437
       for (int j = 2; j < RANGE - 2; j++) {
438
           data[j] += data[j + 1];
439
       }
440
    }
441

442
    @Test
443
    static void test32(byte[] data) {
444
       for (int j = 2; j < RANGE - 2; j++) {
445
           data[j] += data[j - 1];
446
       }
447
    }
448

449
    @Test
450
    static void test33(byte[] data) {
451
       for (int j = 2; j < RANGE - 2; j++) {
452
           data[j] += data[j - 2];
453
       }
454
    }
455

456
    @Run(test = "test30")
457
    @Warmup(100)
458
    public void runTest30() {
459
        byte[] data = new byte[RANGE];
460
        init(data);
461
        test30(data);
462
        verify("test30", data, gold30);
463
    }
464

465
    @Run(test = "test31")
466
    @Warmup(100)
467
    public void runTest31() {
468
        byte[] data = new byte[RANGE];
469
        init(data);
470
        test31(data);
471
        verify("test31", data, gold31);
472
    }
473

474
    @Run(test = "test32")
475
    @Warmup(100)
476
    public void runTest32() {
477
        byte[] data = new byte[RANGE];
478
        init(data);
479
        test32(data);
480
        verify("test32", data, gold32);
481
    }
482

483
    @Run(test = "test33")
484
    @Warmup(100)
485
    public void runTest33() {
486
        byte[] data = new byte[RANGE];
487
        init(data);
488
        test33(data);
489
        verify("test33", data, gold33);
490
    }
491

492

493
    // ------------------------- Char -----------------------------
494

495
    @Test
496
    @IR(counts = {IRNode.LOAD_VECTOR_C, "> 0", IRNode.ADD_VS, "> 0", IRNode.STORE_VECTOR, "> 0"},
497
        applyIf = {"AlignVector", "false"},
498
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
499
    static void test40(char[] data) {
500
       for (int j = 2; j < RANGE - 2; j++) {
501
           data[j] += data[j + 2];
502
       }
503
    }
504

505
    @Test
506
    @IR(counts = {IRNode.LOAD_VECTOR_C, "> 0", IRNode.ADD_VS, "> 0", IRNode.STORE_VECTOR, "> 0"},
507
        applyIf = {"AlignVector", "false"},
508
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
509
    static void test41(char[] data) {
510
       for (int j = 2; j < RANGE - 2; j++) {
511
           data[j] += data[j + 1];
512
       }
513
    }
514

515
    @Test
516
    static void test42(char[] data) {
517
       for (int j = 2; j < RANGE - 2; j++) {
518
           data[j] += data[j - 1];
519
       }
520
    }
521

522
    @Test
523
    static void test43(char[] data) {
524
       for (int j = 2; j < RANGE - 2; j++) {
525
           data[j] += data[j - 2];
526
       }
527
    }
528

529
    @Run(test = "test40")
530
    @Warmup(100)
531
    public void runTest40() {
532
        char[] data = new char[RANGE];
533
        init(data);
534
        test40(data);
535
        verify("test40", data, gold40);
536
    }
537

538
    @Run(test = "test41")
539
    @Warmup(100)
540
    public void runTest41() {
541
        char[] data = new char[RANGE];
542
        init(data);
543
        test41(data);
544
        verify("test41", data, gold41);
545
    }
546

547
    @Run(test = "test42")
548
    @Warmup(100)
549
    public void runTest42() {
550
        char[] data = new char[RANGE];
551
        init(data);
552
        test42(data);
553
        verify("test42", data, gold42);
554
    }
555

556
    @Run(test = "test43")
557
    @Warmup(100)
558
    public void runTest43() {
559
        char[] data = new char[RANGE];
560
        init(data);
561
        test43(data);
562
        verify("test43", data, gold43);
563
    }
564

565
    // ------------------------- Float -----------------------------
566

567
    @Test
568
    @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.ADD_VF, "> 0", IRNode.STORE_VECTOR, "> 0"},
569
        applyIf = {"AlignVector", "false"},
570
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
571
    static void test50(float[] data) {
572
       for (int j = 2; j < RANGE - 2; j++) {
573
           data[j] += data[j + 2];
574
       }
575
    }
576

577
    @Test
578
    @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.ADD_VF, "> 0", IRNode.STORE_VECTOR, "> 0"},
579
        applyIf = {"AlignVector", "false"},
580
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
581
    static void test51(float[] data) {
582
       for (int j = 2; j < RANGE - 2; j++) {
583
           data[j] += data[j + 1];
584
       }
585
    }
586

587
    @Test
588
    static void test52(float[] data) {
589
       for (int j = 2; j < RANGE - 2; j++) {
590
           data[j] += data[j - 1];
591
       }
592
    }
593

594
    @Test
595
    static void test53(float[] data) {
596
       for (int j = 2; j < RANGE - 2; j++) {
597
           data[j] += data[j - 2];
598
       }
599
    }
600

601
    @Run(test = "test50")
602
    @Warmup(100)
603
    public void runTest50() {
604
        float[] data = new float[RANGE];
605
        init(data);
606
        test50(data);
607
        verify("test50", data, gold50);
608
    }
609

610
    @Run(test = "test51")
611
    @Warmup(100)
612
    public void runTest51() {
613
        float[] data = new float[RANGE];
614
        init(data);
615
        test51(data);
616
        verify("test51", data, gold51);
617
    }
618

619
    @Run(test = "test52")
620
    @Warmup(100)
621
    public void runTest52() {
622
        float[] data = new float[RANGE];
623
        init(data);
624
        test52(data);
625
        verify("test52", data, gold52);
626
    }
627

628
    @Run(test = "test53")
629
    @Warmup(100)
630
    public void runTest53() {
631
        float[] data = new float[RANGE];
632
        init(data);
633
        test53(data);
634
        verify("test53", data, gold53);
635
    }
636

637
    // ------------------------- Double -----------------------------
638

639
    @Test
640
    @IR(counts = {IRNode.LOAD_VECTOR_D, "> 0", IRNode.ADD_VD, "> 0", IRNode.STORE_VECTOR, "> 0"},
641
        applyIf = {"AlignVector", "false"},
642
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
643
    static void test60(double[] data) {
644
       for (int j = 2; j < RANGE - 2; j++) {
645
           data[j] += data[j + 2];
646
       }
647
    }
648

649
    @Test
650
    @IR(counts = {IRNode.LOAD_VECTOR_D, "> 0", IRNode.ADD_VD, "> 0", IRNode.STORE_VECTOR, "> 0"},
651
        applyIf = {"AlignVector", "false"},
652
        applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
653
    static void test61(double[] data) {
654
       for (int j = 2; j < RANGE - 2; j++) {
655
           data[j] += data[j + 1];
656
       }
657
    }
658

659
    @Test
660
    static void test62(double[] data) {
661
       for (int j = 2; j < RANGE - 2; j++) {
662
           data[j] += data[j - 1];
663
       }
664
    }
665

666
    @Test
667
    static void test63(double[] data) {
668
       // 128-bit vectors -> can vectorize because only 2 elements
669
       for (int j = 2; j < RANGE - 2; j++) {
670
           data[j] += data[j - 2];
671
       }
672
    }
673

674
    @Run(test = "test60")
675
    @Warmup(100)
676
    public void runTest60() {
677
        double[] data = new double[RANGE];
678
        init(data);
679
        test60(data);
680
        verify("test60", data, gold60);
681
    }
682

683
    @Run(test = "test61")
684
    @Warmup(100)
685
    public void runTest61() {
686
        double[] data = new double[RANGE];
687
        init(data);
688
        test61(data);
689
        verify("test61", data, gold61);
690
    }
691

692
    @Run(test = "test62")
693
    @Warmup(100)
694
    public void runTest62() {
695
        double[] data = new double[RANGE];
696
        init(data);
697
        test62(data);
698
        verify("test62", data, gold62);
699
    }
700

701
    @Run(test = "test63")
702
    @Warmup(100)
703
    public void runTest63() {
704
        double[] data = new double[RANGE];
705
        init(data);
706
        test63(data);
707
        verify("test63", data, gold63);
708
    }
709

710
    static void init(long[] data) {
711
       for (int j = 0; j < RANGE; j++) {
712
           data[j] = j;
713
       }
714
    }
715

716
    static void init(short[] data) {
717
       for (int j = 0; j < RANGE; j++) {
718
           data[j] = (short)j;
719
       }
720
    }
721

722
    static void init(byte[] data) {
723
       for (int j = 0; j < RANGE; j++) {
724
           data[j] = (byte)j;
725
       }
726
    }
727

728
    static void init(char[] data) {
729
       for (int j = 0; j < RANGE; j++) {
730
           data[j] = (char)j;
731
       }
732
    }
733

734

735
    static void init(float[] data) {
736
       for (int j = 0; j < RANGE; j++) {
737
           data[j] = j;
738
       }
739
    }
740

741

742
    static void init(double[] data) {
743
       for (int j = 0; j < RANGE; j++) {
744
           data[j] = j;
745
       }
746
    }
747

748
    static void verify(String name, int[] data, int[] gold) {
749
        for (int i = 0; i < RANGE; i++) {
750
            if (data[i] != gold[i]) {
751
                throw new RuntimeException(" Invalid " + name + " result: data[" + i + "]: " + data[i] + " != " + gold[i]);
752
            }
753
        }
754
    }
755

756
    static void verify(String name, long[] data, long[] gold) {
757
        for (int i = 0; i < RANGE; i++) {
758
            if (data[i] != gold[i]) {
759
                throw new RuntimeException(" Invalid " + name + " result: data[" + i + "]: " + data[i] + " != " + gold[i]);
760
            }
761
        }
762
    }
763

764
    static void verify(String name, short[] data, short[] gold) {
765
        for (int i = 0; i < RANGE; i++) {
766
            if (data[i] != gold[i]) {
767
                throw new RuntimeException(" Invalid " + name + " result: data[" + i + "]: " + data[i] + " != " + gold[i]);
768
            }
769
        }
770
    }
771

772
    static void verify(String name, byte[] data, byte[] gold) {
773
        for (int i = 0; i < RANGE; i++) {
774
            if (data[i] != gold[i]) {
775
                throw new RuntimeException(" Invalid " + name + " result: data[" + i + "]: " + data[i] + " != " + gold[i]);
776
            }
777
        }
778
    }
779

780
    static void verify(String name, char[] data, char[] gold) {
781
        for (int i = 0; i < RANGE; i++) {
782
            if (data[i] != gold[i]) {
783
                throw new RuntimeException(" Invalid " + name + " result: data[" + i + "]: " + data[i] + " != " + gold[i]);
784
            }
785
        }
786
    }
787

788
    static void verify(String name, float[] data, float[] gold) {
789
        for (int i = 0; i < RANGE; i++) {
790
            if (data[i] != gold[i]) {
791
                throw new RuntimeException(" Invalid " + name + " result: data[" + i + "]: " + data[i] + " != " + gold[i]);
792
            }
793
        }
794
    }
795

796
    static void verify(String name, double[] data, double[] gold) {
797
        for (int i = 0; i < RANGE; i++) {
798
            if (data[i] != gold[i]) {
799
                throw new RuntimeException(" Invalid " + name + " result: data[" + i + "]: " + data[i] + " != " + gold[i]);
800
            }
801
        }
802
    }
803
}
804

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.