Skip to content

Commit 8374d16

Browse files
committed
8335006: C2 SuperWord: add JMH benchmark VectorLoadToStoreForwarding.java
Reviewed-by: shade, kvn, sviswanathan
1 parent 4ffc5e6 commit 8374d16

File tree

1 file changed

+212
-0
lines changed

1 file changed

+212
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
/*
2+
* Copyright (c) 2024, 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+
package org.openjdk.bench.vm.compiler;
24+
25+
import org.openjdk.jmh.annotations.*;
26+
import org.openjdk.jmh.infra.*;
27+
28+
import java.util.concurrent.TimeUnit;
29+
import java.util.Random;
30+
31+
@BenchmarkMode(Mode.AverageTime)
32+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
33+
@State(Scope.Thread)
34+
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
35+
@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
36+
@Fork(value = 1)
37+
public abstract class VectorLoadToStoreForwarding {
38+
@Param({"2048"})
39+
public int SIZE;
40+
41+
private int[] aI;
42+
43+
@Param("0")
44+
private int seed;
45+
private Random r = new Random(seed);
46+
47+
@Setup
48+
public void init() {
49+
aI = new int[SIZE];
50+
51+
for (int i = 0; i < SIZE; i++) {
52+
aI[i] = r.nextInt();
53+
}
54+
}
55+
56+
@Benchmark
57+
public void benchmark_00() {
58+
for (int i = 20; i < SIZE; i++) {
59+
aI[i] = aI[i - 0] + 1;
60+
}
61+
}
62+
63+
@Benchmark
64+
public void benchmark_01() {
65+
for (int i = 20; i < SIZE; i++) {
66+
aI[i] = aI[i - 1] + 1;
67+
}
68+
}
69+
70+
@Benchmark
71+
public void benchmark_02() {
72+
for (int i = 20; i < SIZE; i++) {
73+
aI[i] = aI[i - 2] + 1;
74+
}
75+
}
76+
77+
@Benchmark
78+
public void benchmark_03() {
79+
for (int i = 20; i < SIZE; i++) {
80+
aI[i] = aI[i - 3] + 1;
81+
}
82+
}
83+
84+
@Benchmark
85+
public void benchmark_04() {
86+
for (int i = 20; i < SIZE; i++) {
87+
aI[i] = aI[i - 4] + 1;
88+
}
89+
}
90+
91+
@Benchmark
92+
public void benchmark_05() {
93+
for (int i = 20; i < SIZE; i++) {
94+
aI[i] = aI[i - 5] + 1;
95+
}
96+
}
97+
98+
@Benchmark
99+
public void benchmark_06() {
100+
for (int i = 20; i < SIZE; i++) {
101+
aI[i] = aI[i - 6] + 1;
102+
}
103+
}
104+
105+
@Benchmark
106+
public void benchmark_07() {
107+
for (int i = 20; i < SIZE; i++) {
108+
aI[i] = aI[i - 7] + 1;
109+
}
110+
}
111+
112+
@Benchmark
113+
public void benchmark_08() {
114+
for (int i = 20; i < SIZE; i++) {
115+
aI[i] = aI[i - 8] + 1;
116+
}
117+
}
118+
119+
@Benchmark
120+
public void benchmark_09() {
121+
for (int i = 20; i < SIZE; i++) {
122+
aI[i] = aI[i - 9] + 1;
123+
}
124+
}
125+
126+
@Benchmark
127+
public void benchmark_10() {
128+
for (int i = 20; i < SIZE; i++) {
129+
aI[i] = aI[i - 10] + 1;
130+
}
131+
}
132+
133+
@Benchmark
134+
public void benchmark_11() {
135+
for (int i = 20; i < SIZE; i++) {
136+
aI[i] = aI[i - 11] + 1;
137+
}
138+
}
139+
140+
@Benchmark
141+
public void benchmark_12() {
142+
for (int i = 20; i < SIZE; i++) {
143+
aI[i] = aI[i - 12] + 1;
144+
}
145+
}
146+
147+
@Benchmark
148+
public void benchmark_13() {
149+
for (int i = 20; i < SIZE; i++) {
150+
aI[i] = aI[i - 13] + 1;
151+
}
152+
}
153+
154+
@Benchmark
155+
public void benchmark_14() {
156+
for (int i = 20; i < SIZE; i++) {
157+
aI[i] = aI[i - 14] + 1;
158+
}
159+
}
160+
161+
@Benchmark
162+
public void benchmark_15() {
163+
for (int i = 20; i < SIZE; i++) {
164+
aI[i] = aI[i - 15] + 1;
165+
}
166+
}
167+
168+
@Benchmark
169+
public void benchmark_16() {
170+
for (int i = 20; i < SIZE; i++) {
171+
aI[i] = aI[i - 16] + 1;
172+
}
173+
}
174+
175+
@Benchmark
176+
public void benchmark_17() {
177+
for (int i = 20; i < SIZE; i++) {
178+
aI[i] = aI[i - 17] + 1;
179+
}
180+
}
181+
182+
@Benchmark
183+
public void benchmark_18() {
184+
for (int i = 20; i < SIZE; i++) {
185+
aI[i] = aI[i - 18] + 1;
186+
}
187+
}
188+
189+
@Benchmark
190+
public void benchmark_19() {
191+
for (int i = 20; i < SIZE; i++) {
192+
aI[i] = aI[i - 19] + 1;
193+
}
194+
}
195+
196+
@Benchmark
197+
public void benchmark_20() {
198+
for (int i = 20; i < SIZE; i++) {
199+
aI[i] = aI[i - 20] + 1;
200+
}
201+
}
202+
203+
@Fork(value = 1, jvmArgsPrepend = {
204+
"-XX:+UseSuperWord"
205+
})
206+
public static class VectorLoadToStoreForwardingSuperWord extends VectorLoadToStoreForwarding {}
207+
208+
@Fork(value = 1, jvmArgsPrepend = {
209+
"-XX:-UseSuperWord"
210+
})
211+
public static class VectorLoadToStoreForwardingNoSuperWord extends VectorLoadToStoreForwarding {}
212+
}

0 commit comments

Comments
 (0)