summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-04-19 17:54:25 +0200
committerMichael Bien <[email protected]>2011-04-19 17:54:25 +0200
commitd50d5a7b1c0411492d111d9a3e5a781bc8cdfd55 (patch)
tree33e33d02dee020032f58f24fac0d31de312e295d
parent623423c7e09a240c6220566a24ad9ac65527da94 (diff)
code cleanup in CLProgramBuilder.writeObject().
-rw-r--r--src/com/jogamp/opencl/CLProgramBuilder.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/com/jogamp/opencl/CLProgramBuilder.java b/src/com/jogamp/opencl/CLProgramBuilder.java
index bcde3db6..389adce8 100644
--- a/src/com/jogamp/opencl/CLProgramBuilder.java
+++ b/src/com/jogamp/opencl/CLProgramBuilder.java
@@ -286,20 +286,28 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
- Set<CLDevice> devices = binariesMap.keySet();
- String suffix = devices.iterator().next().getPlatform().getICDSuffix();
- out.writeUTF(suffix);
+ CLDevice[] deviceList = null;
+ String suffix = null;
+
+ if(!binariesMap.isEmpty()) {
+ CLPlatform platform = binariesMap.keySet().iterator().next().getPlatform();
+ deviceList = platform.listCLDevices();
- out.writeInt(binariesMap.size());
+ suffix = platform.getICDSuffix();
+ }
+
+ out.writeUTF(suffix); // null if we have no binaries or no devices specified
+ out.writeInt(binariesMap.size()); // may be 0
- for (CLDevice device : devices) {
- byte[] binaries = binariesMap.get(device);
+ for (Map.Entry<CLDevice, byte[]> entry : binariesMap.entrySet()) {
+ CLDevice device = entry.getKey();
+ byte[] binaries = entry.getValue();
// we use the device index as identifier since there is currently no other way
// to distinguish identical devices via CL.
// it should be persistent between runs but may change on driver/hardware update. In this situations we would
// have to build from source anyway (build failures).
- int index = indexOf(device, device.getPlatform().listCLDevices());
+ int index = indexOf(device, deviceList);
out.writeInt(index);
out.writeInt(binaries.length);
out.write(binaries);