Skip to content

Commit c7f555e

Browse files
committed
JavaCL: info getters now all use raw calls
1 parent 1d476be commit c7f555e

File tree

17 files changed

+205
-237
lines changed

17 files changed

+205
-237
lines changed

Core/src/main/Header.vm

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@
8282
#macro (eventOutWrapper $queue) CLEvent.createEventFromPointer($queue, eventOut) #end
8383
#macro (returnEventOut $queue) return #eventOutWrapper($queue); #end
8484

85-
/*
86-
#declareReusablePtrsAndEventsInOut()
87-
error(CL.clEnqueueTask(queue.getEntityPeer(), getEntityPeer(), #eventsInOutArgs()));
88-
#returnEventOut()
89-
*/
85+
#macro (declareInfosGetter $name $function)
86+
protected static CLInfoGetter $name = new CLInfoGetter() {
87+
@Override
88+
protected int getInfo(long entity, int infoTypeEnum, long size, Pointer out, Pointer<SizeT> sizeOut) {
89+
return $function(entity, infoTypeEnum, size, getPeer(out), getPeer(sizeOut));
90+
}
91+
};
92+
#end

Core/src/main/velocity/com/nativelibs4java/opencl/CLContext.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,8 @@ else if ("false".equals(prop) || "0".equals(env))
128128
return cacheBinaries;
129129
}
130130

131-
private static CLInfoGetter<cl_context> infos = new CLInfoGetter<cl_context>() {
132-
133-
@Override
134-
protected int getInfo(cl_context entity, int infoTypeEnum, long size, Pointer out, Pointer<SizeT> sizeOut) {
135-
return CL.clGetContextInfo(entity, infoTypeEnum, size, out, sizeOut);
136-
}
137-
};
131+
#declareInfosGetter("infos", "CL.clGetContextInfo")
132+
138133
CLPlatform platform;
139134
protected Pointer<cl_device_id> deviceIds;
140135

@@ -258,7 +253,7 @@ public CLSampler createSampler(boolean normalized_coords, AddressingMode address
258253
}
259254

260255
public int getDeviceCount() {
261-
return infos.getOptionalFeatureInt(getEntity(), CL.CL_CONTEXT_NUM_DEVICES);
256+
return infos.getOptionalFeatureInt(getEntityPeer(), CL.CL_CONTEXT_NUM_DEVICES);
262257
}
263258

264259
/**
@@ -267,7 +262,7 @@ public int getDeviceCount() {
267262
*/
268263
public synchronized CLDevice[] getDevices() {
269264
if (deviceIds == null) {
270-
deviceIds = infos.getMemory(getEntity(), CL_CONTEXT_DEVICES).as(cl_device_id.class);
265+
deviceIds = infos.getMemory(getEntityPeer(), CL_CONTEXT_DEVICES).as(cl_device_id.class);
271266
}
272267
int n = (int)deviceIds.getValidElements();
273268

0 commit comments

Comments
 (0)