TestDoubleVect.java 23.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
/*
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 *
 */

/**
 * @test
 * @bug 6340864
 * @summary Implement vectorization optimizations in hotspot-server
 *
 * @run main/othervm/timeout=400 -Xbatch -Xmx64m TestDoubleVect
 */

public class TestDoubleVect {
  private static final int ARRLEN = 997;
  private static final int ITERS  = 11000;
  private static final double ADD_INIT = -7500.;
  private static final double VALUE = 15.;

  public static void main(String args[]) {
    System.out.println("Testing Double vectors");
    int errn = test();
    if (errn > 0) {
      System.err.println("FAILED: " + errn + " errors");
      System.exit(97);
    }
    System.out.println("PASSED");
  }

  static int test() {
    double[] a0 = new double[ARRLEN];
    double[] a1 = new double[ARRLEN];
    double[] a2 = new double[ARRLEN];
    double[] a3 = new double[ARRLEN];
    // Initialize
    double gold_sum = 0;
    for (int i=0; i<ARRLEN; i++) {
      double val = ADD_INIT+(double)i;
      gold_sum += val;
      a1[i] = val;
      a2[i] = VALUE;
      a3[i] = -VALUE;
    }

    System.out.println("Warmup");
    for (int i=0; i<ITERS; i++) {
      test_sum(a1);
      test_addc(a0, a1);
      test_addv(a0, a1, VALUE);
      test_adda(a0, a1, a2);
      test_subc(a0, a1);
      test_subv(a0, a1, VALUE);
      test_suba(a0, a1, a2);
      test_mulc(a0, a1);
      test_mulv(a0, a1, VALUE);
      test_mula(a0, a1, a2);
      test_divc(a0, a1);
      test_divv(a0, a1, VALUE);
      test_diva(a0, a1, a2);
      test_mulc_n(a0, a1);
      test_mulv(a0, a1, -VALUE);
      test_mula(a0, a1, a3);
      test_divc_n(a0, a1);
      test_divv(a0, a1, -VALUE);
      test_diva(a0, a1, a3);
    }
    // Test and verify results
    System.out.println("Verification");
    int errn = 0;
    {
      double sum = test_sum(a1);
      if (sum != gold_sum) {
        System.err.println("test_sum:  " + sum + " != " + gold_sum);
        errn++;
      }
      // Overwrite with NaN values
      a1[0] = Double.NaN;
      a1[1] = Double.POSITIVE_INFINITY;
      a1[2] = Double.NEGATIVE_INFINITY;
      a1[3] = Double.MAX_VALUE;
      a1[4] = Double.MIN_VALUE;
      a1[5] = Double.MIN_NORMAL;

      a2[6] = a1[0];
      a2[7] = a1[1];
      a2[8] = a1[2];
      a2[9] = a1[3];
      a2[10] = a1[4];
      a2[11] = a1[5];

      a3[6] = -a2[6];
      a3[7] = -a2[7];
      a3[8] = -a2[8];
      a3[9] = -a2[9];
      a3[10] = -a2[10];
      a3[11] = -a2[11];

      test_addc(a0, a1);
      errn += verify("test_addc: ", 0, a0[0], (Double.NaN+VALUE));
      errn += verify("test_addc: ", 1, a0[1], (Double.POSITIVE_INFINITY+VALUE));
      errn += verify("test_addc: ", 2, a0[2], (Double.NEGATIVE_INFINITY+VALUE));
      errn += verify("test_addc: ", 3, a0[3], (Double.MAX_VALUE+VALUE));
      errn += verify("test_addc: ", 4, a0[4], (Double.MIN_VALUE+VALUE));
      errn += verify("test_addc: ", 5, a0[5], (Double.MIN_NORMAL+VALUE));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_addc: ", i, a0[i], ((ADD_INIT+i)+VALUE));
      }
      test_addv(a0, a1, VALUE);
      errn += verify("test_addv: ", 0, a0[0], (Double.NaN+VALUE));
      errn += verify("test_addv: ", 1, a0[1], (Double.POSITIVE_INFINITY+VALUE));
      errn += verify("test_addv: ", 2, a0[2], (Double.NEGATIVE_INFINITY+VALUE));
      errn += verify("test_addv: ", 3, a0[3], (Double.MAX_VALUE+VALUE));
      errn += verify("test_addv: ", 4, a0[4], (Double.MIN_VALUE+VALUE));
      errn += verify("test_addv: ", 5, a0[5], (Double.MIN_NORMAL+VALUE));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_addv: ", i, a0[i], ((ADD_INIT+i)+VALUE));
      }
      test_adda(a0, a1, a2);
      errn += verify("test_adda: ", 0, a0[0], (Double.NaN+VALUE));
      errn += verify("test_adda: ", 1, a0[1], (Double.POSITIVE_INFINITY+VALUE));
      errn += verify("test_adda: ", 2, a0[2], (Double.NEGATIVE_INFINITY+VALUE));
      errn += verify("test_adda: ", 3, a0[3], (Double.MAX_VALUE+VALUE));
      errn += verify("test_adda: ", 4, a0[4], (Double.MIN_VALUE+VALUE));
      errn += verify("test_adda: ", 5, a0[5], (Double.MIN_NORMAL+VALUE));
      errn += verify("test_adda: ", 6, a0[6], ((ADD_INIT+6)+Double.NaN));
      errn += verify("test_adda: ", 7, a0[7], ((ADD_INIT+7)+Double.POSITIVE_INFINITY));
      errn += verify("test_adda: ", 8, a0[8], ((ADD_INIT+8)+Double.NEGATIVE_INFINITY));
      errn += verify("test_adda: ", 9, a0[9], ((ADD_INIT+9)+Double.MAX_VALUE));
      errn += verify("test_adda: ", 10, a0[10], ((ADD_INIT+10)+Double.MIN_VALUE));
      errn += verify("test_adda: ", 11, a0[11], ((ADD_INIT+11)+Double.MIN_NORMAL));
      for (int i=12; i<ARRLEN; i++) {
        errn += verify("test_adda: ", i, a0[i], ((ADD_INIT+i)+VALUE));
      }

