hotspot/test/compiler/7196199/Test7196199.java
changeset 13883 6979b9850feb
equal deleted inserted replaced
13882:80d5d0d21b75 13883:6979b9850feb
       
     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 7196199
       
    28  * @summary java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
       
    29  *
       
    30  * @run main/othervm/timeout=400 -Xmx32m -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:CompileCommand=exclude,Test7196199.test -XX:+SafepointALot -XX:GuaranteedSafepointInterval=100 Test7196199
       
    31  */
       
    32 
       
    33 
       
    34 public class Test7196199 {
       
    35   private static final int ARRLEN = 97;
       
    36   private static final int ITERS  = 5000;
       
    37   private static final int INI_ITERS  = 1000;
       
    38   private static final int SFP_ITERS  = 10000;
       
    39   private static final float SFP_ITERS_F  = 10000.f;
       
    40   private static final float VALUE = 15.f;
       
    41   public static void main(String args[]) {
       
    42     int errn = test();
       
    43     if (errn > 0) {
       
    44       System.err.println("FAILED: " + errn + " errors");
       
    45       System.exit(97);
       
    46     }
       
    47     System.out.println("PASSED");
       
    48   }
       
    49 
       
    50   static int test() {
       
    51     float[] a0 = new float[ARRLEN];
       
    52     float[] a1 = new float[ARRLEN];
       
    53     // Initialize
       
    54     for (int i=0; i<ARRLEN; i++) {
       
    55       a0[i] = 0.f;
       
    56       a1[i] = (float)i;
       
    57     }
       
    58     System.out.println("Warmup");
       
    59     for (int i=0; i<INI_ITERS; i++) {
       
    60       test_incrc(a0);
       
    61       test_incrv(a0, VALUE);
       
    62       test_addc(a0, a1);
       
    63       test_addv(a0, a1, VALUE);
       
    64     }
       
    65     // Test and verify results
       
    66     System.out.println("Verification");
       
    67     int errn = 0;
       
    68     for (int i=0; i<ARRLEN; i++)
       
    69       a0[i] = 0.f;
       
    70 
       
    71     System.out.println("  test_incrc");
       
    72     for (int j=0; j<ITERS; j++) {
       
    73       test_incrc(a0);
       
    74       for (int i=0; i<ARRLEN; i++) {
       
    75         errn += verify("test_incrc: ", i, a0[i], VALUE*SFP_ITERS_F);
       
    76         a0[i] = 0.f; // Reset
       
    77       }
       
    78     }
       
    79 
       
    80     System.out.println("  test_incrv");
       
    81     for (int j=0; j<ITERS; j++) {
       
    82       test_incrv(a0, VALUE);
       
    83       for (int i=0; i<ARRLEN; i++) {
       
    84         errn += verify("test_incrv: ", i, a0[i], VALUE*SFP_ITERS_F);
       
    85         a0[i] = 0.f; // Reset
       
    86       }
       
    87     }
       
    88 
       
    89     System.out.println("  test_addc");
       
    90     for (int j=0; j<ITERS; j++) {
       
    91       test_addc(a0, a1);
       
    92       for (int i=0; i<ARRLEN; i++) {
       
    93         errn += verify("test_addc: ", i, a0[i], ((float)i + VALUE)*SFP_ITERS_F);
       
    94         a0[i] = 0.f; // Reset
       
    95       }
       
    96     }
       
    97 
       
    98     System.out.println("  test_addv");
       
    99     for (int j=0; j<ITERS; j++) {
       
   100       test_addv(a0, a1, VALUE);
       
   101       for (int i=0; i<ARRLEN; i++) {
       
   102         errn += verify("test_addv: ", i, a0[i], ((float)i + VALUE)*SFP_ITERS_F);
       
   103         a0[i] = 0.f; // Reset
       
   104       }
       
   105     }
       
   106 
       
   107     if (errn > 0)
       
   108       return errn;
       
   109 
       
   110     System.out.println("Time");
       
   111     long start, end;
       
   112 
       
   113     start = System.currentTimeMillis();
       
   114     for (int i=0; i<INI_ITERS; i++) {
       
   115       test_incrc(a0);
       
   116     }
       
   117     end = System.currentTimeMillis();
       
   118     System.out.println("test_incrc: " + (end - start));
       
   119 
       
   120     start = System.currentTimeMillis();
       
   121     for (int i=0; i<INI_ITERS; i++) {
       
   122       test_incrv(a0, VALUE);
       
   123     }
       
   124     end = System.currentTimeMillis();
       
   125     System.out.println("test_incrv: " + (end - start));
       
   126 
       
   127     start = System.currentTimeMillis();
       
   128     for (int i=0; i<INI_ITERS; i++) {
       
   129       test_addc(a0, a1);
       
   130     }
       
   131     end = System.currentTimeMillis();
       
   132     System.out.println("test_addc: " + (end - start));
       
   133 
       
   134     start = System.currentTimeMillis();
       
   135     for (int i=0; i<INI_ITERS; i++) {
       
   136       test_addv(a0, a1, VALUE);
       
   137     }
       
   138     end = System.currentTimeMillis();
       
   139     System.out.println("test_addv: " + (end - start));
       
   140 
       
   141     return errn;
       
   142   }
       
   143 
       
   144   static void test_incrc(float[] a0) {
       
   145     // Non-counted loop with safepoint.
       
   146     for (long l = 0; l < SFP_ITERS; l++) {
       
   147       // Counted and vectorized loop.
       
   148       for (int i = 0; i < a0.length; i+=1) {
       
   149         a0[i] += VALUE;
       
   150       }
       
   151     }
       
   152   }
       
   153   static void test_incrv(float[] a0, float b) {
       
   154     // Non-counted loop with safepoint.
       
   155     for (long l = 0; l < SFP_ITERS; l++) {
       
   156       // Counted and vectorized loop.
       
   157       for (int i = 0; i < a0.length; i+=1) {
       
   158         a0[i] += b;
       
   159       }
       
   160     }
       
   161   }
       
   162   static void test_addc(float[] a0, float[] a1) {
       
   163     // Non-counted loop with safepoint.
       
   164     for (long l = 0; l < SFP_ITERS; l++) {
       
   165       // Counted and vectorized loop.
       
   166       for (int i = 0; i < a0.length; i+=1) {
       
   167         a0[i] += a1[i]+VALUE;
       
   168       }
       
   169     }
       
   170   }
       
   171   static void test_addv(float[] a0, float[] a1, float b) {
       
   172     // Non-counted loop with safepoint.
       
   173     for (long l = 0; l < SFP_ITERS; l++) {
       
   174       // Counted and vectorized loop.
       
   175       for (int i = 0; i < a0.length; i+=1) {
       
   176         a0[i] += a1[i]+b;
       
   177       }
       
   178     }
       
   179   }
       
   180 
       
   181   static int verify(String text, int i, float elem, float val) {
       
   182     if (elem != val) {
       
   183       System.err.println(text + "[" + i + "] = " + elem + " != " + val);
       
   184       return 1;
       
   185     }
       
   186     return 0;
       
   187   }
       
   188 }
       
   189