test/compiler/7196199/Test7196199.java

changeset 0
f90c822e73f8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/compiler/7196199/Test7196199.java	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,189 @@
     1.4 +/*
     1.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +/**
    1.29 + * @test
    1.30 + * @bug 7196199
    1.31 + * @summary java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
    1.32 + *
    1.33 + * @run main/othervm/timeout=400 -Xmx32m -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:CompileCommand=exclude,Test7196199.test -XX:+SafepointALot -XX:GuaranteedSafepointInterval=100 Test7196199
    1.34 + */
    1.35 +
    1.36 +
    1.37 +public class Test7196199 {
    1.38 +  private static final int ARRLEN = 97;
    1.39 +  private static final int ITERS  = 5000;
    1.40 +  private static final int INI_ITERS  = 1000;
    1.41 +  private static final int SFP_ITERS  = 10000;
    1.42 +  private static final float SFP_ITERS_F  = 10000.f;
    1.43 +  private static final float VALUE = 15.f;
    1.44 +  public static void main(String args[]) {
    1.45 +    int errn = test();
    1.46 +    if (errn > 0) {
    1.47 +      System.err.println("FAILED: " + errn + " errors");
    1.48 +      System.exit(97);
    1.49 +    }
    1.50 +    System.out.println("PASSED");
    1.51 +  }
    1.52 +
    1.53 +  static int test() {
    1.54 +    float[] a0 = new float[ARRLEN];
    1.55 +    float[] a1 = new float[ARRLEN];
    1.56 +    // Initialize
    1.57 +    for (int i=0; i<ARRLEN; i++) {
    1.58 +      a0[i] = 0.f;
    1.59 +      a1[i] = (float)i;
    1.60 +    }
    1.61 +    System.out.println("Warmup");
    1.62 +    for (int i=0; i<INI_ITERS; i++) {
    1.63 +      test_incrc(a0);
    1.64 +      test_incrv(a0, VALUE);
    1.65 +      test_addc(a0, a1);
    1.66 +      test_addv(a0, a1, VALUE);
    1.67 +    }
    1.68 +    // Test and verify results
    1.69 +    System.out.println("Verification");
    1.70 +    int errn = 0;
    1.71 +    for (int i=0; i<ARRLEN; i++)
    1.72 +      a0[i] = 0.f;
    1.73 +
    1.74 +    System.out.println("  test_incrc");
    1.75 +    for (int j=0; j<ITERS; j++) {
    1.76 +      test_incrc(a0);
    1.77 +      for (int i=0; i<ARRLEN; i++) {
    1.78 +        errn += verify("test_incrc: ", i, a0[i], VALUE*SFP_ITERS_F);
    1.79 +        a0[i] = 0.f; // Reset
    1.80 +      }
    1.81 +    }
    1.82 +
    1.83 +    System.out.println("  test_incrv");
    1.84 +    for (int j=0; j<ITERS; j++) {
    1.85 +      test_incrv(a0, VALUE);
    1.86 +      for (int i=0; i<ARRLEN; i++) {
    1.87 +        errn += verify("test_incrv: ", i, a0[i], VALUE*SFP_ITERS_F);
    1.88 +        a0[i] = 0.f; // Reset
    1.89 +      }
    1.90 +    }
    1.91 +
    1.92 +    System.out.println("  test_addc");
    1.93 +    for (int j=0; j<ITERS; j++) {
    1.94 +      test_addc(a0, a1);
    1.95 +      for (int i=0; i<ARRLEN; i++) {
    1.96 +        errn += verify("test_addc: ", i, a0[i], ((float)i + VALUE)*SFP_ITERS_F);
    1.97 +        a0[i] = 0.f; // Reset
    1.98 +      }
    1.99 +    }
   1.100 +
   1.101 +    System.out.println("  test_addv");
   1.102 +    for (int j=0; j<ITERS; j++) {
   1.103 +      test_addv(a0, a1, VALUE);
   1.104 +      for (int i=0; i<ARRLEN; i++) {
   1.105 +        errn += verify("test_addv: ", i, a0[i], ((float)i + VALUE)*SFP_ITERS_F);
   1.106 +        a0[i] = 0.f; // Reset
   1.107 +      }
   1.108 +    }
   1.109 +
   1.110 +    if (errn > 0)
   1.111 +      return errn;
   1.112 +
   1.113 +    System.out.println("Time");
   1.114 +    long start, end;
   1.115 +
   1.116 +    start = System.currentTimeMillis();
   1.117 +    for (int i=0; i<INI_ITERS; i++) {
   1.118 +      test_incrc(a0);
   1.119 +    }
   1.120 +    end = System.currentTimeMillis();
   1.121 +    System.out.println("test_incrc: " + (end - start));
   1.122 +
   1.123 +    start = System.currentTimeMillis();
   1.124 +    for (int i=0; i<INI_ITERS; i++) {
   1.125 +      test_incrv(a0, VALUE);
   1.126 +    }
   1.127 +    end = System.currentTimeMillis();
   1.128 +    System.out.println("test_incrv: " + (end - start));
   1.129 +
   1.130 +    start = System.currentTimeMillis();
   1.131 +    for (int i=0; i<INI_ITERS; i++) {
   1.132 +      test_addc(a0, a1);
   1.133 +    }
   1.134 +    end = System.currentTimeMillis();
   1.135 +    System.out.println("test_addc: " + (end - start));
   1.136 +
   1.137 +    start = System.currentTimeMillis();
   1.138 +    for (int i=0; i<INI_ITERS; i++) {
   1.139 +      test_addv(a0, a1, VALUE);
   1.140 +    }
   1.141 +    end = System.currentTimeMillis();
   1.142 +    System.out.println("test_addv: " + (end - start));
   1.143 +
   1.144 +    return errn;
   1.145 +  }
   1.146 +
   1.147 +  static void test_incrc(float[] a0) {
   1.148 +    // Non-counted loop with safepoint.
   1.149 +    for (long l = 0; l < SFP_ITERS; l++) {
   1.150 +      // Counted and vectorized loop.
   1.151 +      for (int i = 0; i < a0.length; i+=1) {
   1.152 +        a0[i] += VALUE;
   1.153 +      }
   1.154 +    }
   1.155 +  }
   1.156 +  static void test_incrv(float[] a0, float b) {
   1.157 +    // Non-counted loop with safepoint.
   1.158 +    for (long l = 0; l < SFP_ITERS; l++) {
   1.159 +      // Counted and vectorized loop.
   1.160 +      for (int i = 0; i < a0.length; i+=1) {
   1.161 +        a0[i] += b;
   1.162 +      }
   1.163 +    }
   1.164 +  }
   1.165 +  static void test_addc(float[] a0, float[] a1) {
   1.166 +    // Non-counted loop with safepoint.
   1.167 +    for (long l = 0; l < SFP_ITERS; l++) {
   1.168 +      // Counted and vectorized loop.
   1.169 +      for (int i = 0; i < a0.length; i+=1) {
   1.170 +        a0[i] += a1[i]+VALUE;
   1.171 +      }
   1.172 +    }
   1.173 +  }
   1.174 +  static void test_addv(float[] a0, float[] a1, float b) {
   1.175 +    // Non-counted loop with safepoint.
   1.176 +    for (long l = 0; l < SFP_ITERS; l++) {
   1.177 +      // Counted and vectorized loop.
   1.178 +      for (int i = 0; i < a0.length; i+=1) {
   1.179 +        a0[i] += a1[i]+b;
   1.180 +      }
   1.181 +    }
   1.182 +  }
   1.183 +
   1.184 +  static int verify(String text, int i, float elem, float val) {
   1.185 +    if (elem != val) {
   1.186 +      System.err.println(text + "[" + i + "] = " + elem + " != " + val);
   1.187 +      return 1;
   1.188 +    }
   1.189 +    return 0;
   1.190 +  }
   1.191 +}
   1.192 +

mercurial