Skip to content

Commit de6083a

Browse files
Julia Boesmcimadamore
Julia Boes
authored andcommittedOct 20, 2021
Address failures in jdk.incubator.foreign benchmarks
Reviewed-by: mcimadamore
1 parent 5158b94 commit de6083a

10 files changed

+31
-40
lines changed
 

‎test/jdk/java/foreign/TestArrayCopy.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -14,7 +14,7 @@
1414
*
1515
* You should have received a copy of the GNU General Public License version
1616
* 2 along with this work; if not, write to the Free Software Foundation,
17-
* Inc., 51 Franklin St, Fifth Floorston, MA 02110-1301 USA.
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1818
*
1919
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2020
* or visit www.oracle.com if you need additional information or have any

‎test/micro/org/openjdk/bench/jdk/incubator/foreign/BulkOps.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,6 @@
4343
import java.nio.IntBuffer;
4444
import java.util.concurrent.TimeUnit;
4545

46-
import static jdk.incubator.foreign.ValueLayout.JAVA_BYTE;
4746
import static jdk.incubator.foreign.ValueLayout.JAVA_INT;
4847

4948
@BenchmarkMode(Mode.AverageTime)
@@ -138,20 +137,20 @@ public void segment_copy() {
138137
@Benchmark
139138
@OutputTimeUnit(TimeUnit.NANOSECONDS)
140139
public void segment_copy_static() {
141-
MemorySegment.copy(bytes, 0, segment, JAVA_BYTE, 0, bytes.length);
140+
MemorySegment.copy(bytes, 0, segment, JAVA_INT, 0, bytes.length);
142141
}
143142

144143
@Benchmark
145144
@OutputTimeUnit(TimeUnit.NANOSECONDS)
146145
public void segment_copy_static_small() {
147-
MemorySegment.copy(bytes, 0, segment, JAVA_BYTE, 0, 10);
146+
MemorySegment.copy(bytes, 0, segment, JAVA_INT, 0, 10);
148147
}
149148

150149
@Benchmark
151150
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
152151
@OutputTimeUnit(TimeUnit.NANOSECONDS)
153152
public void segment_copy_static_small_dontinline() {
154-
MemorySegment.copy(bytes, 0, segment, JAVA_BYTE, 0, 10);
153+
MemorySegment.copy(bytes, 0, segment, JAVA_INT, 0, 10);
155154
}
156155

157156
@Benchmark
@@ -176,7 +175,7 @@ public void buffer_copy() {
176175
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
177176
@OutputTimeUnit(TimeUnit.NANOSECONDS)
178177
public void segment_copy_static_dontinline() {
179-
MemorySegment.copy(bytes, 0, segment, JAVA_BYTE, 0, bytes.length);
178+
MemorySegment.copy(bytes, 0, segment, JAVA_INT, 0, bytes.length);
180179
}
181180

182181
@Benchmark

‎test/micro/org/openjdk/bench/jdk/incubator/foreign/CallOverheadVirtual.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public MemorySegment panama_identity_struct_shared() throws Throwable {
7272

7373
@Benchmark
7474
public MemorySegment panama_identity_struct_confined_3() throws Throwable {
75-
return (MemorySegment) identity_struct_v.invokeExact(identity_struct_addr, recycling_allocator, confinedPoint, confinedPoint, confinedPoint);
75+
return (MemorySegment) identity_struct_3_v.invokeExact(identity_struct_3_addr, recycling_allocator, confinedPoint, confinedPoint, confinedPoint);
7676
}
7777

7878
@Benchmark
7979
public MemorySegment panama_identity_struct_shared_3() throws Throwable {
80-
return (MemorySegment) identity_struct_v.invokeExact(identity_struct_addr, recycling_allocator, sharedPoint, sharedPoint, sharedPoint);
80+
return (MemorySegment) identity_struct_3_v.invokeExact(identity_struct_3_addr, recycling_allocator, sharedPoint, sharedPoint, sharedPoint);
8181
}
8282

8383
@Benchmark
@@ -102,22 +102,22 @@ public MemoryAddress panama_identity_memory_address_confined_3() throws Throwabl
102102

103103
@Benchmark
104104
public MemoryAddress panama_identity_struct_ref_shared() throws Throwable {
105-
return (MemoryAddress) identity_memory_address_v.invokeExact((Addressable)sharedPoint);
105+
return (MemoryAddress) identity_memory_address_v.invokeExact(identity_struct_addr, (Addressable)sharedPoint);
106106
}
107107

108108
@Benchmark
109109
public MemoryAddress panama_identity_struct_ref_confined() throws Throwable {
110-
return (MemoryAddress) identity_memory_address_v.invokeExact((Addressable)confinedPoint);
110+
return (MemoryAddress) identity_memory_address_v.invokeExact(identity_struct_addr, (Addressable)confinedPoint);
111111
}
112112

113113
@Benchmark
114114
public MemoryAddress panama_identity_struct_ref_shared_3() throws Throwable {
115-
return (MemoryAddress) identity_memory_address_3_v.invokeExact((Addressable)sharedPoint, (Addressable)sharedPoint, (Addressable)sharedPoint);
115+
return (MemoryAddress) identity_memory_address_3_v.invokeExact(identity_struct_3_addr, (Addressable)sharedPoint, (Addressable)sharedPoint, (Addressable)sharedPoint);
116116
}
117117

118118
@Benchmark
119119
public MemoryAddress panama_identity_struct_ref_confined_3() throws Throwable {
120-
return (MemoryAddress) identity_memory_address_3_v.invokeExact((Addressable)confinedPoint, (Addressable)confinedPoint, (Addressable)confinedPoint);
120+
return (MemoryAddress) identity_memory_address_3_v.invokeExact(identity_struct_3_addr, (Addressable)confinedPoint, (Addressable)confinedPoint, (Addressable)confinedPoint);
121121
}
122122

123123
@Benchmark
@@ -132,7 +132,7 @@ public MemorySegment panama_identity_struct() throws Throwable {
132132

133133
@Benchmark
134134
public MemoryAddress panama_identity_memory_address_null() throws Throwable {
135-
return (MemoryAddress) identity_memory_address_v.invokeExact(identity_memory_address_addr, MemoryAddress.NULL);
135+
return (MemoryAddress) identity_memory_address_v.invokeExact(identity_memory_address_addr, (Addressable)MemoryAddress.NULL);
136136
}
137137

138138
@Benchmark

‎test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstant.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@
5151
@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
5252
@State(org.openjdk.jmh.annotations.Scope.Thread)
5353
@OutputTimeUnit(TimeUnit.MILLISECONDS)
54-
@Fork(value = 3, jvmArgsAppend = { "--add-modules=jdk.incubator.foreign" })
54+
@Fork(value = 3, jvmArgsAppend = { "--add-modules=jdk.incubator.foreign", "--enable-native-access=ALL-UNNAMED" })
5555
public class LoopOverNonConstant {
5656

5757
static final Unsafe unsafe = Utils.unsafe;

‎test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstantHeap.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -144,15 +144,6 @@ public int segment_loop_instance() {
144144
return res;
145145
}
146146

147-
@Benchmark
148-
public int segment_loop_instance_address() {
149-
int res = 0;
150-
for (int i = 0; i < ELEM_SIZE; i ++) {
151-
res += segment.address().get(JAVA_INT, i * CARRIER_SIZE);
152-
}
153-
return res;
154-
}
155-
156147
@Benchmark
157148
public int segment_loop_slice() {
158149
int sum = 0;

‎test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstantMapped.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -57,7 +57,7 @@
5757
@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
5858
@State(org.openjdk.jmh.annotations.Scope.Thread)
5959
@OutputTimeUnit(TimeUnit.MILLISECONDS)
60-
@Fork(value = 3, jvmArgsAppend = { "--add-modules=jdk.incubator.foreign" })
60+
@Fork(value = 3, jvmArgsAppend = { "--add-modules=jdk.incubator.foreign", "--enable-native-access=ALL-UNNAMED" })
6161
public class LoopOverNonConstantMapped {
6262

6363
static final Unsafe unsafe = Utils.unsafe;

‎test/micro/org/openjdk/bench/jdk/incubator/foreign/QSort.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ interface JNIComparator {
104104

105105
@Benchmark
106106
public void native_qsort() throws Throwable {
107-
clib_qsort.invokeExact((Addressable)INPUT_SEGMENT, (long) INPUT.length, JAVA_INT.byteSize(), native_compar);
107+
clib_qsort.invokeExact((Addressable)INPUT_SEGMENT, (long) INPUT.length, JAVA_INT.byteSize(), (Addressable)native_compar);
108108
}
109109

110110
@Benchmark
@@ -119,7 +119,7 @@ public void jni_upcall_qsort_naive() {
119119

120120
@Benchmark
121121
public void panama_upcall_qsort() throws Throwable {
122-
clib_qsort.invokeExact((Addressable)INPUT_SEGMENT, (long) INPUT.length, JAVA_INT.byteSize(), panama_upcall_compar);
122+
clib_qsort.invokeExact((Addressable)INPUT_SEGMENT, (long) INPUT.length, JAVA_INT.byteSize(), (Addressable)panama_upcall_compar);
123123
}
124124

125125
private static int getIntAbsolute(MemoryAddress addr) {

‎test/micro/org/openjdk/bench/jdk/incubator/foreign/UnrolledAccess.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
4040
@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
4141
@State(org.openjdk.jmh.annotations.Scope.Thread)
4242
@OutputTimeUnit(TimeUnit.MICROSECONDS)
43-
@Fork(3)
43+
@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED" })
4444
public class UnrolledAccess {
4545

4646
static final Unsafe U = Utils.unsafe;

‎test/micro/org/openjdk/bench/jdk/incubator/foreign/Upcalls.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -148,7 +148,7 @@ public void jni_blank() throws Throwable {
148148

149149
@Benchmark
150150
public void panama_blank() throws Throwable {
151-
blank.invokeExact(cb_blank);
151+
blank.invokeExact((Addressable)cb_blank);
152152
}
153153

154154
@Benchmark
@@ -168,17 +168,17 @@ public void jni_args10() throws Throwable {
168168

169169
@Benchmark
170170
public int panama_identity() throws Throwable {
171-
return (int) identity.invokeExact(10, cb_identity);
171+
return (int) identity.invokeExact(10, (Addressable)cb_identity);
172172
}
173173

174174
@Benchmark
175175
public void panama_args5() throws Throwable {
176-
args5.invokeExact(1L, 2D, 3L, 4D, 5L, cb_args5);
176+
args5.invokeExact(1L, 2D, 3L, 4D, 5L, (Addressable)cb_args5);
177177
}
178178

179179
@Benchmark
180180
public void panama_args10() throws Throwable {
181-
args10.invokeExact(1L, 2D, 3L, 4D, 5L, 6D, 7L, 8D, 9L, 10D, cb_args10);
181+
args10.invokeExact(1L, 2D, 3L, 4D, 5L, 6D, 7L, 8D, 9L, 10D, (Addressable)cb_args10);
182182
}
183183

184184
static void blank() {}

‎test/micro/org/openjdk/bench/jdk/incubator/foreign/points/support/PanamaPoint.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,7 @@
2222
*/
2323
package org.openjdk.bench.jdk.incubator.foreign.points.support;
2424

25+
import jdk.incubator.foreign.Addressable;
2526
import jdk.incubator.foreign.CLinker;
2627
import jdk.incubator.foreign.FunctionDescriptor;
2728
import jdk.incubator.foreign.MemoryAddress;
@@ -105,7 +106,7 @@ public double distanceTo(PanamaPoint other) {
105106

106107
public double distanceToPtrs(PanamaPoint other) {
107108
try {
108-
return (double) MH_distance_ptrs.invokeExact(segment.address(), other.segment.address());
109+
return (double) MH_distance_ptrs.invokeExact((Addressable)segment, (Addressable)other.segment);
109110
} catch (Throwable throwable) {
110111
throw new InternalError(throwable);
111112
}

0 commit comments

Comments
 (0)
Please sign in to comment.