Test7196199.java revision 4012
4012N/A/*
4012N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4012N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4012N/A *
4012N/A * This code is free software; you can redistribute it and/or modify it
4012N/A * under the terms of the GNU General Public License version 2 only, as
4012N/A * published by the Free Software Foundation.
4012N/A *
4012N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4012N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4012N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4012N/A * version 2 for more details (a copy is included in the LICENSE file that
4012N/A * accompanied this code).
4012N/A *
4012N/A * You should have received a copy of the GNU General Public License version
4012N/A * 2 along with this work; if not, write to the Free Software Foundation,
4012N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4012N/A *
4012N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4012N/A * or visit www.oracle.com if you need additional information or have any
4012N/A * questions.
4012N/A *
4012N/A */
4012N/A
4012N/A/**
4012N/A * @test
4012N/A * @bug 7196199
4012N/A * @summary java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
4012N/A *
4012N/A * @run main/othervm/timeout=400 -Xmx32m -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:CompileCommand=exclude,Test7196199.test -XX:+SafepointALot -XX:GuaranteedSafepointInterval=100 Test7196199
4012N/A */
4012N/A
4012N/A
4012N/Apublic class Test7196199 {
4012N/A private static final int ARRLEN = 97;
4012N/A private static final int ITERS = 5000;
4012N/A private static final int INI_ITERS = 1000;
4012N/A private static final int SFP_ITERS = 10000;
4012N/A private static final float SFP_ITERS_F = 10000.f;
4012N/A private static final float VALUE = 15.f;
4012N/A public static void main(String args[]) {
4012N/A int errn = test();
4012N/A if (errn > 0) {
4012N/A System.err.println("FAILED: " + errn + " errors");
4012N/A System.exit(97);
4012N/A }
4012N/A System.out.println("PASSED");
4012N/A }
4012N/A
4012N/A static int test() {
4012N/A float[] a0 = new float[ARRLEN];
4012N/A float[] a1 = new float[ARRLEN];
4012N/A // Initialize
4012N/A for (int i=0; i<ARRLEN; i++) {
4012N/A a0[i] = 0.f;
4012N/A a1[i] = (float)i;
4012N/A }
4012N/A System.out.println("Warmup");
4012N/A for (int i=0; i<INI_ITERS; i++) {
4012N/A test_incrc(a0);
4012N/A test_incrv(a0, VALUE);
4012N/A test_addc(a0, a1);
4012N/A test_addv(a0, a1, VALUE);
4012N/A }
4012N/A // Test and verify results
4012N/A System.out.println("Verification");
4012N/A int errn = 0;
4012N/A for (int i=0; i<ARRLEN; i++)
4012N/A a0[i] = 0.f;
4012N/A
4012N/A System.out.println(" test_incrc");
4012N/A for (int j=0; j<ITERS; j++) {
4012N/A test_incrc(a0);
4012N/A for (int i=0; i<ARRLEN; i++) {
4012N/A errn += verify("test_incrc: ", i, a0[i], VALUE*SFP_ITERS_F);
4012N/A a0[i] = 0.f; // Reset
4012N/A }
4012N/A }
4012N/A
4012N/A System.out.println(" test_incrv");
4012N/A for (int j=0; j<ITERS; j++) {
4012N/A test_incrv(a0, VALUE);
4012N/A for (int i=0; i<ARRLEN; i++) {
4012N/A errn += verify("test_incrv: ", i, a0[i], VALUE*SFP_ITERS_F);
4012N/A a0[i] = 0.f; // Reset
4012N/A }
4012N/A }
4012N/A
4012N/A System.out.println(" test_addc");
4012N/A for (int j=0; j<ITERS; j++) {
4012N/A test_addc(a0, a1);
4012N/A for (int i=0; i<ARRLEN; i++) {
4012N/A errn += verify("test_addc: ", i, a0[i], ((float)i + VALUE)*SFP_ITERS_F);
4012N/A a0[i] = 0.f; // Reset
4012N/A }
4012N/A }
4012N/A
4012N/A System.out.println(" test_addv");
4012N/A for (int j=0; j<ITERS; j++) {
4012N/A test_addv(a0, a1, VALUE);
4012N/A for (int i=0; i<ARRLEN; i++) {
4012N/A errn += verify("test_addv: ", i, a0[i], ((float)i + VALUE)*SFP_ITERS_F);
4012N/A a0[i] = 0.f; // Reset
4012N/A }
4012N/A }
4012N/A
4012N/A if (errn > 0)
4012N/A return errn;
4012N/A
4012N/A System.out.println("Time");
4012N/A long start, end;
4012N/A
4012N/A start = System.currentTimeMillis();
4012N/A for (int i=0; i<INI_ITERS; i++) {
4012N/A test_incrc(a0);
4012N/A }
4012N/A end = System.currentTimeMillis();
4012N/A System.out.println("test_incrc: " + (end - start));
4012N/A
4012N/A start = System.currentTimeMillis();
4012N/A for (int i=0; i<INI_ITERS; i++) {
4012N/A test_incrv(a0, VALUE);
4012N/A }
4012N/A end = System.currentTimeMillis();
4012N/A System.out.println("test_incrv: " + (end - start));
4012N/A
4012N/A start = System.currentTimeMillis();
4012N/A for (int i=0; i<INI_ITERS; i++) {
4012N/A test_addc(a0, a1);
4012N/A }
4012N/A end = System.currentTimeMillis();
4012N/A System.out.println("test_addc: " + (end - start));
4012N/A
4012N/A start = System.currentTimeMillis();
4012N/A for (int i=0; i<INI_ITERS; i++) {
4012N/A test_addv(a0, a1, VALUE);
4012N/A }
4012N/A end = System.currentTimeMillis();
4012N/A System.out.println("test_addv: " + (end - start));
4012N/A
4012N/A return errn;
4012N/A }
4012N/A
4012N/A static void test_incrc(float[] a0) {
4012N/A // Non-counted loop with safepoint.
4012N/A for (long l = 0; l < SFP_ITERS; l++) {
4012N/A // Counted and vectorized loop.
4012N/A for (int i = 0; i < a0.length; i+=1) {
4012N/A a0[i] += VALUE;
4012N/A }
4012N/A }
4012N/A }
4012N/A static void test_incrv(float[] a0, float b) {
4012N/A // Non-counted loop with safepoint.
4012N/A for (long l = 0; l < SFP_ITERS; l++) {
4012N/A // Counted and vectorized loop.
4012N/A for (int i = 0; i < a0.length; i+=1) {
4012N/A a0[i] += b;
4012N/A }
4012N/A }
4012N/A }
4012N/A static void test_addc(float[] a0, float[] a1) {
4012N/A // Non-counted loop with safepoint.
4012N/A for (long l = 0; l < SFP_ITERS; l++) {
4012N/A // Counted and vectorized loop.
4012N/A for (int i = 0; i < a0.length; i+=1) {
4012N/A a0[i] += a1[i]+VALUE;
4012N/A }
4012N/A }
4012N/A }
4012N/A static void test_addv(float[] a0, float[] a1, float b) {
4012N/A // Non-counted loop with safepoint.
4012N/A for (long l = 0; l < SFP_ITERS; l++) {
4012N/A // Counted and vectorized loop.
4012N/A for (int i = 0; i < a0.length; i+=1) {
4012N/A a0[i] += a1[i]+b;
4012N/A }
4012N/A }
4012N/A }
4012N/A
4012N/A static int verify(String text, int i, float elem, float val) {
4012N/A if (elem != val) {
4012N/A System.err.println(text + "[" + i + "] = " + elem + " != " + val);
4012N/A return 1;
4012N/A }
4012N/A return 0;
4012N/A }
4012N/A}
4012N/A