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