test/compiler/6340864/TestDoubleVect.java

Thu, 17 Apr 2014 16:09:08 -0700

author
amurillo
date
Thu, 17 Apr 2014 16:09:08 -0700
changeset 6635
49b5160951dd
parent 0
f90c822e73f8
permissions
-rw-r--r--

Added tag hs25.20-b11 for changeset b6a2ba7d3ea7

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

mercurial