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