summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLProgram.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-10-22 01:26:53 +0200
committerMichael Bien <[email protected]>2009-10-22 01:26:53 +0200
commitb3881a0924ecbe17cf27cededeae8df40b2d6933 (patch)
treea2ae7930eca5d771ab89fddd1a9e62802b6ffac9 /src/com/mbien/opencl/CLProgram.java
parentfe1e2739bf7596bc488de977166603edd18c41fb (diff)
api cleanup and refactoring.
Diffstat (limited to 'src/com/mbien/opencl/CLProgram.java')
-rw-r--r--src/com/mbien/opencl/CLProgram.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/com/mbien/opencl/CLProgram.java b/src/com/mbien/opencl/CLProgram.java
index 020de17c..566ae6b2 100644
--- a/src/com/mbien/opencl/CLProgram.java
+++ b/src/com/mbien/opencl/CLProgram.java
@@ -123,7 +123,7 @@ public class CLProgram {
return Collections.unmodifiableMap(kernels);
}
- void kernelReleased(CLKernel kernel) {
+ void onKernelReleased(CLKernel kernel) {
this.kernels.remove(kernel.name);
}
@@ -140,7 +140,7 @@ public class CLProgram {
}
int ret = cl.clReleaseProgram(ID);
- context.programReleased(this);
+ context.onProgramReleased(this);
checkForError(ret, "can not release program");
}
@@ -184,7 +184,35 @@ public class CLProgram {
return getProgramInfoString(CL.CL_PROGRAM_SOURCE);
}
- // TODO binaries, serialization, program build options
+ public Map<CLDevice, byte[]> getBinaries() {
+
+ CLDevice[] devices = getCLDevices();
+
+ ByteBuffer sizes = ByteBuffer.allocate(8*devices.length).order(ByteOrder.nativeOrder());
+ int ret = cl.clGetProgramInfo(ID, CL.CL_PROGRAM_BINARY_SIZES, sizes.capacity(), sizes, null, 0);
+ checkForError(ret, "on clGetProgramInfo");
+
+ int binarySize = 0;
+ while(sizes.remaining() != 0)
+ binarySize += (int)sizes.getLong();
+
+ ByteBuffer binaries = ByteBuffer.allocate(binarySize).order(ByteOrder.nativeOrder());
+ ret = cl.clGetProgramInfo(ID, CL.CL_PROGRAM_BINARIES, binaries.capacity(), binaries, null, 0); // crash, driver bug?
+ checkForError(ret, "on clGetProgramInfo");
+
+ Map<CLDevice, byte[]> map = new HashMap<CLDevice, byte[]>();
+
+ for (int i = 0; i < devices.length; i++) {
+ byte[] bytes = new byte[(int)sizes.getLong()];
+ binaries.get(bytes);
+ map.put(devices[i], bytes);
+ }
+
+ return map;
+ }
+
+
+ // TODO serialization, program build options
private final String getBuildInfoString(long device, int flag) {