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