diff options
author | Michael Bien <[email protected]> | 2011-02-27 02:07:37 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2011-02-27 02:07:37 +0100 |
commit | 61d365bd7c352262bff711b3954731e7928c203f (patch) | |
tree | 38e4ebe7b19e80ca090090b6d722b0086df129a8 /src/com/jogamp | |
parent | ca1dee15d86d5c6327b3ffb6f4c85c6a5621e621 (diff) |
code review using findbugs
keyset iterations, typos, @Override, synchronization, varargs
Diffstat (limited to 'src/com/jogamp')
-rw-r--r-- | src/com/jogamp/opencl/CLCommandQueue.java | 21 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLContext.java | 4 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLProgram.java | 8 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLProgramBuilder.java | 10 |
4 files changed, 27 insertions, 16 deletions
diff --git a/src/com/jogamp/opencl/CLCommandQueue.java b/src/com/jogamp/opencl/CLCommandQueue.java index 15fd1480..0fc7d383 100644 --- a/src/com/jogamp/opencl/CLCommandQueue.java +++ b/src/com/jogamp/opencl/CLCommandQueue.java @@ -46,9 +46,12 @@ import static com.jogamp.opencl.util.CLUtil.*; * The command queue is used to queue a set of operations for a specific {@link CLDevice}. * Having multiple command-queues allows applications to queue multiple independent commands without * requiring synchronization. Note that this should work as long as these objects are - * not being shared.<br/> + * not being shared. + * <p> + * concurrency note:<br/> * Sharing of objects across multiple queues or using a CLCommandQueue * form multiple Threads will require the application to perform appropriate synchronization. + * </p> * @see CLDevice#createCommandQueue(com.jogamp.opencl.CLCommandQueue.Mode...) * @author Michael Bien */ @@ -103,7 +106,7 @@ public class CLCommandQueue extends CLObject implements CLResource { public CLCommandQueue putWriteBuffer(CLBuffer<?> writeBuffer, boolean blockingRead, CLEventList events) { return putWriteBuffer(writeBuffer, blockingRead, null, events); } - + /** * Calls {@native clEnqueueWriteBuffer}. */ @@ -115,7 +118,7 @@ public class CLCommandQueue extends CLObject implements CLResource { conditionIDs = condition.IDs; conditions = condition.size; } - + int ret = cl.clEnqueueWriteBuffer( ID, writeBuffer.ID, clBoolean(blockingWrite), 0, writeBuffer.getNIOSize(), writeBuffer.buffer, @@ -159,7 +162,7 @@ public class CLCommandQueue extends CLObject implements CLResource { conditionIDs = condition.IDs; conditions = condition.size; } - + int ret = cl.clEnqueueReadBuffer( ID, readBuffer.ID, clBoolean(blockingRead), 0, readBuffer.getNIOSize(), readBuffer.buffer, @@ -229,10 +232,10 @@ public class CLCommandQueue extends CLObject implements CLResource { /** * Calls {@native clEnqueueWriteBufferRect}. */ - public CLCommandQueue putWriteBufferRect(CLBuffer<?> WriteBuffer, + public CLCommandQueue putWriteBufferRect(CLBuffer<?> writeBuffer, int originX, int originY, int hostX, int hostY, int rangeX, int rangeY, boolean blockingWrite, CLEventList condition, CLEventList events) { - putWriteBufferRect(WriteBuffer, originX, originY, hostX, hostY, rangeX, rangeY, 0, 0, 0, 0, blockingWrite, condition, events); + putWriteBufferRect(writeBuffer, originX, originY, hostX, hostY, rangeX, rangeY, 0, 0, 0, 0, blockingWrite, condition, events); return this; } @@ -243,7 +246,7 @@ public class CLCommandQueue extends CLObject implements CLResource { int originX, int originY, int hostX, int hostY, int rangeX, int rangeY, long rowPitch, long slicePitch, long hostRowPitch, long hostSlicePitch, boolean blockingWrite, CLEventList condition, CLEventList events) { - // spec: if 2d: origin/hostpos=0, ragne=1 + // spec: if 2d: origin/hostpos=0, range=1 putWriteBufferRect( writeBuffer, originX, originY, 0, hostX, hostY, 0, rangeX, rangeY, 1, @@ -387,7 +390,7 @@ public class CLCommandQueue extends CLObject implements CLResource { public CLCommandQueue putCopyBufferRect(CLBuffer<?> src, CLBuffer<?> dest, int srcOriginX, int srcOriginY, int destOriginX, int destOriginY, int rangeX, int rangeY, CLEventList condition, CLEventList events) { - // spec: if 2d: origin/destpos=0, ragne=1 + // spec: if 2d: origin/destpos=0, range=1 putCopyBufferRect( src, dest, srcOriginX, srcOriginY, 0, destOriginX, destOriginY, 0, rangeX, rangeY, 1, @@ -1731,7 +1734,7 @@ public class CLCommandQueue extends CLObject implements CLResource { return "\ncond.: " + condition +" events: "+events; } - private String toStr(int... values) { + private String toStr(Integer... values) { return Arrays.asList(values).toString(); } diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java index a5f4e52e..81eb5f37 100644 --- a/src/com/jogamp/opencl/CLContext.java +++ b/src/com/jogamp/opencl/CLContext.java @@ -494,6 +494,7 @@ public class CLContext extends CLObject implements CLResource { /** * Releases this context and all resources. */ + @Override public synchronized void release() { try{ @@ -700,7 +701,8 @@ public class CLContext extends CLObject implements CLResource { private CLErrorHandler[] clientHandlers = new CLErrorHandler[0]; - public void onError(String errinfo, ByteBuffer private_info, long cb) { + @Override + public synchronized void onError(String errinfo, ByteBuffer private_info, long cb) { CLErrorHandler[] handlers = this.clientHandlers; for (int i = 0; i < handlers.length; i++) { handlers[i].onError(errinfo, private_info, cb); diff --git a/src/com/jogamp/opencl/CLProgram.java b/src/com/jogamp/opencl/CLProgram.java index 3cb63003..544df117 100644 --- a/src/com/jogamp/opencl/CLProgram.java +++ b/src/com/jogamp/opencl/CLProgram.java @@ -96,10 +96,10 @@ public class CLProgram extends CLObject implements CLResource { PointerBuffer lengths = PointerBuffer.allocateDirect(binaries.size()); int i = 0; - Set<CLDevice> keys = binaries.keySet(); - for (CLDevice device : keys) { + for (Map.Entry<CLDevice, byte[]> entry : binaries.entrySet()) { - byte[] bytes = binaries.get(device); + byte[] bytes = entry.getValue(); + CLDevice device = entry.getKey(); devices.put(device.ID); lengths.put(bytes.length); @@ -337,6 +337,7 @@ public class CLProgram extends CLObject implements CLResource { BuildProgramCallback callback = null; if(listener != null) { callback = new BuildProgramCallback() { + @Override public void buildFinished(long cl_program) { buildLock.unlock(); listener.buildFinished(CLProgram.this); @@ -446,6 +447,7 @@ public class CLProgram extends CLObject implements CLResource { /** * Releases this program with its kernels. */ + @Override public void release() { releaseKernels(); diff --git a/src/com/jogamp/opencl/CLProgramBuilder.java b/src/com/jogamp/opencl/CLProgramBuilder.java index 00d4dab9..ece9ba36 100644 --- a/src/com/jogamp/opencl/CLProgramBuilder.java +++ b/src/com/jogamp/opencl/CLProgramBuilder.java @@ -55,7 +55,7 @@ import java.util.Set; * @see #loadConfiguration(java.io.ObjectInputStream, com.jogamp.opencl.CLContext) * @author Michael Bien */ -public final class CLProgramBuilder implements CLProgramConfiguration, Serializable { +public final class CLProgramBuilder implements CLProgramConfiguration, Serializable, Cloneable { static final long serialVersionUID = 42; @@ -185,8 +185,10 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa @Override public CLProgramBuilder withDefines(Map<String, ? extends Object> defines) { - for (String name : defines.keySet()) { - defineSet.add(CLProgram.define(name, defines.get(name))); + for (Map.Entry<String, ? extends Object> define : defines.entrySet()) { + String name = define.getKey(); + Object value = define.getValue(); + defineSet.add(CLProgram.define(name, value)); } return this; } @@ -319,10 +321,12 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa return builder; } + @Override public CLProgram getProgram() { return program; } + @Override public CLProgramBuilder setProgram(CLProgram program) { this.program = program; return this; |