Path: blob/master/test/hotspot/jtreg/compiler/runtime/Test7196199.java
41152 views
/*1* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 719619926* @summary java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect27*28* @run main/othervm/timeout=400 -Xmx128m -Xbatch -XX:+IgnoreUnrecognizedVMOptions29* -XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation30* -XX:+SafepointALot -XX:GuaranteedSafepointInterval=10031* -XX:CompileCommand=exclude,compiler.runtime.Test7196199::test32* compiler.runtime.Test719619933*/3435package compiler.runtime;3637public class Test7196199 {38private static final int ARRLEN = 97;39private static final int ITERS = 5000;40private static final int INI_ITERS = 1000;41private static final int SFP_ITERS = 10000;42private static final float SFP_ITERS_F = 10000.f;43private static final float VALUE = 15.f;4445public static void main(String args[]) {46int errn = test();47if (errn > 0) {48System.err.println("FAILED: " + errn + " errors");49System.exit(97);50}51System.out.println("PASSED");52}5354static int test() {55float[] a0 = new float[ARRLEN];56float[] a1 = new float[ARRLEN];57// Initialize58for (int i = 0; i < ARRLEN; i++) {59a0[i] = 0.f;60a1[i] = (float) i;61}62System.out.println("Warmup");63for (int i = 0; i < INI_ITERS; i++) {64test_incrc(a0);65test_incrv(a0, VALUE);66test_addc(a0, a1);67test_addv(a0, a1, VALUE);68}69// Test and verify results70System.out.println("Verification");71int errn = 0;72for (int i = 0; i < ARRLEN; i++)73a0[i] = 0.f;7475System.out.println(" test_incrc");76for (int j = 0; j < ITERS; j++) {77test_incrc(a0);78for (int i = 0; i < ARRLEN; i++) {79errn += verify("test_incrc: ", i, a0[i], VALUE * SFP_ITERS_F);80a0[i] = 0.f; // Reset81}82}8384System.out.println(" test_incrv");85for (int j = 0; j < ITERS; j++) {86test_incrv(a0, VALUE);87for (int i = 0; i < ARRLEN; i++) {88errn += verify("test_incrv: ", i, a0[i], VALUE * SFP_ITERS_F);89a0[i] = 0.f; // Reset90}91}9293System.out.println(" test_addc");94for (int j = 0; j < ITERS; j++) {95test_addc(a0, a1);96for (int i = 0; i < ARRLEN; i++) {97errn += verify("test_addc: ", i, a0[i], ((float) i + VALUE) * SFP_ITERS_F);98a0[i] = 0.f; // Reset99}100}101102System.out.println(" test_addv");103for (int j = 0; j < ITERS; j++) {104test_addv(a0, a1, VALUE);105for (int i = 0; i < ARRLEN; i++) {106errn += verify("test_addv: ", i, a0[i], ((float) i + VALUE) * SFP_ITERS_F);107a0[i] = 0.f; // Reset108}109}110111if (errn > 0)112return errn;113114System.out.println("Time");115long start, end;116117start = System.currentTimeMillis();118for (int i = 0; i < INI_ITERS; i++) {119test_incrc(a0);120}121end = System.currentTimeMillis();122System.out.println("test_incrc: " + (end - start));123124start = System.currentTimeMillis();125for (int i = 0; i < INI_ITERS; i++) {126test_incrv(a0, VALUE);127}128end = System.currentTimeMillis();129System.out.println("test_incrv: " + (end - start));130131start = System.currentTimeMillis();132for (int i = 0; i < INI_ITERS; i++) {133test_addc(a0, a1);134}135end = System.currentTimeMillis();136System.out.println("test_addc: " + (end - start));137138start = System.currentTimeMillis();139for (int i = 0; i < INI_ITERS; i++) {140test_addv(a0, a1, VALUE);141}142end = System.currentTimeMillis();143System.out.println("test_addv: " + (end - start));144145return errn;146}147148static void test_incrc(float[] a0) {149// Non-counted loop with safepoint.150for (long l = 0; l < SFP_ITERS; l++) {151// Counted and vectorized loop.152for (int i = 0; i < a0.length; i += 1) {153a0[i] += VALUE;154}155}156}157158static void test_incrv(float[] a0, float b) {159// Non-counted loop with safepoint.160for (long l = 0; l < SFP_ITERS; l++) {161// Counted and vectorized loop.162for (int i = 0; i < a0.length; i += 1) {163a0[i] += b;164}165}166}167168static void test_addc(float[] a0, float[] a1) {169// Non-counted loop with safepoint.170for (long l = 0; l < SFP_ITERS; l++) {171// Counted and vectorized loop.172for (int i = 0; i < a0.length; i += 1) {173a0[i] += a1[i] + VALUE;174}175}176}177178static void test_addv(float[] a0, float[] a1, float b) {179// Non-counted loop with safepoint.180for (long l = 0; l < SFP_ITERS; l++) {181// Counted and vectorized loop.182for (int i = 0; i < a0.length; i += 1) {183a0[i] += a1[i] + b;184}185}186}187188static int verify(String text, int i, float elem, float val) {189if (elem != val) {190System.err.println(text + "[" + i + "] = " + elem + " != " + val);191return 1;192}193return 0;194}195}196197198