      test_subc(a0, a1);
      errn += verify("test_subc: ", 0, a0[0], (Double.NaN-VALUE));
      errn += verify("test_subc: ", 1, a0[1], (Double.POSITIVE_INFINITY-VALUE));
      errn += verify("test_subc: ", 2, a0[2], (Double.NEGATIVE_INFINITY-VALUE));
      errn += verify("test_subc: ", 3, a0[3], (Double.MAX_VALUE-VALUE));
      errn += verify("test_subc: ", 4, a0[4], (Double.MIN_VALUE-VALUE));
      errn += verify("test_subc: ", 5, a0[5], (Double.MIN_NORMAL-VALUE));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_subc: ", i, a0[i], ((ADD_INIT+i)-VALUE));
      }
      test_subv(a0, a1, VALUE);
      errn += verify("test_subv: ", 0, a0[0], (Double.NaN-VALUE));
      errn += verify("test_subv: ", 1, a0[1], (Double.POSITIVE_INFINITY-VALUE));
      errn += verify("test_subv: ", 2, a0[2], (Double.NEGATIVE_INFINITY-VALUE));
      errn += verify("test_subv: ", 3, a0[3], (Double.MAX_VALUE-VALUE));
      errn += verify("test_subv: ", 4, a0[4], (Double.MIN_VALUE-VALUE));
      errn += verify("test_subv: ", 5, a0[5], (Double.MIN_NORMAL-VALUE));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_subv: ", i, a0[i], ((ADD_INIT+i)-VALUE));
      }
      test_suba(a0, a1, a2);
      errn += verify("test_suba: ", 0, a0[0], (Double.NaN-VALUE));
      errn += verify("test_suba: ", 1, a0[1], (Double.POSITIVE_INFINITY-VALUE));
      errn += verify("test_suba: ", 2, a0[2], (Double.NEGATIVE_INFINITY-VALUE));
      errn += verify("test_suba: ", 3, a0[3], (Double.MAX_VALUE-VALUE));
      errn += verify("test_suba: ", 4, a0[4], (Double.MIN_VALUE-VALUE));
      errn += verify("test_suba: ", 5, a0[5], (Double.MIN_NORMAL-VALUE));
      errn += verify("test_suba: ", 6, a0[6], ((ADD_INIT+6)-Double.NaN));
      errn += verify("test_suba: ", 7, a0[7], ((ADD_INIT+7)-Double.POSITIVE_INFINITY));
      errn += verify("test_suba: ", 8, a0[8], ((ADD_INIT+8)-Double.NEGATIVE_INFINITY));
      errn += verify("test_suba: ", 9, a0[9], ((ADD_INIT+9)-Double.MAX_VALUE));
      errn += verify("test_suba: ", 10, a0[10], ((ADD_INIT+10)-Double.MIN_VALUE));
      errn += verify("test_suba: ", 11, a0[11], ((ADD_INIT+11)-Double.MIN_NORMAL));
      for (int i=12; i<ARRLEN; i++) {
        errn += verify("test_suba: ", i, a0[i], ((ADD_INIT+i)-VALUE));
      }

      test_mulc(a0, a1);
      errn += verify("test_mulc: ", 0, a0[0], (Double.NaN*VALUE));
      errn += verify("test_mulc: ", 1, a0[1], (Double.POSITIVE_INFINITY*VALUE));
      errn += verify("test_mulc: ", 2, a0[2], (Double.NEGATIVE_INFINITY*VALUE));
      errn += verify("test_mulc: ", 3, a0[3], (Double.MAX_VALUE*VALUE));
      errn += verify("test_mulc: ", 4, a0[4], (Double.MIN_VALUE*VALUE));
      errn += verify("test_mulc: ", 5, a0[5], (Double.MIN_NORMAL*VALUE));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_mulc: ", i, a0[i], ((ADD_INIT+i)*VALUE));
      }
      test_mulv(a0, a1, VALUE);
      errn += verify("test_mulv: ", 0, a0[0], (Double.NaN*VALUE));
      errn += verify("test_mulv: ", 1, a0[1], (Double.POSITIVE_INFINITY*VALUE));
      errn += verify("test_mulv: ", 2, a0[2], (Double.NEGATIVE_INFINITY*VALUE));
      errn += verify("test_mulv: ", 3, a0[3], (Double.MAX_VALUE*VALUE));
      errn += verify("test_mulv: ", 4, a0[4], (Double.MIN_VALUE*VALUE));
      errn += verify("test_mulv: ", 5, a0[5], (Double.MIN_NORMAL*VALUE));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_mulv: ", i, a0[i], ((ADD_INIT+i)*VALUE));
      }
      test_mula(a0, a1, a2);
      errn += verify("test_mula: ", 0, a0[0], (Double.NaN*VALUE));
      errn += verify("test_mula: ", 1, a0[1], (Double.POSITIVE_INFINITY*VALUE));
      errn += verify("test_mula: ", 2, a0[2], (Double.NEGATIVE_INFINITY*VALUE));
      errn += verify("test_mula: ", 3, a0[3], (Double.MAX_VALUE*VALUE));
      errn += verify("test_mula: ", 4, a0[4], (Double.MIN_VALUE*VALUE));
      errn += verify("test_mula: ", 5, a0[5], (Double.MIN_NORMAL*VALUE));
      errn += verify("test_mula: ", 6, a0[6], ((ADD_INIT+6)*Double.NaN));
      errn += verify("test_mula: ", 7, a0[7], ((ADD_INIT+7)*Double.POSITIVE_INFINITY));
      errn += verify("test_mula: ", 8, a0[8], ((ADD_INIT+8)*Double.NEGATIVE_INFINITY));
      errn += verify("test_mula: ", 9, a0[9], ((ADD_INIT+9)*Double.MAX_VALUE));
      errn += verify("test_mula: ", 10, a0[10], ((ADD_INIT+10)*Double.MIN_VALUE));
      errn += verify("test_mula: ", 11, a0[11], ((ADD_INIT+11)*Double.MIN_NORMAL));
      for (int i=12; i<ARRLEN; i++) {
        errn += verify("test_mula: ", i, a0[i], ((ADD_INIT+i)*VALUE));
      }

      test_divc(a0, a1);
      errn += verify("test_divc: ", 0, a0[0], (Double.NaN/VALUE));
      errn += verify("test_divc: ", 1, a0[1], (Double.POSITIVE_INFINITY/VALUE));
      errn += verify("test_divc: ", 2, a0[2], (Double.NEGATIVE_INFINITY/VALUE));
      errn += verify("test_divc: ", 3, a0[3], (Double.MAX_VALUE/VALUE));
      errn += verify("test_divc: ", 4, a0[4], (Double.MIN_VALUE/VALUE));
      errn += verify("test_divc: ", 5, a0[5], (Double.MIN_NORMAL/VALUE));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_divc: ", i, a0[i], ((ADD_INIT+i)/VALUE));
      }
      test_divv(a0, a1, VALUE);
      errn += verify("test_divv: ", 0, a0[0], (Double.NaN/VALUE));
      errn += verify("test_divv: ", 1, a0[1], (Double.POSITIVE_INFINITY/VALUE));
      errn += verify("test_divv: ", 2, a0[2], (Double.NEGATIVE_INFINITY/VALUE));
      errn += verify("test_divv: ", 3, a0[3], (Double.MAX_VALUE/VALUE));
      errn += verify("test_divv: ", 4, a0[4], (Double.MIN_VALUE/VALUE));
      errn += verify("test_divv: ", 5, a0[5], (Double.MIN_NORMAL/VALUE));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_divv: ", i, a0[i], ((ADD_INIT+i)/VALUE));
      }
      test_diva(a0, a1, a2);
      errn += verify("test_diva: ", 0, a0[0], (Double.NaN/VALUE));
      errn += verify("test_diva: ", 1, a0[1], (Double.POSITIVE_INFINITY/VALUE));
      errn += verify("test_diva: ", 2, a0[2], (Double.NEGATIVE_INFINITY/VALUE));
      errn += verify("test_diva: ", 3, a0[3], (Double.MAX_VALUE/VALUE));
      errn += verify("test_diva: ", 4, a0[4], (Double.MIN_VALUE/VALUE));
      errn += verify("test_diva: ", 5, a0[5], (Double.MIN_NORMAL/VALUE));
      errn += verify("test_diva: ", 6, a0[6], ((ADD_INIT+6)/Double.NaN));
      errn += verify("test_diva: ", 7, a0[7], ((ADD_INIT+7)/Double.POSITIVE_INFINITY));
      errn += verify("test_diva: ", 8, a0[8], ((ADD_INIT+8)/Double.NEGATIVE_INFINITY));
      errn += verify("test_diva: ", 9, a0[9], ((ADD_INIT+9)/Double.MAX_VALUE));
      errn += verify("test_diva: ", 10, a0[10], ((ADD_INIT+10)/Double.MIN_VALUE));
      errn += verify("test_diva: ", 11, a0[11], ((ADD_INIT+11)/Double.MIN_NORMAL));
      for (int i=12; i<ARRLEN; i++) {
        errn += verify("test_diva: ", i, a0[i], ((ADD_INIT+i)/VALUE));
      }

      test_mulc_n(a0, a1);
      errn += verify("test_mulc_n: ", 0, a0[0], (Double.NaN*(-VALUE)));
      errn += verify("test_mulc_n: ", 1, a0[1], (Double.POSITIVE_INFINITY*(-VALUE)));
      errn += verify("test_mulc_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY*(-VALUE)));
      errn += verify("test_mulc_n: ", 3, a0[3], (Double.MAX_VALUE*(-VALUE)));
      errn += verify("test_mulc_n: ", 4, a0[4], (Double.MIN_VALUE*(-VALUE)));
      errn += verify("test_mulc_n: ", 5, a0[5], (Double.MIN_NORMAL*(-VALUE)));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_mulc_n: ", i, a0[i], ((ADD_INIT+i)*(-VALUE)));
      }
      test_mulv(a0, a1, -VALUE);
      errn += verify("test_mulv_n: ", 0, a0[0], (Double.NaN*(-VALUE)));
      errn += verify("test_mulv_n: ", 1, a0[1], (Double.POSITIVE_INFINITY*(-VALUE)));
      errn += verify("test_mulv_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY*(-VALUE)));
      errn += verify("test_mulv_n: ", 3, a0[3], (Double.MAX_VALUE*(-VALUE)));
      errn += verify("test_mulv_n: ", 4, a0[4], (Double.MIN_VALUE*(-VALUE)));
      errn += verify("test_mulv_n: ", 5, a0[5], (Double.MIN_NORMAL*(-VALUE)));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_mulv_n: ", i, a0[i], ((ADD_INIT+i)*(-VALUE)));
      }
      test_mula(a0, a1, a3);
      errn += verify("test_mula_n: ", 0, a0[0], (Double.NaN*(-VALUE)));
      errn += verify("test_mula_n: ", 1, a0[1], (Double.POSITIVE_INFINITY*(-VALUE)));
      errn += verify("test_mula_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY*(-VALUE)));
      errn += verify("test_mula_n: ", 3, a0[3], (Double.MAX_VALUE*(-VALUE)));
      errn += verify("test_mula_n: ", 4, a0[4], (Double.MIN_VALUE*(-VALUE)));
      errn += verify("test_mula_n: ", 5, a0[5], (Double.MIN_NORMAL*(-VALUE)));
      errn += verify("test_mula_n: ", 6, a0[6], ((ADD_INIT+6)*(-Double.NaN)));
      errn += verify("test_mula_n: ", 7, a0[7], ((ADD_INIT+7)*(-Double.POSITIVE_INFINITY)));
      errn += verify("test_mula_n: ", 8, a0[8], ((ADD_INIT+8)*(-Double.NEGATIVE_INFINITY)));
      errn += verify("test_mula_n: ", 9, a0[9], ((ADD_INIT+9)*(-Double.MAX_VALUE)));
      errn += verify("test_mula_n: ", 10, a0[10], ((ADD_INIT+10)*(-Double.MIN_VALUE)));
      errn += verify("test_mula_n: ", 11, a0[11], ((ADD_INIT+11)*(-Double.MIN_NORMAL)));
      for (int i=12; i<ARRLEN; i++) {
        errn += verify("test_mula_n: ", i, a0[i], ((ADD_INIT+i)*(-VALUE)));
      }

      test_divc_n(a0, a1);
      errn += verify("test_divc_n: ", 0, a0[0], (Double.NaN/(-VALUE)));
      errn += verify("test_divc_n: ", 1, a0[1], (Double.POSITIVE_INFINITY/(-VALUE)));
      errn += verify("test_divc_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY/(-VALUE)));
      errn += verify("test_divc_n: ", 3, a0[3], (Double.MAX_VALUE/(-VALUE)));
      errn += verify("test_divc_n: ", 4, a0[4], (Double.MIN_VALUE/(-VALUE)));
      errn += verify("test_divc_n: ", 5, a0[5], (Double.MIN_NORMAL/(-VALUE)));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_divc_n: ", i, a0[i], ((ADD_INIT+i)/(-VALUE)));
      }
      test_divv(a0, a1, -VALUE);
      errn += verify("test_divv_n: ", 0, a0[0], (Double.NaN/(-VALUE)));
      errn += verify("test_divv_n: ", 1, a0[1], (Double.POSITIVE_INFINITY/(-VALUE)));
      errn += verify("test_divv_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY/(-VALUE)));
      errn += verify("test_divv_n: ", 3, a0[3], (Double.MAX_VALUE/(-VALUE)));
      errn += verify("test_divv_n: ", 4, a0[4], (Double.MIN_VALUE/(-VALUE)));
      errn += verify("test_divv_n: ", 5, a0[5], (Double.MIN_NORMAL/(-VALUE)));
      for (int i=6; i<ARRLEN; i++) {
        errn += verify("test_divv_n: ", i, a0[i], ((ADD_INIT+i)/(-VALUE)));
      }
      test_diva(a0, a1, a3);
      errn += verify("test_diva_n: ", 0, a0[0], (Double.NaN/(-VALUE)));
      errn += verify("test_diva_n: ", 1, a0[1], (Double.POSITIVE_INFINITY/(-VALUE)));
      errn += verify("test_diva_n: ", 2, a0[2], (Double.NEGATIVE_INFINITY/(-VALUE)));
      errn += verify("test_diva_n: ", 3, a0[3], (Double.MAX_VALUE/(-VALUE)));
      errn += verify("test_diva_n: ", 4, a0[4], (Double.MIN_VALUE/(-VALUE)));
      errn += verify("test_diva_n: ", 5, a0[5], (Double.MIN_NORMAL/(-VALUE)));
      errn += verify("test_diva_n: ", 6, a0[6], ((ADD_INIT+6)/(-Double.NaN)));
      errn += verify("test_diva_n: ", 7, a0[7], ((ADD_INIT+7)/(-Double.POSITIVE_INFINITY)));
      errn += verify("test_diva_n: ", 8, a0[8], ((ADD_INIT+8)/(-Double.NEGATIVE_INFINITY)));
      errn += verify("test_diva_n: ", 9, a0[9], ((ADD_INIT+9)/(-Double.MAX_VALUE)));
      errn += verify("test_diva_n: ", 10, a0[10], ((ADD_INIT+10)/(-Double.MIN_VALUE)));
      errn += verify("test_diva_n: ", 11, a0[11], ((ADD_INIT+11)/(-Double.MIN_NORMAL)));
      for (int i=12; i<ARRLEN; i++) {
        errn += verify("test_diva_n: ", i, a0[i], ((ADD_INIT+i)/(-VALUE)));
      }

    }

    if (errn > 0)
      return errn;

    System.out.println("Time");
    long start, end;

    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_sum(a1);
    }
    end = System.currentTimeMillis();
    System.out.println("test_sum: " + (end - start));

    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_addc(a0, a1);
    }
    end = System.currentTimeMillis();
    System.out.println("test_addc: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_addv(a0, a1, VALUE);
    }
    end = System.currentTimeMillis();
    System.out.println("test_addv: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_adda(a0, a1, a2);
    }
    end = System.currentTimeMillis();
    System.out.println("test_adda: " + (end - start));

    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_subc(a0, a1);
    }
    end = System.currentTimeMillis();
    System.out.println("test_subc: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_subv(a0, a1, VALUE);
    }
    end = System.currentTimeMillis();
    System.out.println("test_subv: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_suba(a0, a1, a2);
    }
    end = System.currentTimeMillis();
    System.out.println("test_suba: " + (end - start));

    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_mulc(a0, a1);
    }
    end = System.currentTimeMillis();
    System.out.println("test_mulc: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_mulv(a0, a1, VALUE);
    }
    end = System.currentTimeMillis();
    System.out.println("test_mulv: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_mula(a0, a1, a2);
    }
    end = System.currentTimeMillis();
    System.out.println("test_mula: " + (end - start));

    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_divc(a0, a1);
    }
    end = System.currentTimeMillis();
    System.out.println("test_divc: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_divv(a0, a1, VALUE);
    }
    end = System.currentTimeMillis();
    System.out.println("test_divv: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_diva(a0, a1, a2);
    }
    end = System.currentTimeMillis();
    System.out.println("test_diva: " + (end - start));

    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_mulc_n(a0, a1);
    }
    end = System.currentTimeMillis();
    System.out.println("test_mulc_n: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_mulv(a0, a1, -VALUE);
    }
    end = System.currentTimeMillis();
    System.out.println("test_mulv_n: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_mula(a0, a1, a3);
    }
    end = System.currentTimeMillis();
    System.out.println("test_mula_n: " + (end - start));

    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_divc_n(a0, a1);
    }
    end = System.currentTimeMillis();
    System.out.println("test_divc_n: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_divv(a0, a1, -VALUE);
    }
    end = System.currentTimeMillis();
    System.out.println("test_divv_n: " + (end - start));
    start = System.currentTimeMillis();
    for (int i=0; i<ITERS; i++) {
      test_diva(a0, a1, a3);
    }
    end = System.currentTimeMillis();
    System.out.println("test_diva_n: " + (end - start));

    return errn;
  }

  static double test_sum(double[] a1) {
    double sum = 0;
    for (int i = 0; i < a1.length; i+=1) {
      sum += a1[i];
    }
    return sum;
  }

  static void test_addc(double[] a0, double[] a1) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]+VALUE);
    }
  }
  static void test_addv(double[] a0, double[] a1, double b) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]+b);
    }
  }
  static void test_adda(double[] a0, double[] a1, double[] a2) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]+a2[i]);
    }
  }

  static void test_subc(double[] a0, double[] a1) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]-VALUE);
    }
  }
  static void test_subv(double[] a0, double[] a1, double b) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]-b);
    }
  }
  static void test_suba(double[] a0, double[] a1, double[] a2) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]-a2[i]);
    }
  }

  static void test_mulc(double[] a0, double[] a1) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]*VALUE);
    }
  }
  static void test_mulc_n(double[] a0, double[] a1) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]*(-VALUE));
    }
  }
  static void test_mulv(double[] a0, double[] a1, double b) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]*b);
    }
  }
  static void test_mula(double[] a0, double[] a1, double[] a2) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]*a2[i]);
    }
  }

  static void test_divc(double[] a0, double[] a1) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]/VALUE);
    }
  }
  static void test_divc_n(double[] a0, double[] a1) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]/(-VALUE));
    }
  }
  static void test_divv(double[] a0, double[] a1, double b) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]/b);
    }
  }
  static void test_diva(double[] a0, double[] a1, double[] a2) {
    for (int i = 0; i < a0.length; i+=1) {
      a0[i] = (a1[i]/a2[i]);
    }
  }

  static int verify(String text, int i, double elem, double val) {
    if (elem != val && !(Double.isNaN(elem) && Double.isNaN(val))) {
      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
      return 1;
    }
    return 0;
  }
}