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       test_negc(a0, a1);
  90     }
  91     // Test and verify results
  92     System.out.println("Verification");
  93     int errn = 0;
  94     {
  95       float sum = test_sum(a1);
  96       if (sum != gold_sum) {
  97         System.err.println("test_sum:  " + sum + " != " + gold_sum);
  98         errn++;
  99       }
 100       // Overwrite with NaN values
 101       a1[0] = Float.NaN;
 102       a1[1] = Float.POSITIVE_INFINITY;
 103       a1[2] = Float.NEGATIVE_INFINITY;
 104       a1[3] = Float.MAX_VALUE;
 105       a1[4] = Float.MIN_VALUE;
 106       a1[5] = Float.MIN_NORMAL;
 107 
 108       a2[6] = a1[0];
 109       a2[7] = a1[1];
 110       a2[8] = a1[2];
 111       a2[9] = a1[3];
 112       a2[10] = a1[4];
 113       a2[11] = a1[5];
 114 
 115       a3[6] = -a2[6];
 116       a3[7] = -a2[7];
 117       a3[8] = -a2[8];
 118       a3[9] = -a2[9];
 119       a3[10] = -a2[10];
 120       a3[11] = -a2[11];
 121 
 122       test_addc(a0, a1);
 123       errn += verify("test_addc: ", 0, a0[0], (Float.NaN+VALUE));
 124       errn += verify("test_addc: ", 1, a0[1], (Float.POSITIVE_INFINITY+VALUE));
 125       errn += verify("test_addc: ", 2, a0[2], (Float.NEGATIVE_INFINITY+VALUE));
 126       errn += verify("test_addc: ", 3, a0[3], (Float.MAX_VALUE+VALUE));
 127       errn += verify("test_addc: ", 4, a0[4], (Float.MIN_VALUE+VALUE));
 128       errn += verify("test_addc: ", 5, a0[5], (Float.MIN_NORMAL+VALUE));
 129       for (int i=6; i<ARRLEN; i++) {
 130         errn += verify("test_addc: ", i, a0[i], ((ADD_INIT+i)+VALUE));
 131       }
 132       test_addv(a0, a1, VALUE);
 133       errn += verify("test_addv: ", 0, a0[0], (Float.NaN+VALUE));
 134       errn += verify("test_addv: ", 1, a0[1], (Float.POSITIVE_INFINITY+VALUE));
 135       errn += verify("test_addv: ", 2, a0[2], (Float.NEGATIVE_INFINITY+VALUE));
 136       errn += verify("test_addv: ", 3, a0[3], (Float.MAX_VALUE+VALUE));
 137       errn += verify("test_addv: ", 4, a0[4], (Float.MIN_VALUE+VALUE));
 138       errn += verify("test_addv: ", 5, a0[5], (Float.MIN_NORMAL+VALUE));
 139       for (int i=6; i<ARRLEN; i++) {
 140         errn += verify("test_addv: ", i, a0[i], ((ADD_INIT+i)+VALUE));
 141       }
 142       test_adda(a0, a1, a2);
 143       errn += verify("test_adda: ", 0, a0[0], (Float.NaN+VALUE));
 144       errn += verify("test_adda: ", 1, a0[1], (Float.POSITIVE_INFINITY+VALUE));
 145       errn += verify("test_adda: ", 2, a0[2], (Float.NEGATIVE_INFINITY+VALUE));
 146       errn += verify("test_adda: ", 3, a0[3], (Float.MAX_VALUE+VALUE));
 147       errn += verify("test_adda: ", 4, a0[4], (Float.MIN_VALUE+VALUE));
 148       errn += verify("test_adda: ", 5, a0[5], (Float.MIN_NORMAL+VALUE));
 149       errn += verify("test_adda: ", 6, a0[6], ((ADD_INIT+6)+Float.NaN));
 150       errn += verify("test_adda: ", 7, a0[7], ((ADD_INIT+7)+Float.POSITIVE_INFINITY));
 151       errn += verify("test_adda: ", 8, a0[8], ((ADD_INIT+8)+Float.NEGATIVE_INFINITY));
 152       errn += verify("test_adda: ", 9, a0[9], ((ADD_INIT+9)+Float.MAX_VALUE));
 153       errn += verify("test_adda: ", 10, a0[10], ((ADD_INIT+10)+Float.MIN_VALUE));
 154       errn += verify("test_adda: ", 11, a0[11], ((ADD_INIT+11)+Float.MIN_NORMAL));
 155       for (int i=12; i<ARRLEN; i++) {
 156         errn += verify("test_adda: ", i, a0[i], ((ADD_INIT+i)+VALUE));
 157       }
 158 
 159       test_subc(a0, a1);
 160       errn += verify("test_subc: ", 0, a0[0], (Float.NaN-VALUE));
 161       errn += verify("test_subc: ", 1, a0[1], (Float.POSITIVE_INFINITY-VALUE));
 162       errn += verify("test_subc: ", 2, a0[2], (Float.NEGATIVE_INFINITY-VALUE));
 163       errn += verify("test_subc: ", 3, a0[3], (Float.MAX_VALUE-VALUE));
 164       errn += verify("test_subc: ", 4, a0[4], (Float.MIN_VALUE-VALUE));
 165       errn += verify("test_subc: ", 5, a0[5], (Float.MIN_NORMAL-VALUE));
 166       for (int i=6; i<ARRLEN; i++) {
 167         errn += verify("test_subc: ", i, a0[i], ((ADD_INIT+i)-VALUE));
 168       }
 169       test_subv(a0, a1, VALUE);
 170       errn += verify("test_subv: ", 0, a0[0], (Float.NaN-VALUE));
 171       errn += verify("test_subv: ", 1, a0[1], (Float.POSITIVE_INFINITY-VALUE));
 172       errn += verify("test_subv: ", 2, a0[2], (Float.NEGATIVE_INFINITY-VALUE));
 173       errn += verify("test_subv: ", 3, a0[3], (Float.MAX_VALUE-VALUE));
 174       errn += verify("test_subv: ", 4, a0[4], (Float.MIN_VALUE-VALUE));
 175       errn += verify("test_subv: ", 5, a0[5], (Float.MIN_NORMAL-VALUE));
 176       for (int i=6; i<ARRLEN; i++) {
 177         errn += verify("test_subv: ", i, a0[i], ((ADD_INIT+i)-VALUE));
 178       }
 179       test_suba(a0, a1, a2);
 180       errn += verify("test_suba: ", 0, a0[0], (Float.NaN-VALUE));
 181       errn += verify("test_suba: ", 1, a0[1], (Float.POSITIVE_INFINITY-VALUE));
 182       errn += verify("test_suba: ", 2, a0[2], (Float.NEGATIVE_INFINITY-VALUE));
 183       errn += verify("test_suba: ", 3, a0[3], (Float.MAX_VALUE-VALUE));
 184       errn += verify("test_suba: ", 4, a0[4], (Float.MIN_VALUE-VALUE));
 185       errn += verify("test_suba: ", 5, a0[5], (Float.MIN_NORMAL-VALUE));
 186       errn += verify("test_suba: ", 6, a0[6], ((ADD_INIT+6)-Float.NaN));
 187       errn += verify("test_suba: ", 7, a0[7], ((ADD_INIT+7)-Float.POSITIVE_INFINITY));
 188       errn += verify("test_suba: ", 8, a0[8], ((ADD_INIT+8)-Float.NEGATIVE_INFINITY));
 189       errn += verify("test_suba: ", 9, a0[9], ((ADD_INIT+9)-Float.MAX_VALUE));
 190       errn += verify("test_suba: ", 10, a0[10], ((ADD_INIT+10)-Float.MIN_VALUE));
 191       errn += verify("test_suba: ", 11, a0[11], ((ADD_INIT+11)-Float.MIN_NORMAL));
 192       for (int i=12; i<ARRLEN; i++) {
 193         errn += verify("test_suba: ", i, a0[i], ((ADD_INIT+i)-VALUE));
 194       }
 195 
 196       test_mulc(a0, a1);
 197       errn += verify("test_mulc: ", 0, a0[0], (Float.NaN*VALUE));
 198       errn += verify("test_mulc: ", 1, a0[1], (Float.POSITIVE_INFINITY*VALUE));
 199       errn += verify("test_mulc: ", 2, a0[2], (Float.NEGATIVE_INFINITY*VALUE));
 200       errn += verify("test_mulc: ", 3, a0[3], (Float.MAX_VALUE*VALUE));
 201       errn += verify("test_mulc: ", 4, a0[4], (Float.MIN_VALUE*VALUE));
 202       errn += verify("test_mulc: ", 5, a0[5], (Float.MIN_NORMAL*VALUE));
 203       for (int i=6; i<ARRLEN; i++) {
 204         errn += verify("test_mulc: ", i, a0[i], ((ADD_INIT+i)*VALUE));
 205       }
 206       test_mulv(a0, a1, VALUE);
 207       errn += verify("test_mulv: ", 0, a0[0], (Float.NaN*VALUE));
 208       errn += verify("test_mulv: ", 1, a0[1], (Float.POSITIVE_INFINITY*VALUE));
 209       errn += verify("test_mulv: ", 2, a0[2], (Float.NEGATIVE_INFINITY*VALUE));
 210       errn += verify("test_mulv: ", 3, a0[3], (Float.MAX_VALUE*VALUE));
 211       errn += verify("test_mulv: ", 4, a0[4], (Float.MIN_VALUE*VALUE));
 212       errn += verify("test_mulv: ", 5, a0[5], (Float.MIN_NORMAL*VALUE));
 213       for (int i=6; i<ARRLEN; i++) {
 214         errn += verify("test_mulv: ", i, a0[i], ((ADD_INIT+i)*VALUE));
 215       }
 216       test_mula(a0, a1, a2);
 217       errn += verify("test_mula: ", 0, a0[0], (Float.NaN*VALUE));
 218       errn += verify("test_mula: ", 1, a0[1], (Float.POSITIVE_INFINITY*VALUE));
 219       errn += verify("test_mula: ", 2, a0[2], (Float.NEGATIVE_INFINITY*VALUE));
 220       errn += verify("test_mula: ", 3, a0[3], (Float.MAX_VALUE*VALUE));
 221       errn += verify("test_mula: ", 4, a0[4], (Float.MIN_VALUE*VALUE));
 222       errn += verify("test_mula: ", 5, a0[5], (Float.MIN_NORMAL*VALUE));
 223       errn += verify("test_mula: ", 6, a0[6], ((ADD_INIT+6)*Float.NaN));
 224       errn += verify("test_mula: ", 7, a0[7], ((ADD_INIT+7)*Float.POSITIVE_INFINITY));
 225       errn += verify("test_mula: ", 8, a0[8], ((ADD_INIT+8)*Float.NEGATIVE_INFINITY));
 226       errn += verify("test_mula: ", 9, a0[9], ((ADD_INIT+9)*Float.MAX_VALUE));
 227       errn += verify("test_mula: ", 10, a0[10], ((ADD_INIT+10)*Float.MIN_VALUE));
 228       errn += verify("test_mula: ", 11, a0[11], ((ADD_INIT+11)*Float.MIN_NORMAL));
 229       for (int i=12; i<ARRLEN; i++) {
 230         errn += verify("test_mula: ", i, a0[i], ((ADD_INIT+i)*VALUE));
 231       }
 232 
 233       test_divc(a0, a1);
 234       errn += verify("test_divc: ", 0, a0[0], (Float.NaN/VALUE));
 235       errn += verify("test_divc: ", 1, a0[1], (Float.POSITIVE_INFINITY/VALUE));
 236       errn += verify("test_divc: ", 2, a0[2], (Float.NEGATIVE_INFINITY/VALUE));
 237       errn += verify("test_divc: ", 3, a0[3], (Float.MAX_VALUE/VALUE));
 238       errn += verify("test_divc: ", 4, a0[4], (Float.MIN_VALUE/VALUE));
 239       errn += verify("test_divc: ", 5, a0[5], (Float.MIN_NORMAL/VALUE));
 240       for (int i=6; i<ARRLEN; i++) {
 241         errn += verify("test_divc: ", i, a0[i], ((ADD_INIT+i)/VALUE));
 242       }
 243       test_divv(a0, a1, VALUE);
 244       errn += verify("test_divv: ", 0, a0[0], (Float.NaN/VALUE));
 245       errn += verify("test_divv: ", 1, a0[1], (Float.POSITIVE_INFINITY/VALUE));
 246       errn += verify("test_divv: ", 2, a0[2], (Float.NEGATIVE_INFINITY/VALUE));
 247       errn += verify("test_divv: ", 3, a0[3], (Float.MAX_VALUE/VALUE));
 248       errn += verify("test_divv: ", 4, a0[4], (Float.MIN_VALUE/VALUE));
 249       errn += verify("test_divv: ", 5, a0[5], (Float.MIN_NORMAL/VALUE));
 250       for (int i=6; i<ARRLEN; i++) {
 251         errn += verify("test_divv: ", i, a0[i], ((ADD_INIT+i)/VALUE));
 252       }
 253       test_diva(a0, a1, a2);
 254       errn += verify("test_diva: ", 0, a0[0], (Float.NaN/VALUE));
 255       errn += verify("test_diva: ", 1, a0[1], (Float.POSITIVE_INFINITY/VALUE));
 256       errn += verify("test_diva: ", 2, a0[2], (Float.NEGATIVE_INFINITY/VALUE));
 257       errn += verify("test_diva: ", 3, a0[3], (Float.MAX_VALUE/VALUE));
 258       errn += verify("test_diva: ", 4, a0[4], (Float.MIN_VALUE/VALUE));
 259       errn += verify("test_diva: ", 5, a0[5], (Float.MIN_NORMAL/VALUE));
 260       errn += verify("test_diva: ", 6, a0[6], ((ADD_INIT+6)/Float.NaN));
 261       errn += verify("test_diva: ", 7, a0[7], ((ADD_INIT+7)/Float.POSITIVE_INFINITY));
 262       errn += verify("test_diva: ", 8, a0[8], ((ADD_INIT+8)/Float.NEGATIVE_INFINITY));
 263       errn += verify("test_diva: ", 9, a0[9], ((ADD_INIT+9)/Float.MAX_VALUE));
 264       errn += verify("test_diva: ", 10, a0[10], ((ADD_INIT+10)/Float.MIN_VALUE));
 265       errn += verify("test_diva: ", 11, a0[11], ((ADD_INIT+11)/Float.MIN_NORMAL));
 266       for (int i=12; i<ARRLEN; i++) {
 267         errn += verify("test_diva: ", i, a0[i], ((ADD_INIT+i)/VALUE));
 268       }
 269 
 270       test_mulc_n(a0, a1);
 271       errn += verify("test_mulc_n: ", 0, a0[0], (Float.NaN*(-VALUE)));
 272       errn += verify("test_mulc_n: ", 1, a0[1], (Float.POSITIVE_INFINITY*(-VALUE)));
 273       errn += verify("test_mulc_n: ", 2, a0[2], (Float.NEGATIVE_INFINITY*(-VALUE)));
 274       errn += verify("test_mulc_n: ", 3, a0[3], (Float.MAX_VALUE*(-VALUE)));
 275       errn += verify("test_mulc_n: ", 4, a0[4], (Float.MIN_VALUE*(-VALUE)));
 276       errn += verify("test_mulc_n: ", 5, a0[5], (Float.MIN_NORMAL*(-VALUE)));
 277       for (int i=6; i<ARRLEN; i++) {
 278         errn += verify("test_mulc_n: ", i, a0[i], ((ADD_INIT+i)*(-VALUE)));
 279       }
 280       test_mulv(a0, a1, -VALUE);
 281       errn += verify("test_mulv_n: ", 0, a0[0], (Float.NaN*(-VALUE)));
 282       errn += verify("test_mulv_n: ", 1, a0[1], (Float.POSITIVE_INFINITY*(-VALUE)));
 283       errn += verify("test_mulv_n: ", 2, a0[2], (Float.NEGATIVE_INFINITY*(-VALUE)));
 284       errn += verify("test_mulv_n: ", 3, a0[3], (Float.MAX_VALUE*(-VALUE)));
 285       errn += verify("test_mulv_n: ", 4, a0[4], (Float.MIN_VALUE*(-VALUE)));
 286       errn += verify("test_mulv_n: ", 5, a0[5], (Float.MIN_NORMAL*(-VALUE)));
 287       for (int i=6; i<ARRLEN; i++) {
 288         errn += verify("test_mulv_n: ", i, a0[i], ((ADD_INIT+i)*(-VALUE)));
 289       }
 290       test_mula(a0, a1, a3);
 291       errn += verify("test_mula_n: ", 0, a0[0], (Float.NaN*(-VALUE)));
 292       errn += verify("test_mula_n: ", 1, a0[1], (Float.POSITIVE_INFINITY*(-VALUE)));
 293       errn += verify("test_mula_n: ", 2, a0[2], (Float.NEGATIVE_INFINITY*(-VALUE)));
 294       errn += verify("test_mula_n: ", 3, a0[3], (Float.MAX_VALUE*(-VALUE)));
 295       errn += verify("test_mula_n: ", 4, a0[4], (Float.MIN_VALUE*(-VALUE)));
 296       errn += verify("test_mula_n: ", 5, a0[5], (Float.MIN_NORMAL*(-VALUE)));
 297       errn += verify("test_mula_n: ", 6, a0[6], ((ADD_INIT+6)*(-Float.NaN)));
 298       errn += verify("test_mula_n: ", 7, a0[7], ((ADD_INIT+7)*(-Float.POSITIVE_INFINITY)));
 299       errn += verify("test_mula_n: ", 8, a0[8], ((ADD_INIT+8)*(-Float.NEGATIVE_INFINITY)));
 300       errn += verify("test_mula_n: ", 9, a0[9], ((ADD_INIT+9)*(-Float.MAX_VALUE)));
 301       errn += verify("test_mula_n: ", 10, a0[10], ((ADD_INIT+10)*(-Float.MIN_VALUE)));
 302       errn += verify("test_mula_n: ", 11, a0[11], ((ADD_INIT+11)*(-Float.MIN_NORMAL)));
 303       for (int i=12; i<ARRLEN; i++) {
 304         errn += verify("test_mula_n: ", i, a0[i], ((ADD_INIT+i)*(-VALUE)));
 305       }
 306 
 307       test_divc_n(a0, a1);
 308       errn += verify("test_divc_n: ", 0, a0[0], (Float.NaN/(-VALUE)));
 309       errn += verify("test_divc_n: ", 1, a0[1], (Float.POSITIVE_INFINITY/(-VALUE)));
 310       errn += verify("test_divc_n: ", 2, a0[2], (Float.NEGATIVE_INFINITY/(-VALUE)));
 311       errn += verify("test_divc_n: ", 3, a0[3], (Float.MAX_VALUE/(-VALUE)));
 312       errn += verify("test_divc_n: ", 4, a0[4], (Float.MIN_VALUE/(-VALUE)));
 313       errn += verify("test_divc_n: ", 5, a0[5], (Float.MIN_NORMAL/(-VALUE)));
 314       for (int i=6; i<ARRLEN; i++) {
 315         errn += verify("test_divc_n: ", i, a0[i], ((ADD_INIT+i)/(-VALUE)));
 316       }
 317       test_divv(a0, a1, -VALUE);
 318       errn += verify("test_divv_n: ", 0, a0[0], (Float.NaN/(-VALUE)));
 319       errn += verify("test_divv_n: ", 1, a0[1], (Float.POSITIVE_INFINITY/(-VALUE)));
 320       errn += verify("test_divv_n: ", 2, a0[2], (Float.NEGATIVE_INFINITY/(-VALUE)));
 321       errn += verify("test_divv_n: ", 3, a0[3], (Float.MAX_VALUE/(-VALUE)));
 322       errn += verify("test_divv_n: ", 4, a0[4], (Float.MIN_VALUE/(-VALUE)));
 323       errn += verify("test_divv_n: ", 5, a0[5], (Float.MIN_NORMAL/(-VALUE)));
 324       for (int i=6; i<ARRLEN; i++) {
 325         errn += verify("test_divv_n: ", i, a0[i], ((ADD_INIT+i)/(-VALUE)));
 326       }
 327       test_diva(a0, a1, a3);
 328       errn += verify("test_diva_n: ", 0, a0[0], (Float.NaN/(-VALUE)));
 329       errn += verify("test_diva_n: ", 1, a0[1], (Float.POSITIVE_INFINITY/(-VALUE)));
 330       errn += verify("test_diva_n: ", 2, a0[2], (Float.NEGATIVE_INFINITY/(-VALUE)));
 331       errn += verify("test_diva_n: ", 3, a0[3], (Float.MAX_VALUE/(-VALUE)));
 332       errn += verify("test_diva_n: ", 4, a0[4], (Float.MIN_VALUE/(-VALUE)));
 333       errn += verify("test_diva_n: ", 5, a0[5], (Float.MIN_NORMAL/(-VALUE)));
 334       errn += verify("test_diva_n: ", 6, a0[6], ((ADD_INIT+6)/(-Float.NaN)));
 335       errn += verify("test_diva_n: ", 7, a0[7], ((ADD_INIT+7)/(-Float.POSITIVE_INFINITY)));
 336       errn += verify("test_diva_n: ", 8, a0[8], ((ADD_INIT+8)/(-Float.NEGATIVE_INFINITY)));
 337       errn += verify("test_diva_n: ", 9, a0[9], ((ADD_INIT+9)/(-Float.MAX_VALUE)));
 338       errn += verify("test_diva_n: ", 10, a0[10], ((ADD_INIT+10)/(-Float.MIN_VALUE)));
 339       errn += verify("test_diva_n: ", 11, a0[11], ((ADD_INIT+11)/(-Float.MIN_NORMAL)));
 340       for (int i=12; i<ARRLEN; i++) {
 341         errn += verify("test_diva_n: ", i, a0[i], ((ADD_INIT+i)/(-VALUE)));
 342       }
 343 
 344       test_negc(a0, a1);
 345       errn += verify("test_negc: ", 0, a0[0], (Float.NaN));
 346       errn += verify("test_negc: ", 1, a0[1], (Float.NEGATIVE_INFINITY));
 347       errn += verify("test_negc: ", 2, a0[2], (Float.POSITIVE_INFINITY));
 348       errn += verify("test_negc: ", 3, a0[3], (float)(-Float.MAX_VALUE));
 349       errn += verify("test_negc: ", 4, a0[4], (float)(-Float.MIN_VALUE));
 350       errn += verify("test_negc: ", 5, a0[5], (float)(-Float.MIN_NORMAL));
 351       for (int i=6; i<ARRLEN; i++) {
 352         errn += verify("test_negc: ", i, a0[i], (float)(-((float)(ADD_INIT+i))));
 353       }
 354 
 355     }
 356 
 357     if (errn > 0)
 358       return errn;
 359 
 360     System.out.println("Time");
 361     long start, end;
 362 
 363     start = System.currentTimeMillis();
 364     for (int i=0; i<ITERS; i++) {
 365       test_sum(a1);
 366     }
 367     end = System.currentTimeMillis();
 368     System.out.println("test_sum: " + (end - start));
 369 
 370     start = System.currentTimeMillis();
 371     for (int i=0; i<ITERS; i++) {
 372       test_addc(a0, a1);
 373     }
 374     end = System.currentTimeMillis();
 375     System.out.println("test_addc: " + (end - start));
 376     start = System.currentTimeMillis();
 377     for (int i=0; i<ITERS; i++) {
 378       test_addv(a0, a1, VALUE);
 379     }
 380     end = System.currentTimeMillis();
 381     System.out.println("test_addv: " + (end - start));
 382     start = System.currentTimeMillis();
 383     for (int i=0; i<ITERS; i++) {
 384       test_adda(a0, a1, a2);
 385     }
 386     end = System.currentTimeMillis();
 387     System.out.println("test_adda: " + (end - start));
 388 
 389     start = System.currentTimeMillis();
 390     for (int i=0; i<ITERS; i++) {
 391       test_subc(a0, a1);
 392     }
 393     end = System.currentTimeMillis();
 394     System.out.println("test_subc: " + (end - start));
 395     start = System.currentTimeMillis();
 396     for (int i=0; i<ITERS; i++) {
 397       test_subv(a0, a1, VALUE);
 398     }
 399     end = System.currentTimeMillis();
 400     System.out.println("test_subv: " + (end - start));
 401     start = System.currentTimeMillis();
 402     for (int i=0; i<ITERS; i++) {
 403       test_suba(a0, a1, a2);
 404     }
 405     end = System.currentTimeMillis();
 406     System.out.println("test_suba: " + (end - start));
 407 
 408     start = System.currentTimeMillis();
 409     for (int i=0; i<ITERS; i++) {
 410       test_mulc(a0, a1);
 411     }
 412     end = System.currentTimeMillis();
 413     System.out.println("test_mulc: " + (end - start));
 414     start = System.currentTimeMillis();
 415     for (int i=0; i<ITERS; i++) {
 416       test_mulv(a0, a1, VALUE);
 417     }
 418     end = System.currentTimeMillis();
 419     System.out.println("test_mulv: " + (end - start));
 420     start = System.currentTimeMillis();
 421     for (int i=0; i<ITERS; i++) {
 422       test_mula(a0, a1, a2);
 423     }
 424     end = System.currentTimeMillis();
 425     System.out.println("test_mula: " + (end - start));
 426 
 427     start = System.currentTimeMillis();
 428     for (int i=0; i<ITERS; i++) {
 429       test_divc(a0, a1);
 430     }
 431     end = System.currentTimeMillis();
 432     System.out.println("test_divc: " + (end - start));
 433     start = System.currentTimeMillis();
 434     for (int i=0; i<ITERS; i++) {
 435       test_divv(a0, a1, VALUE);
 436     }
 437     end = System.currentTimeMillis();
 438     System.out.println("test_divv: " + (end - start));
 439     start = System.currentTimeMillis();
 440     for (int i=0; i<ITERS; i++) {
 441       test_diva(a0, a1, a2);
 442     }
 443     end = System.currentTimeMillis();
 444     System.out.println("test_diva: " + (end - start));
 445 
 446     start = System.currentTimeMillis();
 447     for (int i=0; i<ITERS; i++) {
 448       test_mulc_n(a0, a1);
 449     }
 450     end = System.currentTimeMillis();
 451     System.out.println("test_mulc_n: " + (end - start));
 452     start = System.currentTimeMillis();
 453     for (int i=0; i<ITERS; i++) {
 454       test_mulv(a0, a1, -VALUE);
 455     }
 456     end = System.currentTimeMillis();
 457     System.out.println("test_mulv_n: " + (end - start));
 458     start = System.currentTimeMillis();
 459     for (int i=0; i<ITERS; i++) {
 460       test_mula(a0, a1, a3);
 461     }
 462     end = System.currentTimeMillis();
 463     System.out.println("test_mula_n: " + (end - start));
 464 
 465     start = System.currentTimeMillis();
 466     for (int i=0; i<ITERS; i++) {
 467       test_divc_n(a0, a1);
 468     }
 469     end = System.currentTimeMillis();
 470     System.out.println("test_divc_n: " + (end - start));
 471     start = System.currentTimeMillis();
 472     for (int i=0; i<ITERS; i++) {
 473       test_divv(a0, a1, -VALUE);
 474     }
 475     end = System.currentTimeMillis();
 476     System.out.println("test_divv_n: " + (end - start));
 477     start = System.currentTimeMillis();
 478     for (int i=0; i<ITERS; i++) {
 479       test_diva(a0, a1, a3);
 480     }
 481     end = System.currentTimeMillis();
 482     System.out.println("test_diva_n: " + (end - start));
 483 
 484     start = System.currentTimeMillis();
 485     for (int i=0; i<ITERS; i++) {
 486       test_negc(a0, a1);
 487     }
 488     end = System.currentTimeMillis();
 489     System.out.println("test_negc_n: " + (end - start));
 490 
 491     return errn;
 492   }
 493 
 494   static float test_sum(float[] a1) {
 495     float sum = 0;
 496     for (int i = 0; i < a1.length; i+=1) {
 497       sum += a1[i];
 498     }
 499     return sum;
 500   }
 501 
 502   static void test_addc(float[] a0, float[] a1) {
 503     for (int i = 0; i < a0.length; i+=1) {
 504       a0[i] = (a1[i]+VALUE);
 505     }
 506   }
 507   static void test_addv(float[] a0, float[] a1, float b) {
 508     for (int i = 0; i < a0.length; i+=1) {
 509       a0[i] = (a1[i]+b);
 510     }
 511   }
 512   static void test_adda(float[] a0, float[] a1, float[] a2) {
 513     for (int i = 0; i < a0.length; i+=1) {
 514       a0[i] = (a1[i]+a2[i]);
 515     }
 516   }
 517 
 518   static void test_subc(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_subv(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_suba(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_mulc(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_mulc_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_mulv(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_mula(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 void test_divc(float[] a0, float[] a1) {
 556     for (int i = 0; i < a0.length; i+=1) {
 557       a0[i] = (a1[i]/VALUE);
 558     }
 559   }
 560   static void test_divc_n(float[] a0, float[] a1) {
 561     for (int i = 0; i < a0.length; i+=1) {
 562       a0[i] = (a1[i]/(-VALUE));
 563     }
 564   }
 565   static void test_divv(float[] a0, float[] a1, float b) {
 566     for (int i = 0; i < a0.length; i+=1) {
 567       a0[i] = (a1[i]/b);
 568     }
 569   }
 570   static void test_diva(float[] a0, float[] a1, float[] a2) {
 571     for (int i = 0; i < a0.length; i+=1) {
 572       a0[i] = (a1[i]/a2[i]);
 573     }
 574   }
 575 
 576   static void test_negc(float[] a0, float[] a1) {
 577     for (int i = 0; i < a0.length; i+=1) {
 578       a0[i] = (float)(-((float)a1[i]));
 579     }
 580   }
 581 
 582   static int verify(String text, int i, float elem, float val) {
 583     if (elem != val && !(Float.isNaN(elem) && Float.isNaN(val))) {
 584       System.err.println(text + "[" + i + "] = " + elem + " != " + val);
 585       return 1;
 586     }
 587     return 0;
 588   }
 589 }