test/compiler/7192963/TestFloatVect.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 0
f90c822e73f8
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

     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 7192963
    28  * @summary assert(_in[req-1] == this) failed: Must pass arg count to 'new'
    29  *
    30  * @run main/othervm/timeout=400 -Xbatch -Xmx64m TestFloatVect
    31  */
    33 public class TestFloatVect {
    34   private static final int ARRLEN = 997;
    35   private static final int ITERS  = 11000;
    36   public static void main(String args[]) {
    37     System.out.println("Testing Float vectors");
    38     int errn = test();
    39     if (errn > 0) {
    40       System.err.println("FAILED: " + errn + " errors");
    41       System.exit(97);
    42     }
    43     System.out.println("PASSED");
    44   }
    46   static int test() {
    47     float[] a0 = new float[ARRLEN];
    48     float[] a1 = new float[ARRLEN];
    49     // Initialize
    50     for (int i=0; i<ARRLEN; i++) {
    51       a1[i] = (float)i;
    52     }
    53     System.out.println("Warmup");
    54     for (int i=0; i<ITERS; i++) {
    55       test_init(a0);
    56       test_addi(a0, a1);
    57       test_divi(a0, a1);
    58       test_unrl_init(a0);
    59       test_unrl_addi(a0, a1);
    60       test_unrl_divi(a0, a1);
    61     }
    62     // Test and verify results
    63     System.out.println("Verification");
    64     int errn = 0;
    65     {
    66       test_init(a0);
    67       for (int i=0; i<ARRLEN; i++) {
    68         errn += verify("test_init: ", i, a0[i], (float)(i&3));
    69       }
    70       test_addi(a0, a1);
    71       for (int i=0; i<ARRLEN; i++) {
    72         errn += verify("test_addi: ", i, a0[i], (float)(i+(i&3)));
    73       }
    74       test_divi(a0, a1);
    75       for (int i=0; i<ARRLEN; i++) {
    76         errn += verify("test_divi: ", i, a0[i], (float)i/(float)((i&3)+1));
    77       }
    78       test_unrl_init(a0);
    79       for (int i=0; i<ARRLEN; i++) {
    80         errn += verify("test_unrl_init: ", i, a0[i], (float)(i&3));
    81       }
    82       test_unrl_addi(a0, a1);
    83       for (int i=0; i<ARRLEN; i++) {
    84         errn += verify("test_unrl_addi: ", i, a0[i], (float)(i+(i&3)));
    85       }
    86       test_unrl_divi(a0, a1);
    87       for (int i=0; i<ARRLEN; i++) {
    88         errn += verify("test_unrl_divi: ", i, a0[i], (float)i/(float)((i&3)+1));
    89       }
    90     }
    92     if (errn > 0)
    93       return errn;
    95     System.out.println("Time");
    96     long start, end;
    98     start = System.currentTimeMillis();
    99     for (int i=0; i<ITERS; i++) {
   100       test_init(a0);
   101     }
   102     end = System.currentTimeMillis();
   103     System.out.println("test_init: " + (end - start));
   105     start = System.currentTimeMillis();
   106     for (int i=0; i<ITERS; i++) {
   107       test_addi(a0, a1);
   108     }
   109     end = System.currentTimeMillis();
   110     System.out.println("test_addi: " + (end - start));
   112     start = System.currentTimeMillis();
   113     for (int i=0; i<ITERS; i++) {
   114       test_divi(a0, a1);
   115     }
   116     end = System.currentTimeMillis();
   117     System.out.println("test_divi: " + (end - start));
   119     start = System.currentTimeMillis();
   120     for (int i=0; i<ITERS; i++) {
   121       test_unrl_init(a0);
   122     }
   123     end = System.currentTimeMillis();
   124     System.out.println("test_unrl_init: " + (end - start));
   126     start = System.currentTimeMillis();
   127     for (int i=0; i<ITERS; i++) {
   128       test_unrl_addi(a0, a1);
   129     }
   130     end = System.currentTimeMillis();
   131     System.out.println("test_unrl_addi: " + (end - start));
   133     start = System.currentTimeMillis();
   134     for (int i=0; i<ITERS; i++) {
   135       test_unrl_divi(a0, a1);
   136     }
   137     end = System.currentTimeMillis();
   138     System.out.println("test_unrl_divi: " + (end - start));
   140     return errn;
   141   }
   143   static void test_init(float[] a0) {
   144     for (int i = 0; i < a0.length; i+=1) {
   145       a0[i] = (float)(i&3);
   146     }
   147   }
   148   static void test_addi(float[] a0, float[] a1) {
   149     for (int i = 0; i < a0.length; i+=1) {
   150       a0[i] = a1[i]+(float)(i&3);
   151     }
   152   }
   153   static void test_divi(float[] a0, float[] a1) {
   154     for (int i = 0; i < a0.length; i+=1) {
   155       a0[i] = a1[i]/(float)((i&3)+1);
   156     }
   157   }
   158   static void test_unrl_init(float[] a0) {
   159     int i = 0;
   160     for (; i < a0.length-4; i+=4) {
   161       a0[i+0] = 0.f;
   162       a0[i+1] = 1.f;
   163       a0[i+2] = 2.f;
   164       a0[i+3] = 3.f;
   165     }
   166     for (; i < a0.length; i++) {
   167       a0[i] = (float)(i&3);
   168     }
   169   }
   170   static void test_unrl_addi(float[] a0, float[] a1) {
   171     int i = 0;
   172     for (; i < a0.length-4; i+=4) {
   173       a0[i+0] = a1[i+0]+0.f;
   174       a0[i+1] = a1[i+1]+1.f;
   175       a0[i+2] = a1[i+2]+2.f;
   176       a0[i+3] = a1[i+3]+3.f;
   177     }
   178     for (; i < a0.length; i++) {
   179       a0[i] = a1[i]+(float)(i&3);
   180     }
   181   }
   182   static void test_unrl_divi(float[] a0, float[] a1) {
   183     int i = 0;
   184     for (; i < a0.length-4; i+=4) {
   185       a0[i+0] = a1[i+0]/1.f;
   186       a0[i+1] = a1[i+1]/2.f;
   187       a0[i+2] = a1[i+2]/3.f;
   188       a0[i+3] = a1[i+3]/4.f;
   189     }
   190     for (; i < a0.length; i++) {
   191       a0[i] = a1[i]/(float)((i&3)+1);
   192     }
   193   }
   195   static int verify(String text, int i, float elem, float val) {
   196     if (elem != val) {
   197       System.err.println(text + "[" + i + "] = " + elem + " != " + val);
   198       return 1;
   199     }
   200     return 0;
   201   }
   202 }

mercurial