Skip to content

Commit 555ee44

Browse files
committed
JavaCL: reuse int[1] eventOut
1 parent 5e9dbcd commit 555ee44

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

libraries/OpenCL/Core/src/main/Header.vm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#end
3434

3535
#macro (declareEventsIn)
36-
int[] eventsInCount = new int[1];
36+
int[] eventsInCount = ptrs.int1Array;
3737
Pointer<cl_event> eventsIn =
3838
CLAbstractEntity.copyNonNullEntities(eventsToWaitFor, eventsInCount, ptrs.events_in);
3939
#end

libraries/OpenCL/Core/src/main/velocity/com/nativelibs4java/opencl/CLAbstractEntity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ protected void setEntity(long entityPeer) {
2929
}
3030

3131
static <T> Pointer<T> copyNonNullEntities(CLAbstractEntity[] entities, int[] countOut, ReusablePointer tmp) {
32-
int n;
33-
if (entities == null || (n = entities.length) == 0) {
32+
if (entities == null) {
3433
countOut[0] = 0;
3534
return null;
3635
}
36+
int n = entities.length;
3737
Pointer<T> out = null;
3838

3939
int count = 0;
@@ -121,4 +121,4 @@ public boolean equals(Object obj) {
121121
return getEntity() == e.getEntity();
122122
}
123123

124-
}
124+
}

libraries/OpenCL/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointers.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @author ochafik
99
*/
1010
final class ReusablePointers {
11+
public final int[] int1Array = new int[1];
12+
1113
public final ReusablePointer
1214
sizeT3_1 = new ReusablePointer(3 * SizeT.SIZE),
1315
sizeT3_2 = new ReusablePointer(3 * SizeT.SIZE),

0 commit comments

Comments
 (0)