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