diff options
author | Sven Gothel <[email protected]> | 2014-07-03 16:35:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-03 16:35:47 +0200 |
commit | a90ee128ce0550cd05f969d0283312c2f42b8254 (patch) | |
tree | dade644101970d8f69ea3845db310499f2b66a76 | |
parent | a0e0c8a39d0ef41ff6b64d9b40d058f21b786e81 (diff) |
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
- Change non static accesses to static members using declaring type
- Change indirect accesses to static members to direct accesses (accesses through subtypes)
- Add final modifier to private fields
- Add final modifier to method parameters
- Add final modifier to local variables
- Remove unnecessary casts
- Remove unnecessary '$NON-NLS$' tags
- Remove trailing white spaces on all lines
72 files changed, 1954 insertions, 1916 deletions
diff --git a/src/com/jogamp/opencl/CLBuffer.java b/src/com/jogamp/opencl/CLBuffer.java index 56cbccda..21338b05 100644 --- a/src/com/jogamp/opencl/CLBuffer.java +++ b/src/com/jogamp/opencl/CLBuffer.java @@ -48,16 +48,16 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { private List<CLSubBuffer<B>> childs; - protected CLBuffer(CLContext context, long size, long id, int flags) { + protected CLBuffer(final CLContext context, final long size, final long id, final int flags) { this(context, null, size, id, flags); } - protected CLBuffer(CLContext context, B directBuffer, long size, long id, int flags) { + protected CLBuffer(final CLContext context, final B directBuffer, final long size, final long id, final int flags) { super(context, directBuffer, size, id, flags); } @SuppressWarnings("rawtypes") - static CLBuffer<?> create(CLContext context, int size, int flags) { + static CLBuffer<?> create(final CLContext context, final int size, final int flags) { if(isHostPointerFlag(flags)) { throw new IllegalArgumentException("no host pointer defined"); @@ -71,7 +71,7 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { return new CLBuffer(context, size, id, flags); } - static <B extends Buffer> CLBuffer<B> create(CLContext context, B directBuffer, int flags) { + static <B extends Buffer> CLBuffer<B> create(final CLContext context, final B directBuffer, final int flags) { if(!directBuffer.isDirect()) throw new IllegalArgumentException("buffer is not direct"); @@ -81,10 +81,10 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { host_ptr = directBuffer; } - CLBufferBinding binding = context.getPlatform().getBufferBinding(); - int[] result = new int[1]; - int size = Buffers.sizeOfBufferElem(directBuffer) * directBuffer.capacity(); - long id = binding.clCreateBuffer(context.ID, flags, size, host_ptr, result, 0); + final CLBufferBinding binding = context.getPlatform().getBufferBinding(); + final int[] result = new int[1]; + final int size = Buffers.sizeOfBufferElem(directBuffer) * directBuffer.capacity(); + final long id = binding.clCreateBuffer(context.ID, flags, size, host_ptr, result, 0); CLException.checkForError(result[0], "can not create cl buffer"); return new CLBuffer<B>(context, directBuffer, size, id, flags); @@ -99,12 +99,12 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { * @param offset The offset in buffer elements. * @param size The size in buffer elements. */ - public CLSubBuffer<B> createSubBuffer(int offset, int size, Mem... flags) { + public CLSubBuffer<B> createSubBuffer(int offset, int size, final Mem... flags) { final B slice; if(buffer != null) { slice = Buffers.slice(buffer, offset, size); - int elemSize = Buffers.sizeOfBufferElem(buffer); + final int elemSize = Buffers.sizeOfBufferElem(buffer); offset *= elemSize; size *= elemSize; } else { @@ -139,7 +139,7 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { super.release(); } - void onReleaseSubBuffer(CLSubBuffer<?> sub) { + void onReleaseSubBuffer(final CLSubBuffer<?> sub) { childs.remove(sub); } @@ -163,7 +163,7 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { } @Override - public <T extends Buffer> CLBuffer<T> cloneWith(T directBuffer) { + public <T extends Buffer> CLBuffer<T> cloneWith(final T directBuffer) { return new CLBuffer<T>(context, directBuffer, size, ID, FLAGS); } diff --git a/src/com/jogamp/opencl/CLCommandQueue.java b/src/com/jogamp/opencl/CLCommandQueue.java index 7d359a08..6e9e2951 100644 --- a/src/com/jogamp/opencl/CLCommandQueue.java +++ b/src/com/jogamp/opencl/CLCommandQueue.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -66,7 +66,7 @@ public class CLCommandQueue extends CLObjectResource { private final CLCommandQueueBinding cl; private final CLDevice device; - private long properties; + private final long properties; /* * Those direct memory buffers are used to move data between the JVM and OpenCL. @@ -76,28 +76,28 @@ public class CLCommandQueue extends CLObjectResource { private final PointerBuffer ibB; private final PointerBuffer ibC; - private CLCommandQueue(CLContext context, long id, CLDevice device, long properties) { + private CLCommandQueue(final CLContext context, final long id, final CLDevice device, final long properties) { super(context, id); this.device = device; this.properties = properties; this.cl = context.getPlatform().getCommandQueueBinding(); - int pbsize = PointerBuffer.ELEMENT_SIZE; - CachedBufferFactory factory = CachedBufferFactory.create(9*pbsize + 4, true); - + final int pbsize = PointerBuffer.ELEMENT_SIZE; + final CachedBufferFactory factory = CachedBufferFactory.create(9*pbsize + 4, true); + this.ibA = PointerBuffer.wrap(factory.newDirectByteBuffer(3*pbsize)); this.ibB = PointerBuffer.wrap(factory.newDirectByteBuffer(3*pbsize)); this.ibC = PointerBuffer.wrap(factory.newDirectByteBuffer(3*pbsize)); - + this.pbA = factory.newDirectIntBuffer(1); } - static CLCommandQueue create(CLContext context, CLDevice device, long properties) { - int[] status = new int[1]; - CLCommandQueueBinding binding = context.getPlatform().getCommandQueueBinding(); - long id = binding.clCreateCommandQueue(context.ID, device.ID, properties, status, 0); + static CLCommandQueue create(final CLContext context, final CLDevice device, final long properties) { + final int[] status = new int[1]; + final CLCommandQueueBinding binding = context.getPlatform().getCommandQueueBinding(); + final long id = binding.clCreateCommandQueue(context.ID, device.ID, properties, status, 0); if(status[0] != CL_SUCCESS) { throw newException(status[0], "can not create command queue on " + device +" with properties: " + Mode.valuesOf(properties)); @@ -109,21 +109,21 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueWriteBuffer}. */ - public CLCommandQueue putWriteBuffer(CLBuffer<?> writeBuffer, boolean blockingRead) { + public CLCommandQueue putWriteBuffer(final CLBuffer<?> writeBuffer, final boolean blockingRead) { return putWriteBuffer(writeBuffer, blockingRead, null, null); } /** * Calls {@native clEnqueueWriteBuffer}. */ - public CLCommandQueue putWriteBuffer(CLBuffer<?> writeBuffer, boolean blockingRead, CLEventList events) { + public CLCommandQueue putWriteBuffer(final CLBuffer<?> writeBuffer, final boolean blockingRead, final CLEventList events) { return putWriteBuffer(writeBuffer, blockingRead, null, events); } - + /** * Calls {@native clEnqueueWriteBuffer}. */ - public CLCommandQueue putWriteBuffer(CLBuffer<?> writeBuffer, boolean blockingWrite, CLEventList condition, CLEventList events) { + public CLCommandQueue putWriteBuffer(final CLBuffer<?> writeBuffer, final boolean blockingWrite, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -131,8 +131,8 @@ public class CLCommandQueue extends CLObjectResource { conditionIDs = condition.IDsView; conditions = condition.size; } - - int ret = cl.clEnqueueWriteBuffer( + + final int ret = cl.clEnqueueWriteBuffer( ID, writeBuffer.ID, clBoolean(blockingWrite), 0, writeBuffer.getNIOSize(), writeBuffer.buffer, conditions, conditionIDs, events==null ? null : events.IDs); @@ -151,7 +151,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReadBuffer}. */ - public CLCommandQueue putReadBuffer(CLBuffer<?> readBuffer, boolean blockingRead) { + public CLCommandQueue putReadBuffer(final CLBuffer<?> readBuffer, final boolean blockingRead) { putReadBuffer(readBuffer, blockingRead, null, null); return this; } @@ -159,7 +159,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReadBuffer}. */ - public CLCommandQueue putReadBuffer(CLBuffer<?> readBuffer, boolean blockingRead, CLEventList events) { + public CLCommandQueue putReadBuffer(final CLBuffer<?> readBuffer, final boolean blockingRead, final CLEventList events) { putReadBuffer(readBuffer, blockingRead, null, events); return this; } @@ -167,7 +167,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReadBuffer}. */ - public CLCommandQueue putReadBuffer(CLBuffer<?> readBuffer, boolean blockingRead, CLEventList condition, CLEventList events) { + public CLCommandQueue putReadBuffer(final CLBuffer<?> readBuffer, final boolean blockingRead, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -175,8 +175,8 @@ public class CLCommandQueue extends CLObjectResource { conditionIDs = condition.IDsView; conditions = condition.size; } - - int ret = cl.clEnqueueReadBuffer( + + final int ret = cl.clEnqueueReadBuffer( ID, readBuffer.ID, clBoolean(blockingRead), 0, readBuffer.getNIOSize(), readBuffer.buffer, conditions, conditionIDs, events==null ? null : events.IDs); @@ -195,28 +195,28 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueCopyBuffer}. */ - public CLCommandQueue putCopyBuffer(CLBuffer<?> src, CLBuffer<?> dest) { + public CLCommandQueue putCopyBuffer(final CLBuffer<?> src, final CLBuffer<?> dest) { return putCopyBuffer(src, dest, 0, 0, src.getCLSize(), null, null); } /** * Calls {@native clEnqueueCopyBuffer}. */ - public CLCommandQueue putCopyBuffer(CLBuffer<?> src, CLBuffer<?> dest, long bytesToCopy) { + public CLCommandQueue putCopyBuffer(final CLBuffer<?> src, final CLBuffer<?> dest, final long bytesToCopy) { return putCopyBuffer(src, dest, 0, 0, bytesToCopy, null, null); } /** * Calls {@native clEnqueueCopyBuffer}. */ - public CLCommandQueue putCopyBuffer(CLBuffer<?> src, CLBuffer<?> dest, int srcOffset, int destOffset, long bytesToCopy, CLEventList events) { + public CLCommandQueue putCopyBuffer(final CLBuffer<?> src, final CLBuffer<?> dest, final int srcOffset, final int destOffset, final long bytesToCopy, final CLEventList events) { return putCopyBuffer(src, dest, srcOffset, destOffset, bytesToCopy, null, events); } /** * Calls {@native clEnqueueCopyBuffer}. */ - public CLCommandQueue putCopyBuffer(CLBuffer<?> src, CLBuffer<?> dest, int srcOffset, int destOffset, long bytesToCopy, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyBuffer(final CLBuffer<?> src, final CLBuffer<?> dest, final int srcOffset, final int destOffset, final long bytesToCopy, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -225,7 +225,7 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - int ret = cl.clEnqueueCopyBuffer( + final int ret = cl.clEnqueueCopyBuffer( ID, src.ID, dest.ID, srcOffset, destOffset, bytesToCopy, conditions, conditionIDs, events==null ? null : events.IDs); @@ -245,9 +245,9 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueWriteBufferRect}. */ - public CLCommandQueue putWriteBufferRect(CLBuffer<?> writeBuffer, - int originX, int originY, int hostX, int hostY, int rangeX, int rangeY, - boolean blockingWrite, CLEventList condition, CLEventList events) { + public CLCommandQueue putWriteBufferRect(final CLBuffer<?> writeBuffer, + final int originX, final int originY, final int hostX, final int hostY, final int rangeX, final int rangeY, + final boolean blockingWrite, final CLEventList condition, final CLEventList events) { putWriteBufferRect(writeBuffer, originX, originY, hostX, hostY, rangeX, rangeY, 0, 0, 0, 0, blockingWrite, condition, events); return this; } @@ -255,10 +255,10 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueWriteBufferRect}. */ - public CLCommandQueue putWriteBufferRect(CLBuffer<?> writeBuffer, - 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) { + public CLCommandQueue putWriteBufferRect(final CLBuffer<?> writeBuffer, + final int originX, final int originY, final int hostX, final int hostY, final int rangeX, final int rangeY, + final long rowPitch, final long slicePitch, final long hostRowPitch, final long hostSlicePitch, + final boolean blockingWrite, final CLEventList condition, final CLEventList events) { // spec: if 2d: origin/hostpos=0, range=1 putWriteBufferRect( writeBuffer, originX, originY, 0, hostX, hostY, 0, @@ -271,9 +271,9 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueWriteBufferRect}. */ - public CLCommandQueue putWriteBufferRect(CLBuffer<?> writeBuffer, - int originX, int originY, int originZ, int hostX, int hostY, int hostZ, int rangeX, int rangeY, int rangeZ, - boolean blockingWrite, CLEventList condition, CLEventList events) { + public CLCommandQueue putWriteBufferRect(final CLBuffer<?> writeBuffer, + final int originX, final int originY, final int originZ, final int hostX, final int hostY, final int hostZ, final int rangeX, final int rangeY, final int rangeZ, + final boolean blockingWrite, final CLEventList condition, final CLEventList events) { putWriteBufferRect(writeBuffer, originX, originY, originZ, hostX, hostY, hostZ, rangeX, rangeY, rangeZ, 0, 0, 0, 0, blockingWrite, condition, events); @@ -283,10 +283,10 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueWriteBufferRect}. */ - public CLCommandQueue putWriteBufferRect(CLBuffer<?> writeBuffer, - int originX, int originY, int originZ, int hostX, int hostY, int hostZ, int rangeX, int rangeY, int rangeZ, - long rowPitch, long slicePitch, long hostRowPitch, long hostSlicePitch, - boolean blockingWrite, CLEventList condition, CLEventList events) { + public CLCommandQueue putWriteBufferRect(final CLBuffer<?> writeBuffer, + final int originX, final int originY, final int originZ, final int hostX, final int hostY, final int hostZ, final int rangeX, final int rangeY, final int rangeZ, + final long rowPitch, final long slicePitch, final long hostRowPitch, final long hostSlicePitch, + final boolean blockingWrite, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -299,7 +299,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibB, hostX, hostY, hostZ); copy2NIO(ibC, rangeX, rangeY, rangeZ); - int ret = cl.clEnqueueWriteBufferRect( + final int ret = cl.clEnqueueWriteBufferRect( ID, writeBuffer.ID, clBoolean(blockingWrite), ibA, ibB, ibC, rowPitch, slicePitch, hostRowPitch, hostSlicePitch, writeBuffer.getBuffer(), conditions, conditionIDs, events==null ? null : events.IDs); @@ -322,9 +322,9 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReadBufferRect}. */ - public CLCommandQueue putReadBufferRect(CLBuffer<?> readBuffer, - int originX, int originY, int hostX, int hostY, int rangeX, int rangeY, - boolean blockingRead, CLEventList condition, CLEventList events) { + public CLCommandQueue putReadBufferRect(final CLBuffer<?> readBuffer, + final int originX, final int originY, final int hostX, final int hostY, final int rangeX, final int rangeY, + final boolean blockingRead, final CLEventList condition, final CLEventList events) { putReadBufferRect(readBuffer, originX, originY, hostX, hostY, rangeX, rangeY, 0, 0, 0, 0, blockingRead, condition, events); return this; } @@ -332,10 +332,10 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReadBufferRect}. */ - public CLCommandQueue putReadBufferRect(CLBuffer<?> readBuffer, - int originX, int originY, int hostX, int hostY, int rangeX, int rangeY, - long rowPitch, long slicePitch, long hostRowPitch, long hostSlicePitch, - boolean blockingRead, CLEventList condition, CLEventList events) { + public CLCommandQueue putReadBufferRect(final CLBuffer<?> readBuffer, + final int originX, final int originY, final int hostX, final int hostY, final int rangeX, final int rangeY, + final long rowPitch, final long slicePitch, final long hostRowPitch, final long hostSlicePitch, + final boolean blockingRead, final CLEventList condition, final CLEventList events) { // spec: if 2d: origin/hostpos=0, range=1 putReadBufferRect( readBuffer, originX, originY, 0, hostX, hostY, 0, @@ -348,9 +348,9 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReadBufferRect}. */ - public CLCommandQueue putReadBufferRect(CLBuffer<?> readBuffer, - int originX, int originY, int originZ, int hostX, int hostY, int hostZ, int rangeX, int rangeY, int rangeZ, - boolean blockingRead, CLEventList condition, CLEventList events) { + public CLCommandQueue putReadBufferRect(final CLBuffer<?> readBuffer, + final int originX, final int originY, final int originZ, final int hostX, final int hostY, final int hostZ, final int rangeX, final int rangeY, final int rangeZ, + final boolean blockingRead, final CLEventList condition, final CLEventList events) { putReadBufferRect( readBuffer, originX, originY, originZ, hostX, hostY, hostZ, rangeX, rangeY, rangeZ, @@ -361,10 +361,10 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReadBufferRect}. */ - public CLCommandQueue putReadBufferRect(CLBuffer<?> readBuffer, - int originX, int originY, int originZ, int hostX, int hostY, int hostZ, int rangeX, int rangeY, int rangeZ, - long rowPitch, long slicePitch, long hostRowPitch, long hostSlicePitch, - boolean blockingRead, CLEventList condition, CLEventList events) { + public CLCommandQueue putReadBufferRect(final CLBuffer<?> readBuffer, + final int originX, final int originY, final int originZ, final int hostX, final int hostY, final int hostZ, final int rangeX, final int rangeY, final int rangeZ, + final long rowPitch, final long slicePitch, final long hostRowPitch, final long hostSlicePitch, + final boolean blockingRead, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -377,7 +377,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibB, hostX, hostY, hostZ); copy2NIO(ibC, rangeX, rangeY, rangeZ); - int ret = cl.clEnqueueReadBufferRect( + final int ret = cl.clEnqueueReadBufferRect( ID, readBuffer.ID, clBoolean(blockingRead), ibA, ibB, ibC, rowPitch, slicePitch, hostRowPitch, hostSlicePitch, readBuffer.getBuffer(), conditions, conditionIDs, events==null ? null : events.IDs); @@ -400,9 +400,9 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueCopyBufferRect}. */ - public CLCommandQueue putCopyBufferRect(CLBuffer<?> src, CLBuffer<?> dest, - int srcOriginX, int srcOriginY, int destOriginX, int destOriginY, int rangeX, int rangeY, - CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyBufferRect(final CLBuffer<?> src, final CLBuffer<?> dest, + final int srcOriginX, final int srcOriginY, final int destOriginX, final int destOriginY, final int rangeX, final int rangeY, + final CLEventList condition, final CLEventList events) { // spec: if 2d: origin/destpos=0, range=1 putCopyBufferRect( src, dest, srcOriginX, srcOriginY, 0, destOriginX, destOriginY, 0, @@ -414,10 +414,10 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueCopyBufferRect}. */ - public CLCommandQueue putCopyBufferRect(CLBuffer<?> src, CLBuffer<?> dest, - int srcOriginX, int srcOriginY, int destOriginX, int destOriginY, int rangeX, int rangeY, - long srcRowPitch, long srcSlicePitch, long destRowPitch, long destSlicePitch, - CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyBufferRect(final CLBuffer<?> src, final CLBuffer<?> dest, + final int srcOriginX, final int srcOriginY, final int destOriginX, final int destOriginY, final int rangeX, final int rangeY, + final long srcRowPitch, final long srcSlicePitch, final long destRowPitch, final long destSlicePitch, + final CLEventList condition, final CLEventList events) { putCopyBufferRect( src, dest, srcOriginX, srcOriginY, 0, destOriginX, destOriginY, 0, rangeX, rangeY, 1, @@ -430,9 +430,9 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueCopyBufferRect}. */ - public CLCommandQueue putCopyBufferRect(CLBuffer<?> src, CLBuffer<?> dest, - int srcOriginX, int srcOriginY, int srcOriginZ, int destOriginX, int destOriginY, int destOriginZ, int rangeX, int rangeY, int rangeZ, - CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyBufferRect(final CLBuffer<?> src, final CLBuffer<?> dest, + final int srcOriginX, final int srcOriginY, final int srcOriginZ, final int destOriginX, final int destOriginY, final int destOriginZ, final int rangeX, final int rangeY, final int rangeZ, + final CLEventList condition, final CLEventList events) { putCopyBufferRect( src, dest, srcOriginX, srcOriginY, srcOriginZ, destOriginX, destOriginY, destOriginZ, rangeX, rangeY, rangeZ, @@ -442,10 +442,10 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueCopyBufferRect}. */ - public CLCommandQueue putCopyBufferRect(CLBuffer<?> src, CLBuffer<?> dest, - int srcOriginX, int srcOriginY, int srcOriginZ, int destOriginX, int destOriginY, int destOriginZ, int rangeX, int rangeY, int rangeZ, - long srcRowPitch, long srcSlicePitch, long destRowPitch, long destSlicePitch, - CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyBufferRect(final CLBuffer<?> src, final CLBuffer<?> dest, + final int srcOriginX, final int srcOriginY, final int srcOriginZ, final int destOriginX, final int destOriginY, final int destOriginZ, final int rangeX, final int rangeY, final int rangeZ, + final long srcRowPitch, final long srcSlicePitch, final long destRowPitch, final long destSlicePitch, + final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -458,7 +458,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibB, destOriginX, destOriginY, destOriginZ); copy2NIO(ibC, rangeX, rangeY, rangeZ); - int ret = cl.clEnqueueCopyBufferRect( + final int ret = cl.clEnqueueCopyBufferRect( ID, src.ID, dest.ID, ibA, ibB, ibC, srcRowPitch, srcSlicePitch, destRowPitch, destSlicePitch, conditions, conditionIDs, events==null ? null : events.IDs); @@ -483,37 +483,37 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueWriteImage}. */ - public CLCommandQueue putWriteImage(CLImage2d<?> writeImage, boolean blockingWrite) { + public CLCommandQueue putWriteImage(final CLImage2d<?> writeImage, final boolean blockingWrite) { return putWriteImage(writeImage, 0, 0, 0, writeImage.width, writeImage.height, blockingWrite, null, null); } /** * Calls {@native clEnqueueWriteImage}. */ - public CLCommandQueue putWriteImage(CLImage2d<?> writeImage, boolean blockingWrite, CLEventList events) { + public CLCommandQueue putWriteImage(final CLImage2d<?> writeImage, final boolean blockingWrite, final CLEventList events) { return putWriteImage(writeImage, 0, 0, 0, writeImage.width, writeImage.height, blockingWrite, null, events); } /** * Calls {@native clEnqueueWriteImage}. */ - public CLCommandQueue putWriteImage(CLImage2d<?> writeImage, boolean blockingWrite, CLEventList condition, CLEventList events) { + public CLCommandQueue putWriteImage(final CLImage2d<?> writeImage, final boolean blockingWrite, final CLEventList condition, final CLEventList events) { return putWriteImage(writeImage, 0, 0, 0, writeImage.width, writeImage.height, blockingWrite, condition, events); } /** * Calls {@native clEnqueueWriteImage}. */ - public CLCommandQueue putWriteImage(CLImage2d<?> writeImage, int inputRowPitch, - int originX, int originY, int rangeX, int rangeY, boolean blockingWrite) { + public CLCommandQueue putWriteImage(final CLImage2d<?> writeImage, final int inputRowPitch, + final int originX, final int originY, final int rangeX, final int rangeY, final boolean blockingWrite) { return putWriteImage(writeImage, inputRowPitch, originX, originY, rangeX, rangeY, blockingWrite, null, null); } /** * Calls {@native clEnqueueWriteImage}. */ - public CLCommandQueue putWriteImage(CLImage2d<?> writeImage, int inputRowPitch, - int originX, int originY, int rangeX, int rangeY, boolean blockingWrite, CLEventList condition, CLEventList events) { + public CLCommandQueue putWriteImage(final CLImage2d<?> writeImage, final int inputRowPitch, + final int originX, final int originY, final int rangeX, final int rangeY, final boolean blockingWrite, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -527,7 +527,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibA, originX, originY, 0); copy2NIO(ibB, rangeX, rangeY, 1); - int ret = cl.clEnqueueWriteImage(ID, writeImage.ID, clBoolean(blockingWrite), + final int ret = cl.clEnqueueWriteImage(ID, writeImage.ID, clBoolean(blockingWrite), ibA, ibB, inputRowPitch, 0, writeImage.buffer, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { @@ -545,37 +545,37 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueWriteImage}. */ - public CLCommandQueue putWriteImage(CLImage3d<?> writeImage, boolean blockingWrite) { + public CLCommandQueue putWriteImage(final CLImage3d<?> writeImage, final boolean blockingWrite) { return putWriteImage(writeImage, 0, 0, 0, 0, 0, writeImage.width, writeImage.height, writeImage.depth, blockingWrite, null, null); } /** * Calls {@native clEnqueueWriteImage}. */ - public CLCommandQueue putWriteImage(CLImage3d<?> writeImage, boolean blockingWrite, CLEventList events) { + public CLCommandQueue putWriteImage(final CLImage3d<?> writeImage, final boolean blockingWrite, final CLEventList events) { return putWriteImage(writeImage, 0, 0, 0, 0, 0, writeImage.width, writeImage.height, writeImage.depth, blockingWrite, null, events); } /** * Calls {@native clEnqueueWriteImage}. */ - public CLCommandQueue putWriteImage(CLImage3d<?> writeImage, boolean blockingWrite, CLEventList condition, CLEventList events) { + public CLCommandQueue putWriteImage(final CLImage3d<?> writeImage, final boolean blockingWrite, final CLEventList condition, final CLEventList events) { return putWriteImage(writeImage, 0, 0, 0, 0, 0, writeImage.width, writeImage.height, writeImage.depth, blockingWrite, condition, events); } /** * Calls {@native clEnqueueWriteImage}. */ - public CLCommandQueue putWriteImage(CLImage3d<?> writeImage, int inputRowPitch, int inputSlicePitch, - int originX, int originY, int originZ, int rangeX, int rangeY, int rangeZ, boolean blockingWrite) { + public CLCommandQueue putWriteImage(final CLImage3d<?> writeImage, final int inputRowPitch, final int inputSlicePitch, + final int originX, final int originY, final int originZ, final int rangeX, final int rangeY, final int rangeZ, final boolean blockingWrite) { return putWriteImage(writeImage, inputRowPitch, inputSlicePitch, originX, originY, originZ, rangeX, rangeY, rangeZ, blockingWrite, null, null); } /** * Calls {@native clEnqueueWriteImage}. */ - public CLCommandQueue putWriteImage(CLImage3d<?> writeImage, int inputRowPitch, int inputSlicePitch, - int originX, int originY, int originZ, int rangeX, int rangeY, int rangeZ, boolean blockingWrite, CLEventList condition, CLEventList events) { + public CLCommandQueue putWriteImage(final CLImage3d<?> writeImage, final int inputRowPitch, final int inputSlicePitch, + final int originX, final int originY, final int originZ, final int rangeX, final int rangeY, final int rangeZ, final boolean blockingWrite, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -587,7 +587,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibA, originX, originY, originZ); copy2NIO(ibB, rangeX, rangeY, rangeZ); - int ret = cl.clEnqueueWriteImage(ID, writeImage.ID, clBoolean(blockingWrite), + final int ret = cl.clEnqueueWriteImage(ID, writeImage.ID, clBoolean(blockingWrite), ibA, ibB, inputRowPitch, inputSlicePitch, writeImage.buffer, conditions, conditionIDs, events==null ? null : events.IDs); @@ -606,37 +606,37 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReadImage}. */ - public CLCommandQueue putReadImage(CLImage2d<?> readImage, boolean blockingRead) { + public CLCommandQueue putReadImage(final CLImage2d<?> readImage, final boolean blockingRead) { return putReadImage(readImage, 0, 0, 0, readImage.width, readImage.height, blockingRead, null, null); } /** * Calls {@native clEnqueueReadImage}. */ - public CLCommandQueue putReadImage(CLImage2d<?> readImage, boolean blockingRead, CLEventList events) { + public CLCommandQueue putReadImage(final CLImage2d<?> readImage, final boolean blockingRead, final CLEventList events) { return putReadImage(readImage, 0, 0, 0, readImage.width, readImage.height, blockingRead, null, events); } /** * Calls {@native clEnqueueReadImage}. */ - public CLCommandQueue putReadImage(CLImage2d<?> readImage, boolean blockingRead, CLEventList condition, CLEventList events) { + public CLCommandQueue putReadImage(final CLImage2d<?> readImage, final boolean blockingRead, final CLEventList condition, final CLEventList events) { return putReadImage(readImage, 0, 0, 0, readImage.width, readImage.height, blockingRead, condition, events); } /** * Calls {@native clEnqueueReadImage}. */ - public CLCommandQueue putReadImage(CLImage2d<?> readImage, int inputRowPitch, - int originX, int originY, int rangeX, int rangeY, boolean blockingRead) { + public CLCommandQueue putReadImage(final CLImage2d<?> readImage, final int inputRowPitch, + final int originX, final int originY, final int rangeX, final int rangeY, final boolean blockingRead) { return putReadImage(readImage, inputRowPitch, originX, originY, rangeX, rangeY, blockingRead, null, null); } /** * Calls {@native clEnqueueReadImage}. */ - public CLCommandQueue putReadImage(CLImage2d<?> readImage, int inputRowPitch, - int originX, int originY, int rangeX, int rangeY, boolean blockingRead, CLEventList condition, CLEventList events) { + public CLCommandQueue putReadImage(final CLImage2d<?> readImage, final int inputRowPitch, + final int originX, final int originY, final int rangeX, final int rangeY, final boolean blockingRead, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -650,7 +650,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibA, originX, originY, 0); copy2NIO(ibB, rangeX, rangeY, 1); - int ret = cl.clEnqueueReadImage(ID, readImage.ID, clBoolean(blockingRead), + final int ret = cl.clEnqueueReadImage(ID, readImage.ID, clBoolean(blockingRead), ibA, ibB, inputRowPitch, 0, readImage.buffer, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { @@ -668,37 +668,37 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReadImage}. */ - public CLCommandQueue putReadImage(CLImage3d<?> readImage, boolean blockingRead) { + public CLCommandQueue putReadImage(final CLImage3d<?> readImage, final boolean blockingRead) { return putReadImage(readImage, 0, 0, 0, 0, 0, readImage.width, readImage.height, readImage.depth, blockingRead, null, null); } /** * Calls {@native clEnqueueReadImage}. */ - public CLCommandQueue putReadImage(CLImage3d<?> readImage, boolean blockingRead, CLEventList events) { + public CLCommandQueue putReadImage(final CLImage3d<?> readImage, final boolean blockingRead, final CLEventList events) { return putReadImage(readImage, 0, 0, 0, 0, 0, readImage.width, readImage.height, readImage.depth, blockingRead, null, events); } /** * Calls {@native clEnqueueReadImage}. */ - public CLCommandQueue putReadImage(CLImage3d<?> readImage, boolean blockingRead, CLEventList condition, CLEventList events) { + public CLCommandQueue putReadImage(final CLImage3d<?> readImage, final boolean blockingRead, final CLEventList condition, final CLEventList events) { return putReadImage(readImage, 0, 0, 0, 0, 0, readImage.width, readImage.height, readImage.depth, blockingRead, condition, events); } /** * Calls {@native clEnqueueReadImage}. */ - public CLCommandQueue putReadImage(CLImage3d<?> readImage, int inputRowPitch, int inputSlicePitch, - int originX, int originY, int originZ, int rangeX, int rangeY, int rangeZ, boolean blockingRead) { + public CLCommandQueue putReadImage(final CLImage3d<?> readImage, final int inputRowPitch, final int inputSlicePitch, + final int originX, final int originY, final int originZ, final int rangeX, final int rangeY, final int rangeZ, final boolean blockingRead) { return putReadImage(readImage, inputRowPitch, inputSlicePitch, originX, originY, originZ, rangeX, rangeY, rangeZ, blockingRead, null, null); } /** * Calls {@native clEnqueueReadImage}. */ - public CLCommandQueue putReadImage(CLImage3d<?> readImage, int inputRowPitch, int inputSlicePitch, - int originX, int originY, int originZ, int rangeX, int rangeY, int rangeZ, boolean blockingRead, CLEventList condition, CLEventList events) { + public CLCommandQueue putReadImage(final CLImage3d<?> readImage, final int inputRowPitch, final int inputSlicePitch, + final int originX, final int originY, final int originZ, final int rangeX, final int rangeY, final int rangeZ, final boolean blockingRead, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -710,7 +710,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibA, originX, originY, originZ); copy2NIO(ibB, rangeX, rangeY, rangeZ); - int ret = cl.clEnqueueReadImage(ID, readImage.ID, clBoolean(blockingRead), + final int ret = cl.clEnqueueReadImage(ID, readImage.ID, clBoolean(blockingRead), ibA, ibB, inputRowPitch, inputSlicePitch, readImage.buffer, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { @@ -728,41 +728,41 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueCopyImage}. */ - public CLCommandQueue putCopyImage(CLImage2d<?> srcImage, CLImage2d<?> dstImage) { + public CLCommandQueue putCopyImage(final CLImage2d<?> srcImage, final CLImage2d<?> dstImage) { return putCopyImage(srcImage, dstImage, null); } /** * Calls {@native clEnqueueCopyImage}. */ - public CLCommandQueue putCopyImage(CLImage2d<?> srcImage, CLImage2d<?> dstImage, CLEventList events) { + public CLCommandQueue putCopyImage(final CLImage2d<?> srcImage, final CLImage2d<?> dstImage, final CLEventList events) { return putCopyImage(srcImage, dstImage, 0, 0, 0, 0, srcImage.width, srcImage.height, null, events); } /** * Calls {@native clEnqueueCopyImage}. */ - public CLCommandQueue putCopyImage(CLImage2d<?> srcImage, CLImage2d<?> dstImage, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyImage(final CLImage2d<?> srcImage, final CLImage2d<?> dstImage, final CLEventList condition, final CLEventList events) { return putCopyImage(srcImage, dstImage, 0, 0, 0, 0, srcImage.width, srcImage.height, condition, events); } /** * Calls {@native clEnqueueCopyImage}. */ - public CLCommandQueue putCopyImage(CLImage2d<?> srcImage, CLImage2d<?> dstImage, - int srcOriginX, int srcOriginY, - int dstOriginX, int dstOriginY, - int rangeX, int rangeY) { + public CLCommandQueue putCopyImage(final CLImage2d<?> srcImage, final CLImage2d<?> dstImage, + final int srcOriginX, final int srcOriginY, + final int dstOriginX, final int dstOriginY, + final int rangeX, final int rangeY) { return putCopyImage(srcImage, dstImage, srcOriginX, srcOriginY, dstOriginX, dstOriginY, rangeX, rangeY, null, null); } /** * Calls {@native clEnqueueCopyImage}. */ - public CLCommandQueue putCopyImage(CLImage2d<?> srcImage, CLImage2d<?> dstImage, - int srcOriginX, int srcOriginY, - int dstOriginX, int dstOriginY, - int rangeX, int rangeY, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyImage(final CLImage2d<?> srcImage, final CLImage2d<?> dstImage, + final int srcOriginX, final int srcOriginY, + final int dstOriginX, final int dstOriginY, + final int rangeX, final int rangeY, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -777,7 +777,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibB, dstOriginX, dstOriginY, 0); copy2NIO(ibC, rangeX, rangeY, 1); - int ret = cl.clEnqueueCopyImage(ID, srcImage.ID, dstImage.ID, ibA, ibB, ibC, + final int ret = cl.clEnqueueCopyImage(ID, srcImage.ID, dstImage.ID, ibA, ibB, ibC, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { throw newException(ret, "can not enqueue copy-image " + srcImage +" to "+ dstImage @@ -795,31 +795,31 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueCopyImage}. */ - public CLCommandQueue putCopyImage(CLImage3d<?> srcImage, CLImage3d<?> dstImage) { + public CLCommandQueue putCopyImage(final CLImage3d<?> srcImage, final CLImage3d<?> dstImage) { return putCopyImage(srcImage, dstImage, null); } /** * Calls {@native clEnqueueCopyImage}. */ - public CLCommandQueue putCopyImage(CLImage3d<?> srcImage, CLImage3d<?> dstImage, CLEventList events) { + public CLCommandQueue putCopyImage(final CLImage3d<?> srcImage, final CLImage3d<?> dstImage, final CLEventList events) { return putCopyImage(srcImage, dstImage, 0, 0, 0, 0, 0, 0, srcImage.width, srcImage.height, srcImage.depth, null, events); } /** * Calls {@native clEnqueueCopyImage}. */ - public CLCommandQueue putCopyImage(CLImage3d<?> srcImage, CLImage3d<?> dstImage, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyImage(final CLImage3d<?> srcImage, final CLImage3d<?> dstImage, final CLEventList condition, final CLEventList events) { return putCopyImage(srcImage, dstImage, 0, 0, 0, 0, 0, 0, srcImage.width, srcImage.height, srcImage.depth, condition, events); } /** * Calls {@native clEnqueueCopyImage}. */ - public CLCommandQueue putCopyImage(CLImage3d<?> srcImage, CLImage3d<?> dstImage, - int srcOriginX, int srcOriginY, int srcOriginZ, - int dstOriginX, int dstOriginY, int dstOriginZ, - int rangeX, int rangeY, int rangeZ) { + public CLCommandQueue putCopyImage(final CLImage3d<?> srcImage, final CLImage3d<?> dstImage, + final int srcOriginX, final int srcOriginY, final int srcOriginZ, + final int dstOriginX, final int dstOriginY, final int dstOriginZ, + final int rangeX, final int rangeY, final int rangeZ) { return putCopyImage(srcImage, dstImage, srcOriginX, srcOriginY, srcOriginZ, dstOriginX, dstOriginY, dstOriginZ, rangeX, rangeY, rangeZ, null, null); @@ -828,10 +828,10 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueCopyImage}. */ - public CLCommandQueue putCopyImage(CLImage<?> srcImage, CLImage<?> dstImage, - int srcOriginX, int srcOriginY, int srcOriginZ, - int dstOriginX, int dstOriginY, int dstOriginZ, - int rangeX, int rangeY, int rangeZ, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyImage(final CLImage<?> srcImage, final CLImage<?> dstImage, + final int srcOriginX, final int srcOriginY, final int srcOriginZ, + final int dstOriginX, final int dstOriginY, final int dstOriginZ, + final int rangeX, final int rangeY, final int rangeZ, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -844,7 +844,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibB, dstOriginX, dstOriginY, dstOriginZ); copy2NIO(ibC, rangeX, rangeY, rangeZ); - int ret = cl.clEnqueueCopyImage(ID, srcImage.ID, dstImage.ID, ibA, ibB, ibC, + final int ret = cl.clEnqueueCopyImage(ID, srcImage.ID, dstImage.ID, ibA, ibB, ibC, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { throw newException(ret, "can not enqueue copy-image " + srcImage +" to "+ dstImage @@ -857,45 +857,45 @@ public class CLCommandQueue extends CLObjectResource { } return this; } - + //2D /** * Calls {@native clEnqueueCopyBufferToImage}. */ - public CLCommandQueue putCopyBufferToImage(CLBuffer<?> srcBuffer, CLImage2d<?> dstImage) { + public CLCommandQueue putCopyBufferToImage(final CLBuffer<?> srcBuffer, final CLImage2d<?> dstImage) { return putCopyBufferToImage(srcBuffer, dstImage, null); } - + /** * Calls {@native clEnqueueCopyBufferToImage}. */ - public CLCommandQueue putCopyBufferToImage(CLBuffer<?> srcBuffer, CLImage2d<?> dstImage, CLEventList events) { + public CLCommandQueue putCopyBufferToImage(final CLBuffer<?> srcBuffer, final CLImage2d<?> dstImage, final CLEventList events) { return putCopyBufferToImage(srcBuffer, dstImage, 0, 0, 0, dstImage.width, dstImage.height, null, events); } /** * Calls {@native clEnqueueCopyBufferToImage}. */ - public CLCommandQueue putCopyBufferToImage(CLBuffer<?> srcBuffer, CLImage2d<?> dstImage, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyBufferToImage(final CLBuffer<?> srcBuffer, final CLImage2d<?> dstImage, final CLEventList condition, final CLEventList events) { return putCopyBufferToImage(srcBuffer, dstImage, 0, 0, 0, dstImage.width, dstImage.height, condition, events); } - + /** * Calls {@native clEnqueueCopyBufferToImage}. */ - public CLCommandQueue putCopyBufferToImage(CLBuffer<?> srcBuffer, CLImage2d<?> dstImage, - long srcOffset, int dstOriginX, int dstOriginY, - int rangeX, int rangeY) { - return putCopyBufferToImage(srcBuffer, dstImage, + public CLCommandQueue putCopyBufferToImage(final CLBuffer<?> srcBuffer, final CLImage2d<?> dstImage, + final long srcOffset, final int dstOriginX, final int dstOriginY, + final int rangeX, final int rangeY) { + return putCopyBufferToImage(srcBuffer, dstImage, srcOffset, dstOriginX, dstOriginY, rangeX, rangeY, null, null); } - + /** * Calls {@native clEnqueueCopyBufferToImage}. */ - public CLCommandQueue putCopyBufferToImage(CLBuffer<?> srcBuffer, CLImage2d<?> dstImage, - long srcOffset, int dstOriginX, int dstOriginY, - int rangeX, int rangeY, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyBufferToImage(final CLBuffer<?> srcBuffer, final CLImage2d<?> dstImage, + final long srcOffset, final int dstOriginX, final int dstOriginY, + final int rangeX, final int rangeY, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -909,7 +909,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibA, dstOriginX, dstOriginY, 0); copy2NIO(ibB, rangeX, rangeY, 1); - int ret = cl.clEnqueueCopyBufferToImage(ID, srcBuffer.ID, dstImage.ID, + final int ret = cl.clEnqueueCopyBufferToImage(ID, srcBuffer.ID, dstImage.ID, srcOffset, ibA, ibB, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { @@ -923,46 +923,46 @@ public class CLCommandQueue extends CLObjectResource { } return this; } - + //3D /** * Calls {@native clEnqueueCopyBufferToImage}. */ - public CLCommandQueue putCopyBufferToImage(CLBuffer<?> srcBuffer, CLImage3d<?> dstImage) { + public CLCommandQueue putCopyBufferToImage(final CLBuffer<?> srcBuffer, final CLImage3d<?> dstImage) { return putCopyBufferToImage(srcBuffer, dstImage, null); } - + /** * Calls {@native clEnqueueCopyBufferToImage}. */ - public CLCommandQueue putCopyBufferToImage(CLBuffer<?> srcBuffer, CLImage3d<?> dstImage, CLEventList events) { + public CLCommandQueue putCopyBufferToImage(final CLBuffer<?> srcBuffer, final CLImage3d<?> dstImage, final CLEventList events) { return putCopyBufferToImage(srcBuffer, dstImage, 0, 0, 0, 0, dstImage.width, dstImage.height, dstImage.depth, null, events); } /** * Calls {@native clEnqueueCopyBufferToImage}. */ - public CLCommandQueue putCopyBufferToImage(CLBuffer<?> srcBuffer, CLImage3d<?> dstImage, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyBufferToImage(final CLBuffer<?> srcBuffer, final CLImage3d<?> dstImage, final CLEventList condition, final CLEventList events) { return putCopyBufferToImage(srcBuffer, dstImage, 0, 0, 0, 0, dstImage.width, dstImage.height, dstImage.depth, condition, events); } - + /** * Calls {@native clEnqueueCopyBufferToImage}. */ - public CLCommandQueue putCopyBufferToImage(CLBuffer<?> srcBuffer, CLImage3d<?> dstImage, - long srcOffset, int dstOriginX, int dstOriginY, int dstOriginZ, - int rangeX, int rangeY, int rangeZ) { - return putCopyBufferToImage(srcBuffer, dstImage, + public CLCommandQueue putCopyBufferToImage(final CLBuffer<?> srcBuffer, final CLImage3d<?> dstImage, + final long srcOffset, final int dstOriginX, final int dstOriginY, final int dstOriginZ, + final int rangeX, final int rangeY, final int rangeZ) { + return putCopyBufferToImage(srcBuffer, dstImage, srcOffset, dstOriginX, dstOriginY, dstOriginZ, rangeX, rangeY, rangeZ, null, null); - + } - + /** * Calls {@native clEnqueueCopyBufferToImage}. */ - public CLCommandQueue putCopyBufferToImage(CLBuffer<?> srcBuffer, CLImage3d<?> dstImage, - long srcOffset, int dstOriginX, int dstOriginY, int dstOriginZ, - int rangeX, int rangeY, int rangeZ, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyBufferToImage(final CLBuffer<?> srcBuffer, final CLImage3d<?> dstImage, + final long srcOffset, final int dstOriginX, final int dstOriginY, final int dstOriginZ, + final int rangeX, final int rangeY, final int rangeZ, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -974,7 +974,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibA, dstOriginX, dstOriginY, dstOriginZ); copy2NIO(ibB, rangeX, rangeY, rangeZ); - int ret = cl.clEnqueueCopyBufferToImage(ID, srcBuffer.ID, dstImage.ID, + final int ret = cl.clEnqueueCopyBufferToImage(ID, srcBuffer.ID, dstImage.ID, srcOffset, ibA, ibB, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { @@ -993,40 +993,40 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueCopyImageToBuffer}. */ - public CLCommandQueue putCopyImageToBuffer(CLImage2d<?> srcImage, CLBuffer<?> dstBuffer) { + public CLCommandQueue putCopyImageToBuffer(final CLImage2d<?> srcImage, final CLBuffer<?> dstBuffer) { return putCopyImageToBuffer(srcImage, dstBuffer, null); } - + /** * Calls {@native clEnqueueCopyImageToBuffer}. */ - public CLCommandQueue putCopyImageToBuffer(CLImage2d<?> srcImage, CLBuffer<?> dstBuffer, CLEventList events) { + public CLCommandQueue putCopyImageToBuffer(final CLImage2d<?> srcImage, final CLBuffer<?> dstBuffer, final CLEventList events) { return putCopyImageToBuffer(srcImage, dstBuffer, 0, 0, srcImage.width, srcImage.height, 0, null, events); } /** * Calls {@native clEnqueueCopyImageToBuffer}. */ - public CLCommandQueue putCopyImageToBuffer(CLImage2d<?> srcImage, CLBuffer<?> dstBuffer, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyImageToBuffer(final CLImage2d<?> srcImage, final CLBuffer<?> dstBuffer, final CLEventList condition, final CLEventList events) { return putCopyImageToBuffer(srcImage, dstBuffer, 0, 0, srcImage.width, srcImage.height, 0, condition, events); } - + /** * Calls {@native clEnqueueCopyImageToBuffer}. */ - public CLCommandQueue putCopyImageToBuffer(CLImage2d<?> srcImage, CLBuffer<?> dstBuffer, - int srcOriginX, int srcOriginY, - int rangeX, int rangeY, long dstOffset) { - return putCopyImageToBuffer(srcImage, dstBuffer, + public CLCommandQueue putCopyImageToBuffer(final CLImage2d<?> srcImage, final CLBuffer<?> dstBuffer, + final int srcOriginX, final int srcOriginY, + final int rangeX, final int rangeY, final long dstOffset) { + return putCopyImageToBuffer(srcImage, dstBuffer, srcOriginX, srcOriginY, rangeX, rangeY, dstOffset, null, null); } - + /** * Calls {@native clEnqueueCopyImageToBuffer}. */ - public CLCommandQueue putCopyImageToBuffer(CLImage2d<?> srcImage, CLBuffer<?> dstBuffer, - int srcOriginX, int srcOriginY, - int rangeX, int rangeY, long dstOffset, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyImageToBuffer(final CLImage2d<?> srcImage, final CLBuffer<?> dstBuffer, + final int srcOriginX, final int srcOriginY, + final int rangeX, final int rangeY, final long dstOffset, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -1040,7 +1040,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibA, srcOriginX, srcOriginY, 0); copy2NIO(ibB, rangeX, rangeY, 1); - int ret = cl.clEnqueueCopyImageToBuffer(ID, srcImage.ID, dstBuffer.ID, + final int ret = cl.clEnqueueCopyImageToBuffer(ID, srcImage.ID, dstBuffer.ID, ibA, ibB, dstOffset, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { @@ -1054,47 +1054,47 @@ public class CLCommandQueue extends CLObjectResource { } return this; } - + //3D /** * Calls {@native clEnqueueCopyImageToBuffer}. */ - public CLCommandQueue putCopyImageToBuffer(CLImage3d<?> srcImage, CLBuffer<?> dstBuffer) { + public CLCommandQueue putCopyImageToBuffer(final CLImage3d<?> srcImage, final CLBuffer<?> dstBuffer) { return putCopyImageToBuffer(srcImage, dstBuffer, 0, 0, 0, srcImage.width, srcImage.height, srcImage.depth, 0, null, null); } - + /** * Calls {@native clEnqueueCopyImageToBuffer}. */ - public CLCommandQueue putCopyImageToBuffer(CLImage3d<?> srcImage, CLBuffer<?> dstBuffer, CLEventList events) { + public CLCommandQueue putCopyImageToBuffer(final CLImage3d<?> srcImage, final CLBuffer<?> dstBuffer, final CLEventList events) { return putCopyImageToBuffer(srcImage, dstBuffer, 0, 0, 0, srcImage.width, srcImage.height, srcImage.depth, 0, null, events); } /** * Calls {@native clEnqueueCopyImageToBuffer}. */ - public CLCommandQueue putCopyImageToBuffer(CLImage3d<?> srcImage, CLBuffer<?> dstBuffer, CLEventList condition, CLEventList events) { + public CLCommandQueue putCopyImageToBuffer(final CLImage3d<?> srcImage, final CLBuffer<?> dstBuffer, final CLEventList condition, final CLEventList events) { return putCopyImageToBuffer(srcImage, dstBuffer, 0, 0, 0, srcImage.width, srcImage.height, srcImage.depth, 0, condition, events); } - + /** * Calls {@native clEnqueueCopyImageToBuffer}. */ - public CLCommandQueue putCopyImageToBuffer(CLImage3d<?> srcImage, CLBuffer<?> dstBuffer, - int srcOriginX, int srcOriginY, int srcOriginZ, - int rangeX, int rangeY, int rangeZ, long dstOffset) { - return putCopyImageToBuffer(srcImage, dstBuffer, + public CLCommandQueue putCopyImageToBuffer(final CLImage3d<?> srcImage, final CLBuffer<?> dstBuffer, + final int srcOriginX, final int srcOriginY, final int srcOriginZ, + final int rangeX, final int rangeY, final int rangeZ, final long dstOffset) { + return putCopyImageToBuffer(srcImage, dstBuffer, srcOriginX, srcOriginY, srcOriginZ, rangeX, rangeY, rangeZ, dstOffset, null, null); - + } - + /** * Calls {@native clEnqueueCopyImageToBuffer}. */ - public CLCommandQueue putCopyImageToBuffer(CLImage3d<?> srcImage, CLBuffer<?> dstBuffer, - int srcOriginX, int srcOriginY, int srcOriginZ, - int rangeX, int rangeY, int rangeZ, long dstOffset, CLEventList condition, CLEventList events) { - + public CLCommandQueue putCopyImageToBuffer(final CLImage3d<?> srcImage, final CLBuffer<?> dstBuffer, + final int srcOriginX, final int srcOriginY, final int srcOriginZ, + final int rangeX, final int rangeY, final int rangeZ, final long dstOffset, final CLEventList condition, final CLEventList events) { + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { @@ -1105,7 +1105,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibA, srcOriginX, srcOriginY, srcOriginZ); copy2NIO(ibB, rangeX, rangeY, rangeZ); - int ret = cl.clEnqueueCopyImageToBuffer(ID, srcImage.ID, dstBuffer.ID, + final int ret = cl.clEnqueueCopyImageToBuffer(ID, srcImage.ID, dstBuffer.ID, ibA, ibB, dstOffset, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { @@ -1123,35 +1123,35 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueMapBuffer}. */ - public ByteBuffer putMapBuffer(CLBuffer<?> buffer, CLMemory.Map flag, boolean blockingMap) { + public ByteBuffer putMapBuffer(final CLBuffer<?> buffer, final CLMemory.Map flag, final boolean blockingMap) { return putMapBuffer(buffer, flag, blockingMap, null); } /** * Calls {@native clEnqueueMapBuffer}. */ - public ByteBuffer putMapBuffer(CLBuffer<?> buffer, CLMemory.Map flag, boolean blockingMap, CLEventList events) { + public ByteBuffer putMapBuffer(final CLBuffer<?> buffer, final CLMemory.Map flag, final boolean blockingMap, final CLEventList events) { return putMapBuffer(buffer, flag, 0, buffer.getCLSize(), blockingMap, null, events); } /** * Calls {@native clEnqueueMapBuffer}. */ - public ByteBuffer putMapBuffer(CLBuffer<?> buffer, CLMemory.Map flag, boolean blockingMap, CLEventList condition, CLEventList events) { + public ByteBuffer putMapBuffer(final CLBuffer<?> buffer, final CLMemory.Map flag, final boolean blockingMap, final CLEventList condition, final CLEventList events) { return putMapBuffer(buffer, flag, 0, buffer.getCLSize(), blockingMap, condition, events); } /** * Calls {@native clEnqueueMapBuffer}. */ - public ByteBuffer putMapBuffer(CLBuffer<?> buffer, CLMemory.Map flag, long offset, long length, boolean blockingMap) { + public ByteBuffer putMapBuffer(final CLBuffer<?> buffer, final CLMemory.Map flag, final long offset, final long length, final boolean blockingMap) { return putMapBuffer(buffer, flag, offset, length, blockingMap, null, null); } /** * Calls {@native clEnqueueMapBuffer}. */ - public ByteBuffer putMapBuffer(CLBuffer<?> buffer, CLMemory.Map flag, long offset, long length, boolean blockingMap, CLEventList condition, CLEventList events) { + public ByteBuffer putMapBuffer(final CLBuffer<?> buffer, final CLMemory.Map flag, final long offset, final long length, final boolean blockingMap, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -1160,8 +1160,8 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - IntBuffer error = pbA; - ByteBuffer mappedBuffer = cl.clEnqueueMapBuffer(ID, buffer.ID, clBoolean(blockingMap), + final IntBuffer error = pbA; + final ByteBuffer mappedBuffer = cl.clEnqueueMapBuffer(ID, buffer.ID, clBoolean(blockingMap), flag.FLAGS, offset, length, conditions, conditionIDs, events==null ? null : events.IDs, error); if(error.get(0) != CL_SUCCESS) { @@ -1180,48 +1180,48 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage2d<?> image, CLMemory.Map flag, boolean blockingMap) { + public ByteBuffer putMapImage(final CLImage2d<?> image, final CLMemory.Map flag, final boolean blockingMap) { return putMapImage(image, flag, blockingMap, null); } /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage2d<?> image, CLMemory.Map flag, boolean blockingMap, CLEventList events) { + public ByteBuffer putMapImage(final CLImage2d<?> image, final CLMemory.Map flag, final boolean blockingMap, final CLEventList events) { return putMapImage(image, flag, 0, 0, image.width, image.height, blockingMap, null, events); } /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage2d<?> image, CLMemory.Map flag, boolean blockingMap, CLEventList condition, CLEventList events) { + public ByteBuffer putMapImage(final CLImage2d<?> image, final CLMemory.Map flag, final boolean blockingMap, final CLEventList condition, final CLEventList events) { return putMapImage(image, flag, 0, 0, image.width, image.height, blockingMap, condition, events); } /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage2d<?> buffer, CLMemory.Map flag, int offsetX, int offsetY, - int rangeX, int rangeY, boolean blockingMap) { + public ByteBuffer putMapImage(final CLImage2d<?> buffer, final CLMemory.Map flag, final int offsetX, final int offsetY, + final int rangeX, final int rangeY, final boolean blockingMap) { return putMapImage(buffer, flag, offsetX, offsetY, rangeX, rangeY, blockingMap, null, null); } /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage2d<?> image, CLMemory.Map flag, - int offsetX, int offsetY, - int rangeX, int rangeY, boolean blockingMap, CLEventList condition, CLEventList events) { + public ByteBuffer putMapImage(final CLImage2d<?> image, final CLMemory.Map flag, + final int offsetX, final int offsetY, + final int rangeX, final int rangeY, final boolean blockingMap, final CLEventList condition, final CLEventList events) { return putMapImage(image, flag, offsetX, offsetY, rangeX, rangeY, blockingMap, condition, events, null, null); } - + /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage2d<?> image, CLMemory.Map flag, - int offsetX, int offsetY, - int rangeX, int rangeY, boolean blockingMap, CLEventList condition, CLEventList events, - long[] imageRowPitch, long[] imageSlicePitch ) { + public ByteBuffer putMapImage(final CLImage2d<?> image, final CLMemory.Map flag, + final int offsetX, final int offsetY, + final int rangeX, final int rangeY, final boolean blockingMap, final CLEventList condition, final CLEventList events, + final long[] imageRowPitch, final long[] imageSlicePitch ) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -1230,23 +1230,23 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - IntBuffer error = pbA; + final IntBuffer error = pbA; // spec: CL_INVALID_VALUE if image is a 2D image object and origin[2] is not equal to 0 or region[2] is not equal to 1 copy2NIO(ibB, offsetX, offsetY, 0); copy2NIO(ibC, rangeX, rangeY, 1); - + final PointerBuffer _imageRowPitch = PointerBuffer.allocateDirect(1); // size_t* final PointerBuffer _imageSlicePitch = PointerBuffer.allocateDirect(1); // size_t* - ByteBuffer mappedImage = cl.clEnqueueMapImage(ID, image.ID, clBoolean(blockingMap), + final ByteBuffer mappedImage = cl.clEnqueueMapImage(ID, image.ID, clBoolean(blockingMap), flag.FLAGS, ibB, ibC, _imageRowPitch, _imageSlicePitch, conditions, conditionIDs, events==null ? null : events.IDs, error); if(error.get(0) != CL_SUCCESS) { throw newException(error.get(0), "can not map " + image + " with: " + flag + " offset: " + toStr(offsetX, offsetY) + " range: " + toStr(rangeX, rangeY) + toStr(condition, events)); } - + if( null != imageRowPitch ) { imageRowPitch[0] = _imageRowPitch.get(0); } @@ -1265,39 +1265,39 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage3d<?> image, CLMemory.Map flag, boolean blockingMap) { + public ByteBuffer putMapImage(final CLImage3d<?> image, final CLMemory.Map flag, final boolean blockingMap) { return putMapImage(image, flag, blockingMap, null); } /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage3d<?> image, CLMemory.Map flag, boolean blockingMap, CLEventList events) { + public ByteBuffer putMapImage(final CLImage3d<?> image, final CLMemory.Map flag, final boolean blockingMap, final CLEventList events) { return putMapImage(image, flag, 0, 0, 0, image.width, image.height, image.depth, blockingMap, null, events); } /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage3d<?> image, CLMemory.Map flag, boolean blockingMap, CLEventList condition, CLEventList events) { + public ByteBuffer putMapImage(final CLImage3d<?> image, final CLMemory.Map flag, final boolean blockingMap, final CLEventList condition, final CLEventList events) { return putMapImage(image, flag, 0, 0, 0, image.width, image.height, image.depth, blockingMap, condition, events); } /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage3d<?> image, CLMemory.Map flag, - int offsetX, int offsetY, int offsetZ, - int rangeX, int rangeY, int rangeZ, boolean blockingMap) { + public ByteBuffer putMapImage(final CLImage3d<?> image, final CLMemory.Map flag, + final int offsetX, final int offsetY, final int offsetZ, + final int rangeX, final int rangeY, final int rangeZ, final boolean blockingMap) { return putMapImage(image, flag, offsetX, offsetY, offsetZ, rangeX, rangeY, rangeZ, blockingMap, null, null); } /** * Calls {@native clEnqueueMapImage}. */ - public ByteBuffer putMapImage(CLImage3d<?> image, CLMemory.Map flag, - int offsetX, int offsetY, int offsetZ, - int rangeX, int rangeY, int rangeZ, boolean blockingMap, CLEventList condition, CLEventList events) { + public ByteBuffer putMapImage(final CLImage3d<?> image, final CLMemory.Map flag, + final int offsetX, final int offsetY, final int offsetZ, + final int rangeX, final int rangeY, final int rangeZ, final boolean blockingMap, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -1306,10 +1306,10 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - IntBuffer error = pbA; + final IntBuffer error = pbA; copy2NIO(ibB, offsetX, offsetY, offsetZ); copy2NIO(ibC, rangeX, rangeY, rangeZ); - ByteBuffer mappedImage = cl.clEnqueueMapImage(ID, image.ID, clBoolean(blockingMap), + final ByteBuffer mappedImage = cl.clEnqueueMapImage(ID, image.ID, clBoolean(blockingMap), flag.FLAGS, ibB, ibC, null, null, conditions, conditionIDs, events==null ? null : events.IDs, error); if(error.get(0) != CL_SUCCESS) { @@ -1327,21 +1327,21 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueUnmapMemObject}. */ - public CLCommandQueue putUnmapMemory(CLMemory<?> memory, Buffer mapped) { + public CLCommandQueue putUnmapMemory(final CLMemory<?> memory, final Buffer mapped) { return putUnmapMemory(memory, mapped, null, null); } /** * Calls {@native clEnqueueUnmapMemObject}. */ - public CLCommandQueue putUnmapMemory(CLMemory<?> memory, Buffer mapped, CLEventList events) { + public CLCommandQueue putUnmapMemory(final CLMemory<?> memory, final Buffer mapped, final CLEventList events) { return putUnmapMemory(memory, mapped, null, events); } /** * Calls {@native clEnqueueUnmapMemObject}. */ - public CLCommandQueue putUnmapMemory(CLMemory<?> memory, Buffer mapped, CLEventList condition, CLEventList events) { + public CLCommandQueue putUnmapMemory(final CLMemory<?> memory, final Buffer mapped, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -1350,7 +1350,7 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - int ret = cl.clEnqueueUnmapMemObject(ID, memory.ID, mapped, + final int ret = cl.clEnqueueUnmapMemObject(ID, memory.ID, mapped, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { throw newException(ret, "can not unmap " + memory + toStr(condition, events)); @@ -1365,8 +1365,8 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueMarker}. */ - public CLCommandQueue putMarker(CLEventList events) { - int ret = cl.clEnqueueMarker(ID, events.IDs); + public CLCommandQueue putMarker(final CLEventList events) { + final int ret = cl.clEnqueueMarker(ID, events.IDs); if(ret != CL_SUCCESS) { throw newException(ret, "can not enqueue marker " + events); } @@ -1377,13 +1377,13 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clWaitForEvents} if blockingWait equals true otherwise {@native clEnqueueWaitForEvents}. */ - public CLCommandQueue putWaitForEvent(CLEventList list, int index, boolean blockingWait) { + public CLCommandQueue putWaitForEvent(final CLEventList list, final int index, final boolean blockingWait) { if(blockingWait) { list.waitForEvent(index); } else { - PointerBuffer ids = list.getEventBuffer(index); - int ret = cl.clEnqueueWaitForEvents(ID, 1, ids); + final PointerBuffer ids = list.getEventBuffer(index); + final int ret = cl.clEnqueueWaitForEvents(ID, 1, ids); if(ret != CL_SUCCESS) { throw newException(ret, "can not "+ (blockingWait?"blocking": "") +" wait for event #" + index+ " in "+list); } @@ -1395,11 +1395,11 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clWaitForEvents} if blockingWait equals true otherwise {@native clEnqueueWaitForEvents}. */ - public CLCommandQueue putWaitForEvents(CLEventList list, boolean blockingWait) { + public CLCommandQueue putWaitForEvents(final CLEventList list, final boolean blockingWait) { if(blockingWait) { list.waitForEvents(); }else{ - int ret = cl.clEnqueueWaitForEvents(ID, list.size, list.IDsView); + final int ret = cl.clEnqueueWaitForEvents(ID, list.size, list.IDsView); if(ret != CL_SUCCESS) { throw newException(ret, "can not "+ (blockingWait?"blocking": "") +" wait for events " + list); } @@ -1411,7 +1411,7 @@ public class CLCommandQueue extends CLObjectResource { * Calls {@native clEnqueueBarrier}. */ public CLCommandQueue putBarrier() { - int ret = cl.clEnqueueBarrier(ID); + final int ret = cl.clEnqueueBarrier(ID); checkForError(ret, "can not enqueue Barrier"); return this; } @@ -1422,7 +1422,7 @@ public class CLCommandQueue extends CLObjectResource { * with globalWorkOffset = null, globalWorkSize set to 1, and localWorkSize set to 1. * <p>Calls {@native clEnqueueTask}.</p> */ - public CLCommandQueue putTask(CLKernel kernel) { + public CLCommandQueue putTask(final CLKernel kernel) { putTask(kernel, null, null); return this; } @@ -1431,7 +1431,7 @@ public class CLCommandQueue extends CLObjectResource { * <p>Calls {@native clEnqueueTask}.</p> * @see #putTask(com.jogamp.opencl.CLKernel) */ - public CLCommandQueue putTask(CLKernel kernel, CLEventList events) { + public CLCommandQueue putTask(final CLKernel kernel, final CLEventList events) { putTask(kernel, null, events); return this; } @@ -1440,7 +1440,7 @@ public class CLCommandQueue extends CLObjectResource { * Calls {@native clEnqueueTask}. * @see #putTask(com.jogamp.opencl.CLKernel) */ - public CLCommandQueue putTask(CLKernel kernel, CLEventList condition, CLEventList events) { + public CLCommandQueue putTask(final CLKernel kernel, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -1449,7 +1449,7 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - int ret = cl.clEnqueueTask(ID, kernel.ID, conditions, conditionIDs, events==null ? null : events.IDs); + final int ret = cl.clEnqueueTask(ID, kernel.ID, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { checkForError(ret, "can not enqueue Task: " + kernel + toStr(condition, events)); } @@ -1462,7 +1462,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue put1DRangeKernel(CLKernel kernel, long globalWorkOffset, long globalWorkSize, long localWorkSize) { + public CLCommandQueue put1DRangeKernel(final CLKernel kernel, final long globalWorkOffset, final long globalWorkSize, final long localWorkSize) { this.put1DRangeKernel(kernel, globalWorkOffset, globalWorkSize, localWorkSize, null, null); return this; } @@ -1470,7 +1470,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue put1DRangeKernel(CLKernel kernel, long globalWorkOffset, long globalWorkSize, long localWorkSize, CLEventList events) { + public CLCommandQueue put1DRangeKernel(final CLKernel kernel, final long globalWorkOffset, final long globalWorkSize, final long localWorkSize, final CLEventList events) { this.put1DRangeKernel(kernel, globalWorkOffset, globalWorkSize, localWorkSize, null, events); return this; } @@ -1478,7 +1478,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue put1DRangeKernel(CLKernel kernel, long globalWorkOffset, long globalWorkSize, long localWorkSize, CLEventList condition, CLEventList events) { + public CLCommandQueue put1DRangeKernel(final CLKernel kernel, final long globalWorkOffset, final long globalWorkSize, final long localWorkSize, final CLEventList condition, final CLEventList events) { PointerBuffer globWO = null; PointerBuffer globWS = null; PointerBuffer locWS = null; @@ -1500,9 +1500,9 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue put2DRangeKernel(CLKernel kernel, long globalWorkOffsetX, long globalWorkOffsetY, - long globalWorkSizeX, long globalWorkSizeY, - long localWorkSizeX, long localWorkSizeY) { + public CLCommandQueue put2DRangeKernel(final CLKernel kernel, final long globalWorkOffsetX, final long globalWorkOffsetY, + final long globalWorkSizeX, final long globalWorkSizeY, + final long localWorkSizeX, final long localWorkSizeY) { this.put2DRangeKernel(kernel, globalWorkOffsetX, globalWorkOffsetY, globalWorkSizeX, globalWorkSizeY, @@ -1514,22 +1514,22 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue put2DRangeKernel(CLKernel kernel, long globalWorkOffsetX, long globalWorkOffsetY, - long globalWorkSizeX, long globalWorkSizeY, - long localWorkSizeX, long localWorkSizeY, CLEventList events) { + public CLCommandQueue put2DRangeKernel(final CLKernel kernel, final long globalWorkOffsetX, final long globalWorkOffsetY, + final long globalWorkSizeX, final long globalWorkSizeY, + final long localWorkSizeX, final long localWorkSizeY, final CLEventList events) { this.put2DRangeKernel(kernel, globalWorkOffsetX, globalWorkOffsetY, globalWorkSizeX, globalWorkSizeY, localWorkSizeX, localWorkSizeY, null, events); return this; } - + /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue put2DRangeKernel(CLKernel kernel, long globalWorkOffsetX, long globalWorkOffsetY, - long globalWorkSizeX, long globalWorkSizeY, - long localWorkSizeX, long localWorkSizeY, CLEventList condition, CLEventList events) { + public CLCommandQueue put2DRangeKernel(final CLKernel kernel, final long globalWorkOffsetX, final long globalWorkOffsetY, + final long globalWorkSizeX, final long globalWorkSizeY, + final long localWorkSizeX, final long localWorkSizeY, final CLEventList condition, final CLEventList events) { PointerBuffer globalWorkOffset = null; PointerBuffer globalWorkSize = null; PointerBuffer localWorkSize = null; @@ -1550,9 +1550,9 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue put3DRangeKernel(CLKernel kernel, long globalWorkOffsetX, long globalWorkOffsetY, long globalWorkOffsetZ, - long globalWorkSizeX, long globalWorkSizeY, long globalWorkSizeZ, - long localWorkSizeX, long localWorkSizeY, long localWorkSizeZ) { + public CLCommandQueue put3DRangeKernel(final CLKernel kernel, final long globalWorkOffsetX, final long globalWorkOffsetY, final long globalWorkOffsetZ, + final long globalWorkSizeX, final long globalWorkSizeY, final long globalWorkSizeZ, + final long localWorkSizeX, final long localWorkSizeY, final long localWorkSizeZ) { this.put3DRangeKernel(kernel, globalWorkOffsetX, globalWorkOffsetY, globalWorkOffsetZ, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, @@ -1564,9 +1564,9 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue put3DRangeKernel(CLKernel kernel, long globalWorkOffsetX, long globalWorkOffsetY, long globalWorkOffsetZ, - long globalWorkSizeX, long globalWorkSizeY, long globalWorkSizeZ, - long localWorkSizeX, long localWorkSizeY, long localWorkSizeZ, CLEventList events) { + public CLCommandQueue put3DRangeKernel(final CLKernel kernel, final long globalWorkOffsetX, final long globalWorkOffsetY, final long globalWorkOffsetZ, + final long globalWorkSizeX, final long globalWorkSizeY, final long globalWorkSizeZ, + final long localWorkSizeX, final long localWorkSizeY, final long localWorkSizeZ, final CLEventList events) { this.put3DRangeKernel(kernel, globalWorkOffsetX, globalWorkOffsetY, globalWorkOffsetZ, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, @@ -1577,9 +1577,9 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue put3DRangeKernel(CLKernel kernel, long globalWorkOffsetX, long globalWorkOffsetY, long globalWorkOffsetZ, - long globalWorkSizeX, long globalWorkSizeY, long globalWorkSizeZ, - long localWorkSizeX, long localWorkSizeY, long localWorkSizeZ, CLEventList condition, CLEventList events) { + public CLCommandQueue put3DRangeKernel(final CLKernel kernel, final long globalWorkOffsetX, final long globalWorkOffsetY, final long globalWorkOffsetZ, + final long globalWorkSizeX, final long globalWorkSizeY, final long globalWorkSizeZ, + final long localWorkSizeX, final long localWorkSizeY, final long localWorkSizeZ, final CLEventList condition, final CLEventList events) { PointerBuffer globalWorkOffset = null; PointerBuffer globalWorkSize = null; PointerBuffer localWorkSize = null; @@ -1600,7 +1600,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, PointerBuffer globalWorkOffset, PointerBuffer globalWorkSize, PointerBuffer localWorkSize) { + public CLCommandQueue putNDRangeKernel(final CLKernel kernel, final int workDimension, final PointerBuffer globalWorkOffset, final PointerBuffer globalWorkSize, final PointerBuffer localWorkSize) { this.putNDRangeKernel(kernel, workDimension, globalWorkOffset, globalWorkSize, localWorkSize, null, null); return this; } @@ -1608,7 +1608,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, PointerBuffer globalWorkOffset, PointerBuffer globalWorkSize, PointerBuffer localWorkSize, CLEventList events) { + public CLCommandQueue putNDRangeKernel(final CLKernel kernel, final int workDimension, final PointerBuffer globalWorkOffset, final PointerBuffer globalWorkSize, final PointerBuffer localWorkSize, final CLEventList events) { this.putNDRangeKernel(kernel, workDimension, globalWorkOffset, globalWorkSize, localWorkSize, null, events); return this; } @@ -1616,8 +1616,8 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, PointerBuffer globalWorkOffset, - PointerBuffer globalWorkSize, PointerBuffer localWorkSize, CLEventList condition, CLEventList events) { + public CLCommandQueue putNDRangeKernel(final CLKernel kernel, final int workDimension, final PointerBuffer globalWorkOffset, + final PointerBuffer globalWorkSize, final PointerBuffer localWorkSize, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -1626,11 +1626,11 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - int ret = cl.clEnqueueNDRangeKernel( + final int ret = cl.clEnqueueNDRangeKernel( ID, kernel.ID, workDimension, globalWorkOffset, - globalWorkSize, - localWorkSize, + globalWorkSize, + localWorkSize, conditions, conditionIDs, events==null ? null : events.IDs); @@ -1652,7 +1652,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueAcquireGLObjects}. */ - public CLCommandQueue putAcquireGLObject(CLGLObject glObject) { + public CLCommandQueue putAcquireGLObject(final CLGLObject glObject) { this.putAcquireGLObject(glObject, null, null); return this; } @@ -1660,7 +1660,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueAcquireGLObjects}. */ - public CLCommandQueue putAcquireGLObject(CLGLObject glObject, CLEventList events) { + public CLCommandQueue putAcquireGLObject(final CLGLObject glObject, final CLEventList events) { this.putAcquireGLObject(glObject, null, events); return this; } @@ -1668,7 +1668,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueAcquireGLObjects}. */ - public CLCommandQueue putAcquireGLObject(CLGLObject glObject, CLEventList condition, CLEventList events) { + public CLCommandQueue putAcquireGLObject(final CLGLObject glObject, final CLEventList condition, final CLEventList events) { this.putAcquireGLObjects(copy2NIO(ibA, glObject.getID()), condition, events); return this; } @@ -1676,7 +1676,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueAcquireGLObjects}. */ - public CLCommandQueue putAcquireGLObjects(CLGLObject glObject1, CLGLObject glObject2, CLEventList condition, CLEventList events) { + public CLCommandQueue putAcquireGLObjects(final CLGLObject glObject1, final CLGLObject glObject2, final CLEventList condition, final CLEventList events) { this.putAcquireGLObjects(copy2NIO(ibA, glObject1.getID(), glObject2.getID()), condition, events); return this; } @@ -1684,7 +1684,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueAcquireGLObjects}. */ - public CLCommandQueue putAcquireGLObjects(CLGLObject glObject1, CLGLObject glObject2, CLGLObject glObject3, CLEventList condition, CLEventList events) { + public CLCommandQueue putAcquireGLObjects(final CLGLObject glObject1, final CLGLObject glObject2, final CLGLObject glObject3, final CLEventList condition, final CLEventList events) { this.putAcquireGLObjects(copy2NIO(ibA, glObject1.getID(), glObject2.getID(), glObject3.getID()), condition, events); return this; } @@ -1692,7 +1692,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueAcquireGLObjects}. */ - public CLCommandQueue putAcquireGLObjects(PointerBuffer glObjectIDs, CLEventList condition, CLEventList events) { + public CLCommandQueue putAcquireGLObjects(final PointerBuffer glObjectIDs, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -1701,9 +1701,9 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - CLGL xl = (CLGL) cl; + final CLGL xl = (CLGL) cl; - int ret = xl.clEnqueueAcquireGLObjects(ID, glObjectIDs.remaining(), glObjectIDs, + final int ret = xl.clEnqueueAcquireGLObjects(ID, glObjectIDs.remaining(), glObjectIDs, conditions, conditionIDs, events==null ? null : events.IDs); @@ -1721,7 +1721,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReleaseGLObjects}. */ - public CLCommandQueue putReleaseGLObject(CLGLObject glObject) { + public CLCommandQueue putReleaseGLObject(final CLGLObject glObject) { this.putReleaseGLObject(glObject, null); return this; } @@ -1729,7 +1729,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReleaseGLObjects}. */ - public CLCommandQueue putReleaseGLObject(CLGLObject glObject, CLEventList events) { + public CLCommandQueue putReleaseGLObject(final CLGLObject glObject, final CLEventList events) { this.putReleaseGLObject(glObject, null, events); return this; } @@ -1737,7 +1737,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReleaseGLObjects}. */ - public CLCommandQueue putReleaseGLObject(CLGLObject glObject, CLEventList condition, CLEventList events) { + public CLCommandQueue putReleaseGLObject(final CLGLObject glObject, final CLEventList condition, final CLEventList events) { this.putReleaseGLObjects(copy2NIO(ibA, glObject.getID()), condition, events); return this; } @@ -1745,7 +1745,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueAcquireGLObjects}. */ - public CLCommandQueue putReleaseGLObjects(CLGLObject glObject1, CLGLObject glObject2, CLEventList condition, CLEventList events) { + public CLCommandQueue putReleaseGLObjects(final CLGLObject glObject1, final CLGLObject glObject2, final CLEventList condition, final CLEventList events) { this.putReleaseGLObjects(copy2NIO(ibA, glObject1.getID(), glObject2.getID()), condition, events); return this; } @@ -1753,7 +1753,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueAcquireGLObjects}. */ - public CLCommandQueue putReleaseGLObjects(CLGLObject glObject1, CLGLObject glObject2, CLGLObject glObject3, CLEventList condition, CLEventList events) { + public CLCommandQueue putReleaseGLObjects(final CLGLObject glObject1, final CLGLObject glObject2, final CLGLObject glObject3, final CLEventList condition, final CLEventList events) { this.putReleaseGLObjects(copy2NIO(ibA, glObject1.getID(), glObject2.getID(), glObject3.getID()), condition, events); return this; } @@ -1761,7 +1761,7 @@ public class CLCommandQueue extends CLObjectResource { /** * Calls {@native clEnqueueReleaseGLObjects}. */ - public CLCommandQueue putReleaseGLObjects(PointerBuffer glObjectIDs, CLEventList condition, CLEventList events) { + public CLCommandQueue putReleaseGLObjects(final PointerBuffer glObjectIDs, final CLEventList condition, final CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -1770,9 +1770,9 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - CLGL xl = (CLGL) cl; + final CLGL xl = (CLGL) cl; - int ret = xl.clEnqueueReleaseGLObjects(ID, glObjectIDs.remaining(), glObjectIDs, + final int ret = xl.clEnqueueReleaseGLObjects(ID, glObjectIDs.remaining(), glObjectIDs, conditions, conditionIDs, events==null ? null : events.IDs); @@ -1791,7 +1791,7 @@ public class CLCommandQueue extends CLObjectResource { * Calls {@native clFinish}. */ public CLCommandQueue finish() { - int ret = cl.clFinish(ID); + final int ret = cl.clFinish(ID); checkForError(ret, "can not finish command queue"); return this; } @@ -1800,7 +1800,7 @@ public class CLCommandQueue extends CLObjectResource { * Calls {@native clFlush}. */ public CLCommandQueue flush() { - int ret = cl.clFlush(ID); + final int ret = cl.clFlush(ID); checkForError(ret, "can not flush command queue"); return this; } @@ -1822,30 +1822,30 @@ public class CLCommandQueue extends CLObjectResource { @Override public void release() { super.release(); - int ret = cl.clReleaseCommandQueue(ID); + final int ret = cl.clReleaseCommandQueue(ID); context.onCommandQueueReleased(device, this); if(ret != CL_SUCCESS) { throw newException(ret, "can not release "+this); } } - private static PointerBuffer copy2NIO(PointerBuffer buffer, long a) { + private static PointerBuffer copy2NIO(final PointerBuffer buffer, final long a) { return buffer.put(2, a).position(2); } - private static PointerBuffer copy2NIO(PointerBuffer buffer, long a, long b) { + private static PointerBuffer copy2NIO(final PointerBuffer buffer, final long a, final long b) { return buffer.position(1).put(a).put(b).position(1); } - private static PointerBuffer copy2NIO(PointerBuffer buffer, long a, long b, long c) { + private static PointerBuffer copy2NIO(final PointerBuffer buffer, final long a, final long b, final long c) { return buffer.rewind().put(a).put(b).put(c).rewind(); } - private static String toStr(PointerBuffer buffer) { + private static String toStr(final PointerBuffer buffer) { if(buffer == null) { return null; } - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append('{'); for (int i = buffer.position(); i < buffer.capacity(); i++) { sb.append(buffer.get(i)); @@ -1856,18 +1856,18 @@ public class CLCommandQueue extends CLObjectResource { return sb.append('}').toString(); } - private static String toStr(CLEventList condition, CLEventList events) { + private static String toStr(final CLEventList condition, final CLEventList events) { return "\ncond.: " + condition +" events: "+events; } - private String toStr(Integer... values) { + private String toStr(final Integer... values) { return Arrays.asList(values).toString(); } - private String bufferRectToString(String action, CLBuffer<?> buffer, - long rowPitch, long slicePitch, long hostRowPitch, long hostSlicePitch, - int originX, int originY, int originZ, int hostX, int hostY, int hostZ, - int rangeX, int rangeY, int rangeZ, CLEventList condition, CLEventList events) { + private String bufferRectToString(final String action, final CLBuffer<?> buffer, + final long rowPitch, final long slicePitch, final long hostRowPitch, final long hostSlicePitch, + final int originX, final int originY, final int originZ, final int hostX, final int hostY, final int hostZ, + final int rangeX, final int rangeY, final int rangeZ, final CLEventList condition, final CLEventList events) { return "can not enqueue "+action+"-buffer-rect: " + buffer + "\n" + " with rowPitch: " + rowPitch + " slicePitch: " + slicePitch + " hostRowPitch: " + hostRowPitch + " hostSlicePitch: " + hostSlicePitch + "\n" @@ -1895,7 +1895,7 @@ public class CLCommandQueue extends CLObjectResource { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -1946,11 +1946,11 @@ public class CLCommandQueue extends CLObjectResource { */ public final int QUEUE_MODE; - private Mode(int value) { + private Mode(final int value) { this.QUEUE_MODE = value; } - public static Mode valueOf(int queueMode) { + public static Mode valueOf(final int queueMode) { switch(queueMode) { case(CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE): return OUT_OF_ORDER_MODE; @@ -1960,10 +1960,10 @@ public class CLCommandQueue extends CLObjectResource { return null; } - public static EnumSet<Mode> valuesOf(long bitfield) { - List<Mode> matching = new ArrayList<Mode>(); - Mode[] values = Mode.values(); - for (Mode value : values) { + public static EnumSet<Mode> valuesOf(final long bitfield) { + final List<Mode> matching = new ArrayList<Mode>(); + final Mode[] values = Mode.values(); + for (final Mode value : values) { if((value.QUEUE_MODE & bitfield) != 0) matching.add(value); } diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java index e801c686..dc921722 100644 --- a/src/com/jogamp/opencl/CLContext.java +++ b/src/com/jogamp/opencl/CLContext.java @@ -57,6 +57,7 @@ import com.jogamp.opencl.CLSampler.AddressingMode; import com.jogamp.opencl.CLSampler.FilteringMode; import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.llb.CLContextBinding; +import com.jogamp.opencl.llb.CLMemObjBinding; import com.jogamp.opencl.llb.impl.CLImageFormatImpl; /** @@ -91,7 +92,7 @@ public class CLContext extends CLObjectResource { private final ErrorDispatcher errorHandler; - protected CLContext(CLPlatform platform, long contextID, ErrorDispatcher dispatcher) { + protected CLContext(final CLPlatform platform, final long contextID, final ErrorDispatcher dispatcher) { super(contextID); this.platform = platform; @@ -113,17 +114,17 @@ public class CLContext extends CLObjectResource { } - private synchronized void initDevices(CLContextBinding cl) { + private synchronized void initDevices(final CLContextBinding cl) { if (devices == null) { final PointerBuffer deviceCount = PointerBuffer.allocateDirect(1); - int ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, 0, null, deviceCount); + int ret = cl.clGetContextInfo(ID, CLContextBinding.CL_CONTEXT_DEVICES, 0, null, deviceCount); CLException.checkForError(ret, "can not enumerate devices"); - ByteBuffer deviceIDs = Buffers.newDirectByteBuffer((int)deviceCount.get()); - ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null); + final ByteBuffer deviceIDs = Buffers.newDirectByteBuffer((int)deviceCount.get()); + ret = cl.clGetContextInfo(ID, CLContextBinding.CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null); CLException.checkForError(ret, "can not enumerate devices"); devices = new CLDevice[deviceIDs.capacity() / (Platform.is32Bit() ? 4 : 8)]; @@ -145,14 +146,14 @@ public class CLContext extends CLObjectResource { * Creates a context on the specified device types. * The platform to be used is implementation dependent. */ - public static CLContext create(Type... deviceTypes) { + public static CLContext create(final Type... deviceTypes) { return create(null, deviceTypes); } /** * Creates a context on the specified platform on all available devices (CL_DEVICE_TYPE_ALL). */ - public static CLContext create(CLPlatform platform) { + public static CLContext create(final CLPlatform platform) { return create(platform, Type.ALL); } @@ -160,23 +161,23 @@ public class CLContext extends CLObjectResource { * Creates a context on the specified platform and with the specified * device types. */ - public static CLContext create(CLPlatform platform, Type... deviceTypes) { + public static CLContext create(CLPlatform platform, final Type... deviceTypes) { if(platform == null) { platform = CLPlatform.getDefault(); } - long type = toDeviceBitmap(deviceTypes); + final long type = toDeviceBitmap(deviceTypes); - PointerBuffer properties = setupContextProperties(platform); - ErrorDispatcher dispatcher = new ErrorDispatcher(); + final PointerBuffer properties = setupContextProperties(platform); + final ErrorDispatcher dispatcher = new ErrorDispatcher(); return new CLContext(platform, createContextFromType(platform, dispatcher, properties, type), dispatcher); } /** * Creates a context on the specified devices. */ - public static CLContext create(CLDevice... devices) { + public static CLContext create(final CLDevice... devices) { if(devices == null) { throw new IllegalArgumentException("no devices specified"); @@ -184,11 +185,11 @@ public class CLContext extends CLObjectResource { throw new IllegalArgumentException("first device was null"); } - CLPlatform platform = devices[0].getPlatform(); + final CLPlatform platform = devices[0].getPlatform(); - PointerBuffer properties = setupContextProperties(platform); - ErrorDispatcher dispatcher = new ErrorDispatcher(); - CLContext context = new CLContext(platform, createContext(platform, dispatcher, properties, devices), dispatcher); + final PointerBuffer properties = setupContextProperties(platform); + final ErrorDispatcher dispatcher = new ErrorDispatcher(); + final CLContext context = new CLContext(platform, createContext(platform, dispatcher, properties, devices), dispatcher); if(devices != null) { for (int i = 0; i < devices.length; i++) { devices[i].setContext(context); @@ -197,43 +198,43 @@ public class CLContext extends CLObjectResource { return context; } - protected static long createContextFromType(CLPlatform platform, CLErrorHandler handler, PointerBuffer properties, long deviceType) { - IntBuffer status = Buffers.newDirectIntBuffer(1); - CLContextBinding cl = platform.getContextBinding(); - long context = cl.clCreateContextFromType(properties, deviceType, handler, status); + protected static long createContextFromType(final CLPlatform platform, final CLErrorHandler handler, final PointerBuffer properties, final long deviceType) { + final IntBuffer status = Buffers.newDirectIntBuffer(1); + final CLContextBinding cl = platform.getContextBinding(); + final long context = cl.clCreateContextFromType(properties, deviceType, handler, status); CLException.checkForError(status.get(), "can not create CL context"); return context; } - protected static long createContext(CLPlatform platform, CLErrorHandler handler, PointerBuffer properties, CLDevice... devices) { - IntBuffer status = Buffers.newDirectIntBuffer(1); + protected static long createContext(final CLPlatform platform, final CLErrorHandler handler, final PointerBuffer properties, final CLDevice... devices) { + final IntBuffer status = Buffers.newDirectIntBuffer(1); PointerBuffer pb = null; if(devices != null && devices.length != 0) { pb = PointerBuffer.allocateDirect(devices.length); for (int i = 0; i < devices.length; i++) { - CLDevice device = devices[i]; + final CLDevice device = devices[i]; if(device == null) { throw new IllegalArgumentException("device at index "+i+" was null."); } pb.put(i, device.ID); } } - CLContextBinding cl = platform.getContextBinding(); - long context = cl.clCreateContext(properties, pb, handler, status); + final CLContextBinding cl = platform.getContextBinding(); + final long context = cl.clCreateContext(properties, pb, handler, status); CLException.checkForError(status.get(), "can not create CL context"); return context; } - private static PointerBuffer setupContextProperties(CLPlatform platform) { + private static PointerBuffer setupContextProperties(final CLPlatform platform) { if(platform == null) { throw new RuntimeException("no OpenCL installation found"); } - return PointerBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM) + return PointerBuffer.allocateDirect(3).put(CLContextBinding.CL_CONTEXT_PLATFORM) .put(platform.ID).put(0) // 0 terminated array .rewind(); } @@ -241,8 +242,8 @@ public class CLContext extends CLObjectResource { /** * Creates a program from the given sources, the returned program is not build yet. */ - public CLProgram createProgram(String src) { - CLProgram program = CLProgram.create(this, src); + public CLProgram createProgram(final String src) { + final CLProgram program = CLProgram.create(this, src); programs.add(program); return program; } @@ -252,13 +253,13 @@ public class CLContext extends CLObjectResource { * The InputStream is automatically closed after the sources have been read. * @throws IOException when a IOException occurred while reading or closing the stream. */ - public CLProgram createProgram(InputStream source) throws IOException { + public CLProgram createProgram(final InputStream source) throws IOException { if(source == null) throw new IllegalArgumentException("input stream for program source must not be null"); - BufferedReader reader = new BufferedReader(new InputStreamReader(source)); - StringBuilder sb = new StringBuilder(2048); + final BufferedReader reader = new BufferedReader(new InputStreamReader(source)); + final StringBuilder sb = new StringBuilder(2048); String line; try { @@ -280,8 +281,8 @@ public class CLContext extends CLObjectResource { * <li>binaries are missing for one or more CLDevices</li> * </ul> */ - public CLProgram createProgram(Map<CLDevice, byte[]> binaries) { - CLProgram program = CLProgram.create(this, binaries); + public CLProgram createProgram(final Map<CLDevice, byte[]> binaries) { + final CLProgram program = CLProgram.create(this, binaries); program.setNoSource(); programs.add(program); return program; @@ -290,64 +291,64 @@ public class CLContext extends CLObjectResource { /** * Creates a CLBuffer with the specified flags and element count. No flags creates a MEM.READ_WRITE buffer. */ - public final CLBuffer<ShortBuffer> createShortBuffer(int size, Mem... flags) { + public final CLBuffer<ShortBuffer> createShortBuffer(final int size, final Mem... flags) { return createBuffer(Buffers.newDirectShortBuffer(size), flags); } /** * Creates a CLBuffer with the specified flags and element count. No flags creates a MEM.READ_WRITE buffer. */ - public final CLBuffer<IntBuffer> createIntBuffer(int size, Mem... flags) { + public final CLBuffer<IntBuffer> createIntBuffer(final int size, final Mem... flags) { return createBuffer(Buffers.newDirectIntBuffer(size), flags); } /** * Creates a CLBuffer with the specified flags and element count. No flags creates a MEM.READ_WRITE buffer. */ - public final CLBuffer<LongBuffer> createLongBuffer(int size, Mem... flags) { + public final CLBuffer<LongBuffer> createLongBuffer(final int size, final Mem... flags) { return createBuffer(Buffers.newDirectLongBuffer(size), flags); } /** * Creates a CLBuffer with the specified flags and element count. No flags creates a MEM.READ_WRITE buffer. */ - public final CLBuffer<FloatBuffer> createFloatBuffer(int size, Mem... flags) { + public final CLBuffer<FloatBuffer> createFloatBuffer(final int size, final Mem... flags) { return createBuffer(Buffers.newDirectFloatBuffer(size), flags); } /** * Creates a CLBuffer with the specified flags and element count. No flags creates a MEM.READ_WRITE buffer. */ - public final CLBuffer<DoubleBuffer> createDoubleBuffer(int size, Mem... flags) { + public final CLBuffer<DoubleBuffer> createDoubleBuffer(final int size, final Mem... flags) { return createBuffer(Buffers.newDirectDoubleBuffer(size), flags); } /** * Creates a CLBuffer with the specified flags and buffer size in bytes. No flags creates a MEM.READ_WRITE buffer. */ - public final CLBuffer<ByteBuffer> createByteBuffer(int size, Mem... flags) { + public final CLBuffer<ByteBuffer> createByteBuffer(final int size, final Mem... flags) { return createByteBuffer(size, Mem.flagsToInt(flags)); } /** * Creates a CLBuffer with the specified flags and buffer size in bytes. */ - public final CLBuffer<ByteBuffer> createByteBuffer(int size, int flags) { + public final CLBuffer<ByteBuffer> createByteBuffer(final int size, final int flags) { return createBuffer(Buffers.newDirectByteBuffer(size), flags); } /** * Creates a CLBuffer with the specified flags. No flags creates a MEM.READ_WRITE buffer. */ - public final CLBuffer<?> createBuffer(int size, Mem... flags) { + public final CLBuffer<?> createBuffer(final int size, final Mem... flags) { return createBuffer(size, Mem.flagsToInt(flags)); } /** * Creates a CLBuffer with the specified flags. */ - public final CLBuffer<?> createBuffer(int size, int flags) { - CLBuffer<?> buffer = CLBuffer.create(this, size, flags); + public final CLBuffer<?> createBuffer(final int size, final int flags) { + final CLBuffer<?> buffer = CLBuffer.create(this, size, flags); memoryObjects.add(buffer); return buffer; } @@ -355,15 +356,15 @@ public class CLContext extends CLObjectResource { /** * Creates a CLBuffer with the specified flags. No flags creates a MEM.READ_WRITE buffer. */ - public final <B extends Buffer> CLBuffer<B> createBuffer(B directBuffer, Mem... flags) { + public final <B extends Buffer> CLBuffer<B> createBuffer(final B directBuffer, final Mem... flags) { return createBuffer(directBuffer, Mem.flagsToInt(flags)); } /** * Creates a CLBuffer with the specified flags. */ - public final <B extends Buffer> CLBuffer<B> createBuffer(B directBuffer, int flags) { - CLBuffer<B> buffer = CLBuffer.create(this, directBuffer, flags); + public final <B extends Buffer> CLBuffer<B> createBuffer(final B directBuffer, final int flags) { + final CLBuffer<B> buffer = CLBuffer.create(this, directBuffer, flags); memoryObjects.add(buffer); return buffer; } @@ -371,29 +372,29 @@ public class CLContext extends CLObjectResource { /** * Creates a CLImage2d with the specified format, dimension and flags. */ - public final CLImage2d<?> createImage2d(int width, int height, CLImageFormat format, Mem... flags) { + public final CLImage2d<?> createImage2d(final int width, final int height, final CLImageFormat format, final Mem... flags) { return createImage2d(null, width, height, 0, format, flags); } /** * Creates a CLImage2d with the specified format, dimension and flags. */ - public final CLImage2d<?> createImage2d(int width, int height, int rowPitch, CLImageFormat format, Mem... flags) { + public final CLImage2d<?> createImage2d(final int width, final int height, final int rowPitch, final CLImageFormat format, final Mem... flags) { return createImage2d(null, width, height, rowPitch, format, flags); } /** * Creates a CLImage2d with the specified format, dimension and flags. */ - public final <B extends Buffer> CLImage2d<B> createImage2d(B directBuffer, int width, int height, CLImageFormat format, Mem... flags) { + public final <B extends Buffer> CLImage2d<B> createImage2d(final B directBuffer, final int width, final int height, final CLImageFormat format, final Mem... flags) { return createImage2d(directBuffer, width, height, 0, format, flags); } /** * Creates a CLImage2d with the specified format, dimension and flags. */ - public final <B extends Buffer> CLImage2d<B> createImage2d(B directBuffer, int width, int height, int rowPitch, CLImageFormat format, Mem... flags) { - CLImage2d<B> image = CLImage2d.createImage(this, directBuffer, width, height, rowPitch, format, Mem.flagsToInt(flags)); + public final <B extends Buffer> CLImage2d<B> createImage2d(final B directBuffer, final int width, final int height, final int rowPitch, final CLImageFormat format, final Mem... flags) { + final CLImage2d<B> image = CLImage2d.createImage(this, directBuffer, width, height, rowPitch, format, Mem.flagsToInt(flags)); memoryObjects.add(image); return image; } @@ -401,36 +402,36 @@ public class CLContext extends CLObjectResource { /** * Creates a CLImage3d with the specified format, dimension and flags. */ - public final CLImage3d<?> createImage3d(int width, int height, int depth, CLImageFormat format, Mem... flags) { + public final CLImage3d<?> createImage3d(final int width, final int height, final int depth, final CLImageFormat format, final Mem... flags) { return createImage3d(null, width, height, depth, format, flags); } /** * Creates a CLImage3d with the specified format, dimension and flags. */ - public final CLImage3d<?> createImage3d(int width, int height, int depth, int rowPitch, int slicePitch, CLImageFormat format, Mem... flags) { + public final CLImage3d<?> createImage3d(final int width, final int height, final int depth, final int rowPitch, final int slicePitch, final CLImageFormat format, final Mem... flags) { return createImage3d(null, width, height, depth, rowPitch, slicePitch, format, flags); } /** * Creates a CLImage3d with the specified format, dimension and flags. */ - public final <B extends Buffer> CLImage3d<B> createImage3d(B directBuffer, int width, int height, int depth, CLImageFormat format, Mem... flags) { + public final <B extends Buffer> CLImage3d<B> createImage3d(final B directBuffer, final int width, final int height, final int depth, final CLImageFormat format, final Mem... flags) { return createImage3d(directBuffer, width, height, depth, 0, 0, format, flags); } /** * Creates a CLImage3d with the specified format, dimension and flags. */ - public final <B extends Buffer> CLImage3d<B> createImage3d(B directBuffer, int width, int height, int depth, int rowPitch, int slicePitch, CLImageFormat format, Mem... flags) { - CLImage3d<B> image = CLImage3d.createImage(this, directBuffer, width, height, depth, rowPitch, slicePitch, format, Mem.flagsToInt(flags)); + public final <B extends Buffer> CLImage3d<B> createImage3d(final B directBuffer, final int width, final int height, final int depth, final int rowPitch, final int slicePitch, final CLImageFormat format, final Mem... flags) { + final CLImage3d<B> image = CLImage3d.createImage(this, directBuffer, width, height, depth, rowPitch, slicePitch, format, Mem.flagsToInt(flags)); memoryObjects.add(image); return image; } - CLCommandQueue createCommandQueue(CLDevice device, long properties) { + CLCommandQueue createCommandQueue(final CLDevice device, final long properties) { - CLCommandQueue queue = CLCommandQueue.create(this, device, properties); + final CLCommandQueue queue = CLCommandQueue.create(this, device, properties); synchronized(queuesMap) { List<CLCommandQueue> list = queuesMap.get(device); @@ -444,23 +445,23 @@ public class CLContext extends CLObjectResource { return queue; } - public CLSampler createSampler(AddressingMode addrMode, FilteringMode filtMode, boolean normalizedCoords) { - CLSampler sampler = CLSampler.create(this, addrMode, filtMode, normalizedCoords); + public CLSampler createSampler(final AddressingMode addrMode, final FilteringMode filtMode, final boolean normalizedCoords) { + final CLSampler sampler = CLSampler.create(this, addrMode, filtMode, normalizedCoords); samplers.add(sampler); return sampler; } - void onProgramReleased(CLProgram program) { + void onProgramReleased(final CLProgram program) { programs.remove(program); } - void onMemoryReleased(CLMemory<?> buffer) { + void onMemoryReleased(final CLMemory<?> buffer) { memoryObjects.remove(buffer); } - void onCommandQueueReleased(CLDevice device, CLCommandQueue queue) { + void onCommandQueueReleased(final CLDevice device, final CLCommandQueue queue) { synchronized(queuesMap) { - List<CLCommandQueue> list = queuesMap.get(device); + final List<CLCommandQueue> list = queuesMap.get(device); list.remove(queue); // remove empty lists from map if(list.isEmpty()) @@ -468,19 +469,19 @@ public class CLContext extends CLObjectResource { } } - void onSamplerReleased(CLSampler sampler) { + void onSamplerReleased(final CLSampler sampler) { samplers.remove(sampler); } - public void addCLErrorHandler(CLErrorHandler handler) { + public void addCLErrorHandler(final CLErrorHandler handler) { errorHandler.addHandler(handler); } - public void removeCLErrorHandler(CLErrorHandler handler) { + public void removeCLErrorHandler(final CLErrorHandler handler) { errorHandler.removeHandler(handler); } - private void release(Collection<? extends CLResource> resources) { + private void release(final Collection<? extends CLResource> resources) { // resources remove themselves when released, see above while(!resources.isEmpty()) { resources.iterator().next().release(); @@ -507,39 +508,39 @@ public class CLContext extends CLObjectResource { } } finally { - int ret = platform.getContextBinding().clReleaseContext(ID); + final int ret = platform.getContextBinding().clReleaseContext(ID); CLException.checkForError(ret, "error releasing context"); } } - protected void overrideContext(CLDevice device) { + protected void overrideContext(final CLDevice device) { device.setContext(this); } - private CLImageFormat[] getSupportedImageFormats(int flags, int type) { + private CLImageFormat[] getSupportedImageFormats(final int flags, final int type) { - CLContextBinding binding = platform.getContextBinding(); + final CLContextBinding binding = platform.getContextBinding(); - int[] entries = new int[1]; + final int[] entries = new int[1]; int ret = binding.clGetSupportedImageFormats(ID, flags, type, 0, null, entries, 0); if(ret != CL.CL_SUCCESS) { throw CLException.newException(ret, "error calling clGetSupportedImageFormats"); } - int count = entries[0]; + final int count = entries[0]; if(count == 0) { return new CLImageFormat[0]; } - CLImageFormat[] formats = new CLImageFormat[count]; - CLImageFormatImpl impl = CLImageFormatImpl.create(Buffers.newDirectByteBuffer(count * CLImageFormatImpl.size())); + final CLImageFormat[] formats = new CLImageFormat[count]; + final CLImageFormatImpl impl = CLImageFormatImpl.create(Buffers.newDirectByteBuffer(count * CLImageFormatImpl.size())); ret = binding.clGetSupportedImageFormats(ID, flags, type, count, impl, null); if(ret != CL.CL_SUCCESS) { throw CLException.newException(ret, "error calling clGetSupportedImageFormats"); } - ByteBuffer buffer = impl.getBuffer(); + final ByteBuffer buffer = impl.getBuffer(); for (int i = 0; i < formats.length; i++) { formats[i] = new CLImageFormat(CLImageFormatImpl.create(buffer.slice())); buffer.position(i*CLImageFormatImpl.size()); @@ -552,15 +553,15 @@ public class CLContext extends CLObjectResource { /** * Returns all supported 2d image formats with the (optional) memory allocation flags. */ - public CLImageFormat[] getSupportedImage2dFormats(Mem... flags) { - return getSupportedImageFormats(flags==null?0:Mem.flagsToInt(flags), CL.CL_MEM_OBJECT_IMAGE2D); + public CLImageFormat[] getSupportedImage2dFormats(final Mem... flags) { + return getSupportedImageFormats(flags==null?0:Mem.flagsToInt(flags), CLMemObjBinding.CL_MEM_OBJECT_IMAGE2D); } /** * Returns all supported 3d image formats with the (optional) memory allocation flags. */ - public CLImageFormat[] getSupportedImage3dFormats(Mem... flags) { - return getSupportedImageFormats(flags==null?0:Mem.flagsToInt(flags), CL.CL_MEM_OBJECT_IMAGE3D); + public CLImageFormat[] getSupportedImage3dFormats(final Mem... flags) { + return getSupportedImageFormats(flags==null?0:Mem.flagsToInt(flags), CLMemObjBinding.CL_MEM_OBJECT_IMAGE3D); } /** @@ -618,7 +619,7 @@ public class CLContext extends CLObjectResource { * The device speed is estimated by calculating the product of * MAX_COMPUTE_UNITS and MAX_CLOCK_FREQUENCY. */ - public CLDevice getMaxFlopsDevice(CLDevice.Type type) { + public CLDevice getMaxFlopsDevice(final CLDevice.Type type) { return CLPlatform.findMaxFlopsDevice(getDevices(), type); } @@ -627,7 +628,7 @@ public class CLContext extends CLObjectResource { */ public long getMaxMemBaseAddrAlign() { long maxAlignment = 0; - for (CLDevice device : getDevices()) { + for (final CLDevice device : getDevices()) { maxAlignment = Math.max(maxAlignment, device.getMemBaseAddrAlign()); } return maxAlignment; @@ -648,8 +649,8 @@ public class CLContext extends CLObjectResource { return getPlatform().getCLBinding(); } - CLDevice getDevice(long dID) { - CLDevice[] deviceArray = getDevices(); + CLDevice getDevice(final long dID) { + final CLDevice[] deviceArray = getDevices(); for (int i = 0; i < deviceArray.length; i++) { if(dID == deviceArray[i].ID) return deviceArray[i]; @@ -657,11 +658,11 @@ public class CLContext extends CLObjectResource { return null; } - protected static long toDeviceBitmap(Type[] deviceTypes) { + protected static long toDeviceBitmap(final Type[] deviceTypes) { long bitmap = 0; if (deviceTypes != null) { for (int i = 0; i < deviceTypes.length; i++) { - Type type = deviceTypes[i]; + final Type type = deviceTypes[i]; if(type == null) { throw new IllegalArgumentException("Device type at index "+i+" was null."); } @@ -681,7 +682,7 @@ public class CLContext extends CLObjectResource { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -711,26 +712,26 @@ public class CLContext extends CLObjectResource { private CLErrorHandler[] clientHandlers = new CLErrorHandler[0]; @Override - public synchronized void onError(String errinfo, ByteBuffer private_info, long cb) { - CLErrorHandler[] handlers = this.clientHandlers; + public synchronized void onError(final String errinfo, final ByteBuffer private_info, final long cb) { + final CLErrorHandler[] handlers = this.clientHandlers; for (int i = 0; i < handlers.length; i++) { handlers[i].onError(errinfo, private_info, cb); } } - private synchronized void addHandler(CLErrorHandler handler) { + private synchronized void addHandler(final CLErrorHandler handler) { if(handler == null) { throw new IllegalArgumentException("handler was null."); } - CLErrorHandler[] handlers = new CLErrorHandler[clientHandlers.length+1]; + final CLErrorHandler[] handlers = new CLErrorHandler[clientHandlers.length+1]; System.arraycopy(clientHandlers, 0, handlers, 0, clientHandlers.length); handlers[handlers.length-1] = handler; clientHandlers = handlers; } - private synchronized void removeHandler(CLErrorHandler handler) { + private synchronized void removeHandler(final CLErrorHandler handler) { if(handler == null) { throw new IllegalArgumentException("handler was null."); @@ -738,7 +739,7 @@ public class CLContext extends CLObjectResource { for (int i = 0; i < clientHandlers.length; i++) { if(handler.equals(clientHandlers[i])) { - CLErrorHandler[] handlers = new CLErrorHandler[clientHandlers.length-1]; + final CLErrorHandler[] handlers = new CLErrorHandler[clientHandlers.length-1]; System.arraycopy(clientHandlers, 0, handlers, 0, i); System.arraycopy(clientHandlers, i, handlers, 0, handlers.length-i); clientHandlers = handlers; diff --git a/src/com/jogamp/opencl/CLDevice.java b/src/com/jogamp/opencl/CLDevice.java index d8e90106..bac93cca 100644 --- a/src/com/jogamp/opencl/CLDevice.java +++ b/src/com/jogamp/opencl/CLDevice.java @@ -39,6 +39,7 @@ import java.util.Scanner; import java.util.Set; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLDeviceBinding; import com.jogamp.opencl.spi.CLInfoAccessor; import com.jogamp.opencl.util.CLUtil; @@ -57,13 +58,13 @@ public class CLDevice extends CLObject { private final CLInfoAccessor deviceInfo; private final CLPlatform platform; - protected CLDevice(CLPlatform platform, long id) { + protected CLDevice(final CLPlatform platform, final long id) { super(id); this.platform = platform; this.deviceInfo = platform.getAccessorFactory().createDeviceInfoAccessor(platform.getDeviceBinding(), id); } - protected CLDevice(CLContext context, long id) { + protected CLDevice(final CLContext context, final long id) { super(context, id); this.platform = context.getPlatform(); this.deviceInfo = platform.getAccessorFactory().createDeviceInfoAccessor(platform.getDeviceBinding(), id); @@ -73,11 +74,11 @@ public class CLDevice extends CLObject { return createCommandQueue(0); } - public CLCommandQueue createCommandQueue(CLCommandQueue.Mode property) { + public CLCommandQueue createCommandQueue(final CLCommandQueue.Mode property) { return createCommandQueue(property.QUEUE_MODE); } - public CLCommandQueue createCommandQueue(CLCommandQueue.Mode... properties) { + public CLCommandQueue createCommandQueue(final CLCommandQueue.Mode... properties) { int flags = 0; if(properties != null) { for (int i = 0; i < properties.length; i++) { @@ -87,14 +88,14 @@ public class CLDevice extends CLObject { return createCommandQueue(flags); } - public CLCommandQueue createCommandQueue(long properties) { + public CLCommandQueue createCommandQueue(final long properties) { if(context == null) throw new IllegalStateException("this device is not associated with a context"); return context.createCommandQueue(this, properties); } /*keep this package private*/ - void setContext(CLContext context) { + void setContext(final CLContext context) { this.context = context; } @@ -108,7 +109,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NAME") public String getName() { - return deviceInfo.getString(CL.CL_DEVICE_NAME); + return deviceInfo.getString(CLDeviceBinding.CL_DEVICE_NAME); } /** @@ -116,7 +117,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PROFILE") public String getProfile() { - return deviceInfo.getString(CL.CL_DEVICE_PROFILE); + return deviceInfo.getString(CLDeviceBinding.CL_DEVICE_PROFILE); } /** @@ -124,7 +125,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_VENDOR") public String getVendor() { - return deviceInfo.getString(CL.CL_DEVICE_VENDOR); + return deviceInfo.getString(CLDeviceBinding.CL_DEVICE_VENDOR); } /** @@ -132,7 +133,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_VENDOR_ID") public long getVendorID() { - return deviceInfo.getLong(CL.CL_DEVICE_VENDOR_ID); + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_VENDOR_ID); } /** @@ -140,7 +141,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_VERSION") public CLVersion getVersion() { - return new CLVersion(deviceInfo.getString(CL.CL_DEVICE_VERSION)); + return new CLVersion(deviceInfo.getString(CLDeviceBinding.CL_DEVICE_VERSION)); } /** @@ -148,7 +149,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_OPENCL_C_VERSION") public CLVersion getCVersion() { - return new CLVersion(deviceInfo.getString(CL.CL_DEVICE_OPENCL_C_VERSION)); + return new CLVersion(deviceInfo.getString(CLDeviceBinding.CL_DEVICE_OPENCL_C_VERSION)); } /** @@ -164,7 +165,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_TYPE") public Type getType() { - return Type.valueOf((int)deviceInfo.getLong(CL.CL_DEVICE_TYPE)); + return Type.valueOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_TYPE)); } /** @@ -173,7 +174,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_ADDRESS_BITS") public int getAddressBits() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_ADDRESS_BITS); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_ADDRESS_BITS); } /** @@ -182,7 +183,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT") public int getPreferredShortVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT); } /** @@ -191,7 +192,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR") public int getPreferredCharVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR); } /** @@ -200,7 +201,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT") public int getPreferredIntVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT); } /** @@ -209,7 +210,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG") public int getPreferredLongVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG); } /** @@ -218,7 +219,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT") public int getPreferredFloatVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT); } /** @@ -227,7 +228,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE") public int getPreferredDoubleVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE); } /** @@ -236,7 +237,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR") public int getNativeCharVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR); } /** @@ -245,7 +246,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT") public int getNativeShortVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT); } /** @@ -254,7 +255,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_INT") public int getNativeIntVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_INT); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_INT); } /** @@ -263,7 +264,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG") public int getNativeLongVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG); } /** @@ -272,7 +273,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF") public int getNativeHalfVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF); } /** @@ -281,7 +282,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT") public int getNativeFloatVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT); } /** @@ -290,7 +291,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE") public int getNativeDoubleVectorWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE); } /** @@ -299,7 +300,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_COMPUTE_UNITS") public int getMaxComputeUnits() { - return (int) deviceInfo.getLong(CL.CL_DEVICE_MAX_COMPUTE_UNITS); + return (int) deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_COMPUTE_UNITS); } /** @@ -309,7 +310,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_WORK_GROUP_SIZE") public int getMaxWorkGroupSize() { - return (int) deviceInfo.getLong(CL.CL_DEVICE_MAX_WORK_GROUP_SIZE); + return (int) deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_WORK_GROUP_SIZE); } /** @@ -317,7 +318,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_CLOCK_FREQUENCY") public int getMaxClockFrequency() { - return (int) (deviceInfo.getLong(CL.CL_DEVICE_MAX_CLOCK_FREQUENCY)); + return (int) (deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_CLOCK_FREQUENCY)); } /** @@ -327,7 +328,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS") public int getMaxWorkItemDimensions() { - return (int) deviceInfo.getLong(CL.CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS); + return (int) deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS); } /** @@ -337,8 +338,8 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_WORK_ITEM_SIZES") public int[] getMaxWorkItemSizes() { - int n = getMaxWorkItemDimensions(); - return deviceInfo.getInts(CL.CL_DEVICE_MAX_WORK_ITEM_SIZES, n); + final int n = getMaxWorkItemDimensions(); + return deviceInfo.getInts(CLDeviceBinding.CL_DEVICE_MAX_WORK_ITEM_SIZES, n); } /** @@ -348,7 +349,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_PARAMETER_SIZE") public long getMaxParameterSize() { - return deviceInfo.getLong(CL.CL_DEVICE_MAX_PARAMETER_SIZE); + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_PARAMETER_SIZE); } /** @@ -356,7 +357,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_MEM_ALLOC_SIZE") public long getMaxMemAllocSize() { - return deviceInfo.getLong(CL.CL_DEVICE_MAX_MEM_ALLOC_SIZE); + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_MEM_ALLOC_SIZE); } /** @@ -365,7 +366,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MEM_BASE_ADDR_ALIGN") public long getMemBaseAddrAlign() { - return deviceInfo.getUInt32Long(CL.CL_DEVICE_MEM_BASE_ADDR_ALIGN); + return deviceInfo.getUInt32Long(CLDeviceBinding.CL_DEVICE_MEM_BASE_ADDR_ALIGN); } /** @@ -373,7 +374,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_GLOBAL_MEM_SIZE") public long getGlobalMemSize() { - return deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_SIZE); + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_GLOBAL_MEM_SIZE); } /** @@ -383,7 +384,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_LOCAL_MEM_SIZE") public long getLocalMemSize() { - return deviceInfo.getLong(CL.CL_DEVICE_LOCAL_MEM_SIZE); + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_LOCAL_MEM_SIZE); } /** @@ -391,7 +392,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_HOST_UNIFIED_MEMORY") public boolean isMemoryUnified() { - return deviceInfo.getLong(CL.CL_DEVICE_HOST_UNIFIED_MEMORY) == CL.CL_TRUE; + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_HOST_UNIFIED_MEMORY) == CL.CL_TRUE; } /** @@ -400,7 +401,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE") public long getMaxConstantBufferSize() { - return deviceInfo.getLong(CL.CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE); + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE); } /** @@ -408,7 +409,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE") public long getGlobalMemCachelineSize() { - return deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE); + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE); } /** @@ -416,7 +417,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_GLOBAL_MEM_CACHE_SIZE") public long getGlobalMemCacheSize() { - return deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_CACHE_SIZE); + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_GLOBAL_MEM_CACHE_SIZE); } /** @@ -425,7 +426,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_CONSTANT_ARGS") public long getMaxConstantArgs() { - return deviceInfo.getLong(CL.CL_DEVICE_MAX_CONSTANT_ARGS); + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_CONSTANT_ARGS); } /** @@ -433,7 +434,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE_SUPPORT") public boolean isImageSupportAvailable() { - return deviceInfo.getLong(CL.CL_DEVICE_IMAGE_SUPPORT) == CL.CL_TRUE; + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE_SUPPORT) == CL.CL_TRUE; } /** @@ -442,7 +443,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_READ_IMAGE_ARGS") public int getMaxReadImageArgs() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_MAX_READ_IMAGE_ARGS); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_READ_IMAGE_ARGS); } /** @@ -451,7 +452,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_WRITE_IMAGE_ARGS") public int getMaxWriteImageArgs() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_MAX_WRITE_IMAGE_ARGS); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_WRITE_IMAGE_ARGS); } /** @@ -460,7 +461,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE2D_MAX_WIDTH") public int getMaxImage2dWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE2D_MAX_WIDTH); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE2D_MAX_WIDTH); } /** @@ -469,7 +470,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE2D_MAX_HEIGHT") public int getMaxImage2dHeight() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE2D_MAX_HEIGHT); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE2D_MAX_HEIGHT); } /** @@ -478,7 +479,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE3D_MAX_WIDTH") public int getMaxImage3dWidth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE3D_MAX_WIDTH); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE3D_MAX_WIDTH); } /** @@ -487,7 +488,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE3D_MAX_HEIGHT") public int getMaxImage3dHeight() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE3D_MAX_HEIGHT); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE3D_MAX_HEIGHT); } /** @@ -496,7 +497,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE3D_MAX_DEPTH") public int getMaxImage3dDepth() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE3D_MAX_DEPTH); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE3D_MAX_DEPTH); } /** @@ -505,7 +506,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_SAMPLERS") public int getMaxSamplers() { - return (int)deviceInfo.getLong(CL.CL_DEVICE_MAX_SAMPLERS); + return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_SAMPLERS); } /** @@ -513,7 +514,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PROFILING_TIMER_RESOLUTION") public long getProfilingTimerResolution() { - return deviceInfo.getLong(CL.CL_DEVICE_PROFILING_TIMER_RESOLUTION); + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PROFILING_TIMER_RESOLUTION); } /** @@ -521,7 +522,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_EXECUTION_CAPABILITIES") public EnumSet<Capabilities> getExecutionCapabilities() { - return Capabilities.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_EXECUTION_CAPABILITIES)); + return Capabilities.valuesOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_EXECUTION_CAPABILITIES)); } /** @@ -534,7 +535,7 @@ public class CLDevice extends CLObject { @CLProperty("CL_DEVICE_HALF_FP_CONFIG") public EnumSet<FPConfig> getHalfFPConfig() { if(isHalfFPAvailable()) - return FPConfig.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_HALF_FP_CONFIG)); + return FPConfig.valuesOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_HALF_FP_CONFIG)); else return EnumSet.noneOf(FPConfig.class); } @@ -547,7 +548,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_SINGLE_FP_CONFIG") public EnumSet<FPConfig> getSingleFPConfig() { - return FPConfig.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_SINGLE_FP_CONFIG)); + return FPConfig.valuesOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_SINGLE_FP_CONFIG)); } /** @@ -560,7 +561,7 @@ public class CLDevice extends CLObject { @CLProperty("CL_DEVICE_DOUBLE_FP_CONFIG") public EnumSet<FPConfig> getDoubleFPConfig() { if(isDoubleFPAvailable()) - return FPConfig.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_DOUBLE_FP_CONFIG)); + return FPConfig.valuesOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_DOUBLE_FP_CONFIG)); else return EnumSet.noneOf(FPConfig.class); } @@ -570,7 +571,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_LOCAL_MEM_TYPE") public LocalMemType getLocalMemType() { - return LocalMemType.valueOf((int)deviceInfo.getLong(CL.CL_DEVICE_LOCAL_MEM_TYPE)); + return LocalMemType.valueOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_LOCAL_MEM_TYPE)); } /** @@ -578,7 +579,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_GLOBAL_MEM_CACHE_TYPE") public GlobalMemCacheType getGlobalMemCacheType() { - return GlobalMemCacheType.valueOf((int)deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_CACHE_TYPE)); + return GlobalMemCacheType.valueOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_GLOBAL_MEM_CACHE_TYPE)); } @@ -587,7 +588,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_QUEUE_PROPERTIES") public EnumSet<CLCommandQueue.Mode> getQueueProperties() { - return CLCommandQueue.Mode.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_QUEUE_PROPERTIES)); + return CLCommandQueue.Mode.valuesOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_QUEUE_PROPERTIES)); } /** @@ -595,7 +596,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_AVAILABLE") public boolean isAvailable() { - return deviceInfo.getLong(CL.CL_DEVICE_AVAILABLE) == CL.CL_TRUE; + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_AVAILABLE) == CL.CL_TRUE; } /** @@ -605,7 +606,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_COMPILER_AVAILABLE") public boolean isCompilerAvailable() { - return deviceInfo.getLong(CL.CL_DEVICE_COMPILER_AVAILABLE) == CL.CL_TRUE; + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_COMPILER_AVAILABLE) == CL.CL_TRUE; } /** @@ -613,7 +614,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_ENDIAN_LITTLE") public boolean isLittleEndian() { - return deviceInfo.getLong(CL.CL_DEVICE_ENDIAN_LITTLE) == CL.CL_TRUE; + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_ENDIAN_LITTLE) == CL.CL_TRUE; } /** @@ -623,7 +624,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_ERROR_CORRECTION_SUPPORT") public boolean isErrorCorrectionSupported() { - return deviceInfo.getLong(CL.CL_DEVICE_ERROR_CORRECTION_SUPPORT) == CL.CL_TRUE; + return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_ERROR_CORRECTION_SUPPORT) == CL.CL_TRUE; } /** @@ -666,7 +667,7 @@ public class CLDevice extends CLObject { * Returns true if the extension is supported on this device. * @see #getExtensions() */ - public boolean isExtensionAvailable(String extension) { + public boolean isExtensionAvailable(final String extension) { return getExtensions().contains(extension); } @@ -689,8 +690,8 @@ public class CLDevice extends CLObject { if(extensions == null) { extensions = new HashSet<String>(); - String ext = deviceInfo.getString(CL.CL_DEVICE_EXTENSIONS); - Scanner scanner = new Scanner(ext); + final String ext = deviceInfo.getString(CLDeviceBinding.CL_DEVICE_EXTENSIONS); + final Scanner scanner = new Scanner(ext); while(scanner.hasNext()) extensions.add(scanner.next()); @@ -722,7 +723,7 @@ public class CLDevice extends CLObject { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -763,11 +764,11 @@ public class CLDevice extends CLObject { */ public final int CAPS; - private Capabilities(int type) { + private Capabilities(final int type) { this.CAPS = type; } - public static Capabilities valueOf(int caps) { + public static Capabilities valueOf(final int caps) { switch(caps) { case(CL.CL_EXEC_KERNEL): return EXEC_KERNEL; @@ -777,7 +778,7 @@ public class CLDevice extends CLObject { return null; } - public static EnumSet<Capabilities> valuesOf(int bitfield) { + public static EnumSet<Capabilities> valuesOf(final int bitfield) { if((EXEC_KERNEL.CAPS & bitfield) != 0) { if((EXEC_NATIVE_KERNEL.CAPS & bitfield) != 0) { return EnumSet.of(EXEC_KERNEL, EXEC_NATIVE_KERNEL); @@ -824,23 +825,23 @@ public class CLDevice extends CLObject { */ public final long TYPE; - private Type(long type) { + private Type(final long type) { this.TYPE = type; } - public static Type valueOf(long clDeviceType) { + public static Type valueOf(final long clDeviceType) { - if(clDeviceType == CL.CL_DEVICE_TYPE_ALL) + if(clDeviceType == CLDeviceBinding.CL_DEVICE_TYPE_ALL) return ALL; switch((int)clDeviceType) { - case(CL.CL_DEVICE_TYPE_DEFAULT): + case(CLDeviceBinding.CL_DEVICE_TYPE_DEFAULT): return DEFAULT; - case(CL.CL_DEVICE_TYPE_CPU): + case(CLDeviceBinding.CL_DEVICE_TYPE_CPU): return CPU; - case(CL.CL_DEVICE_TYPE_GPU): + case(CLDeviceBinding.CL_DEVICE_TYPE_GPU): return GPU; - case(CL.CL_DEVICE_TYPE_ACCELERATOR): + case(CLDeviceBinding.CL_DEVICE_TYPE_ACCELERATOR): return ACCELERATOR; } return null; @@ -889,17 +890,17 @@ public class CLDevice extends CLObject { */ public final int CONFIG; - private FPConfig(int config) { + private FPConfig(final int config) { this.CONFIG = config; } /** * Returns a EnumSet for the given bitfield. */ - public static EnumSet<FPConfig> valuesOf(int bitfield) { - List<FPConfig> matching = new ArrayList<FPConfig>(); - FPConfig[] values = FPConfig.values(); - for (FPConfig value : values) { + public static EnumSet<FPConfig> valuesOf(final int bitfield) { + final List<FPConfig> matching = new ArrayList<FPConfig>(); + final FPConfig[] values = FPConfig.values(); + for (final FPConfig value : values) { if((value.CONFIG & bitfield) != 0) matching.add(value); } @@ -937,16 +938,16 @@ public class CLDevice extends CLObject { */ public final int TYPE; - private GlobalMemCacheType(int type) { + private GlobalMemCacheType(final int type) { this.TYPE = type; } /** * Returns the matching GlobalMemCacheType for the given cl type. */ - public static GlobalMemCacheType valueOf(int bitfield) { - GlobalMemCacheType[] values = GlobalMemCacheType.values(); - for (GlobalMemCacheType value : values) { + public static GlobalMemCacheType valueOf(final int bitfield) { + final GlobalMemCacheType[] values = GlobalMemCacheType.values(); + for (final GlobalMemCacheType value : values) { if(value.TYPE == bitfield) return value; } @@ -974,17 +975,17 @@ public class CLDevice extends CLObject { */ public final int TYPE; - private LocalMemType(int type) { + private LocalMemType(final int type) { this.TYPE = type; } /** * Returns the matching LocalMemCacheType for the given cl type. */ - public static LocalMemType valueOf(int clLocalCacheType) { - if(clLocalCacheType == CL.CL_GLOBAL) + public static LocalMemType valueOf(final int clLocalCacheType) { + if(clLocalCacheType == CLDeviceBinding.CL_GLOBAL) return GLOBAL; - else if(clLocalCacheType == CL.CL_LOCAL) + else if(clLocalCacheType == CLDeviceBinding.CL_LOCAL) return LOCAL; return null; } diff --git a/src/com/jogamp/opencl/CLErrorHandler.java b/src/com/jogamp/opencl/CLErrorHandler.java index 2a8a1537..dcf2da55 100644 --- a/src/com/jogamp/opencl/CLErrorHandler.java +++ b/src/com/jogamp/opencl/CLErrorHandler.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. diff --git a/src/com/jogamp/opencl/CLEvent.java b/src/com/jogamp/opencl/CLEvent.java index 7537cfdb..2d0e5568 100644 --- a/src/com/jogamp/opencl/CLEvent.java +++ b/src/com/jogamp/opencl/CLEvent.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -51,7 +51,7 @@ public class CLEvent extends CLObjectResource { private final CLEventProfilingInfoAccessor eventProfilingInfo; private final CLEventBinding binding; - CLEvent(CLContext context, long id) { + CLEvent(final CLContext context, final long id) { super(context, id); binding = context.getPlatform().getEventBinding(); this.eventInfo = new CLEventInfoAccessor(); @@ -66,9 +66,9 @@ public class CLEvent extends CLObjectResource { } // apparently only ExecutionStatus.COMPLETE is allowed -> private - private void registerCallback(final CLEventListener callback, ExecutionStatus trigger) { + private void registerCallback(final CLEventListener callback, final ExecutionStatus trigger) { binding.clSetEventCallback(ID, trigger.STATUS, new CLEventCallback() { - @Override public void eventStateChanged(long event, int status) { + @Override public void eventStateChanged(final long event, final int status) { callback.eventStateChanged(CLEvent.this, status); } }); @@ -77,7 +77,7 @@ public class CLEvent extends CLObjectResource { @Override public void release() { super.release(); - int ret = binding.clReleaseEvent(ID); + final int ret = binding.clReleaseEvent(ID); checkForError(ret, "can not release event"); } @@ -94,17 +94,17 @@ public class CLEvent extends CLObjectResource { public boolean isComplete() { return ExecutionStatus.COMPLETE.equals(getStatus()); } - + public int getStatusCode() { return (int)eventInfo.getLong(CL_EVENT_COMMAND_EXECUTION_STATUS); } public CommandType getType() { - int status = (int)eventInfo.getLong(CL_EVENT_COMMAND_TYPE); + final int status = (int)eventInfo.getLong(CL_EVENT_COMMAND_TYPE); return CommandType.valueOf(status); } - public long getProfilingInfo(ProfilingCommand command) { + public long getProfilingInfo(final ProfilingCommand command) { return eventProfilingInfo.getLong(command.COMMAND); } @@ -117,7 +117,7 @@ public class CLEvent extends CLObjectResource { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -142,12 +142,12 @@ public class CLEvent extends CLObjectResource { return hash; } - + private class CLEventInfoAccessor extends CLTLInfoAccessor { @Override - protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { + protected int getInfo(final int name, final long valueSize, final Buffer value, final PointerBuffer valueSizeRet) { return binding.clGetEventInfo(ID, name, valueSize, value, valueSizeRet); } @@ -156,7 +156,7 @@ public class CLEvent extends CLObjectResource { private class CLEventProfilingInfoAccessor extends CLTLInfoAccessor { @Override - protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { + protected int getInfo(final int name, final long valueSize, final Buffer value, final PointerBuffer valueSizeRet) { return binding.clGetEventProfilingInfo(ID, name, valueSize, value, valueSizeRet); } @@ -196,11 +196,11 @@ public class CLEvent extends CLObjectResource { */ public final int COMMAND; - private ProfilingCommand(int command) { + private ProfilingCommand(final int command) { this.COMMAND = command; } - public static ProfilingCommand valueOf(int status) { + public static ProfilingCommand valueOf(final int status) { switch(status) { case(CL_PROFILING_COMMAND_QUEUED): return QUEUED; @@ -230,7 +230,7 @@ public class CLEvent extends CLObjectResource { * associated with the command-queue. */ SUBMITTED(CL_SUBMITTED), - + /** * Device is currently executing this command. */ @@ -252,11 +252,11 @@ public class CLEvent extends CLObjectResource { */ public final int STATUS; - private ExecutionStatus(int status) { + private ExecutionStatus(final int status) { this.STATUS = status; } - public static ExecutionStatus valueOf(int status) { + public static ExecutionStatus valueOf(final int status) { switch(status) { case(CL_QUEUED): return QUEUED; @@ -304,13 +304,13 @@ public class CLEvent extends CLObjectResource { */ public final int TYPE; - private CommandType(int type) { + private CommandType(final int type) { this.TYPE = type; } - public static CommandType valueOf(int commandType) { - CommandType[] values = CommandType.values(); - for (CommandType value : values) { + public static CommandType valueOf(final int commandType) { + final CommandType[] values = CommandType.values(); + for (final CommandType value : values) { if(value.TYPE == commandType) return value; } diff --git a/src/com/jogamp/opencl/CLEventList.java b/src/com/jogamp/opencl/CLEventList.java index cae3a03c..b415da09 100644 --- a/src/com/jogamp/opencl/CLEventList.java +++ b/src/com/jogamp/opencl/CLEventList.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -44,34 +44,34 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL * stores event ids for fast access. */ final PointerBuffer IDs; - + /** * Points always to the first element of the id buffer. */ final PointerBuffer IDsView; - + int size; - - public CLEventList(int capacity) { + + public CLEventList(final int capacity) { this(null, capacity); } - public CLEventList(CLEvent... events) { + public CLEventList(final CLEvent... events) { this(null, events); } - public CLEventList(CachedBufferFactory factory, int capacity) { + public CLEventList(final CachedBufferFactory factory, final int capacity) { this.events = new CLEvent[capacity]; this.IDs = initIDBuffer(factory, capacity); this.IDsView = IDs.duplicate(); } - public CLEventList(CachedBufferFactory factory, CLEvent... events) { + public CLEventList(final CachedBufferFactory factory, final CLEvent... events) { this.events = events; this.IDs = initIDBuffer(factory, events.length); this.IDsView = IDs.duplicate(); - - for (CLEvent event : events) { + + for (final CLEvent event : events) { if(event == null) { throw new IllegalArgumentException("event list containes null element."); } @@ -80,8 +80,8 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL IDs.rewind(); size = events.length; } - - private PointerBuffer initIDBuffer(CachedBufferFactory factory, int size) { + + private PointerBuffer initIDBuffer(final CachedBufferFactory factory, final int size) { if(factory == null) { return PointerBuffer.allocateDirect(size); }else{ @@ -89,7 +89,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL } } - void createEvent(CLContext context) { + void createEvent(final CLContext context) { if(events[size] != null) events[size].release(); @@ -97,8 +97,8 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL events[size] = new CLEvent(context, IDs.get()); size++; } - - PointerBuffer getEventBuffer(int index) { + + PointerBuffer getEventBuffer(final int index) { return IDs.duplicate().position(index); } @@ -116,7 +116,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL * Waits for all events of the specified region in this list to occur. * Will throw IndexOutOfBoundsException if indices are out of bounds. */ - public void waitForEvents(int start, int range) { + public void waitForEvents(final int start, final int range) { if(start+range < size || range <= 0) { throw new IndexOutOfBoundsException("args: [start: "+start+" range: "+range+"], eventcount: "+size); } @@ -128,7 +128,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL /** * Waits for the event with the given index in this list to occur. */ - public void waitForEvent(int index) { + public void waitForEvent(final int index) { final PointerBuffer view = getEventBuffer(index); getEvent(index).getPlatform().getEventBinding().clWaitForEvents(1, view); } @@ -154,8 +154,8 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL public final void close() { release(); } - - public CLEvent getEvent(int index) { + + public CLEvent getEvent(final int index) { if(index >= size) throw new IndexOutOfBoundsException("list contains "+size+" events, can not return event with index "+index); return events[index]; @@ -186,7 +186,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL @Override public String toString() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()).append('['); for (int i = 0; i < size; i++) { sb.append(events[i].toString()); @@ -203,7 +203,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL private final int size; private int index; - private EventIterator(CLEvent[] events, int size) { + private EventIterator(final CLEvent[] events, final int size) { this.events = events; this.size = size; } diff --git a/src/com/jogamp/opencl/CLEventListener.java b/src/com/jogamp/opencl/CLEventListener.java index b26dc852..204ea8a7 100644 --- a/src/com/jogamp/opencl/CLEventListener.java +++ b/src/com/jogamp/opencl/CLEventListener.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -34,7 +34,7 @@ package com.jogamp.opencl; /** * A callback for a specific command execution status. * @author Michael Bien - * @see CLEvent#registerCallback(com.jogamp.opencl.CLEventListener) + * @see CLEvent#registerCallback(com.jogamp.opencl.CLEventListener) */ public interface CLEventListener { diff --git a/src/com/jogamp/opencl/CLException.java b/src/com/jogamp/opencl/CLException.java index 84d3536c..c74b99bc 100644 --- a/src/com/jogamp/opencl/CLException.java +++ b/src/com/jogamp/opencl/CLException.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -30,6 +30,11 @@ package com.jogamp.opencl; import com.jogamp.opencl.llb.gl.CLGL; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLDeviceBinding; +import com.jogamp.opencl.llb.CLImageBinding; +import com.jogamp.opencl.llb.CLMemObjBinding; +import com.jogamp.opencl.llb.CLPlatformBinding; +import com.jogamp.opencl.llb.CLProgramBinding; /** * Main Exception type for runtime OpenCL errors and failed function calls (e.g. returning not CL_SUCCESS). @@ -47,13 +52,13 @@ public class CLException extends RuntimeException { // private final static String ERROR_CODE_DOC = // "http://www.khronos.org/opencl/sdk/1.1/docs/man/xhtml/errors.html"; - public CLException(String message) { + public CLException(final String message) { super(message); errorcode = 0; error = "none"; } - private CLException(int errorcode, String errorStr, String message) { + private CLException(final int errorcode, final String errorStr, final String message) { super(message + " [error: " + errorStr+"]"/* + " (man page: "+ERROR_CODE_DOC+")"*/); this.error = errorStr; this.errorcode = errorcode; @@ -62,9 +67,9 @@ public class CLException extends RuntimeException { /** * Throws a CLException when <code>status != CL_SUCCESS</code>. */ - public static void checkForError(int status, String message) { + public static void checkForError(final int status, final String message) { if(status != CL.CL_SUCCESS) { - CLException ex = newException(status, message); + final CLException ex = newException(status, message); ex.fillInStackTrace(); throw ex; } @@ -73,8 +78,8 @@ public class CLException extends RuntimeException { /** * Returns a CLException specific to the error code. */ - public static CLException newException(int status, String message) { - CLException specificEx = createSpecificException(status, message); + public static CLException newException(final int status, final String message) { + final CLException specificEx = createSpecificException(status, message); if(specificEx != null) { specificEx.fillInStackTrace(); return specificEx; @@ -95,20 +100,20 @@ public class CLException extends RuntimeException { /** * Returns a human readable String for the OpenCL error code or null if not known. */ - public static String resolveErrorCode(int error) { + public static String resolveErrorCode(final int error) { switch(error) { - case CL.CL_DEVICE_NOT_FOUND: return "CL_DEVICE_NOT_FOUND"; - case CL.CL_DEVICE_NOT_AVAILABLE: return "CL_DEVICE_NOT_AVAILABLE"; + case CLDeviceBinding.CL_DEVICE_NOT_FOUND: return "CL_DEVICE_NOT_FOUND"; + case CLDeviceBinding.CL_DEVICE_NOT_AVAILABLE: return "CL_DEVICE_NOT_AVAILABLE"; case CL.CL_COMPILER_NOT_AVAILABLE: return "CL_COMPILER_NOT_AVAILABLE"; - case CL.CL_MEM_OBJECT_ALLOCATION_FAILURE: return "CL_MEM_OBJECT_ALLOCATION_FAILURE"; + case CLMemObjBinding.CL_MEM_OBJECT_ALLOCATION_FAILURE: return "CL_MEM_OBJECT_ALLOCATION_FAILURE"; case CL.CL_OUT_OF_RESOURCES: return "CL_OUT_OF_RESOURCES"; case CL.CL_OUT_OF_HOST_MEMORY: return "CL_OUT_OF_HOST_MEMORY"; case CL.CL_PROFILING_INFO_NOT_AVAILABLE: return "CL_PROFILING_INFO_NOT_AVAILABLE"; - case CL.CL_MEM_COPY_OVERLAP: return "CL_MEM_COPY_OVERLAP"; - case CL.CL_IMAGE_FORMAT_MISMATCH: return "CL_IMAGE_FORMAT_MISMATCH"; - case CL.CL_IMAGE_FORMAT_NOT_SUPPORTED: return "CL_IMAGE_FORMAT_NOT_SUPPORTED"; - case CL.CL_BUILD_PROGRAM_FAILURE: return "CL_BUILD_PROGRAM_FAILURE"; - case CL.CL_MAP_FAILURE: return "CL_MAP_FAILURE"; + case CLMemObjBinding.CL_MEM_COPY_OVERLAP: return "CL_MEM_COPY_OVERLAP"; + case CLImageBinding.CL_IMAGE_FORMAT_MISMATCH: return "CL_IMAGE_FORMAT_MISMATCH"; + case CLImageBinding.CL_IMAGE_FORMAT_NOT_SUPPORTED: return "CL_IMAGE_FORMAT_NOT_SUPPORTED"; + case CLProgramBinding.CL_BUILD_PROGRAM_FAILURE: return "CL_BUILD_PROGRAM_FAILURE"; + case CLMemObjBinding.CL_MAP_FAILURE: return "CL_MAP_FAILURE"; case CL.CL_INVALID_VALUE: return "CL_INVALID_VALUE"; case CL.CL_INVALID_DEVICE_TYPE: return "CL_INVALID_DEVICE_TYPE"; case CL.CL_INVALID_PLATFORM: return "CL_INVALID_PLATFORM"; @@ -143,7 +148,7 @@ public class CLException extends RuntimeException { case CL.CL_INVALID_MIP_LEVEL: return "CL_INVALID_MIP_LEVEL"; case CL.CL_INVALID_GLOBAL_WORK_SIZE: return "CL_INVALID_GLOBAL_WORK_SIZE"; case CL.CL_INVALID_PROPERTY: return "CL_INVALID_PROPERTY"; - case CL.CL_PLATFORM_NOT_FOUND_KHR: return "CL_PLATFORM_NOT_FOUND_KHR"; + case CLPlatformBinding.CL_PLATFORM_NOT_FOUND_KHR: return "CL_PLATFORM_NOT_FOUND_KHR"; case CL.CL_MISALIGNED_SUB_BUFFER_OFFSET: return "CL_MISALIGNED_SUB_BUFFER_OFFSET"; case CL.CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST: return "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST"; case CLGL.CL_INVALID_GL_OBJECT: return "CL_INVALID_GL_OBJECT"; @@ -152,20 +157,20 @@ public class CLException extends RuntimeException { } } - private static CLException createSpecificException(int error, String message) { + private static CLException createSpecificException(final int error, final String message) { switch(error) { - case CL.CL_DEVICE_NOT_FOUND: return new CLDeviceNotFoundException(message); - case CL.CL_DEVICE_NOT_AVAILABLE: return new CLDeviceNotAvailableException(message); + case CLDeviceBinding.CL_DEVICE_NOT_FOUND: return new CLDeviceNotFoundException(message); + case CLDeviceBinding.CL_DEVICE_NOT_AVAILABLE: return new CLDeviceNotAvailableException(message); case CL.CL_COMPILER_NOT_AVAILABLE: return new CLCompilerNotAvailableException(message); - case CL.CL_MEM_OBJECT_ALLOCATION_FAILURE: return new CLMemObjectAllocationFailureException(message); + case CLMemObjBinding.CL_MEM_OBJECT_ALLOCATION_FAILURE: return new CLMemObjectAllocationFailureException(message); case CL.CL_OUT_OF_RESOURCES: return new CLOutOfResourcesException(message); case CL.CL_OUT_OF_HOST_MEMORY: return new CLOutOfHostMemoryException(message); case CL.CL_PROFILING_INFO_NOT_AVAILABLE: return new CLProfilingInfoNotAvailableException(message); - case CL.CL_MEM_COPY_OVERLAP: return new CLMemCopyOverlapException(message); - case CL.CL_IMAGE_FORMAT_MISMATCH: return new CLImageFormatMismatchException(message); - case CL.CL_IMAGE_FORMAT_NOT_SUPPORTED: return new CLImageFormatNotSupportedException(message); - case CL.CL_BUILD_PROGRAM_FAILURE: return new CLBuildProgramFailureException(message); - case CL.CL_MAP_FAILURE: return new CLMapFailureException(message); + case CLMemObjBinding.CL_MEM_COPY_OVERLAP: return new CLMemCopyOverlapException(message); + case CLImageBinding.CL_IMAGE_FORMAT_MISMATCH: return new CLImageFormatMismatchException(message); + case CLImageBinding.CL_IMAGE_FORMAT_NOT_SUPPORTED: return new CLImageFormatNotSupportedException(message); + case CLProgramBinding.CL_BUILD_PROGRAM_FAILURE: return new CLBuildProgramFailureException(message); + case CLMemObjBinding.CL_MAP_FAILURE: return new CLMapFailureException(message); case CL.CL_INVALID_VALUE: return new CLInvalidValueException(message); case CL.CL_INVALID_DEVICE_TYPE: return new CLInvalidDeviceTypeException(message); case CL.CL_INVALID_PLATFORM: return new CLInvalidPlatformException(message); @@ -200,7 +205,7 @@ public class CLException extends RuntimeException { case CL.CL_INVALID_MIP_LEVEL: return new CLInvalidMipLevelException(message); case CL.CL_INVALID_GLOBAL_WORK_SIZE: return new CLInvalidGlobalWorkSizeException(message); case CL.CL_INVALID_PROPERTY: return new CLInvalidPropertyException(message); - case CL.CL_PLATFORM_NOT_FOUND_KHR: return new CLPlatformNotFoundKhrException(message); + case CLPlatformBinding.CL_PLATFORM_NOT_FOUND_KHR: return new CLPlatformNotFoundKhrException(message); case CL.CL_MISALIGNED_SUB_BUFFER_OFFSET: return new CLMisalignedSubBufferOffsetException(message); case CL.CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST: return new CLExecStatusErrorForEventsInWaitListException(message); case CLGL.CL_INVALID_GL_OBJECT: return new CLInvalidGLObjectException(message); @@ -214,8 +219,8 @@ public class CLException extends RuntimeException { */ public final static class CLDeviceNotFoundException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_DEVICE_NOT_FOUND; - public CLDeviceNotFoundException(String message) { - super(CL.CL_DEVICE_NOT_FOUND, "CL_DEVICE_NOT_FOUND", message); + public CLDeviceNotFoundException(final String message) { + super(CLDeviceBinding.CL_DEVICE_NOT_FOUND, "CL_DEVICE_NOT_FOUND", message); } } @@ -224,8 +229,8 @@ public class CLException extends RuntimeException { */ public final static class CLDeviceNotAvailableException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_DEVICE_NOT_AVAILABLE; - public CLDeviceNotAvailableException(String message) { - super(CL.CL_DEVICE_NOT_AVAILABLE, "CL_DEVICE_NOT_AVAILABLE", message); + public CLDeviceNotAvailableException(final String message) { + super(CLDeviceBinding.CL_DEVICE_NOT_AVAILABLE, "CL_DEVICE_NOT_AVAILABLE", message); } } @@ -234,7 +239,7 @@ public class CLException extends RuntimeException { */ public final static class CLCompilerNotAvailableException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_COMPILER_NOT_AVAILABLE; - public CLCompilerNotAvailableException(String message) { + public CLCompilerNotAvailableException(final String message) { super(CL.CL_COMPILER_NOT_AVAILABLE, "CL_COMPILER_NOT_AVAILABLE", message); } } @@ -244,8 +249,8 @@ public class CLException extends RuntimeException { */ public final static class CLMemObjectAllocationFailureException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_MEM_OBJECT_ALLOCATION_FAILURE; - public CLMemObjectAllocationFailureException(String message) { - super(CL.CL_MEM_OBJECT_ALLOCATION_FAILURE, "CL_MEM_OBJECT_ALLOCATION_FAILURE", message); + public CLMemObjectAllocationFailureException(final String message) { + super(CLMemObjBinding.CL_MEM_OBJECT_ALLOCATION_FAILURE, "CL_MEM_OBJECT_ALLOCATION_FAILURE", message); } } @@ -254,7 +259,7 @@ public class CLException extends RuntimeException { */ public final static class CLOutOfResourcesException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_OUT_OF_RESOURCES; - public CLOutOfResourcesException(String message) { + public CLOutOfResourcesException(final String message) { super(CL.CL_OUT_OF_RESOURCES, "CL_OUT_OF_RESOURCES", message); } } @@ -264,7 +269,7 @@ public class CLException extends RuntimeException { */ public final static class CLOutOfHostMemoryException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_OUT_OF_HOST_MEMORY; - public CLOutOfHostMemoryException(String message) { + public CLOutOfHostMemoryException(final String message) { super(CL.CL_OUT_OF_HOST_MEMORY, "CL_OUT_OF_HOST_MEMORY", message); } } @@ -274,7 +279,7 @@ public class CLException extends RuntimeException { */ public final static class CLProfilingInfoNotAvailableException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_PROFILING_INFO_NOT_AVAILABLE; - public CLProfilingInfoNotAvailableException(String message) { + public CLProfilingInfoNotAvailableException(final String message) { super(CL.CL_PROFILING_INFO_NOT_AVAILABLE, "CL_PROFILING_INFO_NOT_AVAILABLE", message); } } @@ -284,8 +289,8 @@ public class CLException extends RuntimeException { */ public final static class CLMemCopyOverlapException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_MEM_COPY_OVERLAP; - public CLMemCopyOverlapException(String message) { - super(CL.CL_MEM_COPY_OVERLAP, "CL_MEM_COPY_OVERLAP", message); + public CLMemCopyOverlapException(final String message) { + super(CLMemObjBinding.CL_MEM_COPY_OVERLAP, "CL_MEM_COPY_OVERLAP", message); } } @@ -294,8 +299,8 @@ public class CLException extends RuntimeException { */ public final static class CLImageFormatMismatchException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_IMAGE_FORMAT_MISMATCH; - public CLImageFormatMismatchException(String message) { - super(CL.CL_IMAGE_FORMAT_MISMATCH, "CL_IMAGE_FORMAT_MISMATCH", message); + public CLImageFormatMismatchException(final String message) { + super(CLImageBinding.CL_IMAGE_FORMAT_MISMATCH, "CL_IMAGE_FORMAT_MISMATCH", message); } } @@ -304,8 +309,8 @@ public class CLException extends RuntimeException { */ public final static class CLImageFormatNotSupportedException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_IMAGE_FORMAT_NOT_SUPPORTED; - public CLImageFormatNotSupportedException(String message) { - super(CL.CL_IMAGE_FORMAT_NOT_SUPPORTED, "CL_IMAGE_FORMAT_NOT_SUPPORTED", message); + public CLImageFormatNotSupportedException(final String message) { + super(CLImageBinding.CL_IMAGE_FORMAT_NOT_SUPPORTED, "CL_IMAGE_FORMAT_NOT_SUPPORTED", message); } } @@ -314,8 +319,8 @@ public class CLException extends RuntimeException { */ public final static class CLBuildProgramFailureException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_BUILD_PROGRAM_FAILURE; - public CLBuildProgramFailureException(String message) { - super(CL.CL_BUILD_PROGRAM_FAILURE, "CL_BUILD_PROGRAM_FAILURE", message); + public CLBuildProgramFailureException(final String message) { + super(CLProgramBinding.CL_BUILD_PROGRAM_FAILURE, "CL_BUILD_PROGRAM_FAILURE", message); } } @@ -324,436 +329,436 @@ public class CLException extends RuntimeException { */ public final static class CLMapFailureException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_MAP_FAILURE; - public CLMapFailureException(String message) { - super(CL.CL_MAP_FAILURE, "CL_MAP_FAILURE", message); + public CLMapFailureException(final String message) { + super(CLMemObjBinding.CL_MAP_FAILURE, "CL_MAP_FAILURE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_VALUE errors. - * + * */ public final static class CLInvalidValueException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_VALUE; - public CLInvalidValueException(String message) { + public CLInvalidValueException(final String message) { super(CL.CL_INVALID_VALUE, "CL_INVALID_VALUE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_DEVICE_TYPE errors. - * + * */ public final static class CLInvalidDeviceTypeException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_DEVICE_TYPE; - public CLInvalidDeviceTypeException(String message) { + public CLInvalidDeviceTypeException(final String message) { super(CL.CL_INVALID_DEVICE_TYPE, "CL_INVALID_DEVICE_TYPE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_PLATFORM errors. - * + * */ public final static class CLInvalidPlatformException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_PLATFORM; - public CLInvalidPlatformException(String message) { + public CLInvalidPlatformException(final String message) { super(CL.CL_INVALID_PLATFORM, "CL_INVALID_PLATFORM", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_DEVICE errors. - * + * */ public final static class CLInvalidDeviceException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_DEVICE; - public CLInvalidDeviceException(String message) { + public CLInvalidDeviceException(final String message) { super(CL.CL_INVALID_DEVICE, "CL_INVALID_DEVICE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_CONTEXT errors. - * + * */ public final static class CLInvalidContextException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_CONTEXT; - public CLInvalidContextException(String message) { + public CLInvalidContextException(final String message) { super(CL.CL_INVALID_CONTEXT, "CL_INVALID_CONTEXT", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_QUEUE_PROPERTIES errors. - * + * */ public final static class CLInvalidQueuePropertiesException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_QUEUE_PROPERTIES; - public CLInvalidQueuePropertiesException(String message) { + public CLInvalidQueuePropertiesException(final String message) { super(CL.CL_INVALID_QUEUE_PROPERTIES, "CL_INVALID_QUEUE_PROPERTIES", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_COMMAND_QUEUE errors. - * + * */ public final static class CLInvalidCommandQueueException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_COMMAND_QUEUE; - public CLInvalidCommandQueueException(String message) { + public CLInvalidCommandQueueException(final String message) { super(CL.CL_INVALID_COMMAND_QUEUE, "CL_INVALID_COMMAND_QUEUE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_HOST_PTR errors. - * + * */ public final static class CLInvalidHostPtrException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_HOST_PTR; - public CLInvalidHostPtrException(String message) { + public CLInvalidHostPtrException(final String message) { super(CL.CL_INVALID_HOST_PTR, "CL_INVALID_HOST_PTR", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_MEM_OBJECT errors. - * + * */ public final static class CLInvalidMemObjectException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_MEM_OBJECT; - public CLInvalidMemObjectException(String message) { + public CLInvalidMemObjectException(final String message) { super(CL.CL_INVALID_MEM_OBJECT, "CL_INVALID_MEM_OBJECT", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_IMAGE_FORMAT_DESCRIPTOR errors. - * + * */ public final static class CLInvalidImageFormatDescriptorException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_IMAGE_FORMAT_DESCRIPTOR; - public CLInvalidImageFormatDescriptorException(String message) { + public CLInvalidImageFormatDescriptorException(final String message) { super(CL.CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_IMAGE_SIZE errors. - * + * */ public final static class CLInvalidImageSizeException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_IMAGE_SIZE; - public CLInvalidImageSizeException(String message) { + public CLInvalidImageSizeException(final String message) { super(CL.CL_INVALID_IMAGE_SIZE, "CL_INVALID_IMAGE_SIZE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_SAMPLER errors. - * + * */ public final static class CLInvalidSamplerException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_SAMPLER; - public CLInvalidSamplerException(String message) { + public CLInvalidSamplerException(final String message) { super(CL.CL_INVALID_SAMPLER, "CL_INVALID_SAMPLER", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_BINARY errors. - * + * */ public final static class CLInvalidBinaryException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_BINARY; - public CLInvalidBinaryException(String message) { + public CLInvalidBinaryException(final String message) { super(CL.CL_INVALID_BINARY, "CL_INVALID_BINARY", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_BUILD_OPTIONS errors. - * + * */ public final static class CLInvalidBuildOptionsException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_BUILD_OPTIONS; - public CLInvalidBuildOptionsException(String message) { + public CLInvalidBuildOptionsException(final String message) { super(CL.CL_INVALID_BUILD_OPTIONS, "CL_INVALID_BUILD_OPTIONS", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_PROGRAM errors. - * + * */ public final static class CLInvalidProgramException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_PROGRAM; - public CLInvalidProgramException(String message) { + public CLInvalidProgramException(final String message) { super(CL.CL_INVALID_PROGRAM, "CL_INVALID_PROGRAM", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_PROGRAM_EXECUTABLE errors. - * + * */ public final static class CLInvalidProgramExecutableException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_PROGRAM_EXECUTABLE; - public CLInvalidProgramExecutableException(String message) { + public CLInvalidProgramExecutableException(final String message) { super(CL.CL_INVALID_PROGRAM_EXECUTABLE, "CL_INVALID_PROGRAM_EXECUTABLE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_KERNEL_NAME errors. - * + * */ public final static class CLInvalidKernelNameException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_KERNEL_NAME; - public CLInvalidKernelNameException(String message) { + public CLInvalidKernelNameException(final String message) { super(CL.CL_INVALID_KERNEL_NAME, "CL_INVALID_KERNEL_NAME", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_KERNEL_DEFINITION errors. - * + * */ public final static class CLInvalidKernelDefinitionException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_KERNEL_DEFINITION; - public CLInvalidKernelDefinitionException(String message) { + public CLInvalidKernelDefinitionException(final String message) { super(CL.CL_INVALID_KERNEL_DEFINITION, "CL_INVALID_KERNEL_DEFINITION", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_KERNEL errors. - * + * */ public final static class CLInvalidKernelException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_KERNEL; - public CLInvalidKernelException(String message) { + public CLInvalidKernelException(final String message) { super(CL.CL_INVALID_KERNEL, "CL_INVALID_KERNEL", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_ARG_INDEX errors. - * + * */ public final static class CLInvalidArgIndexException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_ARG_INDEX; - public CLInvalidArgIndexException(String message) { + public CLInvalidArgIndexException(final String message) { super(CL.CL_INVALID_ARG_INDEX, "CL_INVALID_ARG_INDEX", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_ARG_VALUE errors. - * + * */ public final static class CLInvalidArgValueException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_ARG_VALUE; - public CLInvalidArgValueException(String message) { + public CLInvalidArgValueException(final String message) { super(CL.CL_INVALID_ARG_VALUE, "CL_INVALID_ARG_VALUE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_ARG_SIZE errors. - * + * */ public final static class CLInvalidArgSizeException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_ARG_SIZE; - public CLInvalidArgSizeException(String message) { + public CLInvalidArgSizeException(final String message) { super(CL.CL_INVALID_ARG_SIZE, "CL_INVALID_ARG_SIZE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_KERNEL_ARGS errors. - * + * */ public final static class CLInvalidKernelArgsException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_KERNEL_ARGS; - public CLInvalidKernelArgsException(String message) { + public CLInvalidKernelArgsException(final String message) { super(CL.CL_INVALID_KERNEL_ARGS, "CL_INVALID_KERNEL_ARGS", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_WORK_DIMENSION errors. - * + * */ public final static class CLInvalidWorkDimensionException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_WORK_DIMENSION; - public CLInvalidWorkDimensionException(String message) { + public CLInvalidWorkDimensionException(final String message) { super(CL.CL_INVALID_WORK_DIMENSION, "CL_INVALID_WORK_DIMENSION", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_WORK_GROUP_SIZE errors. - * + * */ public final static class CLInvalidWorkGroupSizeException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_WORK_GROUP_SIZE; - public CLInvalidWorkGroupSizeException(String message) { + public CLInvalidWorkGroupSizeException(final String message) { super(CL.CL_INVALID_WORK_GROUP_SIZE, "CL_INVALID_WORK_GROUP_SIZE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_WORK_ITEM_SIZE errors. - * + * */ public final static class CLInvalidWorkItemSizeException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_WORK_ITEM_SIZE; - public CLInvalidWorkItemSizeException(String message) { + public CLInvalidWorkItemSizeException(final String message) { super(CL.CL_INVALID_WORK_ITEM_SIZE, "CL_INVALID_WORK_ITEM_SIZE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_GLOBAL_OFFSET errors. - * + * */ public final static class CLInvalidGlobalOffsetException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_GLOBAL_OFFSET; - public CLInvalidGlobalOffsetException(String message) { + public CLInvalidGlobalOffsetException(final String message) { super(CL.CL_INVALID_GLOBAL_OFFSET, "CL_INVALID_GLOBAL_OFFSET", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_EVENT_WAIT_LIST errors. - * + * */ public final static class CLInvalidEventWaitListException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_EVENT_WAIT_LIST; - public CLInvalidEventWaitListException(String message) { + public CLInvalidEventWaitListException(final String message) { super(CL.CL_INVALID_EVENT_WAIT_LIST, "CL_INVALID_EVENT_WAIT_LIST", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_EVENT errors. - * + * */ public final static class CLInvalidEventException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_EVENT; - public CLInvalidEventException(String message) { + public CLInvalidEventException(final String message) { super(CL.CL_INVALID_EVENT, "CL_INVALID_EVENT", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_OPERATION errors. - * + * */ public final static class CLInvalidOperationException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_OPERATION; - public CLInvalidOperationException(String message) { + public CLInvalidOperationException(final String message) { super(CL.CL_INVALID_OPERATION, "CL_INVALID_OPERATION", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_GL_OBJECT errors. - * + * */ public final static class CLInvalidGLObjectException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CLGL.CL_INVALID_GL_OBJECT; - public CLInvalidGLObjectException(String message) { + public CLInvalidGLObjectException(final String message) { super(CLGL.CL_INVALID_GL_OBJECT, "CL_INVALID_GL_OBJECT", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_BUFFER_SIZE errors. - * + * */ public final static class CLInvalidBufferSizeException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_BUFFER_SIZE; - public CLInvalidBufferSizeException(String message) { + public CLInvalidBufferSizeException(final String message) { super(CL.CL_INVALID_BUFFER_SIZE, "CL_INVALID_BUFFER_SIZE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_MIP_LEVEL errors. - * + * */ public final static class CLInvalidMipLevelException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_MIP_LEVEL; - public CLInvalidMipLevelException(String message) { + public CLInvalidMipLevelException(final String message) { super(CL.CL_INVALID_MIP_LEVEL, "CL_INVALID_MIP_LEVEL", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_GLOBAL_WORK_SIZE errors. - * + * */ public final static class CLInvalidGlobalWorkSizeException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_GLOBAL_WORK_SIZE; - public CLInvalidGlobalWorkSizeException(String message) { + public CLInvalidGlobalWorkSizeException(final String message) { super(CL.CL_INVALID_GLOBAL_WORK_SIZE, "CL_INVALID_GLOBAL_WORK_SIZE", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_PROPERTY errors. - * + * */ public final static class CLInvalidPropertyException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_PROPERTY; - public CLInvalidPropertyException(String message) { + public CLInvalidPropertyException(final String message) { super(CL.CL_INVALID_PROPERTY, "CL_INVALID_PROPERTY", message); } } /** * {@link CLException} thrown on CL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR errors. - * + * */ public final static class CLInvalidGLSharegroupReferenceKhrException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CLGL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR; - public CLInvalidGLSharegroupReferenceKhrException(String message) { + public CLInvalidGLSharegroupReferenceKhrException(final String message) { super(CLGL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR, "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR", message); } } /** * {@link CLException} thrown on CL.CL_PLATFORM_NOT_FOUND_KHR errors. - * + * */ public final static class CLPlatformNotFoundKhrException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_PLATFORM_NOT_FOUND_KHR; - public CLPlatformNotFoundKhrException(String message) { - super(CL.CL_PLATFORM_NOT_FOUND_KHR, "CL_PLATFORM_NOT_FOUND_KHR", message); + public CLPlatformNotFoundKhrException(final String message) { + super(CLPlatformBinding.CL_PLATFORM_NOT_FOUND_KHR, "CL_PLATFORM_NOT_FOUND_KHR", message); } } /** * {@link CLException} thrown on CL.CL_MISALIGNED_SUB_BUFFER_OFFSET errors. - * + * */ public final static class CLMisalignedSubBufferOffsetException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_MISALIGNED_SUB_BUFFER_OFFSET; - public CLMisalignedSubBufferOffsetException(String message) { + public CLMisalignedSubBufferOffsetException(final String message) { super(CL.CL_MISALIGNED_SUB_BUFFER_OFFSET, "CL_MISALIGNED_SUB_BUFFER_OFFSET", message); } } /** * {@link CLException} thrown on CL.CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST errors. - * + * */ public final static class CLExecStatusErrorForEventsInWaitListException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST; - public CLExecStatusErrorForEventsInWaitListException(String message) { + public CLExecStatusErrorForEventsInWaitListException(final String message) { super(CL.CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST, "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST", message); } } diff --git a/src/com/jogamp/opencl/CLImage.java b/src/com/jogamp/opencl/CLImage.java index 32aa30df..497850fd 100644 --- a/src/com/jogamp/opencl/CLImage.java +++ b/src/com/jogamp/opencl/CLImage.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -48,11 +48,11 @@ public abstract class CLImage<B extends Buffer> extends CLMemory<B> { public final int width; public final int height; - protected CLImage(CLContext context, B directBuffer, CLImageFormat format, int width, int height, long id, int flags) { + protected CLImage(final CLContext context, final B directBuffer, final CLImageFormat format, final int width, final int height, final long id, final int flags) { this(context, directBuffer, format, createAccessor(context, id), width, height, id, flags); } - protected CLImage(CLContext context, B directBuffer, CLImageFormat format, CLImageInfoAccessor accessor, int width, int height, long id, int flags) { + protected CLImage(final CLContext context, final B directBuffer, final CLImageFormat format, final CLImageInfoAccessor accessor, final int width, final int height, final long id, final int flags) { super(context, directBuffer, getSizeImpl(context, id), id, flags); this.imageInfo = accessor; this.format = format; @@ -60,7 +60,7 @@ public abstract class CLImage<B extends Buffer> extends CLMemory<B> { this.height = height; } - private static CLImageInfoAccessor createAccessor(CLContext context, long id) { + private static CLImageInfoAccessor createAccessor(final CLContext context, final long id) { return new CLImageInfoAccessor(context.getPlatform().getImageBinding(), id); } @@ -111,12 +111,12 @@ public abstract class CLImage<B extends Buffer> extends CLMemory<B> { private final long id; private final CLImageBinding cl; - public CLImageInfoAccessor(CLImageBinding cl, long id) { + public CLImageInfoAccessor(final CLImageBinding cl, final long id) { this.cl = cl; this.id = id; } @Override - public int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { + public int getInfo(final int name, final long valueSize, final Buffer value, final PointerBuffer valueSizeRet) { return cl.clGetImageInfo(id, name, valueSize, value, valueSizeRet); } } diff --git a/src/com/jogamp/opencl/CLImage2d.java b/src/com/jogamp/opencl/CLImage2d.java index 05ac966a..f60bb23d 100644 --- a/src/com/jogamp/opencl/CLImage2d.java +++ b/src/com/jogamp/opencl/CLImage2d.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -41,31 +41,31 @@ import static com.jogamp.opencl.CLException.*; */ public class CLImage2d<B extends Buffer> extends CLImage<B> { - private CLImage2d(CLContext context, B directBuffer, CLImageFormat format, int width, int height, long id, int flags) { + private CLImage2d(final CLContext context, final B directBuffer, final CLImageFormat format, final int width, final int height, final long id, final int flags) { super(context, directBuffer, format, width, height, id, flags); } - - protected CLImage2d(CLContext context, B directBuffer, CLImageFormat format, CLImageInfoAccessor accessor, int width, int height, long id, int flags) { + + protected CLImage2d(final CLContext context, final B directBuffer, final CLImageFormat format, final CLImageInfoAccessor accessor, final int width, final int height, final long id, final int flags) { super(context, directBuffer, format, accessor, width, height, id, flags); } - static <B extends Buffer> CLImage2d<B> createImage(CLContext context, B directBuffer, - int width, int height, int rowPitch, CLImageFormat format, int flags) { + static <B extends Buffer> CLImage2d<B> createImage(final CLContext context, final B directBuffer, + final int width, final int height, final int rowPitch, final CLImageFormat format, final int flags) { - CLImageBinding cl = context.getPlatform().getImageBinding(); - IntBuffer err = Buffers.newDirectIntBuffer(1); + final CLImageBinding cl = context.getPlatform().getImageBinding(); + final IntBuffer err = Buffers.newDirectIntBuffer(1); B host_ptr = null; if(isHostPointerFlag(flags)) { host_ptr = directBuffer; } - long id = cl.clCreateImage2D(context.ID, flags, format.getFormatImpl(), width, height, rowPitch, host_ptr, err); + final long id = cl.clCreateImage2D(context.ID, flags, format.getFormatImpl(), width, height, rowPitch, host_ptr, err); checkForError(err.get(), "can not create 2d image"); return new CLImage2d<B>(context, directBuffer, format, width, height, id, flags); } @Override - public <T extends Buffer> CLImage2d<T> cloneWith(T directBuffer) { + public <T extends Buffer> CLImage2d<T> cloneWith(final T directBuffer) { return new CLImage2d<T>(context, directBuffer, format, width, height, ID, FLAGS); } diff --git a/src/com/jogamp/opencl/CLImage3d.java b/src/com/jogamp/opencl/CLImage3d.java index cdea61ad..9b1c7fcc 100644 --- a/src/com/jogamp/opencl/CLImage3d.java +++ b/src/com/jogamp/opencl/CLImage3d.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -44,34 +44,34 @@ public class CLImage3d<B extends Buffer> extends CLImage<B> { public final int depth; - private CLImage3d(CLContext context, B directBuffer, CLImageFormat format, int width, int height, int depth, long id, int flags) { + private CLImage3d(final CLContext context, final B directBuffer, final CLImageFormat format, final int width, final int height, final int depth, final long id, final int flags) { super(context, directBuffer, format, width, height, id, flags); this.depth = depth; } - protected CLImage3d(CLContext context, B directBuffer, CLImageFormat format, CLImageInfoAccessor accessor, int width, int height, int depth, long id, int flags) { + protected CLImage3d(final CLContext context, final B directBuffer, final CLImageFormat format, final CLImageInfoAccessor accessor, final int width, final int height, final int depth, final long id, final int flags) { super(context, directBuffer, format, accessor, width, height, id, flags); this.depth = depth; } - - static <B extends Buffer> CLImage3d<B> createImage(CLContext context, B directBuffer, - int width, int height, int depth, int rowPitch, int slicePitch, CLImageFormat format, int flags) { - CLImageBinding cl = context.getPlatform().getImageBinding(); - IntBuffer err = Buffers.newDirectIntBuffer(1); + static <B extends Buffer> CLImage3d<B> createImage(final CLContext context, final B directBuffer, + final int width, final int height, final int depth, final int rowPitch, final int slicePitch, final CLImageFormat format, final int flags) { + + final CLImageBinding cl = context.getPlatform().getImageBinding(); + final IntBuffer err = Buffers.newDirectIntBuffer(1); B host_ptr = null; if(isHostPointerFlag(flags)) { host_ptr = directBuffer; } - long id = cl.clCreateImage3D(context.ID, flags, format.getFormatImpl(), width, height, depth, rowPitch, slicePitch, host_ptr, err); + final long id = cl.clCreateImage3D(context.ID, flags, format.getFormatImpl(), width, height, depth, rowPitch, slicePitch, host_ptr, err); checkForError(err.get(), "can not create 2d image"); return new CLImage3d<B>(context, directBuffer, format, width, height, depth, id, flags); } @Override - public <T extends Buffer> CLImage3d<T> cloneWith(T directBuffer) { + public <T extends Buffer> CLImage3d<T> cloneWith(final T directBuffer) { return new CLImage3d<T>(context, directBuffer, format, width, height, depth, ID, FLAGS); } diff --git a/src/com/jogamp/opencl/CLImageFormat.java b/src/com/jogamp/opencl/CLImageFormat.java index 08fe7c7f..1d8af345 100644 --- a/src/com/jogamp/opencl/CLImageFormat.java +++ b/src/com/jogamp/opencl/CLImageFormat.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -46,22 +46,22 @@ public final class CLImageFormat { format = CLImageFormatImpl.create(); } - CLImageFormat(CLImageFormatImpl format) { + CLImageFormat(final CLImageFormatImpl format) { this.format = format; } - public CLImageFormat(ChannelOrder order, ChannelType type) { + public CLImageFormat(final ChannelOrder order, final ChannelType type) { format = CLImageFormatImpl.create(); setImageChannelOrder(order); setImageChannelDataType(type); } - public CLImageFormat setImageChannelOrder(ChannelOrder order) { + public CLImageFormat setImageChannelOrder(final ChannelOrder order) { format.setImageChannelOrder(order.ORDER); return this; } - public CLImageFormat setImageChannelDataType(ChannelType type) { + public CLImageFormat setImageChannelDataType(final ChannelType type) { format.setImageChannelDataType(type.TYPE); return this; } @@ -87,7 +87,7 @@ public final class CLImageFormat { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -117,7 +117,7 @@ public final class CLImageFormat { * layout in which channels are stored in the image. */ public enum ChannelOrder { - + /** * */ @@ -190,18 +190,18 @@ public final class CLImageFormat { * {@link ChannelType#SNORM_INT16}, {@link ChannelType#HALF_FLOAT}, or {@link ChannelType#FLOAT}. */ LUMINANCE(CL_LUMINANCE); - - + + /** * Value of wrapped OpenCL flag. */ public final int ORDER; - private ChannelOrder(int order) { + private ChannelOrder(final int order) { this.ORDER = order; } - public static ChannelOrder valueOf(int orderFlag) { + public static ChannelOrder valueOf(final int orderFlag) { switch (orderFlag) { case CL_R: return R; @@ -245,7 +245,7 @@ public final class CLImageFormat { * Each channel component is a normalized signed 8-bit integer value. */ SNORM_INT8(CL_SNORM_INT8), - + /** * Each channel component is a normalized signed 16-bit integer value. */ @@ -324,11 +324,11 @@ public final class CLImageFormat { */ public final int TYPE; - private ChannelType(int channel) { + private ChannelType(final int channel) { this.TYPE = channel; } - public static ChannelType valueOf(int channelFlag) { + public static ChannelType valueOf(final int channelFlag) { switch (channelFlag) { case CL_SNORM_INT8: return SNORM_INT8; diff --git a/src/com/jogamp/opencl/CLKernel.java b/src/com/jogamp/opencl/CLKernel.java index e54fb25a..26f7f1d3 100644 --- a/src/com/jogamp/opencl/CLKernel.java +++ b/src/com/jogamp/opencl/CLKernel.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -63,11 +63,11 @@ public class CLKernel extends CLObjectResource implements Cloneable { private int argIndex; private boolean force32BitArgs; - CLKernel(CLProgram program, long id) { + CLKernel(final CLProgram program, final long id) { this(program, null, id); } - CLKernel(CLProgram program, String name, long id) { + CLKernel(final CLProgram program, final String name, final long id) { super(program.getContext(), id); this.program = program; @@ -77,22 +77,22 @@ public class CLKernel extends CLObjectResource implements Cloneable { if(name == null) { // get function name - PointerBuffer size = PointerBuffer.wrap(buffer); + final PointerBuffer size = PointerBuffer.wrap(buffer); int ret = binding.clGetKernelInfo(ID, CL_KERNEL_FUNCTION_NAME, 0, null, size); checkForError(ret, "error while asking for kernel function name"); - ByteBuffer bb = Buffers.newDirectByteBuffer((int)size.get(0)); + final ByteBuffer bb = Buffers.newDirectByteBuffer((int)size.get(0)); ret = binding.clGetKernelInfo(ID, CL_KERNEL_FUNCTION_NAME, bb.capacity(), bb, null); checkForError(ret, "error while asking for kernel function name"); - + this.name = CLUtil.clString2JavaString(bb, bb.capacity()); }else{ this.name = name; } // get number of arguments - int ret = binding.clGetKernelInfo(ID, CL_KERNEL_NUM_ARGS, buffer.capacity(), buffer, null); + final int ret = binding.clGetKernelInfo(ID, CL_KERNEL_NUM_ARGS, buffer.capacity(), buffer, null); checkForError(ret, "error while asking for number of function arguments."); numArgs = buffer.getInt(0); @@ -103,50 +103,50 @@ public class CLKernel extends CLObjectResource implements Cloneable { // setArg(argIndex++, value); // return this; // } - - public CLKernel putArg(CLMemory<?> value) { + + public CLKernel putArg(final CLMemory<?> value) { setArg(argIndex, value); argIndex++; return this; } - public CLKernel putArg(short value) { + public CLKernel putArg(final short value) { setArg(argIndex, value); argIndex++; return this; } - public CLKernel putArg(int value) { + public CLKernel putArg(final int value) { setArg(argIndex, value); argIndex++; return this; } - public CLKernel putArg(long value) { + public CLKernel putArg(final long value) { setArg(argIndex, value); argIndex++; return this; } - public CLKernel putArg(float value) { + public CLKernel putArg(final float value) { setArg(argIndex, value); argIndex++; return this; } - public CLKernel putArg(double value) { + public CLKernel putArg(final double value) { setArg(argIndex, value); argIndex++; return this; } - public CLKernel putNullArg(int size) { + public CLKernel putNullArg(final int size) { setNullArg(argIndex, size); argIndex++; return this; } - public CLKernel putArgs(CLMemory<?>... values) { + public CLKernel putArgs(final CLMemory<?>... values) { setArgs(argIndex, values); argIndex += values.length; return this; @@ -172,22 +172,22 @@ public class CLKernel extends CLObjectResource implements Cloneable { // return this; // } - public CLKernel setArg(int argumentIndex, CLMemory<?> value) { + public CLKernel setArg(final int argumentIndex, final CLMemory<?> value) { setArgument(argumentIndex, is32Bit()?4:8, wrap(value.ID)); return this; } - public CLKernel setArg(int argumentIndex, short value) { + public CLKernel setArg(final int argumentIndex, final short value) { setArgument(argumentIndex, 2, wrap(value)); return this; } - public CLKernel setArg(int argumentIndex, int value) { + public CLKernel setArg(final int argumentIndex, final int value) { setArgument(argumentIndex, 4, wrap(value)); return this; } - public CLKernel setArg(int argumentIndex, long value) { + public CLKernel setArg(final int argumentIndex, final long value) { if(force32BitArgs) { setArgument(argumentIndex, 4, wrap((int)value)); }else{ @@ -196,12 +196,12 @@ public class CLKernel extends CLObjectResource implements Cloneable { return this; } - public CLKernel setArg(int argumentIndex, float value) { + public CLKernel setArg(final int argumentIndex, final float value) { setArgument(argumentIndex, 4, wrap(value)); return this; } - public CLKernel setArg(int argumentIndex, double value) { + public CLKernel setArg(final int argumentIndex, final double value) { if(force32BitArgs) { setArgument(argumentIndex, 4, wrap((float)value)); }else{ @@ -210,22 +210,22 @@ public class CLKernel extends CLObjectResource implements Cloneable { return this; } - public CLKernel setNullArg(int argumentIndex, int size) { + public CLKernel setNullArg(final int argumentIndex, final int size) { setArgument(argumentIndex, size, null); return this; } - public CLKernel setArgs(CLMemory<?>... values) { + public CLKernel setArgs(final CLMemory<?>... values) { setArgs(0, values); return this; } - public CLKernel setArgs(Object... values) { + public CLKernel setArgs(final Object... values) { if(values == null || values.length == 0) { throw new IllegalArgumentException("values array was empty or null."); } for (int i = 0; i < values.length; i++) { - Object value = values[i]; + final Object value = values[i]; if(value instanceof CLMemory<?>) { setArg(i, (CLMemory<?>)value); }else if(value instanceof Short) { @@ -245,13 +245,13 @@ public class CLKernel extends CLObjectResource implements Cloneable { return this; } - private void setArgs(int startIndex, CLMemory<?>... values) { + private void setArgs(final int startIndex, final CLMemory<?>... values) { for (int i = 0; i < values.length; i++) { setArg(i+startIndex, values[i]); } } - private void setArgument(int argumentIndex, int size, Buffer value) { + private void setArgument(final int argumentIndex, final int size, final Buffer value) { if(argumentIndex >= numArgs || argumentIndex < 0) { throw new IndexOutOfBoundsException("kernel "+ this +" has "+numArgs+ " arguments, can not set argument with index "+argumentIndex); @@ -261,7 +261,7 @@ public class CLKernel extends CLObjectResource implements Cloneable { " arguments for a not executable program. "+program); } - int ret = binding.clSetKernelArg(ID, argumentIndex, size, value); + final int ret = binding.clSetKernelArg(ID, argumentIndex, size, value); if(ret != CL_SUCCESS) { throw newException(ret, "error setting arg "+argumentIndex+" to value "+value+" of size "+size+" of "+this); } @@ -271,39 +271,39 @@ public class CLKernel extends CLObjectResource implements Cloneable { * Forces double and long arguments to be passed as float and int to the OpenCL kernel. * This can be used in applications which want to mix kernels with different floating point precision. */ - public CLKernel setForce32BitArgs(boolean force) { + public CLKernel setForce32BitArgs(final boolean force) { this.force32BitArgs = force; return this; } - + public CLProgram getProgram() { return program; } /** - * @see #setForce32BitArgs(boolean) + * @see #setForce32BitArgs(boolean) */ public boolean isForce32BitArgsEnabled() { return force32BitArgs; } - private Buffer wrap(float value) { + private Buffer wrap(final float value) { return buffer.putFloat(0, value); } - private Buffer wrap(double value) { + private Buffer wrap(final double value) { return buffer.putDouble(0, value); } - private Buffer wrap(short value) { + private Buffer wrap(final short value) { return buffer.putShort(0, value); } - private Buffer wrap(int value) { + private Buffer wrap(final int value) { return buffer.putInt(0, value); } - private Buffer wrap(long value) { + private Buffer wrap(final long value) { return buffer.putLong(0, value); } @@ -316,7 +316,7 @@ public class CLKernel extends CLObjectResource implements Cloneable { * If the local memory size, for any pointer argument to the kernel declared with * the <code>__local</code> address qualifier, is not specified, its size is assumed to be 0. */ - public long getLocalMemorySize(CLDevice device) { + public long getLocalMemorySize(final CLDevice device) { return getWorkGroupInfo(device, CL_KERNEL_LOCAL_MEM_SIZE); } @@ -325,9 +325,9 @@ public class CLKernel extends CLObjectResource implements Cloneable { * This provides a mechanism for the application to query the work-group size * that can be used to execute a kernel on a specific device given by device. * The OpenCL implementation uses the resource requirements of the kernel - * (register usage etc.) to determine what this work-group size should be. + * (register usage etc.) to determine what this work-group size should be. */ - public long getWorkGroupSize(CLDevice device) { + public long getWorkGroupSize(final CLDevice device) { return getWorkGroupInfo(device, CL_KERNEL_WORK_GROUP_SIZE); } @@ -336,8 +336,8 @@ public class CLKernel extends CLObjectResource implements Cloneable { * If the work-group size is not specified using the above attribute qualifier <code>new long[]{(0, 0, 0)}</code> is returned. * The returned array has always three elements. */ - public long[] getCompileWorkGroupSize(CLDevice device) { - int ret = binding.clGetKernelWorkGroupInfo(ID, device.ID, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, (is32Bit()?4:8)*3, buffer, null); + public long[] getCompileWorkGroupSize(final CLDevice device) { + final int ret = binding.clGetKernelWorkGroupInfo(ID, device.ID, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, (is32Bit()?4:8)*3, buffer, null); if(ret != CL_SUCCESS) { throw newException(ret, "error while asking for CL_KERNEL_COMPILE_WORK_GROUP_SIZE of "+this+" on "+device); } @@ -349,8 +349,8 @@ public class CLKernel extends CLObjectResource implements Cloneable { } } - private long getWorkGroupInfo(CLDevice device, int flag) { - int ret = binding.clGetKernelWorkGroupInfo(ID, device.ID, flag, 8, buffer, null); + private long getWorkGroupInfo(final CLDevice device, final int flag) { + final int ret = binding.clGetKernelWorkGroupInfo(ID, device.ID, flag, 8, buffer, null); if(ret != CL_SUCCESS) { throw newException(ret, "error while asking for clGetKernelWorkGroupInfo of "+this+" on "+device); } @@ -363,7 +363,7 @@ public class CLKernel extends CLObjectResource implements Cloneable { @Override public void release() { super.release(); - int ret = binding.clReleaseKernel(ID); + final int ret = binding.clReleaseKernel(ID); program.onKernelReleased(this); if(ret != CL_SUCCESS) { throw newException(ret, "can not release "+this); @@ -377,7 +377,7 @@ public class CLKernel extends CLObjectResource implements Cloneable { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } diff --git a/src/com/jogamp/opencl/CLMemObjectListener.java b/src/com/jogamp/opencl/CLMemObjectListener.java index 0e4ca097..9624160b 100644 --- a/src/com/jogamp/opencl/CLMemObjectListener.java +++ b/src/com/jogamp/opencl/CLMemObjectListener.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -40,7 +40,7 @@ package com.jogamp.opencl; public interface CLMemObjectListener { /** - * + * */ public void memoryDeallocated(CLMemory<?> mem); diff --git a/src/com/jogamp/opencl/CLMemory.java b/src/com/jogamp/opencl/CLMemory.java index c736abea..9fb81e7e 100644 --- a/src/com/jogamp/opencl/CLMemory.java +++ b/src/com/jogamp/opencl/CLMemory.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -48,22 +48,22 @@ import static com.jogamp.opencl.llb.gl.CLGL.*; * @author Michael Bien, et al. */ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { - + B buffer; protected final int FLAGS; protected long size; - + // depends on the nio buffer type protected int elementSize; protected int clCapacity; private final CLMemObjBinding binding; - - protected <Buffer> CLMemory(CLContext context, long size, long id, int flags) { + + protected <Buffer> CLMemory(final CLContext context, final long size, final long id, final int flags) { this(context, null, size, id, flags); } - - protected CLMemory(CLContext context, B directBuffer, long size, long id, int flags) { + + protected CLMemory(final CLContext context, final B directBuffer, final long size, final long id, final int flags) { super(context, id); this.buffer = directBuffer; this.FLAGS = flags; @@ -84,20 +84,20 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { /** * Returns true if a host pointer must be specified on mem object creation. */ - protected static boolean isHostPointerFlag(int flags) { + protected static boolean isHostPointerFlag(final int flags) { return (flags & CL_MEM_COPY_HOST_PTR) != 0 || (flags & CL_MEM_USE_HOST_PTR) != 0; } - protected static long getSizeImpl(CLContext context, long id) { - PointerBuffer pb = PointerBuffer.allocateDirect(1); - CLMemObjBinding binding = context.getPlatform().getMemObjectBinding(); // FIXME: CL separation makes this pretty complicated ! - int ret = binding.clGetMemObjectInfo(id, CL_MEM_SIZE, pb.elementSize(), pb.getBuffer(), null); + protected static long getSizeImpl(final CLContext context, final long id) { + final PointerBuffer pb = PointerBuffer.allocateDirect(1); + final CLMemObjBinding binding = context.getPlatform().getMemObjectBinding(); // FIXME: CL separation makes this pretty complicated ! + final int ret = binding.clGetMemObjectInfo(id, CL_MEM_SIZE, pb.elementSize(), pb.getBuffer(), null); checkForError(ret, "can not obtain buffer info"); return pb.get(); } - protected static CL getCL(CLContext context) { + protected static CL getCL(final CLContext context) { return context.getCL(); } @@ -108,7 +108,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { public void registerDestructorCallback(final CLMemObjectListener listener) { binding.clSetMemObjectDestructorCallback(ID, new CLMemObjectDestructorCallback() { @Override - public void memoryDeallocated(long memObjID) { + public void memoryDeallocated(final long memObjID) { listener.memoryDeallocated(CLMemory.this); } }); @@ -120,7 +120,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { public abstract <T extends Buffer> CLMemory<T> cloneWith(T directBuffer); - public CLMemory<B> use(B buffer) { + public CLMemory<B> use(final B buffer) { if(this.buffer != null && buffer != null && this.buffer.getClass() != buffer.getClass()) { throw new IllegalArgumentException( "expected a Buffer of class " + this.buffer.getClass() @@ -172,7 +172,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { public int getCLCapacity() { return clCapacity; } - + /** * Returns the size in bytes of a single buffer element. * This method returns 1 if no buffer is available indicating regular byte access. @@ -193,8 +193,8 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { * It is unsuitable for general use in applications. This feature is provided for debugging. */ public int getMapCount() { - IntBuffer value = Buffers.newDirectIntBuffer(1); - int ret = binding.clGetMemObjectInfo(ID, CL_MEM_MAP_COUNT, 4, value, null); + final IntBuffer value = Buffers.newDirectIntBuffer(1); + final int ret = binding.clGetMemObjectInfo(ID, CL_MEM_MAP_COUNT, 4, value, null); checkForError(ret, "can not obtain buffer map count."); return value.get(); } @@ -223,7 +223,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { @Override public void release() { super.release(); - int ret = binding.clReleaseMemObject(ID); + final int ret = binding.clReleaseMemObject(ID); context.onMemoryReleased(this); if(ret != CL_SUCCESS) { throw newException(ret, "can not release "+this); @@ -254,7 +254,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { // } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -345,11 +345,11 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { */ public final int CONFIG; - private Mem(int config) { + private Mem(final int config) { this.CONFIG = config; } - public static Mem valueOf(int bufferFlag) { + public static Mem valueOf(final int bufferFlag) { switch (bufferFlag) { case CL_MEM_READ_WRITE: return Mem.READ_WRITE; @@ -367,10 +367,10 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { return null; } - public static EnumSet<Mem> valuesOf(int bitfield) { - List<Mem> matching = new ArrayList<Mem>(); - Mem[] values = Mem.values(); - for (Mem value : values) { + public static EnumSet<Mem> valuesOf(final int bitfield) { + final List<Mem> matching = new ArrayList<Mem>(); + final Mem[] values = Mem.values(); + for (final Mem value : values) { if((value.CONFIG & bitfield) != 0) matching.add(value); } @@ -380,7 +380,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { return EnumSet.copyOf(matching); } - public static int flagsToInt(Mem[] flags) { + public static int flagsToInt(final Mem[] flags) { int clFlags = 0; if (flags != null) { for (int i = 0; i < flags.length; i++) { @@ -425,11 +425,11 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { */ public final int FLAGS; - private Map(int flags) { + private Map(final int flags) { this.FLAGS = flags; } - public Map valueOf(int flag) { + public Map valueOf(final int flag) { if(flag == WRITE.FLAGS) return WRITE; else if(flag == READ.FLAGS) @@ -450,11 +450,11 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { public final int TYPE; - private GLObjectType(int type) { + private GLObjectType(final int type) { this.TYPE = type; } - public static GLObjectType valueOf(int type) { + public static GLObjectType valueOf(final int type) { if(type == CL_GL_OBJECT_BUFFER) return GL_OBJECT_BUFFER; else if(type == CL_GL_OBJECT_TEXTURE2D) diff --git a/src/com/jogamp/opencl/CLObject.java b/src/com/jogamp/opencl/CLObject.java index 5a57dc3f..7cde6029 100644 --- a/src/com/jogamp/opencl/CLObject.java +++ b/src/com/jogamp/opencl/CLObject.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -39,15 +39,15 @@ public abstract class CLObject { * The OpenCL object handle. */ public final long ID; - + protected CLContext context; - CLObject(long ID) { + CLObject(final long ID) { this.context = null; this.ID = ID; } - CLObject(CLContext context, long ID) { + CLObject(final CLContext context, final long ID) { this.context = context; this.ID = ID; } diff --git a/src/com/jogamp/opencl/CLObjectResource.java b/src/com/jogamp/opencl/CLObjectResource.java index d4686fde..161263be 100644 --- a/src/com/jogamp/opencl/CLObjectResource.java +++ b/src/com/jogamp/opencl/CLObjectResource.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -39,11 +39,11 @@ abstract class CLObjectResource extends CLObject implements CLResource, AutoClos private boolean released; - public CLObjectResource(long ID) { + public CLObjectResource(final long ID) { super(ID); } - public CLObjectResource(CLContext context, long ID) { + public CLObjectResource(final CLContext context, final long ID) { super(context, ID); } @@ -72,6 +72,6 @@ abstract class CLObjectResource extends CLObject implements CLResource, AutoClos public boolean isReleased() { return released; } - + } diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java index 95e02333..8e31b74a 100644 --- a/src/com/jogamp/opencl/CLPlatform.java +++ b/src/com/jogamp/opencl/CLPlatform.java @@ -46,6 +46,7 @@ import com.jogamp.opencl.llb.CLEventBinding; import com.jogamp.opencl.llb.CLMemObjBinding; import com.jogamp.opencl.spi.CLPlatformInfoAccessor; import com.jogamp.opencl.util.CLUtil; +import com.jogamp.opencl.llb.impl.CLAbstractImpl; import com.jogamp.opencl.llb.impl.CLImpl; import com.jogamp.opencl.spi.CLAccessorFactory; import com.jogamp.opencl.util.Filter; @@ -117,11 +118,11 @@ public class CLPlatform { protected final CLPlatformInfoAccessor info; - private CLPlatform(long id) { + private CLPlatform(final long id) { this(id, null); } - protected CLPlatform(long id, CLAccessorFactory factory) { + protected CLPlatform(final long id, final CLAccessorFactory factory) { initialize(); this.ID = id; if(factory == null) { @@ -147,7 +148,7 @@ public class CLPlatform { * @param factory CLAccessorFactory used for creating the bindings. * @throws JogampRuntimeException if something went wrong in the initialization (e.g. OpenCL lib not found). */ - synchronized static void initialize(CLAccessorFactory factory) throws JogampRuntimeException { + synchronized static void initialize(final CLAccessorFactory factory) throws JogampRuntimeException { if(cl != null) { return; @@ -162,14 +163,14 @@ public class CLPlatform { } try { - if( null == CLImpl.getCLProcAddressTable() ) { + if( null == CLAbstractImpl.getCLProcAddressTable() ) { throw new JogampRuntimeException("JOCL ProcAddressTable is NULL"); } cl = new CLImpl(); - }catch(UnsatisfiedLinkError ex) { + }catch(final UnsatisfiedLinkError ex) { System.err.println(JoclVersion.getInstance().getAllVersions(null).toString()); throw ex; - }catch(Exception ex) { + }catch(final Exception ex) { System.err.println(JoclVersion.getInstance().getAllVersions(null).toString()); throw new JogampRuntimeException("JOCL initialization error.", ex); } @@ -188,8 +189,8 @@ public class CLPlatform { * Returns the default OpenCL platform or null when no platform found. */ @SuppressWarnings("unchecked") - public static CLPlatform getDefault(Filter<CLPlatform>... filter) { - CLPlatform[] platforms = listCLPlatforms(filter); + public static CLPlatform getDefault(final Filter<CLPlatform>... filter) { + final CLPlatform[] platforms = listCLPlatforms(filter); if(platforms.length > 0) { return latest(platforms); }else{ @@ -197,9 +198,9 @@ public class CLPlatform { } } - private static CLPlatform latest(CLPlatform[] platforms) { + private static CLPlatform latest(final CLPlatform[] platforms) { CLPlatform best = platforms[0]; - for (CLPlatform platform : platforms) { + for (final CLPlatform platform : platforms) { if (platform.version.compareTo(best.version) > 0) { best = platform; } @@ -221,23 +222,23 @@ public class CLPlatform { * @throws CLException if something went wrong initializing OpenCL */ @SuppressWarnings("unchecked") - public static CLPlatform[] listCLPlatforms(Filter<CLPlatform>... filter) { + public static CLPlatform[] listCLPlatforms(final Filter<CLPlatform>... filter) { initialize(); - IntBuffer ib = Buffers.newDirectIntBuffer(1); + final IntBuffer ib = Buffers.newDirectIntBuffer(1); // find all available OpenCL platforms int ret = cl.clGetPlatformIDs(0, null, ib); checkForError(ret, "can not enumerate platforms"); // receive platform ids - PointerBuffer platformId = PointerBuffer.allocateDirect(ib.get(0)); + final PointerBuffer platformId = PointerBuffer.allocateDirect(ib.get(0)); ret = cl.clGetPlatformIDs(platformId.capacity(), platformId, null); checkForError(ret, "can not enumerate platforms"); - List<CLPlatform> platforms = new ArrayList<CLPlatform>(); + final List<CLPlatform> platforms = new ArrayList<CLPlatform>(); for (int i = 0; i < platformId.capacity(); i++) { - CLPlatform platform = new CLPlatform(platformId.get(i)); + final CLPlatform platform = new CLPlatform(platformId.get(i)); addIfAccepted(platform, platforms, filter); } @@ -258,7 +259,7 @@ public class CLPlatform { */ public static void unloadCompiler() { initialize(); - int ret = cl.clUnloadCompiler(); + final int ret = cl.clUnloadCompiler(); checkForError(ret, "error while sending unload compiler hint"); } @@ -273,15 +274,15 @@ public class CLPlatform { /** * Lists all physical devices available on this platform matching the given {@link CLDevice.Type}. */ - public CLDevice[] listCLDevices(CLDevice.Type... types) { + public CLDevice[] listCLDevices(final CLDevice.Type... types) { initialize(); - List<CLDevice> list = new ArrayList<CLDevice>(); + final List<CLDevice> list = new ArrayList<CLDevice>(); for(int t = 0; t < types.length; t++) { - CLDevice.Type type = types[t]; + final CLDevice.Type type = types[t]; - long[] deviceIDs = info.getDeviceIDs(type.TYPE); + final long[] deviceIDs = info.getDeviceIDs(type.TYPE); //add device to list for (int n = 0; n < deviceIDs.length; n++) { @@ -297,16 +298,16 @@ public class CLPlatform { * Lists all physical devices available on this platform matching the given {@link Filter}. */ @SuppressWarnings("unchecked") - public CLDevice[] listCLDevices(Filter<CLDevice>... filters) { + public CLDevice[] listCLDevices(final Filter<CLDevice>... filters) { initialize(); - List<CLDevice> list = new ArrayList<CLDevice>(); + final List<CLDevice> list = new ArrayList<CLDevice>(); - long[] deviceIDs = info.getDeviceIDs(CL_DEVICE_TYPE_ALL); + final long[] deviceIDs = info.getDeviceIDs(CL_DEVICE_TYPE_ALL); //add device to list for (int n = 0; n < deviceIDs.length; n++) { - CLDevice device = createDevice(deviceIDs[n]); + final CLDevice device = createDevice(deviceIDs[n]); addIfAccepted(device, list, filters); } @@ -314,16 +315,16 @@ public class CLPlatform { } - protected CLDevice createDevice(long id) { + protected CLDevice createDevice(final long id) { return new CLDevice(this, id); } - private static <I> void addIfAccepted(I item, List<I> list, Filter<I>[] filters) { + private static <I> void addIfAccepted(final I item, final List<I> list, final Filter<I>[] filters) { if(filters == null) { list.add(item); }else{ boolean accepted = true; - for (Filter<I> filter : filters) { + for (final Filter<I> filter : filters) { if(!filter.accept(item)) { accepted = false; break; @@ -335,11 +336,11 @@ public class CLPlatform { } } - static CLDevice findMaxFlopsDevice(CLDevice[] devices) { + static CLDevice findMaxFlopsDevice(final CLDevice[] devices) { return findMaxFlopsDevice(devices, null); } - static CLDevice findMaxFlopsDevice(CLDevice[] devices, CLDevice.Type type) { + static CLDevice findMaxFlopsDevice(final CLDevice[] devices, final CLDevice.Type type) { initialize(); CLDevice maxFLOPSDevice = null; @@ -348,13 +349,13 @@ public class CLPlatform { for (int i = 0; i < devices.length; i++) { - CLDevice device = devices[i]; + final CLDevice device = devices[i]; if(type == null || type.equals(device.getType())) { - int maxComputeUnits = device.getMaxComputeUnits(); - int maxClockFrequency = device.getMaxClockFrequency(); - int flops = maxComputeUnits*maxClockFrequency; + final int maxComputeUnits = device.getMaxComputeUnits(); + final int maxClockFrequency = device.getMaxClockFrequency(); + final int flops = maxComputeUnits*maxClockFrequency; if(flops > maxflops) { maxflops = flops; @@ -383,7 +384,7 @@ public class CLPlatform { * The device speed is estimated by calculating the product of * MAX_COMPUTE_UNITS and MAX_CLOCK_FREQUENCY. */ - public CLDevice getMaxFlopsDevice(CLDevice.Type... types) { + public CLDevice getMaxFlopsDevice(final CLDevice.Type... types) { return findMaxFlopsDevice(listCLDevices(types)); } @@ -393,7 +394,7 @@ public class CLPlatform { * MAX_COMPUTE_UNITS and MAX_CLOCK_FREQUENCY. */ @SuppressWarnings("unchecked") - public CLDevice getMaxFlopsDevice(Filter<CLDevice>... filter) { + public CLDevice getMaxFlopsDevice(final Filter<CLDevice>... filter) { return findMaxFlopsDevice(listCLDevices(filter)); } @@ -423,14 +424,14 @@ public class CLPlatform { /** * @see CLVersion#isAtLeast(com.jogamp.opencl.CLVersion) */ - public boolean isAtLeast(CLVersion other) { + public boolean isAtLeast(final CLVersion other) { return version.isAtLeast(other); } /** * @see CLVersion#isAtLeast(int, int) */ - public boolean isAtLeast(int major, int minor) { + public boolean isAtLeast(final int major, final int minor) { return version.isAtLeast(major, minor); } @@ -467,7 +468,7 @@ public class CLPlatform { /** * Returns true if the extension is supported on this platform. */ - public boolean isExtensionAvailable(String extension) { + public boolean isExtensionAvailable(final String extension) { return getExtensions().contains(extension); } @@ -479,8 +480,8 @@ public class CLPlatform { if(extensions == null) { extensions = new HashSet<String>(); - String ext = getInfoString(CL_PLATFORM_EXTENSIONS); - Scanner scanner = new Scanner(ext); + final String ext = getInfoString(CL_PLATFORM_EXTENSIONS); + final Scanner scanner = new Scanner(ext); while(scanner.hasNext()) extensions.add(scanner.next()); @@ -503,7 +504,7 @@ public class CLPlatform { /** * Returns a info string in exchange for a key (CL_PLATFORM_*). */ - public final String getInfoString(int key) { + public final String getInfoString(final int key) { return info.getString(key); } @@ -572,7 +573,7 @@ public class CLPlatform { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } diff --git a/src/com/jogamp/opencl/CLProgram.java b/src/com/jogamp/opencl/CLProgram.java index 9dd3db82..7e1ef6cf 100644 --- a/src/com/jogamp/opencl/CLProgram.java +++ b/src/com/jogamp/opencl/CLProgram.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -64,7 +64,7 @@ public class CLProgram extends CLObjectResource { private final static ReentrantLock buildLock = new ReentrantLock(); private final CLProgramBinding binding; - + private final Set<CLKernel> kernels; private Map<CLDevice, Status> buildStatusMap; @@ -73,54 +73,54 @@ public class CLProgram extends CLObjectResource { /** Set if program created from binary, or else getting source can crash the driver on Macs. */ private boolean noSource; - private CLProgram(CLContext context, long id) { + private CLProgram(final CLContext context, final long id) { super(context, id); this.kernels = new HashSet<CLKernel>(); this.binding = context.getPlatform().getProgramBinding(); } - - static CLProgram create(CLContext context, String src) { - IntBuffer status = newDirectIntBuffer(1); - - PointerBuffer length = PointerBuffer.allocateDirect(1).put(0, src.length()); - String[] srcArray = new String[] {src}; - + static CLProgram create(final CLContext context, final String src) { + + final IntBuffer status = newDirectIntBuffer(1); + + final PointerBuffer length = PointerBuffer.allocateDirect(1).put(0, src.length()); + final String[] srcArray = new String[] {src}; + // Create the program - CLProgramBinding binding = context.getPlatform().getProgramBinding(); - long id = binding.clCreateProgramWithSource(context.ID, 1, srcArray, length, status); + final CLProgramBinding binding = context.getPlatform().getProgramBinding(); + final long id = binding.clCreateProgramWithSource(context.ID, 1, srcArray, length, status); - int err = status.get(); + final int err = status.get(); if(err != CL_SUCCESS) { throw newException(err, "can not create program with source on "+context); } - + return new CLProgram(context, id); } - static CLProgram create(CLContext context, Map<CLDevice, byte[]> binaries) { + static CLProgram create(final CLContext context, final Map<CLDevice, byte[]> binaries) { + + final Set<Entry<CLDevice, byte[]>> entries = binaries.entrySet(); - Set<Entry<CLDevice, byte[]>> entries = binaries.entrySet(); - // calculate buffer size int binarySize = 0; - for (Map.Entry<CLDevice, byte[]> entry : entries) { + for (final Map.Entry<CLDevice, byte[]> entry : entries) { binarySize += entry.getValue().length; } - int pbSize = PointerBuffer.ELEMENT_SIZE; - int deviceCount = binaries.size(); - - CachedBufferFactory bf = CachedBufferFactory.create(binarySize + pbSize*deviceCount*3 + 4, true); - PointerBuffer devices = PointerBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); - PointerBuffer codeBuffers = PointerBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); - PointerBuffer lengths = PointerBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); - + final int pbSize = PointerBuffer.ELEMENT_SIZE; + final int deviceCount = binaries.size(); + + final CachedBufferFactory bf = CachedBufferFactory.create(binarySize + pbSize*deviceCount*3 + 4, true); + final PointerBuffer devices = PointerBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); + final PointerBuffer codeBuffers = PointerBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); + final PointerBuffer lengths = PointerBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); + int i = 0; - for (Map.Entry<CLDevice, byte[]> entry : entries) { + for (final Map.Entry<CLDevice, byte[]> entry : entries) { - byte[] bytes = entry.getValue(); - CLDevice device = entry.getKey(); + final byte[] bytes = entry.getValue(); + final CLDevice device = entry.getKey(); devices.put(device.ID); lengths.put(bytes.length); @@ -131,16 +131,16 @@ public class CLProgram extends CLObjectResource { devices.rewind(); lengths.rewind(); - IntBuffer errBuffer = bf.newDirectIntBuffer(1); + final IntBuffer errBuffer = bf.newDirectIntBuffer(1); // IntBuffer status = newDirectByteBuffer(binaries.size()*4).asIntBuffer(); - CLProgramBinding binding = context.getPlatform().getProgramBinding(); - long id = binding.clCreateProgramWithBinary(context.ID, devices.capacity(), devices, lengths, codeBuffers, /*status*/null, errBuffer); + final CLProgramBinding binding = context.getPlatform().getProgramBinding(); + final long id = binding.clCreateProgramWithBinary(context.ID, devices.capacity(), devices, lengths, codeBuffers, /*status*/null, errBuffer); // while(status.remaining() != 0) { // checkForError(status.get(), "unable to load binaries on all devices"); // } - int err = errBuffer.get(); + final int err = errBuffer.get(); if(err != CL_SUCCESS) { throw newException(err, "can not create program on "+context +" with binaries "+binaries); } @@ -152,10 +152,10 @@ public class CLProgram extends CLObjectResource { if(buildStatusMap == null) { // synchronized(buildLock) { - Map<CLDevice, Status> map = new HashMap<CLDevice, Status>(); - CLDevice[] devices = getCLDevices(); - for (CLDevice device : devices) { - Status status = getBuildStatus(device); + final Map<CLDevice, Status> map = new HashMap<CLDevice, Status>(); + final CLDevice[] devices = getCLDevices(); + for (final CLDevice device : devices) { + final Status status = getBuildStatus(device); if(status == Status.BUILD_SUCCESS) { executable = true; } @@ -166,20 +166,20 @@ public class CLProgram extends CLObjectResource { } } - private String getBuildInfoString(CLDevice device, int flag) { + private String getBuildInfoString(final CLDevice device, final int flag) { if(released) { return ""; } - PointerBuffer size = PointerBuffer.allocateDirect(1); + final PointerBuffer size = PointerBuffer.allocateDirect(1); int ret = binding.clGetProgramBuildInfo(ID, device.ID, flag, 0, null, size); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramBuildInfo with "+device); } - ByteBuffer buffer = newDirectByteBuffer((int)size.get(0)); + final ByteBuffer buffer = newDirectByteBuffer((int)size.get(0)); ret = binding.clGetProgramBuildInfo(ID, device.ID, flag, buffer.capacity(), buffer, null); if(ret != CL_SUCCESS) { @@ -189,18 +189,18 @@ public class CLProgram extends CLObjectResource { return CLUtil.clString2JavaString(buffer, (int)size.get(0)); } - private String getProgramInfoString(int flag) { + private String getProgramInfoString(final int flag) { if(released) { return ""; } - PointerBuffer size = PointerBuffer.allocateDirect(1); + final PointerBuffer size = PointerBuffer.allocateDirect(1); int ret = binding.clGetProgramInfo(ID, flag, 0, null, size); checkForError(ret, "on clGetProgramInfo"); - ByteBuffer buffer = newDirectByteBuffer((int)size.get(0)); + final ByteBuffer buffer = newDirectByteBuffer((int)size.get(0)); ret = binding.clGetProgramInfo(ID, flag, buffer.capacity(), buffer, null); checkForError(ret, "on clGetProgramInfo"); @@ -208,11 +208,11 @@ public class CLProgram extends CLObjectResource { return CLUtil.clString2JavaString(buffer, (int)size.get(0)); } - private int getBuildInfoInt(CLDevice device, int flag) { + private int getBuildInfoInt(final CLDevice device, final int flag) { - ByteBuffer buffer = newDirectByteBuffer(4); + final ByteBuffer buffer = newDirectByteBuffer(4); - int ret = binding.clGetProgramBuildInfo(ID, device.ID, flag, buffer.capacity(), buffer, null); + final int ret = binding.clGetProgramBuildInfo(ID, device.ID, flag, buffer.capacity(), buffer, null); checkForError(ret, "error on clGetProgramBuildInfo"); return buffer.getInt(); @@ -237,17 +237,17 @@ public class CLProgram extends CLObjectResource { * @param listener A listener who is notified when the program was built. * @return this */ - public CLProgram build(CLBuildListener listener) { + public CLProgram build(final CLBuildListener listener) { build(listener, null, (CLDevice[])null); return this; } - + /** * Builds this program for the given devices. * @param devices A list of devices this program should be build on or null for all devices of its context. * @return this */ - public CLProgram build(CLDevice... devices) { + public CLProgram build(final CLDevice... devices) { build(null, (String) null, devices); return this; } @@ -259,7 +259,7 @@ public class CLProgram extends CLObjectResource { * @param devices A list of devices this program should be build on or null for all devices of its context. * @return this */ - public CLProgram build(CLBuildListener listener, CLDevice... devices) { + public CLProgram build(final CLBuildListener listener, final CLDevice... devices) { build(listener,null, devices); return this; } @@ -269,7 +269,7 @@ public class CLProgram extends CLObjectResource { * @see CompilerOptions * @return this */ - public CLProgram build(String options) { + public CLProgram build(final String options) { build(null, options, (CLDevice[])null); return this; } @@ -281,7 +281,7 @@ public class CLProgram extends CLObjectResource { * @param listener A listener who is notified when the program was built. * @return this */ - public CLProgram build(CLBuildListener listener, String options) { + public CLProgram build(final CLBuildListener listener, final String options) { build(listener, options, (CLDevice[])null); return this; } @@ -290,7 +290,7 @@ public class CLProgram extends CLObjectResource { * Builds this program for all devices associated with the context using the specified build options. * @see CompilerOptions */ - public CLProgram build(String... options) { + public CLProgram build(final String... options) { build(null, optionsOf(options), (CLDevice[])null); return this; } @@ -301,7 +301,7 @@ public class CLProgram extends CLObjectResource { * @see CLBuildListener * @param listener A listener who is notified when the program was built. */ - public CLProgram build(CLBuildListener listener, String... options) { + public CLProgram build(final CLBuildListener listener, final String... options) { build(listener, optionsOf(options), (CLDevice[])null); return this; } @@ -313,7 +313,7 @@ public class CLProgram extends CLObjectResource { * @param devices A list of devices this program should be build on or null for all devices of its context. * @return this */ - public CLProgram build(String options, CLDevice... devices) { + public CLProgram build(final String options, final CLDevice... devices) { build(null, options, devices); return this; } @@ -327,7 +327,7 @@ public class CLProgram extends CLObjectResource { * @param devices A list of devices this program should be build on or null for all devices of its context. * @param listener A listener who is notified when the program was built. */ - public CLProgram build(final CLBuildListener listener, String options, CLDevice... devices) { + public CLProgram build(final CLBuildListener listener, String options, final CLDevice... devices) { if(released) { throw new CLException("can not build a released program"); @@ -363,7 +363,7 @@ public class CLProgram extends CLObjectResource { if(listener != null) { callback = new BuildProgramCallback() { @Override - public void buildFinished(long cl_program) { + public void buildFinished(final long cl_program) { buildLock.unlock(); listener.buildFinished(CLProgram.this); } @@ -405,19 +405,19 @@ public class CLProgram extends CLObjectResource { /** * Creates a kernel with the specified kernel name. */ - public CLKernel createCLKernel(String kernelName) { + public CLKernel createCLKernel(final String kernelName) { if(released) { return null; } - int[] err = new int[1]; - long id = getKernelBinding().clCreateKernel(ID, kernelName, err, 0); + final int[] err = new int[1]; + final long id = getKernelBinding().clCreateKernel(ID, kernelName, err, 0); if(err[0] != CL_SUCCESS) { throw newException(err[0], "unable to create Kernel with name: "+kernelName); } - CLKernel kernel = new CLKernel(this, kernelName, id); + final CLKernel kernel = new CLKernel(this, kernelName, id); kernels.add(kernel); return kernel; } @@ -431,10 +431,10 @@ public class CLProgram extends CLObjectResource { return Collections.emptyMap(); } - HashMap<String, CLKernel> newKernels = new HashMap<String, CLKernel>(); + final HashMap<String, CLKernel> newKernels = new HashMap<String, CLKernel>(); - IntBuffer numKernels = newDirectByteBuffer(4).asIntBuffer(); - CLKernelBinding kernelBinding = getKernelBinding(); + final IntBuffer numKernels = newDirectByteBuffer(4).asIntBuffer(); + final CLKernelBinding kernelBinding = getKernelBinding(); int ret = kernelBinding.clCreateKernelsInProgram(ID, 0, null, numKernels); if(ret != CL_SUCCESS) { throw newException(ret, "can not create kernels for "+this); @@ -442,14 +442,14 @@ public class CLProgram extends CLObjectResource { if(numKernels.get(0) > 0) { - PointerBuffer kernelIDs = PointerBuffer.allocateDirect(numKernels.get(0)); + final PointerBuffer kernelIDs = PointerBuffer.allocateDirect(numKernels.get(0)); ret = kernelBinding.clCreateKernelsInProgram(ID, kernelIDs.capacity(), kernelIDs, null); if(ret != CL_SUCCESS) { throw newException(ret, "can not create "+kernelIDs.capacity()+" kernels for "+this); } for (int i = 0; i < kernelIDs.capacity(); i++) { - CLKernel kernel = new CLKernel(this, kernelIDs.get(i)); + final CLKernel kernel = new CLKernel(this, kernelIDs.get(i)); kernels.add(kernel); newKernels.put(kernel.name, kernel); } @@ -466,7 +466,7 @@ public class CLProgram extends CLObjectResource { return newKernels; } - void onKernelReleased(CLKernel kernel) { + void onKernelReleased(final CLKernel kernel) { this.kernels.remove(kernel); } @@ -482,8 +482,8 @@ public class CLProgram extends CLObjectResource { executable = false; released = true; buildStatusMap = null; - - int ret = binding.clReleaseProgram(ID); + + final int ret = binding.clReleaseProgram(ID); context.onProgramReleased(this); if(ret != CL_SUCCESS) { throw newException(ret, "can not release "+this); @@ -493,8 +493,8 @@ public class CLProgram extends CLObjectResource { private void releaseKernels() { if(!kernels.isEmpty()) { // copy to array to prevent concurrent modification exception - CLKernel[] array = kernels.toArray(new CLKernel[kernels.size()]); - for (CLKernel kernel : array) { + final CLKernel[] array = kernels.toArray(new CLKernel[kernels.size()]); + for (final CLKernel kernel : array) { kernel.release(); } } @@ -508,20 +508,20 @@ public class CLProgram extends CLObjectResource { return new CLDevice[0]; } - PointerBuffer size = PointerBuffer.allocateDirect(1); + final PointerBuffer size = PointerBuffer.allocateDirect(1); int ret = binding.clGetProgramInfo(ID, CL_PROGRAM_DEVICES, 0, null, size); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramInfo of "+this); } - ByteBuffer bb = newDirectByteBuffer((int) size.get(0)); + final ByteBuffer bb = newDirectByteBuffer((int) size.get(0)); ret = binding.clGetProgramInfo(ID, CL_PROGRAM_DEVICES, bb.capacity(), bb, null); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramInfo of "+this); } - int count = bb.capacity() / (Platform.is32Bit()?4:8); - CLDevice[] devices = new CLDevice[count]; + final int count = bb.capacity() / (Platform.is32Bit()?4:8); + final CLDevice[] devices = new CLDevice[count]; for (int i = 0; i < count; i++) { devices[i] = context.getDevice(Platform.is32Bit()?bb.getInt():bb.getLong()); } @@ -538,12 +538,12 @@ public class CLProgram extends CLObjectResource { if(released) { return ""; } - StringBuilder sb = new StringBuilder(200); - CLDevice[] devices = getCLDevices(); + final StringBuilder sb = new StringBuilder(200); + final CLDevice[] devices = getCLDevices(); for (int i = 0; i < devices.length; i++) { - CLDevice device = devices[i]; + final CLDevice device = devices[i]; sb.append(device).append(" build log:\n"); - String log = getBuildLog(device).trim(); + final String log = getBuildLog(device).trim(); sb.append(log.isEmpty()?" <empty>":log); if(i != devices.length-1) sb.append("\n"); @@ -578,18 +578,18 @@ public class CLProgram extends CLObjectResource { * Returns the build log for this program on the specified device. The contents * of the log are implementation dependent log can be an empty String. */ - public String getBuildLog(CLDevice device) { + public String getBuildLog(final CLDevice device) { return getBuildInfoString(device, CL_PROGRAM_BUILD_LOG); } /** * Returns the build status enum for this program on the specified device. */ - public Status getBuildStatus(CLDevice device) { + public Status getBuildStatus(final CLDevice device) { if(released) { return Status.BUILD_NONE; } - int clStatus = getBuildInfoInt(device, CL_PROGRAM_BUILD_STATUS); + final int clStatus = getBuildInfoInt(device, CL_PROGRAM_BUILD_STATUS); return Status.valueOf(clStatus); } @@ -611,7 +611,7 @@ public class CLProgram extends CLObjectResource { // some drivers return IVE codes if the program haven't been built from source. try{ return getProgramInfoString(CL_PROGRAM_SOURCE); - }catch(CLException.CLInvalidValueException ingore) { + }catch(final CLException.CLInvalidValueException ingore) { return ""; } } @@ -625,10 +625,10 @@ public class CLProgram extends CLObjectResource { if(!isExecutable()) { return Collections.emptyMap(); } - - CLDevice[] devices = getCLDevices(); - PointerBuffer sizes = PointerBuffer.allocateDirect(devices.length); + final CLDevice[] devices = getCLDevices(); + + final PointerBuffer sizes = PointerBuffer.allocateDirect(devices.length); int ret = binding.clGetProgramInfo(ID, CL_PROGRAM_BINARY_SIZES, sizes.capacity()*sizes.elementSize(), sizes.getBuffer(), null); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramInfo(CL_PROGRAM_BINARY_SIZES) of "+this); @@ -636,30 +636,30 @@ public class CLProgram extends CLObjectResource { int binariesSize = 0; while(sizes.remaining() != 0) { - int size = (int) sizes.get(); + final int size = (int) sizes.get(); binariesSize += size; } - ByteBuffer binaries = newDirectByteBuffer(binariesSize); + final ByteBuffer binaries = newDirectByteBuffer(binariesSize); + - long address = InternalBufferUtil.getDirectBufferAddress(binaries); - PointerBuffer addresses = PointerBuffer.allocateDirect(sizes.capacity()); + final PointerBuffer addresses = PointerBuffer.allocateDirect(sizes.capacity()); sizes.rewind(); while(sizes.remaining() != 0) { addresses.put(address); address += sizes.get(); } addresses.rewind(); - + ret = binding.clGetProgramInfo(ID, CL_PROGRAM_BINARIES, addresses.capacity()*addresses.elementSize(), addresses.getBuffer(), null); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramInfo(CL_PROGRAM_BINARIES) of "+this); } - Map<CLDevice, byte[]> map = new LinkedHashMap<CLDevice, byte[]>(); + final Map<CLDevice, byte[]> map = new LinkedHashMap<CLDevice, byte[]>(); sizes.rewind(); for (int i = 0; i < devices.length; i++) { - byte[] bytes = new byte[(int)sizes.get()]; + final byte[] bytes = new byte[(int)sizes.get()]; binaries.get(bytes); map.put(devices[i], bytes); } @@ -670,8 +670,8 @@ public class CLProgram extends CLObjectResource { /** * Utility method which builds a properly seperated option string. */ - public static String optionsOf(String... options) { - StringBuilder sb = new StringBuilder(options.length * 24); + public static String optionsOf(final String... options) { + final StringBuilder sb = new StringBuilder(options.length * 24); for (int i = 0; i < options.length; i++) { sb.append(options[i]); if(i!= options.length-1) @@ -683,14 +683,14 @@ public class CLProgram extends CLObjectResource { /** * Utility method for defining macros as build options (Returns "-D name"). */ - public static String define(String name) { + public static String define(final String name) { return "-D "+name; } /** * Utility method for defining macros as build options (Returns "-D name=value"). */ - public static String define(String name, Object value) { + public static String define(final String name, final Object value) { return "-D "+name+"="+value; } @@ -701,7 +701,7 @@ public class CLProgram extends CLObjectResource { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -725,7 +725,7 @@ public class CLProgram extends CLObjectResource { hash = 37 * hash + (int) (this.ID ^ (this.ID >>> 32)); return hash; } - + public enum Status { BUILD_SUCCESS(CL_BUILD_SUCCESS), @@ -738,11 +738,11 @@ public class CLProgram extends CLObjectResource { */ public final int STATUS; - private Status(int status) { + private Status(final int status) { this.STATUS = status; } - public static Status valueOf(int clBuildStatus) { + public static Status valueOf(final int clBuildStatus) { switch(clBuildStatus) { case(CL_BUILD_SUCCESS): return BUILD_SUCCESS; diff --git a/src/com/jogamp/opencl/CLProgramBuilder.java b/src/com/jogamp/opencl/CLProgramBuilder.java index dd0c64f9..a042b7ef 100644 --- a/src/com/jogamp/opencl/CLProgramBuilder.java +++ b/src/com/jogamp/opencl/CLProgramBuilder.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -76,11 +76,11 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa this(null); } - private CLProgramBuilder(CLProgram program) { + private CLProgramBuilder(final CLProgram program) { this(program, null, null); } - private CLProgramBuilder(CLProgram program, String source, Map<CLDevice, byte[]> map) { + private CLProgramBuilder(final CLProgram program, final String source, final Map<CLDevice, byte[]> map) { this.program = program; this.source = source; if(map != null) { @@ -98,7 +98,7 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa /** * Creates a new CLProgramConfiguration for this program. */ - public static CLProgramConfiguration createConfiguration(CLProgram program) { + public static CLProgramConfiguration createConfiguration(final CLProgram program) { return new CLProgramBuilder(program); } @@ -106,7 +106,7 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa * Loads a CLBuildConfiguration. * @param ois The ObjectInputStream for reading the object. */ - public static CLBuildConfiguration loadConfiguration(ObjectInputStream ois) throws IOException, ClassNotFoundException { + public static CLBuildConfiguration loadConfiguration(final ObjectInputStream ois) throws IOException, ClassNotFoundException { return (CLBuildConfiguration) ois.readObject(); } @@ -119,12 +119,12 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa * @param ois The ObjectInputStream for reading the object. * @param context The context used for program initialization. */ - public static CLProgramConfiguration loadConfiguration(ObjectInputStream ois, CLContext context) throws IOException, ClassNotFoundException { - CLProgramBuilder config = (CLProgramBuilder) ois.readObject(); + public static CLProgramConfiguration loadConfiguration(final ObjectInputStream ois, final CLContext context) throws IOException, ClassNotFoundException { + final CLProgramBuilder config = (CLProgramBuilder) ois.readObject(); if(allBinariesAvailable(config)) { try{ config.program = context.createProgram(config.binariesMap); - }catch(CLException.CLInvalidBinaryException ex) { + }catch(final CLException.CLInvalidBinaryException ex) { if(config.source != null) { config.program = context.createProgram(config.source); }else{ @@ -138,9 +138,9 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa } return config; } - - private static boolean allBinariesAvailable(CLProgramBuilder config) { - for (Map.Entry<CLDevice, byte[]> entry : config.binariesMap.entrySet()) { + + private static boolean allBinariesAvailable(final CLProgramBuilder config) { + for (final Map.Entry<CLDevice, byte[]> entry : config.binariesMap.entrySet()) { if(Arrays.equals(NO_BINARIES, entry.getValue())) { return false; } @@ -149,7 +149,7 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa } @Override - public void save(ObjectOutputStream oos) throws IOException { + public void save(final ObjectOutputStream oos) throws IOException { if(program != null) { this.source = program.getSource(); if(program.isExecutable()) { @@ -161,49 +161,49 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa @Override - public CLProgramBuilder withOption(String option) { + public CLProgramBuilder withOption(final String option) { optionSet.add(option); return this; } @Override - public CLProgramBuilder withOptions(String... options) { + public CLProgramBuilder withOptions(final String... options) { optionSet.addAll(Arrays.asList(options)); return this; } @Override - public CLProgramBuilder withDefine(String name) { + public CLProgramBuilder withDefine(final String name) { defineSet.add(CLProgram.define(name)); return this; } @Override - public CLProgramBuilder withDefines(String... names) { - for (String name : names) { + public CLProgramBuilder withDefines(final String... names) { + for (final String name : names) { defineSet.add(CLProgram.define(name)); } return this; } @Override - public CLProgramBuilder withDefine(String name, Object value) { + public CLProgramBuilder withDefine(final String name, final Object value) { defineSet.add(CLProgram.define(name, value.toString())); return this; } @Override - public CLProgramBuilder withDefines(Map<String, ? extends Object> defines) { - for (Map.Entry<String, ? extends Object> define : defines.entrySet()) { - String name = define.getKey(); - Object value = define.getValue(); + public CLProgramBuilder withDefines(final Map<String, ? extends Object> defines) { + for (final Map.Entry<String, ? extends Object> define : defines.entrySet()) { + final String name = define.getKey(); + final Object value = define.getValue(); defineSet.add(CLProgram.define(name, value)); } return this; } @Override - public CLProgramBuilder forDevice(CLDevice device) { + public CLProgramBuilder forDevice(final CLDevice device) { if(!binariesMap.containsKey(device)) { binariesMap.put(device, NO_BINARIES); } @@ -211,8 +211,8 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa } @Override - public CLProgramBuilder forDevices(CLDevice... devices) { - for (CLDevice device : devices) { + public CLProgramBuilder forDevices(final CLDevice... devices) { + for (final CLDevice device : devices) { forDevice(device); } return this; @@ -224,25 +224,25 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa } @Override - public CLProgram build(CLBuildListener listener) { + public CLProgram build(final CLBuildListener listener) { return build(program, listener); } @Override - public CLProgram build(CLProgram program) { + public CLProgram build(final CLProgram program) { return build(program, null); } - + @Override - public CLProgram build(CLProgram program, CLBuildListener listener) { + public CLProgram build(final CLProgram program, final CLBuildListener listener) { if(program == null) { throw new NullPointerException("no program has been set"); } - List<String> setup = new ArrayList<String>(); + final List<String> setup = new ArrayList<String>(); setup.addAll(optionSet); setup.addAll(defineSet); - String options = CLProgram.optionsOf(setup.toArray(new String[setup.size()])); - CLDevice[] devices = binariesMap.keySet().toArray(new CLDevice[binariesMap.size()]); + final String options = CLProgram.optionsOf(setup.toArray(new String[setup.size()])); + final CLDevice[] devices = binariesMap.keySet().toArray(new CLDevice[binariesMap.size()]); return program.build(listener, options, devices); } @@ -273,37 +273,37 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa } // format: { platform_suffix, num_binaries, (device_name, length, binaries)+ } - private void writeObject(ObjectOutputStream out) throws IOException { + private void writeObject(final ObjectOutputStream out) throws IOException { out.defaultWriteObject(); String suffix = ""; if(!binariesMap.isEmpty()) { - CLDevice device = binariesMap.keySet().iterator().next(); + final CLDevice device = binariesMap.keySet().iterator().next(); if(device.isICDAvailable()) suffix = device.getPlatform().getICDSuffix(); } - + // empty string if we have no binaries or no devices specified, or if cl_khr_icd isn't supported out.writeUTF(suffix); out.writeInt(binariesMap.size()); // may be 0 - for (Map.Entry<CLDevice, byte[]> entry : binariesMap.entrySet()) { - CLDevice device = entry.getKey(); - byte[] binaries = entry.getValue(); - + for (final Map.Entry<CLDevice, byte[]> entry : binariesMap.entrySet()) { + final CLDevice device = entry.getKey(); + final byte[] binaries = entry.getValue(); + out.writeUTF(device.getName()); out.writeInt(binaries.length); out.write(binaries); } } - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - String suffix = in.readUTF(); // empty string means no suffix was written; just picks first platform + final String suffix = in.readUTF(); // empty string means no suffix was written; just picks first platform CLPlatform platform = null; - for (CLPlatform p : CLPlatform.listCLPlatforms()) { + for (final CLPlatform p : CLPlatform.listCLPlatforms()) { if(suffix.isEmpty() || p.getICDSuffix().equals(suffix)) { platform = p; break; @@ -311,24 +311,24 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa } this.binariesMap = new LinkedHashMap<CLDevice, byte[]>(); - + List<CLDevice> devices; if(platform != null) { devices = new ArrayList<CLDevice>(Arrays.asList(platform.listCLDevices())); }else{ devices = Collections.emptyList(); } - - int mapSize = in.readInt(); + + final int mapSize = in.readInt(); for (int i = 0; i < mapSize; i++) { - String name = in.readUTF(); - int length = in.readInt(); - byte[] binaries = new byte[length]; + final String name = in.readUTF(); + final int length = in.readInt(); + final byte[] binaries = new byte[length]; in.readFully(binaries); - + for (int d = 0; d < devices.size(); d++) { - CLDevice device = devices.get(d); + final CLDevice device = devices.get(d); if(device.getName().equals(name)) { binariesMap.put(device, binaries); devices.remove(d); @@ -340,15 +340,15 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa @Override public CLProgramBuilder asBuildConfiguration() { - CLProgramBuilder builder = new CLProgramBuilder(); + final CLProgramBuilder builder = new CLProgramBuilder(); builder.defineSet.addAll(defineSet); builder.optionSet.addAll(optionSet); return builder; } - + @Override public CLProgramBuilder clone() { - CLProgramBuilder builder = new CLProgramBuilder(program, source, binariesMap); + final CLProgramBuilder builder = new CLProgramBuilder(program, source, binariesMap); builder.defineSet.addAll(defineSet); builder.optionSet.addAll(optionSet); return builder; @@ -360,7 +360,7 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa } @Override - public CLProgramBuilder setProgram(CLProgram program) { + public CLProgramBuilder setProgram(final CLProgram program) { this.program = program; return this; } @@ -377,11 +377,11 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa } @Override - public boolean equals(Object o) { + public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - CLProgramBuilder that = (CLProgramBuilder) o; + final CLProgramBuilder that = (CLProgramBuilder) o; if (source != null ? !source.equals(that.source) : that.source != null) return false; if (defineSet != null ? !defineSet.equals(that.defineSet) : that.defineSet != null) return false; @@ -391,11 +391,11 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa if(binariesMap.size() != that.binariesMap.size()) { return false; } - Iterator<CLDevice> iterator0 = binariesMap.keySet().iterator(); - Iterator<CLDevice> iterator1 = that.binariesMap.keySet().iterator(); + final Iterator<CLDevice> iterator0 = binariesMap.keySet().iterator(); + final Iterator<CLDevice> iterator1 = that.binariesMap.keySet().iterator(); for (int i = 0; i < binariesMap.size(); i++) { - CLDevice device0 = iterator0.next(); - CLDevice device1 = iterator1.next(); + final CLDevice device0 = iterator0.next(); + final CLDevice device1 = iterator1.next(); if(!device0.equals(device1) || !Arrays.equals(binariesMap.get(device0), that.binariesMap.get(device1))) return false; } diff --git a/src/com/jogamp/opencl/CLProperty.java b/src/com/jogamp/opencl/CLProperty.java index f5e61df3..6ca46c33 100644 --- a/src/com/jogamp/opencl/CLProperty.java +++ b/src/com/jogamp/opencl/CLProperty.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -41,7 +41,7 @@ import java.lang.annotation.Target; * OpenCL property. * @author Michael Bien * @see CLUtil#obtainDeviceProperties(com.jogamp.opencl.CLDevice) - * @see CLUtil#obtainPlatformProperties(com.jogamp.opencl.CLPlatform) + * @see CLUtil#obtainPlatformProperties(com.jogamp.opencl.CLPlatform) */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) diff --git a/src/com/jogamp/opencl/CLResource.java b/src/com/jogamp/opencl/CLResource.java index 578ba92d..4797a706 100644 --- a/src/com/jogamp/opencl/CLResource.java +++ b/src/com/jogamp/opencl/CLResource.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. diff --git a/src/com/jogamp/opencl/CLSampler.java b/src/com/jogamp/opencl/CLSampler.java index fe780ac1..f3de5ffe 100644 --- a/src/com/jogamp/opencl/CLSampler.java +++ b/src/com/jogamp/opencl/CLSampler.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -48,29 +48,29 @@ public class CLSampler extends CLObjectResource { private final CLSamplerInfoAccessor samplerInfo; private final CLSamplerBinding binding; - private CLSampler(CLContext context, long id, AddressingMode addrMode, FilteringMode filtMode, boolean normalizedCoords) { + private CLSampler(final CLContext context, final long id, final AddressingMode addrMode, final FilteringMode filtMode, final boolean normalizedCoords) { super(context, id); this.binding = context.getPlatform().getSamplerBinding(); this.samplerInfo = new CLSamplerInfoAccessor(); } - static CLSampler create(CLContext context, AddressingMode addrMode, FilteringMode filtMode, boolean normalizedCoords) { - int[] error = new int[1]; + static CLSampler create(final CLContext context, final AddressingMode addrMode, final FilteringMode filtMode, final boolean normalizedCoords) { + final int[] error = new int[1]; - CLSamplerBinding binding = context.getPlatform().getSamplerBinding(); - long id = binding.clCreateSampler(context.ID, clBoolean(normalizedCoords), addrMode.MODE, filtMode.MODE, error, 0); + final CLSamplerBinding binding = context.getPlatform().getSamplerBinding(); + final long id = binding.clCreateSampler(context.ID, clBoolean(normalizedCoords), addrMode.MODE, filtMode.MODE, error, 0); checkForError(error[0], "can not create sampler"); return new CLSampler(context, id, addrMode, filtMode, normalizedCoords); } public FilteringMode getFilteringMode() { - int info = (int)samplerInfo.getLong(CL_SAMPLER_FILTER_MODE); + final int info = (int)samplerInfo.getLong(CL_SAMPLER_FILTER_MODE); return FilteringMode.valueOf(info); } public AddressingMode getAddressingMode() { - int info = (int)samplerInfo.getLong(CL_SAMPLER_ADDRESSING_MODE); + final int info = (int)samplerInfo.getLong(CL_SAMPLER_ADDRESSING_MODE); return AddressingMode.valueOf(info); } @@ -81,7 +81,7 @@ public class CLSampler extends CLObjectResource { @Override public void release() { super.release(); - int ret = binding.clReleaseSampler(ID); + final int ret = binding.clReleaseSampler(ID); context.onSamplerReleased(this); if(ret != CL_SUCCESS) { throw newException(ret, "can not release "+this); @@ -91,7 +91,7 @@ public class CLSampler extends CLObjectResource { private class CLSamplerInfoAccessor extends CLTLInfoAccessor { @Override - protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { + protected int getInfo(final int name, final long valueSize, final Buffer value, final PointerBuffer valueSizeRet) { return binding.clGetSamplerInfo(ID, name, valueSize, value, valueSizeRet); } @@ -107,11 +107,11 @@ public class CLSampler extends CLObjectResource { */ public final int MODE; - private FilteringMode(int mode) { + private FilteringMode(final int mode) { this.MODE = mode; } - public static FilteringMode valueOf(int mode) { + public static FilteringMode valueOf(final int mode) { switch(mode) { case(CL_FILTER_NEAREST): return NEAREST; @@ -134,11 +134,11 @@ public class CLSampler extends CLObjectResource { */ public final int MODE; - private AddressingMode(int mode) { + private AddressingMode(final int mode) { this.MODE = mode; } - public static AddressingMode valueOf(int mode) { + public static AddressingMode valueOf(final int mode) { switch(mode) { case(CL_ADDRESS_REPEAT): return REPEAT; diff --git a/src/com/jogamp/opencl/CLSubBuffer.java b/src/com/jogamp/opencl/CLSubBuffer.java index d8831783..ef3debfe 100644 --- a/src/com/jogamp/opencl/CLSubBuffer.java +++ b/src/com/jogamp/opencl/CLSubBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -38,10 +38,10 @@ import java.nio.Buffer; */ public class CLSubBuffer<B extends Buffer> extends CLBuffer<B> { - private CLBuffer<B> parent; + private final CLBuffer<B> parent; private final int offset; - CLSubBuffer(CLBuffer<B> parent, int origin, int size, B directBuffer, long id, int flags) { + CLSubBuffer(final CLBuffer<B> parent, final int origin, final int size, final B directBuffer, final long id, final int flags) { super(parent.getContext(), directBuffer, size, id, flags); this.parent = parent; this.offset = origin; @@ -52,7 +52,7 @@ public class CLSubBuffer<B extends Buffer> extends CLBuffer<B> { * from sub buffers is not allowed as of OpenCL 1.1. */ @Override - public CLSubBuffer<B> createSubBuffer(int origin, int size, Mem... flags) { + public CLSubBuffer<B> createSubBuffer(final int origin, final int size, final Mem... flags) { throw new UnsupportedOperationException("creating sub buffers from sub buffers is not allowed."); } @@ -73,7 +73,7 @@ public class CLSubBuffer<B extends Buffer> extends CLBuffer<B> { * Returns the offset of this sub buffer to its parent in buffer elements. */ public int getOffset() { - int elemSize = buffer==null ? 1 : Buffers.sizeOfBufferElem(buffer); + final int elemSize = buffer==null ? 1 : Buffers.sizeOfBufferElem(buffer); return offset/elemSize; } diff --git a/src/com/jogamp/opencl/CLUserEvent.java b/src/com/jogamp/opencl/CLUserEvent.java index d1a9da70..cff3701c 100644 --- a/src/com/jogamp/opencl/CLUserEvent.java +++ b/src/com/jogamp/opencl/CLUserEvent.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -43,17 +43,17 @@ import com.jogamp.opencl.llb.CLEventBinding; */ public class CLUserEvent extends CLEvent { - CLUserEvent(CLContext context, long ID) { + CLUserEvent(final CLContext context, final long ID) { super(context, ID); } /** * Creates a new user event. */ - public static CLUserEvent create(CLContext context) { - CLEventBinding binding = context.getPlatform().getEventBinding(); - int[] error = new int[1]; - long ID = binding.clCreateUserEvent(context.ID, error, 0); + public static CLUserEvent create(final CLContext context) { + final CLEventBinding binding = context.getPlatform().getEventBinding(); + final int[] error = new int[1]; + final long ID = binding.clCreateUserEvent(context.ID, error, 0); checkForError(error[0], "can not create user event."); return new CLUserEvent(context, ID); } @@ -62,9 +62,9 @@ public class CLUserEvent extends CLEvent { * Sets the event execution status. * Calls {@native clSetUserEventStatus}. */ - public CLUserEvent setStatus(CLEvent.ExecutionStatus status) { - CLEventBinding binding = getPlatform().getEventBinding(); - int err = binding.clSetUserEventStatus(ID, status.STATUS); + public CLUserEvent setStatus(final CLEvent.ExecutionStatus status) { + final CLEventBinding binding = getPlatform().getEventBinding(); + final int err = binding.clSetUserEventStatus(ID, status.STATUS); if(err != CL_SUCCESS) { newException(err, "can not set status "+status); } diff --git a/src/com/jogamp/opencl/CLVersion.java b/src/com/jogamp/opencl/CLVersion.java index 1ad3012d..3a48f0b7 100644 --- a/src/com/jogamp/opencl/CLVersion.java +++ b/src/com/jogamp/opencl/CLVersion.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -67,9 +67,9 @@ public class CLVersion implements Comparable<CLVersion> { */ public final short major; - protected CLVersion(String version) { + protected CLVersion(final String version) { this.fullversion = version; - Matcher matcher = pattern.matcher(version); + final Matcher matcher = pattern.matcher(version); matcher.matches(); major = Short.parseShort(matcher.group(1)); minor = Short.parseShort(matcher.group(2)); @@ -81,11 +81,11 @@ public class CLVersion implements Comparable<CLVersion> { } } - public int compareTo(CLVersion other) { + public int compareTo(final CLVersion other) { return compareTo(other.major, other.minor); } - - private int compareTo(int otherMajor, int otherMinor) { + + private int compareTo(final int otherMajor, final int otherMinor) { if(otherMajor == major && otherMinor == minor) { return 0; }else if(this.major > otherMajor || (this.major == otherMajor && this.minor > otherMinor)) { @@ -95,19 +95,19 @@ public class CLVersion implements Comparable<CLVersion> { } } - public boolean isAtLeast(CLVersion other) { + public boolean isAtLeast(final CLVersion other) { return this.compareTo(other) >= 0; } - public boolean isAtLeast(int major, int minor) { + public boolean isAtLeast(final int major, final int minor) { return this.compareTo(major, minor) >= 0; } - public boolean isEqual(CLVersion other) { + public boolean isEqual(final CLVersion other) { return this.isEqual(other.major, other.minor); } - - public boolean isEqual(int major, int minor) { + + public boolean isEqual(final int major, final int minor) { return this.major == major && this.minor == minor; } @@ -161,7 +161,7 @@ public class CLVersion implements Comparable<CLVersion> { * Returns true if both {@link #fullversion} Strings match. */ @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { return obj != null && obj.getClass() == getClass() && fullversion.equals(((CLVersion)obj).fullversion); } diff --git a/src/com/jogamp/opencl/InternalBufferUtil.java b/src/com/jogamp/opencl/InternalBufferUtil.java index 44c6890d..ab2acd9c 100644 --- a/src/com/jogamp/opencl/InternalBufferUtil.java +++ b/src/com/jogamp/opencl/InternalBufferUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -43,9 +43,9 @@ class InternalBufferUtil { static { try { - Field f = Buffer.class.getDeclaredField("address"); + final Field f = Buffer.class.getDeclaredField("address"); - Field[] fields = Unsafe.class.getDeclaredFields(); + final Field[] fields = Unsafe.class.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { if (fields[i].getName().equals("theUnsafe")) { fields[i].setAccessible(true); @@ -55,12 +55,12 @@ class InternalBufferUtil { } addressFieldOffset = unsafe.objectFieldOffset(f); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } } - public static long getDirectBufferAddress(Buffer buffer) { + public static long getDirectBufferAddress(final Buffer buffer) { return ((buffer == null) ? 0 : unsafe.getLong(buffer, addressFieldOffset)); } diff --git a/src/com/jogamp/opencl/JoclVersion.java b/src/com/jogamp/opencl/JoclVersion.java index 206f6356..15e868cf 100644 --- a/src/com/jogamp/opencl/JoclVersion.java +++ b/src/com/jogamp/opencl/JoclVersion.java @@ -47,7 +47,7 @@ public class JoclVersion extends JogampVersion { protected static volatile JoclVersion jogampCommonVersionInfo; - protected JoclVersion(String packageName, Manifest mf) { + protected JoclVersion(final String packageName, final Manifest mf) { super(packageName, mf); } @@ -76,7 +76,7 @@ public class JoclVersion extends JogampVersion { sb.append(Platform.getNewline()); toString(sb); sb.append(Platform.getNewline()); - } catch (Exception e) { + } catch (final Exception e) { sb.append(e.getMessage()); e.printStackTrace(); } @@ -94,7 +94,7 @@ public class JoclVersion extends JogampVersion { final CLPlatform[] platforms; try { platforms = CLPlatform.listCLPlatforms(); - } catch (Throwable t) { + } catch (final Throwable t) { final Throwable cause; { Throwable pre = null; @@ -108,7 +108,7 @@ public class JoclVersion extends JogampVersion { System.err.println("CLPlatform.listCLPlatforms() failed, exception: "+cause.getMessage()); t.printStackTrace(); sb.append("CLPlatform.listCLPlatforms() failed, exception: "+cause.getMessage()); - StringWriter stackTrace = new StringWriter(); + final StringWriter stackTrace = new StringWriter(); cause.printStackTrace(new PrintWriter(stackTrace)); sb.append(stackTrace.toString()); return sb; @@ -119,13 +119,13 @@ public class JoclVersion extends JogampVersion { if( 0 > maxKeyStrlen ) { synchronized(this) { if( 0 > maxKeyStrlen ) { - for (CLPlatform p : platforms) { + for (final CLPlatform p : platforms) { platProps.add(p.getProperties()); final CLDevice[] devices = p.listCLDevices(); - for (CLDevice d : devices) { + for (final CLDevice d : devices) { final Map<String,String> props = d.getProperties(); final Set<Map.Entry<String, String>> entries = props.entrySet(); - for(Map.Entry<String, String> e : entries) { + for(final Map.Entry<String, String> e : entries) { maxKeyStrlen = Math.max(maxKeyStrlen, e.getKey().length()); } } @@ -135,17 +135,17 @@ public class JoclVersion extends JogampVersion { } sb.append(String.format("PP:DD:EE - Platform (PP), Device (DD), Entry (EE)%n")); int pI = 0; - for (CLPlatform p : platforms) { + for (final CLPlatform p : platforms) { pI++; platProps.add(p.getProperties()); - CLDevice[] devices = p.listCLDevices(); + final CLDevice[] devices = p.listCLDevices(); int dI = 0; - for (CLDevice d : devices) { + for (final CLDevice d : devices) { dI++; final Map<String,String> props = d.getProperties(); final Set<Map.Entry<String, String>> entries = props.entrySet(); int eI = 0; - for(Map.Entry<String, String> e : entries) { + for(final Map.Entry<String, String> e : entries) { eI++; sb.append(String.format("%02d:%02d:%02d %"+maxKeyStrlen+"s: %s%n", pI, dI, eI, e.getKey(), e.getValue())); } @@ -162,7 +162,7 @@ public class JoclVersion extends JogampVersion { final CLPlatform[] platforms; try { platforms = CLPlatform.listCLPlatforms(); - } catch (Throwable t) { + } catch (final Throwable t) { final Throwable cause; { Throwable pre = null; @@ -176,7 +176,7 @@ public class JoclVersion extends JogampVersion { System.err.println("CLPlatform.listCLPlatforms() failed, exception: "+cause.getMessage()); t.printStackTrace(); sb.append("<pre>CLPlatform.listCLPlatforms() failed, exception: "+cause.getMessage()); - StringWriter stackTrace = new StringWriter(); + final StringWriter stackTrace = new StringWriter(); cause.printStackTrace(new PrintWriter(stackTrace)); sb.append(stackTrace.toString()).append("</pre>"); return sb; @@ -184,19 +184,19 @@ public class JoclVersion extends JogampVersion { sb.append("<table border=\"1\">"); // platforms - List<Map<String, String>> platProps = new ArrayList<Map<String, String>>(); - List<Integer> spans = new ArrayList<Integer>(); - for (CLPlatform p : platforms) { + final List<Map<String, String>> platProps = new ArrayList<Map<String, String>>(); + final List<Integer> spans = new ArrayList<Integer>(); + for (final CLPlatform p : platforms) { platProps.add(p.getProperties()); spans.add(p.listCLDevices().length); } fillHtmlTable(platProps, spans, sb); // devices - ArrayList<Map<String, String>> devProps = new ArrayList<Map<String, String>>(); - for (CLPlatform p : platforms) { - CLDevice[] devices = p.listCLDevices(); - for (CLDevice d : devices) { + final ArrayList<Map<String, String>> devProps = new ArrayList<Map<String, String>>(); + for (final CLPlatform p : platforms) { + final CLDevice[] devices = p.listCLDevices(); + for (final CLDevice d : devices) { devProps.add(d.getProperties()); } } @@ -206,21 +206,21 @@ public class JoclVersion extends JogampVersion { return sb; } - private static void fillHtmlTable(List<Map<String, String>> properties, StringBuilder sb) { - ArrayList<Integer> spans = new ArrayList<Integer>(properties.size()); + private static void fillHtmlTable(final List<Map<String, String>> properties, final StringBuilder sb) { + final ArrayList<Integer> spans = new ArrayList<Integer>(properties.size()); for (int i = 0; i < properties.size(); i++) { spans.add(1); } fillHtmlTable(properties, spans, sb); } - private static void fillHtmlTable(List<Map<String, String>> properties, List<Integer> spans, StringBuilder sb) { + private static void fillHtmlTable(final List<Map<String, String>> properties, final List<Integer> spans, final StringBuilder sb) { boolean header = true; - for (String key : properties.get(0).keySet()) { + for (final String key : properties.get(0).keySet()) { sb.append("<tr>"); htmlCell(sb, key); int i = 0; - for (Map<String, String> map : properties) { + for (final Map<String, String> map : properties) { htmlCell(sb, spans.get(i), map.get(key), header); i++; } @@ -229,11 +229,11 @@ public class JoclVersion extends JogampVersion { } } - private static void htmlCell(StringBuilder sb, String value) { + private static void htmlCell(final StringBuilder sb, final String value) { sb.append("<td>").append(value).append("</td>"); } - private static void htmlCell(StringBuilder sb, int span, String value, boolean header) { + private static void htmlCell(final StringBuilder sb, final int span, final String value, final boolean header) { if(header) { sb.append("<th colspan=\"").append(span).append("\">").append(value).append("</th>"); }else{ @@ -241,7 +241,7 @@ public class JoclVersion extends JogampVersion { } } - public static void main(String args[]) { + public static void main(final String args[]) { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); // System.err.println(NativeWindowVersion.getInstance()); diff --git a/src/com/jogamp/opencl/gl/CLGLBuffer.java b/src/com/jogamp/opencl/gl/CLGLBuffer.java index a9fc49cd..59aacd9f 100644 --- a/src/com/jogamp/opencl/gl/CLGLBuffer.java +++ b/src/com/jogamp/opencl/gl/CLGLBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -50,25 +50,25 @@ public final class CLGLBuffer<B extends Buffer> extends CLBuffer<B> implements C */ public final int GLID; - private CLGLBuffer(CLContext context, B directBuffer, long id, int glObject, long size, int flags) { + private CLGLBuffer(final CLContext context, final B directBuffer, final long id, final int glObject, final long size, final int flags) { super(context, directBuffer, size, id, flags); this.GLID = glObject; } - static <B extends Buffer> CLGLBuffer<B> create(CLContext context, B directBuffer, long size, int flags, int glBuffer) { + static <B extends Buffer> CLGLBuffer<B> create(final CLContext context, final B directBuffer, final long size, final int flags, final int glBuffer) { checkBuffer(directBuffer, flags); - - CLGL clgli = (CLGL)getCL(context); - - int[] result = new int[1]; - long id = clgli.clCreateFromGLBuffer(context.ID, flags, glBuffer, result, 0); + + final CLGL clgli = (CLGL)getCL(context); + + final int[] result = new int[1]; + final long id = clgli.clCreateFromGLBuffer(context.ID, flags, glBuffer, result, 0); CLException.checkForError(result[0], "can not create CLGLObject from glBuffer #"+glBuffer); return new CLGLBuffer<B>(context, directBuffer, id, glBuffer, size, flags); } - static <B extends Buffer> void checkBuffer(B directBuffer, int flags) throws IllegalArgumentException { + static <B extends Buffer> void checkBuffer(final B directBuffer, final int flags) throws IllegalArgumentException { if (directBuffer != null && !directBuffer.isDirect()) { throw new IllegalArgumentException("buffer is not a direct buffer"); } @@ -108,7 +108,7 @@ public final class CLGLBuffer<B extends Buffer> extends CLBuffer<B> implements C } @Override - public <T extends Buffer> CLGLBuffer<T> cloneWith(T directBuffer) { + public <T extends Buffer> CLGLBuffer<T> cloneWith(final T directBuffer) { return new CLGLBuffer<T>(context, directBuffer, ID, GLID, size, FLAGS); } diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java index e99e7ac4..2564a82d 100644 --- a/src/com/jogamp/opencl/gl/CLGLContext.java +++ b/src/com/jogamp/opencl/gl/CLGLContext.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -44,6 +44,8 @@ import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLMemory.Mem; import com.jogamp.opencl.CLPlatform; +import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLContextBinding; import com.jogamp.opencl.llb.gl.CLGL; /** @@ -55,7 +57,7 @@ public final class CLGLContext extends CLContext { final long glID; private final GLContext glContext; - private CLGLContext(CLPlatform platform, GLContext glContext, long clContextID, long glContextID, ErrorDispatcher dispatcher) { + private CLGLContext(final CLPlatform platform, final GLContext glContext, final long clContextID, final long glContextID, final ErrorDispatcher dispatcher) { super(platform, clContextID, dispatcher); this.glID = glContextID; this.glContext = glContext; @@ -65,7 +67,7 @@ public final class CLGLContext extends CLContext { * Creates a shared context on all available devices (CL_DEVICE_TYPE_ALL). * @see GLContext#makeCurrent() */ - public static CLGLContext create(GLContext glContext) { + public static CLGLContext create(final GLContext glContext) { return create(glContext, (CLPlatform)null, CLDevice.Type.ALL); } @@ -73,7 +75,7 @@ public final class CLGLContext extends CLContext { * Creates a shared context on the specified platform on all available devices (CL_DEVICE_TYPE_ALL). * @see GLContext#makeCurrent() */ - public static CLGLContext create(GLContext glContext, CLPlatform platform) { + public static CLGLContext create(final GLContext glContext, final CLPlatform platform) { return create(glContext, platform, CLDevice.Type.ALL); } @@ -82,7 +84,7 @@ public final class CLGLContext extends CLContext { * device types. * @see GLContext#makeCurrent() */ - public static CLGLContext create(GLContext glContext, CLDevice.Type... deviceTypes) { + public static CLGLContext create(final GLContext glContext, final CLDevice.Type... deviceTypes) { return create(glContext, null, deviceTypes); } @@ -91,16 +93,16 @@ public final class CLGLContext extends CLContext { * device types. * @see GLContext#makeCurrent() */ - public static CLGLContext create(GLContext glContext, CLPlatform platform, CLDevice.Type... deviceTypes) { + public static CLGLContext create(final GLContext glContext, CLPlatform platform, final CLDevice.Type... deviceTypes) { if(platform == null) { platform = CLPlatform.getDefault(); } - long[] glID = new long[1]; - PointerBuffer properties = setupContextProperties(platform, glContext, glID); - ErrorDispatcher dispatcher = createErrorHandler(); - long clID = createContextFromType(platform, dispatcher, properties, toDeviceBitmap(deviceTypes)); + final long[] glID = new long[1]; + final PointerBuffer properties = setupContextProperties(platform, glContext, glID); + final ErrorDispatcher dispatcher = createErrorHandler(); + final long clID = createContextFromType(platform, dispatcher, properties, toDeviceBitmap(deviceTypes)); return new CLGLContext(platform, glContext, clID, glID[0], dispatcher); @@ -111,7 +113,7 @@ public final class CLGLContext extends CLContext { * devices. * @see GLContext#makeCurrent() */ - public static CLGLContext create(GLContext glContext, CLDevice... devices) { + public static CLGLContext create(final GLContext glContext, final CLDevice... devices) { if(devices == null) { throw new IllegalArgumentException("no devices specified"); @@ -119,14 +121,14 @@ public final class CLGLContext extends CLContext { throw new IllegalArgumentException("first device was null"); } - CLPlatform platform = devices[0].getPlatform(); + final CLPlatform platform = devices[0].getPlatform(); - long[] glID = new long[1]; - PointerBuffer properties = setupContextProperties(platform, glContext, glID); - ErrorDispatcher dispatcher = createErrorHandler(); - long clID = createContext(platform, dispatcher, properties, devices); + final long[] glID = new long[1]; + final PointerBuffer properties = setupContextProperties(platform, glContext, glID); + final ErrorDispatcher dispatcher = createErrorHandler(); + final long clID = createContext(platform, dispatcher, properties, devices); - CLGLContext context = new CLGLContext(platform, glContext, clID, glID[0], dispatcher); + final CLGLContext context = new CLGLContext(platform, glContext, clID, glID[0], dispatcher); if(devices != null) { for (int i = 0; i < devices.length; i++) { context.overrideContext(devices[i]); @@ -136,7 +138,7 @@ public final class CLGLContext extends CLContext { } - private static PointerBuffer setupContextProperties(CLPlatform platform, GLContext glContext, long[] glID) { + private static PointerBuffer setupContextProperties(final CLPlatform platform, final GLContext glContext, final long[] glID) { if(platform == null) { throw new RuntimeException("no OpenCL installation found"); @@ -151,7 +153,7 @@ public final class CLGLContext extends CLContext { " creating a OpenCL context for context sharing is not allowed in this situation."); } - GLContextImpl ctxImpl = (GLContextImpl)glContext; + final GLContextImpl ctxImpl = (GLContextImpl)glContext; glID[0] = glContext.getHandle(); PointerBuffer properties; @@ -162,36 +164,36 @@ public final class CLGLContext extends CLContext { // set to the Display handle of the X Window System display used to // create the OpenGL context." properties = PointerBuffer.allocateDirect(7); - long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); + final long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); properties.put(CLGL.CL_GL_CONTEXT_KHR).put(glID[0]) - .put(CLGL.CL_GLX_DISPLAY_KHR).put(displayHandle) - .put(CLGL.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CL.CL_GLX_DISPLAY_KHR).put(displayHandle) + .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); }else if(glContext instanceof WindowsWGLContext) { // spec: "When the WGL binding API is supported, the attribute // CL_GL_CONTEXT_KHR should be set to an HGLRC handle to an OpenGL // context, and the attribute CL_WGL_HDC_KHR should be set to the // HDC handle of the display used to create the OpenGL context." properties = PointerBuffer.allocateDirect(7); - long surfaceHandle = ctxImpl.getDrawableImpl().getNativeSurface().getSurfaceHandle(); + final long surfaceHandle = ctxImpl.getDrawableImpl().getNativeSurface().getSurfaceHandle(); properties.put(CLGL.CL_GL_CONTEXT_KHR).put(glID[0]) - .put(CLGL.CL_WGL_HDC_KHR).put(surfaceHandle) - .put(CLGL.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CL.CL_WGL_HDC_KHR).put(surfaceHandle) + .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); }else if(glContext instanceof MacOSXCGLContext) { // spec: "When the CGL binding API is supported, the attribute // CL_CGL_SHAREGROUP_KHR should be set to a CGLShareGroup handle to // a CGL share group object." /** - * FIXME: For all Mac OSX Versions ??? - * CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE used to specify the GL sharing group ID - * on Mac OSX 10.8.4 works. - * Using the std. CL_CGL_SHAREGROUP_KHR on Mac OSX 10.8.4 causes the context creation + * FIXME: For all Mac OSX Versions ??? + * CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE used to specify the GL sharing group ID + * on Mac OSX 10.8.4 works. + * Using the std. CL_CGL_SHAREGROUP_KHR on Mac OSX 10.8.4 causes the context creation * to throw a CL_INVALID_VALUE error. */ - long cgl = CGL.getCGLContext(glID[0]); - long group = CGL.CGLGetShareGroup(cgl); + final long cgl = CGL.getCGLContext(glID[0]); + final long group = CGL.CGLGetShareGroup(cgl); properties = PointerBuffer.allocateDirect(5); properties.put(CLGL.CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE).put(group) - .put(CLGL.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); }else if(glContext instanceof EGLContext) { // TODO test EGL // spec: "When the EGL binding API is supported, the attribute @@ -200,17 +202,17 @@ public final class CLGLContext extends CLContext { // CL_EGL_DISPLAY_KHR should be set to the EGLDisplay handle of the // display used to create the OpenGL ES or OpenGL context." properties = PointerBuffer.allocateDirect(7); - long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); + final long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); properties.put(CLGL.CL_GL_CONTEXT_KHR).put(glID[0]) - .put(CLGL.CL_EGL_DISPLAY_KHR).put(displayHandle) - .put(CLGL.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CL.CL_EGL_DISPLAY_KHR).put(displayHandle) + .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); }else{ throw new RuntimeException("unsupported GLContext: "+glContext); } return properties.put(0).rewind(); // 0 terminated array } - + // Buffers /** * Creates a CLGLBuffer for memory sharing with the specified OpenGL buffer. @@ -218,7 +220,7 @@ public final class CLGLContext extends CLContext { * @param glBufferSize The size of the OpenGL buffer in bytes * @param flags optional flags. */ - public final CLGLBuffer<?> createFromGLBuffer(int glBuffer, long glBufferSize, Mem... flags) { + public final CLGLBuffer<?> createFromGLBuffer(final int glBuffer, final long glBufferSize, final Mem... flags) { return createFromGLBuffer(null, glBuffer, glBufferSize, Mem.flagsToInt(flags)); } @@ -228,7 +230,7 @@ public final class CLGLContext extends CLContext { * @param glBufferSize The size of the OpenGL buffer in bytes * @param flags optional flags. */ - public final CLGLBuffer<?> createFromGLBuffer(int glBuffer, long glBufferSize, int flags) { + public final CLGLBuffer<?> createFromGLBuffer(final int glBuffer, final long glBufferSize, final int flags) { return createFromGLBuffer(null, glBuffer, glBufferSize, flags); } @@ -239,7 +241,7 @@ public final class CLGLContext extends CLContext { * @param glBufferSize The size of the OpenGL buffer in bytes * @param flags optional flags. */ - public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(B directBuffer, int glBuffer, long glBufferSize, Mem... flags) { + public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(final B directBuffer, final int glBuffer, final long glBufferSize, final Mem... flags) { return createFromGLBuffer(directBuffer, glBuffer, glBufferSize, Mem.flagsToInt(flags)); } @@ -250,65 +252,65 @@ public final class CLGLContext extends CLContext { * @param glBufferSize The size of the OpenGL buffer in bytes * @param flags optional flags. */ - public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(B directBuffer, int glBuffer, long glBufferSize, int flags) { - CLGLBuffer<B> buffer = CLGLBuffer.create(this, directBuffer, glBufferSize, flags, glBuffer); + public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(final B directBuffer, final int glBuffer, final long glBufferSize, final int flags) { + final CLGLBuffer<B> buffer = CLGLBuffer.create(this, directBuffer, glBufferSize, flags, glBuffer); memoryObjects.add(buffer); return buffer; } // Renderbuffers - public final CLGLImage2d<?> createFromGLRenderbuffer(int glBuffer, Mem... flags) { + public final CLGLImage2d<?> createFromGLRenderbuffer(final int glBuffer, final Mem... flags) { return createFromGLRenderbuffer(null, glBuffer, Mem.flagsToInt(flags)); } - public final CLGLImage2d<?> createFromGLRenderbuffer(int glBuffer, int flags) { + public final CLGLImage2d<?> createFromGLRenderbuffer(final int glBuffer, final int flags) { return createFromGLRenderbuffer(null, glBuffer, flags); } - public final <B extends Buffer> CLGLImage2d<B> createFromGLRenderbuffer(B directBuffer, int glBuffer, Mem... flags) { + public final <B extends Buffer> CLGLImage2d<B> createFromGLRenderbuffer(final B directBuffer, final int glBuffer, final Mem... flags) { return createFromGLRenderbuffer(directBuffer, glBuffer, Mem.flagsToInt(flags)); } - public final <B extends Buffer> CLGLImage2d<B> createFromGLRenderbuffer(B directBuffer, int glBuffer, int flags) { - CLGLImage2d<B> buffer = CLGLImage2d.createFromGLRenderbuffer(this, directBuffer, flags, glBuffer); + public final <B extends Buffer> CLGLImage2d<B> createFromGLRenderbuffer(final B directBuffer, final int glBuffer, final int flags) { + final CLGLImage2d<B> buffer = CLGLImage2d.createFromGLRenderbuffer(this, directBuffer, flags, glBuffer); memoryObjects.add(buffer); return buffer; } //2d Textures - public final CLGLTexture2d<?> createFromGLTexture2d(int target, int texture, int mipmap, Mem... flags) { + public final CLGLTexture2d<?> createFromGLTexture2d(final int target, final int texture, final int mipmap, final Mem... flags) { return createFromGLTexture2d(null, target, texture, mipmap, Mem.flagsToInt(flags)); } - public final CLGLTexture2d<?> createFromGLTexture2d(int target, int texture, int mipmap, int flags) { + public final CLGLTexture2d<?> createFromGLTexture2d(final int target, final int texture, final int mipmap, final int flags) { return createFromGLTexture2d(null, target, texture, mipmap, flags); } - public final <B extends Buffer> CLGLTexture2d<B> createFromGLTexture2d(B directBuffer, int target, int texture, int mipmap, Mem... flags) { + public final <B extends Buffer> CLGLTexture2d<B> createFromGLTexture2d(final B directBuffer, final int target, final int texture, final int mipmap, final Mem... flags) { return createFromGLTexture2d(directBuffer, target, texture, mipmap, Mem.flagsToInt(flags)); } - public final <B extends Buffer> CLGLTexture2d<B> createFromGLTexture2d(B directBuffer, int target, int texture, int mipmap, int flags) { - CLGLTexture2d<B> buffer = CLGLTexture2d.createFromGLTexture2d(this, directBuffer, target, texture, mipmap, flags); + public final <B extends Buffer> CLGLTexture2d<B> createFromGLTexture2d(final B directBuffer, final int target, final int texture, final int mipmap, final int flags) { + final CLGLTexture2d<B> buffer = CLGLTexture2d.createFromGLTexture2d(this, directBuffer, target, texture, mipmap, flags); memoryObjects.add(buffer); return buffer; } //3d Textures - public final CLGLTexture3d<?> createFromGLTexture3d(int target, int texture, int mipmap, Mem... flags) { + public final CLGLTexture3d<?> createFromGLTexture3d(final int target, final int texture, final int mipmap, final Mem... flags) { return createFromGLTexture3d(null, target, texture, mipmap, Mem.flagsToInt(flags)); } - public final CLGLTexture3d<?> createFromGLTexture3d(int target, int texture, int mipmap, int flags) { + public final CLGLTexture3d<?> createFromGLTexture3d(final int target, final int texture, final int mipmap, final int flags) { return createFromGLTexture3d(null, target, texture, mipmap, flags); } - public final <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(B directBuffer, int target, int texture, int mipmap, Mem... flags) { + public final <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(final B directBuffer, final int target, final int texture, final int mipmap, final Mem... flags) { return createFromGLTexture3d(directBuffer, target, texture, mipmap, Mem.flagsToInt(flags)); } - public final <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(B directBuffer, int target, int texture, int mipmap, int flags) { - CLGLTexture3d<B> buffer = CLGLTexture3d.createFromGLTexture3d(this, directBuffer, flags, target, mipmap, texture); + public final <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(final B directBuffer, final int target, final int texture, final int mipmap, final int flags) { + final CLGLTexture3d<B> buffer = CLGLTexture3d.createFromGLTexture3d(this, directBuffer, flags, target, mipmap, texture); memoryObjects.add(buffer); return buffer; } diff --git a/src/com/jogamp/opencl/gl/CLGLImage2d.java b/src/com/jogamp/opencl/gl/CLGLImage2d.java index 954a2334..19cd51bf 100644 --- a/src/com/jogamp/opencl/gl/CLGLImage2d.java +++ b/src/com/jogamp/opencl/gl/CLGLImage2d.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -29,6 +29,7 @@ package com.jogamp.opencl.gl; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLImageBinding; import com.jogamp.opencl.llb.gl.CLGL; import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLException; @@ -51,33 +52,33 @@ public class CLGLImage2d<B extends Buffer> extends CLImage2d<B> implements CLGLO */ public final int GLID; - protected CLGLImage2d(CLContext context, B directBuffer, CLImageFormat format, CLImageInfoAccessor accessor, int width, int height, long id, int glid, int flags) { + protected CLGLImage2d(final CLContext context, final B directBuffer, final CLImageFormat format, final CLImageInfoAccessor accessor, final int width, final int height, final long id, final int glid, final int flags) { super(context, directBuffer, format, accessor, width, height, id, flags); this.GLID = glid; } - static <B extends Buffer> CLGLImage2d<B> createFromGLRenderbuffer(CLContext context, B directBuffer, int flags, int renderbuffer) { + static <B extends Buffer> CLGLImage2d<B> createFromGLRenderbuffer(final CLContext context, final B directBuffer, final int flags, final int renderbuffer) { CLGLBuffer.checkBuffer(directBuffer, flags); - CL cl = getCL(context); - int[] result = new int[1]; - CLGL clgli = (CLGL)cl; + final CL cl = getCL(context); + final int[] result = new int[1]; + final CLGL clgli = (CLGL)cl; - long id = clgli.clCreateFromGLRenderbuffer(context.ID, flags, renderbuffer, result, 0); + final long id = clgli.clCreateFromGLRenderbuffer(context.ID, flags, renderbuffer, result, 0); CLException.checkForError(result[0], "can not create CLGLImage2d from renderbuffer #"+renderbuffer+"."); return createImage(context, id, directBuffer, renderbuffer, flags); } - static <B extends Buffer> CLGLImage2d<B> createImage(CLContext context, long id, B directBuffer, int glObject, int flags) { - CLImageInfoAccessor accessor = new CLImageInfoAccessor(getCL(context), id); + static <B extends Buffer> CLGLImage2d<B> createImage(final CLContext context, final long id, final B directBuffer, final int glObject, final int flags) { + final CLImageInfoAccessor accessor = new CLImageInfoAccessor(getCL(context), id); - CLImageFormat format = createUninitializedImageFormat(); - accessor.getInfo(CL.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); + final CLImageFormat format = createUninitializedImageFormat(); + accessor.getInfo(CLImageBinding.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); - int width = (int)accessor.getLong(CL.CL_IMAGE_WIDTH); - int height = (int)accessor.getLong(CL.CL_IMAGE_HEIGHT); + final int width = (int)accessor.getLong(CLImageBinding.CL_IMAGE_WIDTH); + final int height = (int)accessor.getLong(CLImageBinding.CL_IMAGE_HEIGHT); return new CLGLImage2d<B>(context, directBuffer, format, accessor, width, height, id, glObject, flags); } diff --git a/src/com/jogamp/opencl/gl/CLGLObject.java b/src/com/jogamp/opencl/gl/CLGLObject.java index a9bad53d..6e86a810 100644 --- a/src/com/jogamp/opencl/gl/CLGLObject.java +++ b/src/com/jogamp/opencl/gl/CLGLObject.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -54,7 +54,7 @@ public interface CLGLObject { * Returns the OpenGL buffer type of this shared object. */ public GLObjectType getGLObjectType(); - + /** * Returns the OpenCL context of this shared object. */ diff --git a/src/com/jogamp/opencl/gl/CLGLTexture.java b/src/com/jogamp/opencl/gl/CLGLTexture.java index f4f90c33..7af41754 100644 --- a/src/com/jogamp/opencl/gl/CLGLTexture.java +++ b/src/com/jogamp/opencl/gl/CLGLTexture.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. diff --git a/src/com/jogamp/opencl/gl/CLGLTexture2d.java b/src/com/jogamp/opencl/gl/CLGLTexture2d.java index 64ac4e0b..30b8164e 100644 --- a/src/com/jogamp/opencl/gl/CLGLTexture2d.java +++ b/src/com/jogamp/opencl/gl/CLGLTexture2d.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -29,6 +29,7 @@ package com.jogamp.opencl.gl; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLImageBinding; import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLException; import com.jogamp.opencl.CLImageFormat; @@ -44,33 +45,33 @@ import java.nio.Buffer; public class CLGLTexture2d<B extends Buffer> extends CLGLImage2d<B> implements CLGLTexture { public final int target; - + public final int mipMapLevel; - public CLGLTexture2d(CLContext context, B directBuffer, CLImageFormat format, CLImageInfoAccessor accessor, int target, int mipLevel, int width, int height, long id, int glid, int flags) { + public CLGLTexture2d(final CLContext context, final B directBuffer, final CLImageFormat format, final CLImageInfoAccessor accessor, final int target, final int mipLevel, final int width, final int height, final long id, final int glid, final int flags) { super(context, directBuffer, format, accessor, width, height, id, glid, flags); this.target = target; this.mipMapLevel = mipLevel; } - static <B extends Buffer> CLGLTexture2d<B> createFromGLTexture2d(CLContext context, B directBuffer, int target, int texture, int mipLevel, int flags) { + static <B extends Buffer> CLGLTexture2d<B> createFromGLTexture2d(final CLContext context, final B directBuffer, final int target, final int texture, final int mipLevel, final int flags) { CLGLBuffer.checkBuffer(directBuffer, flags); - CL cl = getCL(context); - int[] result = new int[1]; - CLGL clgli = (CLGL)cl; + final CL cl = getCL(context); + final int[] result = new int[1]; + final CLGL clgli = (CLGL)cl; - long id = clgli.clCreateFromGLTexture2D(context.ID, flags, target, mipLevel, texture, result, 0); + final long id = clgli.clCreateFromGLTexture2D(context.ID, flags, target, mipLevel, texture, result, 0); CLException.checkForError(result[0], "can not create CLGLTexture2d from texture #"+texture+"."); - CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id); + final CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id); - CLImageFormat format = createUninitializedImageFormat(); - accessor.getInfo(CL.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); + final CLImageFormat format = createUninitializedImageFormat(); + accessor.getInfo(CLImageBinding.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); - int width = (int)accessor.getLong(CL.CL_IMAGE_WIDTH); - int height = (int)accessor.getLong(CL.CL_IMAGE_HEIGHT); + final int width = (int)accessor.getLong(CLImageBinding.CL_IMAGE_WIDTH); + final int height = (int)accessor.getLong(CLImageBinding.CL_IMAGE_HEIGHT); return new CLGLTexture2d<B>(context, directBuffer, format, accessor, target, mipLevel, width, height, id, texture, flags); diff --git a/src/com/jogamp/opencl/gl/CLGLTexture3d.java b/src/com/jogamp/opencl/gl/CLGLTexture3d.java index fdc2ba79..6d832479 100644 --- a/src/com/jogamp/opencl/gl/CLGLTexture3d.java +++ b/src/com/jogamp/opencl/gl/CLGLTexture3d.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -30,6 +30,7 @@ package com.jogamp.opencl.gl; import com.jogamp.opencl.llb.gl.CLGL; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLImageBinding; import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLException; import com.jogamp.opencl.CLImage3d; @@ -52,35 +53,35 @@ public class CLGLTexture3d<B extends Buffer> extends CLImage3d<B> implements CLG public final int GLID; public final int target; - + public final int mipMapLevel; - private CLGLTexture3d(CLContext context, B directBuffer, CLImageFormat format, CLImageInfoAccessor accessor, int target, int mipLevel, int width, int height, int depth, long id, int glid, int flags) { + private CLGLTexture3d(final CLContext context, final B directBuffer, final CLImageFormat format, final CLImageInfoAccessor accessor, final int target, final int mipLevel, final int width, final int height, final int depth, final long id, final int glid, final int flags) { super(context, directBuffer, format, accessor, width, height, depth, id, flags); this.GLID = glid; this.target = target; this.mipMapLevel = mipLevel; } - static <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(CLContext context, B directBuffer, int flags, int target, int mipLevel, int texture) { + static <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(final CLContext context, final B directBuffer, final int flags, final int target, final int mipLevel, final int texture) { CLGLBuffer.checkBuffer(directBuffer, flags); - CL cl = getCL(context); - int[] result = new int[1]; - CLGL clgli = (CLGL)cl; + final CL cl = getCL(context); + final int[] result = new int[1]; + final CLGL clgli = (CLGL)cl; - long id = clgli.clCreateFromGLTexture3D(context.ID, flags, target, mipLevel, texture, result, 0); + final long id = clgli.clCreateFromGLTexture3D(context.ID, flags, target, mipLevel, texture, result, 0); CLException.checkForError(result[0], "can not create CLGLTexture3d from texture #"+texture+"."); - CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id); + final CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id); - CLImageFormat format = createUninitializedImageFormat(); - accessor.getInfo(CL.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); + final CLImageFormat format = createUninitializedImageFormat(); + accessor.getInfo(CLImageBinding.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); - int width = (int)accessor.getLong(CL.CL_IMAGE_WIDTH); - int height = (int)accessor.getLong(CL.CL_IMAGE_HEIGHT); - int depth = (int)accessor.getLong(CL.CL_IMAGE_DEPTH); + final int width = (int)accessor.getLong(CLImageBinding.CL_IMAGE_WIDTH); + final int height = (int)accessor.getLong(CLImageBinding.CL_IMAGE_HEIGHT); + final int depth = (int)accessor.getLong(CLImageBinding.CL_IMAGE_DEPTH); return new CLGLTexture3d<B>(context, directBuffer, format, accessor, target, mipLevel, width, height, depth, id, texture, flags); } diff --git a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java index e0bd7bd5..8422c4ad 100644 --- a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java +++ b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -50,12 +50,12 @@ import static com.jogamp.opencl.CLException.*; public class CLTLAccessorFactory implements CLAccessorFactory { @Override - public CLInfoAccessor createDeviceInfoAccessor(CLDeviceBinding cl, long id) { + public CLInfoAccessor createDeviceInfoAccessor(final CLDeviceBinding cl, final long id) { return new CLDeviceInfoAccessor(cl, id); } @Override - public CLPlatformInfoAccessor createPlatformInfoAccessor(CL cl, long id) { + public CLPlatformInfoAccessor createPlatformInfoAccessor(final CL cl, final long id) { return new CLTLPlatformInfoAccessor(cl, id); } @@ -64,13 +64,13 @@ public class CLTLAccessorFactory implements CLAccessorFactory { private final CLDeviceBinding cl; private final long ID; - private CLDeviceInfoAccessor(CLDeviceBinding cl, long id) { + private CLDeviceInfoAccessor(final CLDeviceBinding cl, final long id) { this.cl = cl; this.ID = id; } @Override - public int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { + public int getInfo(final int name, final long valueSize, final Buffer value, final PointerBuffer valueSizeRet) { return cl.clGetDeviceInfo(ID, name, valueSize, value, valueSizeRet); } @@ -81,34 +81,34 @@ public class CLTLAccessorFactory implements CLAccessorFactory { private final long ID; private final CL cl; - private CLTLPlatformInfoAccessor(CL cl, long id) { + private CLTLPlatformInfoAccessor(final CL cl, final long id) { this.ID = id; this.cl = cl; } @Override - public int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { + public int getInfo(final int name, final long valueSize, final Buffer value, final PointerBuffer valueSizeRet) { return cl.clGetPlatformInfo(ID, name, valueSize, value, valueSizeRet); } @Override - public long[] getDeviceIDs(long type) { + public long[] getDeviceIDs(final long type) { - IntBuffer buffer = getBB(4).asIntBuffer(); + final IntBuffer buffer = getBB(4).asIntBuffer(); int ret = cl.clGetDeviceIDs(ID, type, 0, null, buffer); - int count = buffer.get(0); + final int count = buffer.get(0); // return an empty buffer rather than throwing an exception - if(ret == CL.CL_DEVICE_NOT_FOUND || count == 0) { + if(ret == CLDeviceBinding.CL_DEVICE_NOT_FOUND || count == 0) { return new long[0]; }else{ checkForError(ret, "error while enumerating devices"); - PointerBuffer deviceIDs = PointerBuffer.wrap(getBB(count*PointerBuffer.ELEMENT_SIZE)); + final PointerBuffer deviceIDs = PointerBuffer.wrap(getBB(count*PointerBuffer.ELEMENT_SIZE)); ret = cl.clGetDeviceIDs(ID, type, count, deviceIDs, null); checkForError(ret, "error while enumerating devices"); - long[] ids = new long[count]; + final long[] ids = new long[count]; for (int i = 0; i < ids.length; i++) { ids[i] = deviceIDs.get(i); } diff --git a/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java b/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java index f1419c7b..2cdec77b 100644 --- a/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java +++ b/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java @@ -66,7 +66,7 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor { }; @Override - public final long getUInt32Long(int key) { + public final long getUInt32Long(final int key) { final ByteBuffer buffer = getBB(4).putInt(0, 0); final int ret = getInfo(key, 4, buffer, null); CLException.checkForError(ret, "error while asking for info value"); @@ -74,29 +74,29 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor { } @Override - public final long getLong(int key) { + public final long getLong(final int key) { - ByteBuffer buffer = getBB(8).putLong(0, 0); - int ret = getInfo(key, 8, buffer, null); + final ByteBuffer buffer = getBB(8).putLong(0, 0); + final int ret = getInfo(key, 8, buffer, null); CLException.checkForError(ret, "error while asking for info value"); return buffer.getLong(0); } @Override - public final String getString(int key) { + public final String getString(final int key) { - PointerBuffer sizeBuffer = getNSB(); + final PointerBuffer sizeBuffer = getNSB(); int ret = getInfo(key, 0, null, sizeBuffer); CLException.checkForError(ret, "error while asking for info string"); - int clSize = (int)sizeBuffer.get(0); - ByteBuffer buffer = getBB(clSize); + final int clSize = (int)sizeBuffer.get(0); + final ByteBuffer buffer = getBB(clSize); ret = getInfo(key, buffer.capacity(), buffer, null); CLException.checkForError(ret, "error while asking for info string"); - byte[] array = new byte[clSize]; + final byte[] array = new byte[clSize]; buffer.get(array).rewind(); return CLUtil.clString2JavaString(array, clSize); @@ -104,13 +104,13 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor { } @Override - public final int[] getInts(int key, int n) { + public final int[] getInts(final int key, final int n) { // FIXME: Really 8 bytes per int on 64bit platforms ? - ByteBuffer buffer = getBB(n * (Platform.is32Bit()?4:8)); - int ret = getInfo(key, buffer.capacity(), buffer, null); + final ByteBuffer buffer = getBB(n * (Platform.is32Bit()?4:8)); + final int ret = getInfo(key, buffer.capacity(), buffer, null); CLException.checkForError(ret, "error while asking for info value"); - int[] array = new int[n]; + final int[] array = new int[n]; for(int i = 0; i < array.length; i++) { if(Platform.is32Bit()) { array[i] = buffer.getInt(); @@ -123,7 +123,7 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor { return array; } - protected ByteBuffer getBB(int minCapacity) { + protected ByteBuffer getBB(final int minCapacity) { if(minCapacity > BB_SIZE) { return Buffers.newDirectByteBuffer(minCapacity); }else{ diff --git a/src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java b/src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java index 51bde322..58806610 100644 --- a/src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java +++ b/src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -43,5 +43,5 @@ public interface BuildProgramCallback { * has been built (successfully or unsuccessfully). */ public void buildFinished(long cl_program); - + } diff --git a/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java b/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java index 19d89fc1..517e1002 100644 --- a/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java +++ b/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java @@ -39,6 +39,8 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.*; +import jogamp.common.os.PlatformPropsImpl; + public final class CLDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { private static final boolean isAndroid; private static final List<String> glueLibNames; @@ -55,7 +57,7 @@ public final class CLDynamicLibraryBundleInfo implements DynamicLibraryBundleInf return null; } }); - isAndroid = Platform.OSType.ANDROID == Platform.OS_TYPE; + isAndroid = Platform.OSType.ANDROID == PlatformPropsImpl.OS_TYPE; glueLibNames = new ArrayList<String>(); glueLibNames.add("jocl"); @@ -95,7 +97,7 @@ public final class CLDynamicLibraryBundleInfo implements DynamicLibraryBundleInf @Override public final List<List<String>> getToolLibNames() { - List<List<String>> libNamesList = new ArrayList<List<String>>(); + final List<List<String>> libNamesList = new ArrayList<List<String>>(); final List<String> libCL = new ArrayList<String>(); { @@ -126,7 +128,7 @@ public final class CLDynamicLibraryBundleInfo implements DynamicLibraryBundleInf @Override public final List<String> getToolGetProcAddressFuncNameList() { - List<String> res = new ArrayList<String>(); + final List<String> res = new ArrayList<String>(); res.add("clGetExtensionFunctionAddress"); return res; } @@ -141,13 +143,13 @@ public final class CLDynamicLibraryBundleInfo implements DynamicLibraryBundleInf funcName = funcName.substring(0, funcName.length() - Impl_len); } if( funcName.endsWith("KHR") || funcName.endsWith("EXT") ) { - return CLImpl.clGetExtensionFunctionAddress(toolGetProcAddressHandle, funcName); + return CLAbstractImpl.clGetExtensionFunctionAddress(toolGetProcAddressHandle, funcName); } return 0; // on libs .. } @Override - public final boolean useToolGetProcAdressFirst(String funcName) { + public final boolean useToolGetProcAdressFirst(final String funcName) { return true; } diff --git a/src/com/jogamp/opencl/llb/impl/CLEventCallback.java b/src/com/jogamp/opencl/llb/impl/CLEventCallback.java index 1373995a..352e02a3 100644 --- a/src/com/jogamp/opencl/llb/impl/CLEventCallback.java +++ b/src/com/jogamp/opencl/llb/impl/CLEventCallback.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. diff --git a/src/com/jogamp/opencl/llb/impl/CLImpl.java b/src/com/jogamp/opencl/llb/impl/CLImpl.java index 57d45dfc..6eb9cde5 100644 --- a/src/com/jogamp/opencl/llb/impl/CLImpl.java +++ b/src/com/jogamp/opencl/llb/impl/CLImpl.java @@ -56,7 +56,7 @@ public class CLImpl extends CLAbstractImpl { } @Override - public long clCreateContext(PointerBuffer properties, PointerBuffer devices, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { + public long clCreateContext(final PointerBuffer properties, final PointerBuffer devices, final CLErrorHandler pfn_notify, final IntBuffer errcode_ret) { if (properties != null && !properties.isDirect()) { throw new RuntimeException("Argument \"properties\" was not a direct buffer"); @@ -71,8 +71,8 @@ public class CLImpl extends CLAbstractImpl { throw new UnsupportedOperationException("Method not available"); } - long[] global = new long[1]; - long ctx = this.clCreateContext0( + final long[] global = new long[1]; + final long ctx = this.clCreateContext0( properties != null ? properties.getBuffer() : null, getDirectBufferByteOffset(properties), devices != null ? devices.remaining() : 0, devices != null ? devices.getBuffer() : null, getDirectBufferByteOffset(devices), pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret), address); @@ -88,7 +88,7 @@ public class CLImpl extends CLAbstractImpl { private native long clCreateContext0(Object cl_context_properties, int props_offset, int numDevices, Object devices, int devices_offset, Object pfn_notify, long[] global, Object errcode_ret, int err_offset, long address); @Override - public long clCreateContextFromType(PointerBuffer properties, long device_type, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { + public long clCreateContextFromType(final PointerBuffer properties, final long device_type, final CLErrorHandler pfn_notify, final IntBuffer errcode_ret) { if (properties != null && !properties.isDirect()) { throw new RuntimeException("Argument \"properties\" was not a direct buffer"); } @@ -102,8 +102,8 @@ public class CLImpl extends CLAbstractImpl { throw new UnsupportedOperationException("Method not available"); } - long[] global = new long[1]; - long ctx = this.clCreateContextFromType0( + final long[] global = new long[1]; + final long ctx = this.clCreateContextFromType0( properties != null ? properties.getBuffer() : null, getDirectBufferByteOffset(properties), device_type, pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret), address); @@ -118,7 +118,7 @@ public class CLImpl extends CLAbstractImpl { private native long clCreateContextFromType0(Object properties, int props_offset, long device_type, Object pfn_notify, long[] global, Object errcode_ret, int err_offset, long address); @Override - public int clReleaseContext(long context) { + public int clReleaseContext(final long context) { long global = 0; synchronized (contextCallbackMap) { global = contextCallbackMap.remove(context); @@ -136,7 +136,7 @@ public class CLImpl extends CLAbstractImpl { /** Interface to C language function: <br> <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); </code> */ @Override - public int clBuildProgram(long program, int deviceCount, PointerBuffer deviceList, String options, BuildProgramCallback cb) { + public int clBuildProgram(final long program, final int deviceCount, final PointerBuffer deviceList, final String options, final BuildProgramCallback cb) { if (deviceList != null && !deviceList.isDirect()) { throw new RuntimeException("Argument \"properties\" was not a direct buffer"); } @@ -154,7 +154,7 @@ public class CLImpl extends CLAbstractImpl { @Override - public int clSetEventCallback(long event, int trigger, CLEventCallback callback) { + public int clSetEventCallback(final long event, final int trigger, final CLEventCallback callback) { final long address = addressTable._addressof_clSetEventCallback; if (address == 0) { throw new UnsupportedOperationException("Method not available"); @@ -166,7 +166,7 @@ public class CLImpl extends CLAbstractImpl { @Override - public int clSetMemObjectDestructorCallback(long memObjID, CLMemObjectDestructorCallback cb) { + public int clSetMemObjectDestructorCallback(final long memObjID, final CLMemObjectDestructorCallback cb) { final long address = addressTable._addressof_clSetMemObjectDestructorCallback; if (address == 0) { throw new UnsupportedOperationException("Method not available"); @@ -186,11 +186,11 @@ public class CLImpl extends CLAbstractImpl { @param event a direct {@link com.jogamp.common.nio.PointerBuffer} @param errcode_ret a direct {@link java.nio.IntBuffer} */ @Override - public ByteBuffer clEnqueueMapImage(long command_queue, long image, int blocking_map, long map_flags, - PointerBuffer origin, PointerBuffer range, - PointerBuffer image_row_pitch, PointerBuffer image_slice_pitch, - int num_events_in_wait_list, - PointerBuffer event_wait_list, PointerBuffer event, IntBuffer errcode_ret) { + public ByteBuffer clEnqueueMapImage(final long command_queue, final long image, final int blocking_map, final long map_flags, + final PointerBuffer origin, final PointerBuffer range, + final PointerBuffer image_row_pitch, final PointerBuffer image_slice_pitch, + final int num_events_in_wait_list, + final PointerBuffer event_wait_list, final PointerBuffer event, final IntBuffer errcode_ret) { if (origin != null && !origin.isDirect()) { throw new CLException("Argument \"origin\" was not a direct buffer"); diff --git a/src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java b/src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java index 5ed57cce..b80eb093 100644 --- a/src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java +++ b/src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -40,7 +40,7 @@ package com.jogamp.opencl.llb.impl; public interface CLMemObjectDestructorCallback { /** - * + * */ public void memoryDeallocated(long memObjID); diff --git a/src/com/jogamp/opencl/util/CLBuildConfiguration.java b/src/com/jogamp/opencl/util/CLBuildConfiguration.java index 89f59110..2978c4ff 100644 --- a/src/com/jogamp/opencl/util/CLBuildConfiguration.java +++ b/src/com/jogamp/opencl/util/CLBuildConfiguration.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. diff --git a/src/com/jogamp/opencl/util/CLBuildListener.java b/src/com/jogamp/opencl/util/CLBuildListener.java index d21109f9..09f7fc9b 100644 --- a/src/com/jogamp/opencl/util/CLBuildListener.java +++ b/src/com/jogamp/opencl/util/CLBuildListener.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. diff --git a/src/com/jogamp/opencl/util/CLDeviceFilters.java b/src/com/jogamp/opencl/util/CLDeviceFilters.java index 6281b844..f055ba1e 100644 --- a/src/com/jogamp/opencl/util/CLDeviceFilters.java +++ b/src/com/jogamp/opencl/util/CLDeviceFilters.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -38,18 +38,18 @@ import java.util.List; /** * Pre-defined filters. * @author Michael Bien - * @see com.jogamp.opencl.CLPlatform#listCLDevices(com.jogamp.opencl.util.Filter[]) + * @see com.jogamp.opencl.CLPlatform#listCLDevices(com.jogamp.opencl.util.Filter[]) * @see com.jogamp.opencl.CLPlatform#getMaxFlopsDevice(com.jogamp.opencl.util.Filter[]) */ public class CLDeviceFilters { - + /** * Accepts all devices of the given type. */ public static Filter<CLDevice> type(final CLDevice.Type... types) { return new Filter<CLDevice>() { private final EnumSet<CLDevice.Type> set = EnumSet.copyOf(Arrays.asList(types)); - public boolean accept(CLDevice item) { + public boolean accept(final CLDevice item) { if(set.contains(CLDevice.Type.ALL)) { return true; } @@ -57,51 +57,51 @@ public class CLDeviceFilters { } }; } - + /** * Accepts all devices of the given {@link ByteOrder}. */ public static Filter<CLDevice> byteOrder(final ByteOrder order) { return new Filter<CLDevice>() { - public boolean accept(CLDevice item) { + public boolean accept(final CLDevice item) { return item.getByteOrder().equals(order); } }; } - + /** * Accepts all devices which support OpenGL-OpenCL interoperability. */ public static Filter<CLDevice> glSharing() { return new Filter<CLDevice>() { - public boolean accept(CLDevice item) { + public boolean accept(final CLDevice item) { return item.isGLMemorySharingSupported(); } }; } - + /** * Accepts all devices supporting the given extensions. */ public static Filter<CLDevice> extension(final String... extensions) { return new Filter<CLDevice>() { private final List<String> extensionList = Arrays.asList(extensions); - public boolean accept(CLDevice item) { + public boolean accept(final CLDevice item) { return item.getExtensions().containsAll(extensionList); } }; } - + /** * Accepts all devices supporting the specified command queue modes. */ public static Filter<CLDevice> queueMode(final Mode... modes) { return new Filter<CLDevice>() { private final List<Mode> modeList = Arrays.asList(modes); - public boolean accept(CLDevice item) { + public boolean accept(final CLDevice item) { return item.getQueueProperties().containsAll(modeList); } }; } - + } diff --git a/src/com/jogamp/opencl/util/CLInfo.java b/src/com/jogamp/opencl/util/CLInfo.java index 4d2ab08b..2dfbb5e9 100644 --- a/src/com/jogamp/opencl/util/CLInfo.java +++ b/src/com/jogamp/opencl/util/CLInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -44,7 +44,7 @@ import java.util.Map; */ public class CLInfo { - public static StringBuilder print(StringBuilder sb) { + public static StringBuilder print(final StringBuilder sb) { // host sb.append("HOST_JRE: ").append(System.getProperty("java.runtime.version")).append("\n"); @@ -62,16 +62,16 @@ public class CLInfo { sb.append("\n"); // OpenCL - CLPlatform[] platforms = CLPlatform.listCLPlatforms(); + final CLPlatform[] platforms = CLPlatform.listCLPlatforms(); - for (CLPlatform platform : platforms) { - Map<String, String> platformProperties = platform.getProperties(); + for (final CLPlatform platform : platforms) { + final Map<String, String> platformProperties = platform.getProperties(); sb.append("\n"); printInfo(sb, "", platformProperties); - CLDevice[] devices = platform.listCLDevices(); - for (CLDevice device : devices) { - Map<String, String> deviceProperties = device.getProperties(); + final CLDevice[] devices = platform.listCLDevices(); + for (final CLDevice device : devices) { + final Map<String, String> deviceProperties = device.getProperties(); sb.append("\n"); printInfo(sb, " - ", deviceProperties); } @@ -81,13 +81,13 @@ public class CLInfo { } - private static void printInfo(StringBuilder sb, String prefix, Map<String, String> properties) { - for (Map.Entry<String, String> entry : properties.entrySet()) { + private static void printInfo(final StringBuilder sb, final String prefix, final Map<String, String> properties) { + for (final Map.Entry<String, String> entry : properties.entrySet()) { sb.append(prefix).append(entry.getKey()).append(": ").append(entry.getValue()).append(Platform.getNewline()); } } - public static void main(String[] args) throws Exception { + public static void main(final String[] args) throws Exception { System.out.println(print(new StringBuilder()).toString()); } } diff --git a/src/com/jogamp/opencl/util/CLMultiContext.java b/src/com/jogamp/opencl/util/CLMultiContext.java index c5bed86b..c5624bb4 100644 --- a/src/com/jogamp/opencl/util/CLMultiContext.java +++ b/src/com/jogamp/opencl/util/CLMultiContext.java @@ -34,7 +34,7 @@ public class CLMultiContext implements CLResource { /** * Creates a multi context with all devices of the specified platforms. */ - public static CLMultiContext create(CLPlatform... platforms) { + public static CLMultiContext create(final CLPlatform... platforms) { return create(platforms, ALL); } @@ -42,7 +42,7 @@ public class CLMultiContext implements CLResource { * Creates a multi context with all devices of the specified platforms and types. */ @SuppressWarnings("unchecked") - public static CLMultiContext create(CLPlatform[] platforms, CLDevice.Type... types) { + public static CLMultiContext create(final CLPlatform[] platforms, final CLDevice.Type... types) { return create(platforms, CLDeviceFilters.type(types)); } @@ -50,7 +50,7 @@ public class CLMultiContext implements CLResource { * Creates a multi context with all matching devices of the specified platforms. */ @SuppressWarnings("unchecked") - public static CLMultiContext create(CLPlatform[] platforms, Filter<CLDevice>... filters) { + public static CLMultiContext create(final CLPlatform[] platforms, final Filter<CLDevice>... filters) { if(platforms == null) { throw new NullPointerException("platform list was null"); @@ -58,8 +58,8 @@ public class CLMultiContext implements CLResource { throw new IllegalArgumentException("platform list was empty"); } - List<CLDevice> devices = new ArrayList<CLDevice>(); - for (CLPlatform platform : platforms) { + final List<CLDevice> devices = new ArrayList<CLDevice>(); + for (final CLPlatform platform : platforms) { devices.addAll(asList(platform.listCLDevices(filters))); } return create(devices); @@ -69,21 +69,21 @@ public class CLMultiContext implements CLResource { * Creates a multi context with the specified devices. * The devices don't have to be from the same platform. */ - public static CLMultiContext create(Collection<CLDevice> devices) { + public static CLMultiContext create(final Collection<CLDevice> devices) { if(devices.isEmpty()) { throw new IllegalArgumentException("device list was empty"); } - Map<CLPlatform, List<CLDevice>> platformDevicesMap = filterPlatformConflicts(devices); + final Map<CLPlatform, List<CLDevice>> platformDevicesMap = filterPlatformConflicts(devices); // create contexts - CLMultiContext mc = new CLMultiContext(); - for (Map.Entry<CLPlatform, List<CLDevice>> entry : platformDevicesMap.entrySet()) { - List<CLDevice> list = entry.getValue(); + final CLMultiContext mc = new CLMultiContext(); + for (final Map.Entry<CLPlatform, List<CLDevice>> entry : platformDevicesMap.entrySet()) { + final List<CLDevice> list = entry.getValue(); // one context per device to workaround driver bugs - for (CLDevice device : list) { - CLContext context = CLContext.create(device); + for (final CLDevice device : list) { + final CLContext context = CLContext.create(device); mc.contexts.add(context); } } @@ -94,8 +94,8 @@ public class CLMultiContext implements CLResource { /** * Creates a multi context with specified contexts. */ - public static CLMultiContext wrap(CLContext... contexts) { - CLMultiContext mc = new CLMultiContext(); + public static CLMultiContext wrap(final CLContext... contexts) { + final CLMultiContext mc = new CLMultiContext(); mc.contexts.addAll(asList(contexts)); return mc; } @@ -104,19 +104,19 @@ public class CLMultiContext implements CLResource { * filter devices; don't allow the same device to be used in more than one platform. * example: a CPU available via the AMD and Intel SDKs shouldn't end up in two contexts */ - private static Map<CLPlatform, List<CLDevice>> filterPlatformConflicts(Collection<CLDevice> devices) { + private static Map<CLPlatform, List<CLDevice>> filterPlatformConflicts(final Collection<CLDevice> devices) { // FIXME: devicename-platform is used as unique device identifier - replace if we have something better - - Map<CLPlatform, List<CLDevice>> filtered = new HashMap<CLPlatform, List<CLDevice>>(); - Map<String, CLPlatform> used = new HashMap<String, CLPlatform>(); - for (CLDevice device : devices) { + final Map<CLPlatform, List<CLDevice>> filtered = new HashMap<CLPlatform, List<CLDevice>>(); + final Map<String, CLPlatform> used = new HashMap<String, CLPlatform>(); - String name = device.getName(); + for (final CLDevice device : devices) { - CLPlatform platform = device.getPlatform(); - CLPlatform usedPlatform = used.get(name); + final String name = device.getName(); + + final CLPlatform platform = device.getPlatform(); + final CLPlatform usedPlatform = used.get(name); if(usedPlatform == null || platform.equals(usedPlatform)) { if(!filtered.containsKey(platform)) { @@ -125,7 +125,7 @@ public class CLMultiContext implements CLResource { filtered.get(platform).add(device); used.put(name, platform); } - + } return filtered; } @@ -141,7 +141,7 @@ public class CLMultiContext implements CLResource { throw new RuntimeException(getClass().getSimpleName()+" already released"); } released = true; - for (CLContext context : contexts) { + for (final CLContext context : contexts) { context.release(); } contexts.clear(); @@ -155,8 +155,8 @@ public class CLMultiContext implements CLResource { * Returns a list containing all devices used in this multi context. */ public List<CLDevice> getDevices() { - List<CLDevice> devices = new ArrayList<CLDevice>(); - for (CLContext context : contexts) { + final List<CLDevice> devices = new ArrayList<CLDevice>(); + for (final CLContext context : contexts) { devices.addAll(asList(context.getDevices())); } return devices; diff --git a/src/com/jogamp/opencl/util/CLPlatformFilters.java b/src/com/jogamp/opencl/util/CLPlatformFilters.java index 451c6b1f..8c22306a 100644 --- a/src/com/jogamp/opencl/util/CLPlatformFilters.java +++ b/src/com/jogamp/opencl/util/CLPlatformFilters.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -40,7 +40,7 @@ import javax.media.opengl.GLContext; * Pre-defined filters. * @author Michael Bien * @see CLPlatform#getDefault(com.jogamp.opencl.util.Filter[]) - * @see CLPlatform#listCLPlatforms(com.jogamp.opencl.util.Filter[]) + * @see CLPlatform#listCLPlatforms(com.jogamp.opencl.util.Filter[]) */ public class CLPlatformFilters { @@ -49,7 +49,7 @@ public class CLPlatformFilters { */ public static Filter<CLPlatform> version(final CLVersion version) { return new Filter<CLPlatform>() { - public boolean accept(CLPlatform item) { + public boolean accept(final CLPlatform item) { return item.isAtLeast(version); } }; @@ -60,21 +60,21 @@ public class CLPlatformFilters { */ public static Filter<CLPlatform> type(final CLDevice.Type type) { return new Filter<CLPlatform>() { - public boolean accept(CLPlatform item) { + public boolean accept(final CLPlatform item) { return item.listCLDevices(type).length > 0; } }; } - + /** * Accepts all platforms containing at least one devices of which supports OpenGL-OpenCL interoperability. */ public static Filter<CLPlatform> glSharing() { return new Filter<CLPlatform>() { private final Filter<CLDevice> glFilter = CLDeviceFilters.glSharing(); - public boolean accept(CLPlatform item) { - CLDevice[] devices = item.listCLDevices(); - for (CLDevice device : devices) { + public boolean accept(final CLPlatform item) { + final CLDevice[] devices = item.listCLDevices(); + for (final CLDevice device : devices) { if(glFilter.accept(device)) { return true; } @@ -91,14 +91,14 @@ public class CLPlatformFilters { public static Filter<CLPlatform> glSharing(final GLContext context) { return new Filter<CLPlatform>() { private final Filter<CLPlatform> glFilter = glSharing(); - public boolean accept(CLPlatform item) { - String glVendor = context.getGL().glGetString(GL.GL_VENDOR); - String clVendor = item.getVendor(); + public boolean accept(final CLPlatform item) { + final String glVendor = context.getGL().glGetString(GL.GL_VENDOR); + final String clVendor = item.getVendor(); return areVendorsCompatible(glVendor,clVendor) && glFilter.accept(item); } }; } - + /** * We need this test because: * - On at least some AMD cards, the GL vendor is ATI, but the CL vendor is AMD. @@ -118,7 +118,7 @@ public class CLPlatformFilters { */ public static Filter<CLPlatform> extension(final String... extensions) { return new Filter<CLPlatform>() { - public boolean accept(CLPlatform item) { + public boolean accept(final CLPlatform item) { return item.getExtensions().containsAll(Arrays.asList(extensions)); } }; @@ -130,8 +130,8 @@ public class CLPlatformFilters { public static Filter<CLPlatform> queueMode(final Mode... modes) { return new Filter<CLPlatform>() { private final Filter<CLDevice> queueModeFilter = CLDeviceFilters.queueMode(modes); - public boolean accept(CLPlatform item) { - for (CLDevice device : item.listCLDevices()) { + public boolean accept(final CLPlatform item) { + for (final CLDevice device : item.listCLDevices()) { if(queueModeFilter.accept(device)) { return true; } diff --git a/src/com/jogamp/opencl/util/CLProgramConfiguration.java b/src/com/jogamp/opencl/util/CLProgramConfiguration.java index 3d460503..5b93a4de 100644 --- a/src/com/jogamp/opencl/util/CLProgramConfiguration.java +++ b/src/com/jogamp/opencl/util/CLProgramConfiguration.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. diff --git a/src/com/jogamp/opencl/util/CLUtil.java b/src/com/jogamp/opencl/util/CLUtil.java index 98a6cd7e..bcab6767 100644 --- a/src/com/jogamp/opencl/util/CLUtil.java +++ b/src/com/jogamp/opencl/util/CLUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -48,7 +48,7 @@ import java.util.Map; */ public class CLUtil { - public static String clString2JavaString(byte[] chars, int clLength) { + public static String clString2JavaString(final byte[] chars, int clLength) { // certain char queries on windows always claim to have a fixed length // e.g. (clDeviceInfo(CL_DEVICE_NAME) is always 64.. but luckily they are 0 terminated) @@ -57,11 +57,11 @@ public class CLUtil { return clLength==0 ? "" : new String(chars, 0, clLength+1); } - public static String clString2JavaString(ByteBuffer chars, int clLength) { + public static String clString2JavaString(final ByteBuffer chars, final int clLength) { if (clLength==0) { return ""; }else{ - byte[] array = new byte[clLength]; + final byte[] array = new byte[clLength]; chars.get(array).rewind(); return clString2JavaString(array, clLength); } @@ -70,48 +70,48 @@ public class CLUtil { /** * Returns true if clBoolean == CL.CL_TRUE. */ - public static boolean clBoolean(int clBoolean) { + public static boolean clBoolean(final int clBoolean) { return clBoolean == CL.CL_TRUE; } /** * Returns b ? CL.CL_TRUE : CL.CL_FALSE */ - public static int clBoolean(boolean b) { + public static int clBoolean(final boolean b) { return b ? CL.CL_TRUE : CL.CL_FALSE; } /** * Reads all platform properties and returns them as key-value map. */ - public static Map<String, String> obtainPlatformProperties(CLPlatform platform) { + public static Map<String, String> obtainPlatformProperties(final CLPlatform platform) { return readCLProperties(platform); } /** * Reads all device properties and returns them as key-value map. */ - public static Map<String, String> obtainDeviceProperties(CLDevice dev) { + public static Map<String, String> obtainDeviceProperties(final CLDevice dev) { return readCLProperties(dev); } - private static Map<String, String> readCLProperties(Object obj) { + private static Map<String, String> readCLProperties(final Object obj) { try { return invoke(listMethods(obj.getClass()), obj); - } catch (IllegalArgumentException ex) { + } catch (final IllegalArgumentException ex) { throw new JogampRuntimeException(ex); - } catch (IllegalAccessException ex) { + } catch (final IllegalAccessException ex) { throw new JogampRuntimeException(ex); } } - static Map<String, String> invoke(List<Method> methods, Object obj) throws IllegalArgumentException, IllegalAccessException { - Map<String, String> map = new LinkedHashMap<String, String>(); - for (Method method : methods) { + static Map<String, String> invoke(final List<Method> methods, final Object obj) throws IllegalArgumentException, IllegalAccessException { + final Map<String, String> map = new LinkedHashMap<String, String>(); + for (final Method method : methods) { Object info = null; try { info = method.invoke(obj); - } catch (InvocationTargetException ex) { + } catch (final InvocationTargetException ex) { info = ex.getTargetException(); } @@ -119,17 +119,17 @@ public class CLUtil { info = asList(info); } - String value = method.getAnnotation(CLProperty.class).value(); + final String value = method.getAnnotation(CLProperty.class).value(); map.put(value, info.toString()); } return map; } - static List<Method> listMethods(Class<?> clazz) throws SecurityException { - List<Method> list = new ArrayList<Method>(); - for (Method method : clazz.getDeclaredMethods()) { - Annotation[] annotations = method.getDeclaredAnnotations(); - for (Annotation annotation : annotations) { + static List<Method> listMethods(final Class<?> clazz) throws SecurityException { + final List<Method> list = new ArrayList<Method>(); + for (final Method method : clazz.getDeclaredMethods()) { + final Annotation[] annotations = method.getDeclaredAnnotations(); + for (final Annotation annotation : annotations) { if (annotation instanceof CLProperty) { list.add(method); } @@ -138,26 +138,26 @@ public class CLUtil { return list; } - private static List<Number> asList(Object info) { - List<Number> list = new ArrayList<Number>(); + private static List<Number> asList(final Object info) { + final List<Number> list = new ArrayList<Number>(); if(info instanceof int[]) { - int[] array = (int[]) info; - for (int i : array) { + final int[] array = (int[]) info; + for (final int i : array) { list.add(i); } }else if(info instanceof long[]) { - long[] array = (long[]) info; - for (long i : array) { + final long[] array = (long[]) info; + for (final long i : array) { list.add(i); } }else if(info instanceof float[]) { - float[] array = (float[]) info; - for (float i : array) { + final float[] array = (float[]) info; + for (final float i : array) { list.add(i); } }else if(info instanceof double[]) { - double[] array = (double[]) info; - for (double i : array) { + final double[] array = (double[]) info; + for (final double i : array) { list.add(i); } } diff --git a/src/com/jogamp/opencl/util/Filter.java b/src/com/jogamp/opencl/util/Filter.java index b8a11faf..f950954e 100644 --- a/src/com/jogamp/opencl/util/Filter.java +++ b/src/com/jogamp/opencl/util/Filter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. diff --git a/src/com/jogamp/opencl/util/JOCLVersion.java b/src/com/jogamp/opencl/util/JOCLVersion.java index 7b837486..cc1edebc 100644 --- a/src/com/jogamp/opencl/util/JOCLVersion.java +++ b/src/com/jogamp/opencl/util/JOCLVersion.java @@ -53,7 +53,7 @@ public class JOCLVersion extends JogampVersion { private static final String PACKAGE = "com.jogamp.opencl"; - private JOCLVersion(Manifest mf) { + private JOCLVersion(final Manifest mf) { super(PACKAGE, mf); } @@ -84,7 +84,7 @@ public class JOCLVersion extends JogampVersion { sb.append(Platform.getNewline()); createInstance().toString(sb); sb.append(Platform.getNewline()); - }catch(Exception e) { + }catch(final Exception e) { sb.append(e.getMessage()); e.printStackTrace(); } @@ -92,7 +92,7 @@ public class JOCLVersion extends JogampVersion { return sb.toString(); } - public static void main(String[] args) { + public static void main(final String[] args) { System.out.println(JOCLVersion.getAllVersions()); } } diff --git a/src/com/jogamp/opencl/util/MultiQueueBarrier.java b/src/com/jogamp/opencl/util/MultiQueueBarrier.java index 9f8a461c..f1692f2e 100644 --- a/src/com/jogamp/opencl/util/MultiQueueBarrier.java +++ b/src/com/jogamp/opencl/util/MultiQueueBarrier.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -52,7 +52,7 @@ public class MultiQueueBarrier { * It is recommented to use {@link #MultiQueueBarrier(CLCommandQueue... allowedQueues)} if possible * which restricts the set of allowed queues for the barrier. */ - public MultiQueueBarrier(int queueCount) { + public MultiQueueBarrier(final int queueCount) { if(queueCount == 0) { throw new IllegalArgumentException("queueCount was 0"); } @@ -64,15 +64,15 @@ public class MultiQueueBarrier { /** * Creates a new MultiQueueBarrier for the given queues. */ - public MultiQueueBarrier(CLCommandQueue... allowedQueues) { + public MultiQueueBarrier(final CLCommandQueue... allowedQueues) { if(allowedQueues.length == 0) { throw new IllegalArgumentException("allowedQueues was empty"); } this.latch = new CountDownLatch(allowedQueues.length); this.count = allowedQueues.length; - HashSet<CLCommandQueue> set = new HashSet<CLCommandQueue>(allowedQueues.length); - for (CLCommandQueue queue : allowedQueues) { + final HashSet<CLCommandQueue> set = new HashSet<CLCommandQueue>(allowedQueues.length); + for (final CLCommandQueue queue : allowedQueues) { set.add(queue); } this.queues = Collections.unmodifiableSet(set); @@ -83,7 +83,7 @@ public class MultiQueueBarrier { * This method may be invoked concurrently without synchronization on the MultiQueueBarrier object * as long each Thread passes a distinct CLCommandQueue as parameter to this method. */ - public MultiQueueBarrier waitFor(CLCommandQueue queue) { + public MultiQueueBarrier waitFor(final CLCommandQueue queue) { checkQueue(queue); queue.putBarrier(); @@ -98,7 +98,7 @@ public class MultiQueueBarrier { * This method may be invoked concurrently without synchronization on the MultiQueueBarrier object * as long each Thread passes a distinct CLCommandQueue as parameter to this method. */ - public MultiQueueBarrier waitFor(CLCommandQueue queue, CLEventList events) { + public MultiQueueBarrier waitFor(final CLCommandQueue queue, final CLEventList events) { checkQueue(queue); queue.putWaitForEvents(events, true); @@ -118,18 +118,18 @@ public class MultiQueueBarrier { rebuildBarrierIfBroken(); return this; } - + /** * @see #await() * @param timeout the maximum time to wait * @param unit the time unit of the {@code timeout} argument */ - public boolean await(long timeout, TimeUnit unit) throws InterruptedException { - boolean ret = latch.await(timeout, unit); + public boolean await(final long timeout, final TimeUnit unit) throws InterruptedException { + final boolean ret = latch.await(timeout, unit); rebuildBarrierIfBroken(); return ret; } - + /** * Resets this barrier and unblocks all waiting threads. */ @@ -160,7 +160,7 @@ public class MultiQueueBarrier { return latch.getCount(); } - private void checkQueue(CLCommandQueue queue) throws IllegalArgumentException { + private void checkQueue(final CLCommandQueue queue) throws IllegalArgumentException { if (queues != null && !queues.contains(queue)) { throw new IllegalArgumentException(queue + " is not in the allowedQueues Set: " + queues); } diff --git a/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java b/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java index a1d376ab..dcd052cf 100644 --- a/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java +++ b/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java @@ -31,23 +31,23 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource private FinishAction finishAction = FinishAction.DO_NOTHING; private boolean released; - private CLCommandQueuePool(CLQueueContextFactory<C> factory, Collection<CLCommandQueue> queues) { + private CLCommandQueuePool(final CLQueueContextFactory<C> factory, final Collection<CLCommandQueue> queues) { this.contexts = initContexts(queues, factory); initExecutor(); } - private List<CLQueueContext> initContexts(Collection<CLCommandQueue> queues, CLQueueContextFactory<C> factory) { - List<CLQueueContext> newContexts = new ArrayList<CLQueueContext>(queues.size()); - + private List<CLQueueContext> initContexts(final Collection<CLCommandQueue> queues, final CLQueueContextFactory<C> factory) { + final List<CLQueueContext> newContexts = new ArrayList<CLQueueContext>(queues.size()); + int index = 0; - for (CLCommandQueue queue : queues) { - + for (final CLCommandQueue queue : queues) { + CLQueueContext old = null; if(this.contexts != null && !this.contexts.isEmpty()) { old = this.contexts.get(index++); old.release(); } - + newContexts.add(factory.setup(queue, old)); } return newContexts; @@ -57,19 +57,19 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource this.excecutor = Executors.newFixedThreadPool(contexts.size(), new QueueThreadFactory(contexts)); } - public static <C extends CLQueueContext> CLCommandQueuePool<C> create(CLQueueContextFactory<C> factory, CLMultiContext mc, CLCommandQueue.Mode... modes) { + public static <C extends CLQueueContext> CLCommandQueuePool<C> create(final CLQueueContextFactory<C> factory, final CLMultiContext mc, final CLCommandQueue.Mode... modes) { return create(factory, mc.getDevices(), modes); } - public static <C extends CLQueueContext> CLCommandQueuePool<C> create(CLQueueContextFactory<C> factory, Collection<CLDevice> devices, CLCommandQueue.Mode... modes) { - List<CLCommandQueue> queues = new ArrayList<CLCommandQueue>(devices.size()); - for (CLDevice device : devices) { + public static <C extends CLQueueContext> CLCommandQueuePool<C> create(final CLQueueContextFactory<C> factory, final Collection<CLDevice> devices, final CLCommandQueue.Mode... modes) { + final List<CLCommandQueue> queues = new ArrayList<CLCommandQueue>(devices.size()); + for (final CLDevice device : devices) { queues.add(device.createCommandQueue(modes)); } return create(factory, queues); } - public static <C extends CLQueueContext> CLCommandQueuePool<C> create(CLQueueContextFactory<C> factory, Collection<CLCommandQueue> queues) { + public static <C extends CLQueueContext> CLCommandQueuePool<C> create(final CLQueueContextFactory<C> factory, final Collection<CLCommandQueue> queues) { return new CLCommandQueuePool<C>(factory, queues); } @@ -77,7 +77,7 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource * Submits this task to the pool for execution returning its {@link Future}. * @see ExecutorService#submit(java.util.concurrent.Callable) */ - public <R> Future<R> submit(CLTask<? super C, R> task) { + public <R> Future<R> submit(final CLTask<? super C, R> task) { return excecutor.submit(new TaskWrapper<C,R>(task, finishAction)); } @@ -85,9 +85,9 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource * Submits all tasks to the pool for execution and returns their {@link Future}. * Calls {@link #submit(com.jogamp.opencl.util.concurrent.CLTask)} for every task. */ - public <R> List<Future<R>> submitAll(Collection<? extends CLTask<? super C, R>> tasks) { - List<Future<R>> futures = new ArrayList<Future<R>>(tasks.size()); - for (CLTask<? super C, R> task : tasks) { + public <R> List<Future<R>> submitAll(final Collection<? extends CLTask<? super C, R>> tasks) { + final List<Future<R>> futures = new ArrayList<Future<R>>(tasks.size()); + for (final CLTask<? super C, R> task : tasks) { futures.add(submit(task)); } return futures; @@ -95,10 +95,10 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource /** * Submits all tasks to the pool for immediate execution (blocking) and returns their {@link Future} holding the result. - * @see ExecutorService#invokeAll(java.util.Collection) + * @see ExecutorService#invokeAll(java.util.Collection) */ - public <R> List<Future<R>> invokeAll(Collection<? extends CLTask<? super C, R>> tasks) throws InterruptedException { - List<TaskWrapper<C, R>> wrapper = wrapTasks(tasks); + public <R> List<Future<R>> invokeAll(final Collection<? extends CLTask<? super C, R>> tasks) throws InterruptedException { + final List<TaskWrapper<C, R>> wrapper = wrapTasks(tasks); return excecutor.invokeAll(wrapper); } @@ -106,14 +106,14 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource * Submits all tasks to the pool for immediate execution (blocking) and returns their {@link Future} holding the result. * @see ExecutorService#invokeAll(java.util.Collection, long, java.util.concurrent.TimeUnit) */ - public <R> List<Future<R>> invokeAll(Collection<? extends CLTask<? super C, R>> tasks, long timeout, TimeUnit unit) throws InterruptedException { - List<TaskWrapper<C, R>> wrapper = wrapTasks(tasks); + public <R> List<Future<R>> invokeAll(final Collection<? extends CLTask<? super C, R>> tasks, final long timeout, final TimeUnit unit) throws InterruptedException { + final List<TaskWrapper<C, R>> wrapper = wrapTasks(tasks); return excecutor.invokeAll(wrapper, timeout, unit); } - private <R> List<TaskWrapper<C, R>> wrapTasks(Collection<? extends CLTask<? super C, R>> tasks) { - List<TaskWrapper<C, R>> wrapper = new ArrayList<TaskWrapper<C, R>>(tasks.size()); - for (CLTask<? super C, R> task : tasks) { + private <R> List<TaskWrapper<C, R>> wrapTasks(final Collection<? extends CLTask<? super C, R>> tasks) { + final List<TaskWrapper<C, R>> wrapper = new ArrayList<TaskWrapper<C, R>>(tasks.size()); + for (final CLTask<? super C, R> task : tasks) { if(task == null) { throw new NullPointerException("at least one task was null"); } @@ -121,17 +121,17 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource } return wrapper; } - + /** * Switches the context of all queues - this operation can be expensive. * Blocks until all tasks finish and sets up a new context for all queues. * @return this */ - public CLCommandQueuePool<C> switchContext(CLQueueContextFactory<C> factory) { - + public CLCommandQueuePool<C> switchContext(final CLQueueContextFactory<C> factory) { + excecutor.shutdown(); finishQueues(); // just to be sure - + contexts = initContexts(getQueues(), factory); initExecutor(); return this; @@ -141,7 +141,7 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource * Calls {@link CLCommandQueue#flush()} on all queues. */ public void flushQueues() { - for (CLQueueContext context : contexts) { + for (final CLQueueContext context : contexts) { context.queue.flush(); } } @@ -150,7 +150,7 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource * Calls {@link CLCommandQueue#finish()} on all queues. */ public void finishQueues() { - for (CLQueueContext context : contexts) { + for (final CLQueueContext context : contexts) { context.queue.finish(); } } @@ -165,7 +165,7 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource } released = true; excecutor.shutdown(); - for (CLQueueContext context : contexts) { + for (final CLQueueContext context : contexts) { context.queue.finish().release(); context.release(); } @@ -175,8 +175,8 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource * Returns the command queues used in this pool. */ public List<CLCommandQueue> getQueues() { - List<CLCommandQueue> queues = new ArrayList<CLCommandQueue>(contexts.size()); - for (CLQueueContext context : contexts) { + final List<CLCommandQueue> queues = new ArrayList<CLCommandQueue>(contexts.size()); + for (final CLQueueContext context : contexts) { queues.add(context.queue); } return queues; @@ -202,7 +202,7 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource * Sets the action which is run after every completed task. * This is mainly intended for debugging, default value is {@link FinishAction#DO_NOTHING}. */ - public void setFinishAction(FinishAction action) { + public void setFinishAction(final FinishAction action) { this.finishAction = action; } @@ -216,28 +216,28 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource private final List<CLQueueContext> context; private int index; - private QueueThreadFactory(List<CLQueueContext> queues) { + private QueueThreadFactory(final List<CLQueueContext> queues) { this.context = queues; this.index = 0; } - public synchronized Thread newThread(Runnable runnable) { + public synchronized Thread newThread(final Runnable runnable) { - SecurityManager sm = System.getSecurityManager(); - ThreadGroup group = (sm != null) ? sm.getThreadGroup() : Thread.currentThread().getThreadGroup(); + final SecurityManager sm = System.getSecurityManager(); + final ThreadGroup group = (sm != null) ? sm.getThreadGroup() : Thread.currentThread().getThreadGroup(); - CLQueueContext queue = context.get(index); - QueueThread thread = new QueueThread(group, runnable, queue, index++); + final CLQueueContext queue = context.get(index); + final QueueThread thread = new QueueThread(group, runnable, queue, index++); thread.setDaemon(true); - + return thread; } } - + private static class QueueThread extends Thread { private final CLQueueContext context; - public QueueThread(ThreadGroup group, Runnable runnable, CLQueueContext context, int index) { + public QueueThread(final ThreadGroup group, final Runnable runnable, final CLQueueContext context, final int index) { super(group, runnable, "queue-worker-thread-"+index+"["+context+"]"); this.context = context; } @@ -247,17 +247,18 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource private final CLTask<? super C, R> task; private final FinishAction mode; - - public TaskWrapper(CLTask<? super C, R> task, FinishAction mode) { + + public TaskWrapper(final CLTask<? super C, R> task, final FinishAction mode) { this.task = task; this.mode = mode; } public R call() throws Exception { - CLQueueContext context = ((QueueThread)Thread.currentThread()).context; + final CLQueueContext context = ((QueueThread)Thread.currentThread()).context; // we make sure to only wrap tasks on the correct kind of thread, so this // shouldn't fail (trying to genericize QueueThread properly becomes tricky) @SuppressWarnings("unchecked") + final R result = task.execute((C)context); if(mode.equals(FinishAction.FLUSH)) { context.queue.flush(); @@ -284,7 +285,7 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource * Flushes the queue on task completion. */ FLUSH, - + /** * Finishes the queue on task completion. */ diff --git a/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java b/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java index 9f92b9a3..a9d3766a 100644 --- a/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java +++ b/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java @@ -24,7 +24,7 @@ public abstract class CLQueueContext implements CLResource { public final CLCommandQueue queue; - public CLQueueContext(CLCommandQueue queue) { + public CLQueueContext(final CLCommandQueue queue) { this.queue = queue; } @@ -45,7 +45,7 @@ public abstract class CLQueueContext implements CLResource { public final CLProgram program; public final Map<String, CLKernel> kernels; - public CLSimpleQueueContext(CLCommandQueue queue, CLProgram program) { + public CLSimpleQueueContext(final CLCommandQueue queue, final CLProgram program) { super(queue); this.program = program; this.kernels = program.createCLKernels(); @@ -55,7 +55,7 @@ public abstract class CLQueueContext implements CLResource { return kernels; } - public CLKernel getKernel(String name) { + public CLKernel getKernel(final String name) { return kernels.get(name); } diff --git a/src/com/jogamp/opencl/util/concurrent/CLQueueContextFactory.java b/src/com/jogamp/opencl/util/concurrent/CLQueueContextFactory.java index 58f389bf..3be33f91 100644 --- a/src/com/jogamp/opencl/util/concurrent/CLQueueContextFactory.java +++ b/src/com/jogamp/opencl/util/concurrent/CLQueueContextFactory.java @@ -24,7 +24,7 @@ public abstract class CLQueueContextFactory<C extends CLQueueContext> { * Creates a simple context factory producing single program contexts. * @param source sourcecode of a OpenCL program. */ - public static CLSimpleContextFactory createSimple(String source) { + public static CLSimpleContextFactory createSimple(final String source) { return new CLSimpleContextFactory(source); } @@ -36,13 +36,13 @@ public abstract class CLQueueContextFactory<C extends CLQueueContext> { private final String source; - public CLSimpleContextFactory(String source) { + public CLSimpleContextFactory(final String source) { this.source = source; } @Override - public CLSimpleQueueContext setup(CLCommandQueue queue, CLQueueContext old) { - CLProgram program = queue.getContext().createProgram(source).build(queue.getDevice()); + public CLSimpleQueueContext setup(final CLCommandQueue queue, final CLQueueContext old) { + final CLProgram program = queue.getContext().createProgram(source).build(queue.getDevice()); return new CLSimpleQueueContext(queue, program); } diff --git a/src/jogamp/opencl/os/android/JoclBaseActivity.java b/src/jogamp/opencl/os/android/JoclBaseActivity.java index 207f5192..6bfe52f5 100644 --- a/src/jogamp/opencl/os/android/JoclBaseActivity.java +++ b/src/jogamp/opencl/os/android/JoclBaseActivity.java @@ -44,7 +44,7 @@ public class JoclBaseActivity extends Activity { rootActivity = this; } - public void setRootActivity(Activity rootActivity) { + public void setRootActivity(final Activity rootActivity) { this.rootActivity = rootActivity; this.isDelegatedActivity = this != rootActivity; } @@ -65,7 +65,7 @@ public class JoclBaseActivity extends Activity { * @param androidWindow * @param newtWindow */ - public void setFullscreenFeature(android.view.Window androidWindow, boolean fullscreen) { + public void setFullscreenFeature(final android.view.Window androidWindow, final boolean fullscreen) { if(null == androidWindow) { throw new IllegalArgumentException("Android or Window null"); } @@ -118,7 +118,7 @@ public class JoclBaseActivity extends Activity { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { Log.d(MD.TAG, "onCreate.0"); if(!isDelegatedActivity()) { super.onCreate(savedInstanceState); diff --git a/src/jogamp/opencl/os/android/JoclVersionActivity.java b/src/jogamp/opencl/os/android/JoclVersionActivity.java index b9884141..1f98a0c8 100644 --- a/src/jogamp/opencl/os/android/JoclVersionActivity.java +++ b/src/jogamp/opencl/os/android/JoclVersionActivity.java @@ -27,6 +27,8 @@ */ package jogamp.opencl.os.android; +import jogamp.common.os.PlatformPropsImpl; + import com.jogamp.common.GlueGenVersion; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionUtil; @@ -42,7 +44,7 @@ import android.widget.TextView; public class JoclVersionActivity extends JoclBaseActivity { @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setFullscreenFeature(getWindow(), true); @@ -61,11 +63,11 @@ public class JoclVersionActivity extends JoclBaseActivity { setContentView(scroller); final JoclVersion joclVersion = JoclVersion.getInstance(); - final String info1 = "JOCL Version Info"+Platform.NEWLINE+ - VersionUtil.getPlatformInfo()+Platform.NEWLINE+ - GlueGenVersion.getInstance()+Platform.NEWLINE+ - joclVersion.toString()+Platform.NEWLINE+ - joclVersion.getOpenCLTextInfo(null).toString()+Platform.NEWLINE; + final String info1 = "JOCL Version Info"+PlatformPropsImpl.NEWLINE+ + VersionUtil.getPlatformInfo()+PlatformPropsImpl.NEWLINE+ + GlueGenVersion.getInstance()+PlatformPropsImpl.NEWLINE+ + joclVersion.toString()+PlatformPropsImpl.NEWLINE+ + joclVersion.getOpenCLTextInfo(null).toString()+PlatformPropsImpl.NEWLINE; System.err.println(info1); tv.setText(info1); diff --git a/src/jogamp/opencl/os/android/JoclVersionActivityLauncher.java b/src/jogamp/opencl/os/android/JoclVersionActivityLauncher.java index 4080250d..549477ea 100644 --- a/src/jogamp/opencl/os/android/JoclVersionActivityLauncher.java +++ b/src/jogamp/opencl/os/android/JoclVersionActivityLauncher.java @@ -8,7 +8,7 @@ import android.util.Log; public class JoclVersionActivityLauncher extends Activity { @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Uri uri = Uri.parse("launch://jogamp.org/jogamp.opencl.os.android.JoclVersionActivity?sys=com.jogamp.common&sys=javax.media.opengl&sys=com.jogamp.opencl&pkg=com.jogamp.opencl.test&jogamp.debug=all&jocl.debug=all"); diff --git a/test/com/jogamp/opencl/CLBufferTest.java b/test/com/jogamp/opencl/CLBufferTest.java index 53222014..d5995903 100644 --- a/test/com/jogamp/opencl/CLBufferTest.java +++ b/test/com/jogamp/opencl/CLBufferTest.java @@ -69,18 +69,18 @@ public class CLBufferTest extends UITestCase { out.println(" - - - highLevelTest; create buffer test - - - "); - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); try{ - int size = 6; + final int size = 6; - CLBuffer<ByteBuffer> bb = context.createByteBuffer(size); - CLBuffer<ShortBuffer> sb = context.createShortBuffer(size); - CLBuffer<IntBuffer> ib = context.createIntBuffer(size); - CLBuffer<LongBuffer> lb = context.createLongBuffer(size); - CLBuffer<FloatBuffer> fb = context.createFloatBuffer(size); - CLBuffer<DoubleBuffer> db = context.createDoubleBuffer(size); + final CLBuffer<ByteBuffer> bb = context.createByteBuffer(size); + final CLBuffer<ShortBuffer> sb = context.createShortBuffer(size); + final CLBuffer<IntBuffer> ib = context.createIntBuffer(size); + final CLBuffer<LongBuffer> lb = context.createLongBuffer(size); + final CLBuffer<FloatBuffer> fb = context.createFloatBuffer(size); + final CLBuffer<DoubleBuffer> db = context.createDoubleBuffer(size); - List<CLMemory<? extends Buffer>> buffers = context.getMemoryObjects(); + final List<CLMemory<? extends Buffer>> buffers = context.getMemoryObjects(); assertEquals(6, buffers.size()); assertEquals(1, bb.getElementSize()); @@ -90,19 +90,19 @@ public class CLBufferTest extends UITestCase { assertEquals(4, fb.getElementSize()); assertEquals(8, db.getElementSize()); - ByteBuffer anotherNIO = newDirectByteBuffer(2); + final ByteBuffer anotherNIO = newDirectByteBuffer(2); - for (CLMemory<? extends Buffer> memory : buffers) { + for (final CLMemory<? extends Buffer> memory : buffers) { - CLBuffer<? extends Buffer> buffer = (CLBuffer<? extends Buffer>) memory; - Buffer nio = buffer.getBuffer(); + final CLBuffer<? extends Buffer> buffer = (CLBuffer<? extends Buffer>) memory; + final Buffer nio = buffer.getBuffer(); assertEquals(nio.capacity(), buffer.getCLCapacity()); assertEquals(buffer.getNIOSize(), buffer.getCLSize()); assertEquals(sizeOfBufferElem(nio), buffer.getElementSize()); assertEquals(nio.capacity() * sizeOfBufferElem(nio), buffer.getCLSize()); - CLBuffer<ByteBuffer> clone = buffer.cloneWith(anotherNIO); + final CLBuffer<ByteBuffer> clone = buffer.cloneWith(anotherNIO); assertEquals(buffer.ID, clone.ID); assertTrue(clone.equals(buffer)); @@ -126,16 +126,16 @@ public class CLBufferTest extends UITestCase { final int elements = NUM_ELEMENTS; - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); // the CL.MEM_* flag is probably completely irrelevant in our case since we do not use a kernel in this test - CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements*SIZEOF_INT, Mem.READ_ONLY); - CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements*SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements*SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements*SIZEOF_INT, Mem.READ_ONLY); // fill only first read buffer -> we will copy the payload to the second later. fillBuffer(clBufferA.buffer, 12345); - CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); + final CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); // asynchronous write of data to GPU device, blocking read later to get the computed results back. queue.putWriteBuffer(clBufferA, false) // write A @@ -158,22 +158,22 @@ public class CLBufferTest extends UITestCase { final int elements = NUM_ELEMENTS; - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); - ByteBuffer buffer = Buffers.newDirectByteBuffer(elements*SIZEOF_INT); + final ByteBuffer buffer = Buffers.newDirectByteBuffer(elements*SIZEOF_INT); // fill only first read buffer -> we will copy the payload to the second later. fillBuffer(buffer, 12345); - CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); + final CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); - Mem[] bufferConfig = new Mem[] {Mem.COPY_BUFFER, Mem.USE_BUFFER}; + final Mem[] bufferConfig = new Mem[] {Mem.COPY_BUFFER, Mem.USE_BUFFER}; for(int i = 0; i < bufferConfig.length; i++) { out.println("testing with "+bufferConfig[i] + " config"); - CLBuffer<ByteBuffer> clBufferA = context.createBuffer(buffer, Mem.READ_ONLY, bufferConfig[i]); - CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements*SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferA = context.createBuffer(buffer, Mem.READ_ONLY, bufferConfig[i]); + final CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements*SIZEOF_INT, Mem.READ_ONLY); // asynchronous write of data to GPU device, blocking read later to get the computed results back. queue.putCopyBuffer(clBufferA, clBufferB, clBufferA.buffer.capacity()) // copy A -> B @@ -223,10 +223,10 @@ public class CLBufferTest extends UITestCase { clBufferB = context.createByteBuffer(sizeInBytes, Mem.READ_WRITE, Mem.USE_BUFFER); } - CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); + final CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); // fill only first buffer -> we will copy the payload to the second later. - ByteBuffer mappedBufferA = queue.putMapBuffer(clBufferA, Map.WRITE, true); + final ByteBuffer mappedBufferA = queue.putMapBuffer(clBufferA, Map.WRITE, true); assertEquals(sizeInBytes, mappedBufferA.capacity()); fillBuffer(mappedBufferA, 12345); // write to A @@ -235,7 +235,7 @@ public class CLBufferTest extends UITestCase { .putCopyBuffer(clBufferA, clBufferB); // copy A -> B // map B for read operations - ByteBuffer mappedBufferB = queue.putMapBuffer(clBufferB, Map.READ, true); + final ByteBuffer mappedBufferB = queue.putMapBuffer(clBufferB, Map.READ, true); assertEquals(sizeInBytes, mappedBufferB.capacity()); out.println("validating computed results..."); @@ -254,13 +254,14 @@ public class CLBufferTest extends UITestCase { out.println(" - - - subBufferTest - - - "); @SuppressWarnings("unchecked") + final CLPlatform platform = CLPlatform.getDefault(version(CL_1_1)); if(platform == null) { out.println("aborting subBufferTest"); return; } - CLContext context = CLContext.create(platform); + final CLContext context = CLContext.create(platform); try{ final int subelements = 5; final long lMaxAlignment = context.getMaxMemBaseAddrAlign(); @@ -270,13 +271,13 @@ public class CLBufferTest extends UITestCase { throw new RuntimeException("Cannot handle MaxMemBaseAddrAlign > MAX_INT, has 0x"+Long.toHexString(lMaxAlignment)); } // device only - CLBuffer<?> buffer = context.createBuffer(iMaxAlignment+subelements); + final CLBuffer<?> buffer = context.createBuffer(iMaxAlignment+subelements); assertFalse(buffer.isSubBuffer()); assertNotNull(buffer.getSubBuffers()); assertTrue(buffer.getSubBuffers().isEmpty()); - CLSubBuffer<?> subBuffer = buffer.createSubBuffer(iMaxAlignment, subelements); + final CLSubBuffer<?> subBuffer = buffer.createSubBuffer(iMaxAlignment, subelements); assertTrue(subBuffer.isSubBuffer()); assertEquals(subelements, subBuffer.getCLSize()); @@ -299,13 +300,14 @@ public class CLBufferTest extends UITestCase { out.println(" - - - subBufferTest - - - "); @SuppressWarnings("unchecked") + final CLPlatform platform = CLPlatform.getDefault(version(CL_1_1)); if(platform == null) { out.println("aborting subBufferTest"); return; } - CLContext context = CLContext.create(platform); + final CLContext context = CLContext.create(platform); try{ final int subelements = 5; final long lMaxAlignment = context.getMaxMemBaseAddrAlign(); @@ -317,12 +319,12 @@ public class CLBufferTest extends UITestCase { // FIXME: See Bug 979: Offset/Alignment via offset calculation per element-count is faulty! final int floatsPerAlignment = iMaxAlignment / Buffers.SIZEOF_FLOAT; // device + direct buffer - CLBuffer<FloatBuffer> buffer = context.createFloatBuffer(floatsPerAlignment+subelements); + final CLBuffer<FloatBuffer> buffer = context.createFloatBuffer(floatsPerAlignment+subelements); assertFalse(buffer.isSubBuffer()); assertNotNull(buffer.getSubBuffers()); assertTrue(buffer.getSubBuffers().isEmpty()); - CLSubBuffer<FloatBuffer> subBuffer = buffer.createSubBuffer(floatsPerAlignment, subelements); + final CLSubBuffer<FloatBuffer> subBuffer = buffer.createSubBuffer(floatsPerAlignment, subelements); assertTrue(subBuffer.isSubBuffer()); assertEquals(subelements, subBuffer.getBuffer().capacity()); @@ -348,13 +350,14 @@ public class CLBufferTest extends UITestCase { out.println(" - - - destructorCallbackTest - - - "); @SuppressWarnings("unchecked") + final CLPlatform platform = CLPlatform.getDefault(version(CL_1_1)); if(platform == null) { out.println("aborting destructorCallbackTest"); return; } - CLContext context = CLContext.create(platform); + final CLContext context = CLContext.create(platform); try{ @@ -362,7 +365,7 @@ public class CLBufferTest extends UITestCase { final CountDownLatch countdown = new CountDownLatch(1); buffer.registerDestructorCallback(new CLMemObjectListener() { - public void memoryDeallocated(CLMemory<?> mem) { + public void memoryDeallocated(final CLMemory<?> mem) { out.println("buffer released"); assertEquals(mem, buffer); countdown.countDown(); @@ -380,8 +383,8 @@ public class CLBufferTest extends UITestCase { } - public static void main(String[] args) throws IOException { - String tstname = CLBufferTest.class.getName(); + public static void main(final String[] args) throws IOException { + final String tstname = CLBufferTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/test/com/jogamp/opencl/CLCommandQueueTest.java b/test/com/jogamp/opencl/CLCommandQueueTest.java index 9b3ed50e..c5c3f94c 100644 --- a/test/com/jogamp/opencl/CLCommandQueueTest.java +++ b/test/com/jogamp/opencl/CLCommandQueueTest.java @@ -43,6 +43,7 @@ import com.jogamp.opencl.CLMemory.Mem; import com.jogamp.opencl.util.CLDeviceFilters; import com.jogamp.opencl.util.CLPlatformFilters; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLCommandQueueBinding; import java.io.IOException; import java.nio.ByteBuffer; @@ -73,26 +74,26 @@ public class CLCommandQueueTest extends UITestCase { public void enumsTest() { //CLCommandQueueEnums - EnumSet<Mode> queueMode = Mode.valuesOf(CL.CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL.CL_QUEUE_PROFILING_ENABLE); + final EnumSet<Mode> queueMode = Mode.valuesOf(CLCommandQueueBinding.CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CLCommandQueueBinding.CL_QUEUE_PROFILING_ENABLE); assertTrue(queueMode.contains(OUT_OF_ORDER_MODE)); assertTrue(queueMode.contains(PROFILING_MODE)); assertNotNull(Mode.valuesOf(0)); assertEquals(0, Mode.valuesOf(0).size()); - for (Mode mode : Mode.values()) { + for (final Mode mode : Mode.values()) { assertEquals(mode, Mode.valueOf(mode.QUEUE_MODE)); } // CLEvent enums - for (ProfilingCommand cmd : ProfilingCommand.values()) { + for (final ProfilingCommand cmd : ProfilingCommand.values()) { assertEquals(cmd, ProfilingCommand.valueOf(cmd.COMMAND)); } - for (CommandType type : CommandType.values()) { + for (final CommandType type : CommandType.values()) { assertEquals(type, CommandType.valueOf(type.TYPE)); } - for (ExecutionStatus status : ExecutionStatus.values()) { + for (final ExecutionStatus status : ExecutionStatus.values()) { assertEquals(status, ExecutionStatus.valueOf(status.STATUS)); } @@ -103,25 +104,25 @@ public class CLCommandQueueTest extends UITestCase { out.println(" - - - event synchronization test - - - "); - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); try{ - CLDevice device = context.getDevices()[0]; - int groupSize = device.getMaxWorkItemSizes()[0]; + final CLDevice device = context.getDevices()[0]; + final int groupSize = device.getMaxWorkItemSizes()[0]; final int elements = roundUp(groupSize, ONE_MB / SIZEOF_INT * 5); // 5MB per buffer - CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); - CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); - CLBuffer<ByteBuffer> clBufferC = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); - CLBuffer<ByteBuffer> clBufferD = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferC = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferD = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); fillBuffer(clBufferA.buffer, 12345); fillBuffer(clBufferB.buffer, 67890); - CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); - CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements); - CLCommandQueue queue = device.createCommandQueue(); + final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); + final CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements); + final CLCommandQueue queue = device.createCommandQueue(); out.println(queue); @@ -174,7 +175,7 @@ public class CLCommandQueueTest extends UITestCase { out.println(" - - - event conditions test - - - "); - CLPlatform platform = CLPlatform.getDefault(CLPlatformFilters.queueMode(OUT_OF_ORDER_MODE)); + final CLPlatform platform = CLPlatform.getDefault(CLPlatformFilters.queueMode(OUT_OF_ORDER_MODE)); CLDevice device = null; // we can still test this with in-order queues @@ -184,15 +185,15 @@ public class CLCommandQueueTest extends UITestCase { device = platform.getMaxFlopsDevice(CLDeviceFilters.queueMode(OUT_OF_ORDER_MODE)); } - CLContext context = CLContext.create(device); + final CLContext context = CLContext.create(device); try{ - CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); + final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); - CLBuffer<IntBuffer> buffer = context.createBuffer(newDirectIntBuffer(new int[]{ 1,1,1, 1,1,1, 1,1,1 })); + final CLBuffer<IntBuffer> buffer = context.createBuffer(newDirectIntBuffer(new int[]{ 1,1,1, 1,1,1, 1,1,1 })); - int elements = buffer.getNIOCapacity(); + final int elements = buffer.getNIOCapacity(); CLCommandQueue queue; if(device.getQueueProperties().contains(OUT_OF_ORDER_MODE)) { @@ -202,11 +203,11 @@ public class CLCommandQueueTest extends UITestCase { } // simulate in-order queue by accumulating events of prior commands - CLEventList events = new CLEventList(3); + final CLEventList events = new CLEventList(3); // (1+1)*2 = 4; conditions enforce propper order - CLKernel addKernel = program.createCLKernel("add").putArg(buffer).putArg(1).putArg(elements); - CLKernel mulKernel = program.createCLKernel("mul").putArg(buffer).putArg(2).putArg(elements); + final CLKernel addKernel = program.createCLKernel("add").putArg(buffer).putArg(1).putArg(elements); + final CLKernel mulKernel = program.createCLKernel("mul").putArg(buffer).putArg(2).putArg(elements); queue.putWriteBuffer(buffer, false, events); @@ -234,24 +235,24 @@ public class CLCommandQueueTest extends UITestCase { out.println(" - - - event synchronization test - - - "); - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); try { - CLDevice device = context.getDevices()[0]; - int groupSize = device.getMaxWorkItemSizes()[0]; + final CLDevice device = context.getDevices()[0]; + final int groupSize = device.getMaxWorkItemSizes()[0]; final int elements = roundUp(groupSize, ONE_MB / SIZEOF_INT * 5); // 5MB per buffer - CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); - CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); - CLBuffer<ByteBuffer> clBufferC = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferC = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); fillBuffer(clBufferA.buffer, 12345); fillBuffer(clBufferB.buffer, 67890); - CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); - CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements); - CLCommandQueue queue = device.createCommandQueue(PROFILING_MODE); + final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); + final CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements); + final CLCommandQueue queue = device.createCommandQueue(PROFILING_MODE); out.println(queue); @@ -266,14 +267,14 @@ public class CLCommandQueueTest extends UITestCase { queue.put1DRangeKernel(vectorAddKernel, 0, elements, groupSize, events); assertEquals(1, events.size()); - CLEvent probe = events.getEvent(0); + final CLEvent probe = events.getEvent(0); out.println(probe); queue.putWaitForEvents(events, true); assertEquals(CLEvent.ExecutionStatus.COMPLETE, probe.getStatus()); out.println(probe); - long time = probe.getProfilingInfo(CLEvent.ProfilingCommand.END) + final long time = probe.getProfilingInfo(CLEvent.ProfilingCommand.END) - probe.getProfilingInfo(CLEvent.ProfilingCommand.START); out.println("time: "+time); assertTrue(time > 0); @@ -289,9 +290,9 @@ public class CLCommandQueueTest extends UITestCase { public void customEventsTest() throws IOException, InterruptedException { out.println(" - - - user events test - - - "); - CLPlatform[] platforms = CLPlatform.listCLPlatforms(); + final CLPlatform[] platforms = CLPlatform.listCLPlatforms(); CLPlatform theChosenOne = platforms[0]; - for (CLPlatform platform : platforms) { + for (final CLPlatform platform : platforms) { if(platform.isAtLeast(CL_1_1)) { theChosenOne = platform; break; @@ -306,21 +307,21 @@ public class CLCommandQueueTest extends UITestCase { final CLContext context = CLContext.create(theChosenOne); try{ - CLDevice device = context.getDevices()[0]; - int groupSize = device.getMaxWorkItemSizes()[0]; + final CLDevice device = context.getDevices()[0]; + final int groupSize = device.getMaxWorkItemSizes()[0]; final int elements = roundUp(groupSize, ONE_MB / SIZEOF_INT * 5); // 5MB per buffer - CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); - CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); - CLBuffer<ByteBuffer> clBufferC = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferC = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); fillBuffer(clBufferA.buffer, 12345); fillBuffer(clBufferB.buffer, 67890); - CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); - CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements); - CLCommandQueue queue = device.createCommandQueue(); + final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); + final CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements); + final CLCommandQueue queue = device.createCommandQueue(); queue.putWriteBuffer(clBufferA, true) // write A .putWriteBuffer(clBufferB, true);// write B @@ -329,7 +330,7 @@ public class CLCommandQueueTest extends UITestCase { // the interesting part... - CLUserEvent condition = CLUserEvent.create(context); + final CLUserEvent condition = CLUserEvent.create(context); assertEquals(CommandType.USER, condition.getType()); assertEquals(ExecutionStatus.SUBMITTED, condition.getStatus()); out.println(condition); @@ -365,14 +366,14 @@ public class CLCommandQueueTest extends UITestCase { out.println(" - - - event callback test - - - "); - CLPlatform platform = CLPlatform.getDefault(); + final CLPlatform platform = CLPlatform.getDefault(); if(!platform.isAtLeast(CL_1_1)) { out.println("test disabled, required CLVersion: "+CL_1_1+" available: "+platform.getVersion()); return; } - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); try{ @@ -381,7 +382,7 @@ public class CLCommandQueueTest extends UITestCase { final CountDownLatch countdown = new CountDownLatch(1); customEvent.registerCallback(new CLEventListener() { @Override - public void eventStateChanged(CLEvent event, int status) { + public void eventStateChanged(final CLEvent event, final int status) { out.println("event received: "+event); assertEquals(event, customEvent); countdown.countDown(); @@ -407,11 +408,11 @@ public class CLCommandQueueTest extends UITestCase { final int elements = ONE_MB / SIZEOF_INT * 10; // 20MB per buffer - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); try{ - CLDevice[] devices = context.getDevices(); + final CLDevice[] devices = context.getDevices(); // ignore this test if we can't test in parallel if (devices.length < 2) { @@ -427,7 +428,7 @@ public class CLCommandQueueTest extends UITestCase { final CLBuffer<ByteBuffer> clBufferA2 = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); final CLBuffer<ByteBuffer> clBufferB2 = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY); - CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); + final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build(); //two independent kernel instances final CLKernel vectorAddKernel1 = program.createCLKernel("VectorAddGM").setArg(3, elements); @@ -444,12 +445,12 @@ public class CLCommandQueueTest extends UITestCase { final MultiQueueBarrier barrier = new MultiQueueBarrier(2); - Thread thread1 = new Thread("C") { + final Thread thread1 = new Thread("C") { @Override public void run() { - int groupSize = queue1.getDevice().getMaxWorkItemSizes()[0]; + final int groupSize = queue1.getDevice().getMaxWorkItemSizes()[0]; fillBuffer(clBufferA1.buffer, 12345); fillBuffer(clBufferB1.buffer, 67890); @@ -462,7 +463,7 @@ public class CLCommandQueueTest extends UITestCase { vectorAddKernel1.setArgs(clBufferA1, clBufferB1, clBufferC); // C = A+B // System.out.println("C kernels"); - CLEventList events1 = new CLEventList(2); + final CLEventList events1 = new CLEventList(2); queue1.put1DRangeKernel(vectorAddKernel1, 0, elements, groupSize, events1) .putReadBuffer(clBufferC, false, events1); @@ -471,14 +472,14 @@ public class CLCommandQueueTest extends UITestCase { } }; - Thread thread2 = new Thread("D") { + final Thread thread2 = new Thread("D") { @Override public void run() { - int maxWorkItemSize = queue2.getDevice().getMaxWorkItemSizes()[0]; - int kernelWorkGroupSize = (int)vectorAddKernel2.getWorkGroupSize( queue2.getDevice() ); - int localWorkSize = Math.min( maxWorkItemSize, kernelWorkGroupSize ); + final int maxWorkItemSize = queue2.getDevice().getMaxWorkItemSizes()[0]; + final int kernelWorkGroupSize = (int)vectorAddKernel2.getWorkGroupSize( queue2.getDevice() ); + final int localWorkSize = Math.min( maxWorkItemSize, kernelWorkGroupSize ); fillBuffer(clBufferA2.buffer, 12345); fillBuffer(clBufferB2.buffer, 67890); @@ -491,7 +492,7 @@ public class CLCommandQueueTest extends UITestCase { vectorAddKernel2.setArgs(clBufferA2, clBufferB2, clBufferD); // D = A+B // System.out.println("D kernels"); - CLEventList events2 = new CLEventList(2); + final CLEventList events2 = new CLEventList(2); queue2.put1DRangeKernel(vectorAddKernel2, 0, elements, localWorkSize, events2); queue2.putReadBuffer(clBufferD, false, events2); @@ -509,15 +510,15 @@ public class CLCommandQueueTest extends UITestCase { checkIfEqual(clBufferC.buffer, clBufferD.buffer, elements); out.println("results are valid"); - } catch (Throwable t ) { + } catch (final Throwable t ) { t.printStackTrace(); } finally { context.release(); } } - public static void main(String[] args) throws IOException { - String tstname = CLCommandQueueTest.class.getName(); + public static void main(final String[] args) throws IOException { + final String tstname = CLCommandQueueTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/test/com/jogamp/opencl/CLExceptionTest.java b/test/com/jogamp/opencl/CLExceptionTest.java index 5a1ce89b..8a61fd0f 100644 --- a/test/com/jogamp/opencl/CLExceptionTest.java +++ b/test/com/jogamp/opencl/CLExceptionTest.java @@ -47,20 +47,20 @@ public class CLExceptionTest extends UITestCase { @Test public void testCLExceptions() throws InstantiationException, IllegalAccessException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException { - Class<?>[] subTypes = CLException.class.getDeclaredClasses(); + final Class<?>[] subTypes = CLException.class.getDeclaredClasses(); - for (Class<?> type : subTypes) { + for (final Class<?> type : subTypes) { if(type.getName().startsWith(CLException.class.getName()+"$CL")) { - CLException exception = (CLException) type.getConstructor(String.class).newInstance("foo"); + final CLException exception = (CLException) type.getConstructor(String.class).newInstance("foo"); assertNotNull("can not resolve "+exception, CLException.resolveErrorCode(exception.errorcode)); try{ CLException.checkForError(exception.errorcode, "foo"); fail("expected exception for: "+exception.getClass().getName()+" code: "+exception.errorcode); - }catch(CLException ex) { + }catch(final CLException ex) { assertTrue("wrong instance; expected "+exception.getClass()+" but got "+ex.getClass(), exception.getClass().equals(ex.getClass())); } @@ -68,8 +68,8 @@ public class CLExceptionTest extends UITestCase { } } - public static void main(String[] args) throws IOException { - String tstname = CLExceptionTest.class.getName(); + public static void main(final String[] args) throws IOException { + final String tstname = CLExceptionTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/test/com/jogamp/opencl/CLImageTest.java b/test/com/jogamp/opencl/CLImageTest.java index 5f5c0503..17bcd65f 100644 --- a/test/com/jogamp/opencl/CLImageTest.java +++ b/test/com/jogamp/opencl/CLImageTest.java @@ -60,18 +60,18 @@ public class CLImageTest extends UITestCase { @BeforeClass public static void init() throws IOException { - BufferedImage bi = ImageIO.read(CLImageTest.class.getResourceAsStream("jogamp.png")); + final BufferedImage bi = ImageIO.read(CLImageTest.class.getResourceAsStream("jogamp.png")); pixels = new int[128*128*4]; bi.getData().getPixels(0, 0, 128, 128, pixels); } public CLDevice getCompatibleDevice() { - CLPlatform[] platforms = CLPlatform.listCLPlatforms(); - for (CLPlatform platform : platforms) { - CLDevice[] devices = platform.listCLDevices(); + final CLPlatform[] platforms = CLPlatform.listCLPlatforms(); + for (final CLPlatform platform : platforms) { + final CLDevice[] devices = platform.listCLDevices(); - for (CLDevice device : devices) { + for (final CLDevice device : devices) { if(device.isImageSupportAvailable()) { return device; } @@ -84,15 +84,15 @@ public class CLImageTest extends UITestCase { @Test public void supportedImageFormatsTest() { - CLDevice device = getCompatibleDevice(); + final CLDevice device = getCompatibleDevice(); if(device == null) { out.println("WARNING: can not test image api."); return; } - CLContext context = CLContext.create(device); + final CLContext context = CLContext.create(device); try{ - CLImageFormat[] formats = context.getSupportedImage2dFormats(); + final CLImageFormat[] formats = context.getSupportedImage2dFormats(); assertTrue(formats.length > 0); out.println("sample image format: "+formats[0]); // for (CLImageFormat format : formats) { @@ -106,28 +106,28 @@ public class CLImageTest extends UITestCase { @Test public void image2dCopyTest() throws IOException { - CLDevice device = getCompatibleDevice(); + final CLDevice device = getCompatibleDevice(); if(device == null) { out.println("WARNING: can not test image api."); return; } - CLContext context = CLContext.create(device); + final CLContext context = CLContext.create(device); - CLCommandQueue queue = device.createCommandQueue(); + final CLCommandQueue queue = device.createCommandQueue(); try{ - CLImageFormat format = new CLImageFormat(RGBA, UNSIGNED_INT32); + final CLImageFormat format = new CLImageFormat(RGBA, UNSIGNED_INT32); - CLImage2d<IntBuffer> imageA = context.createImage2d(newDirectIntBuffer(pixels), 128, 128, format); - CLImage2d<IntBuffer> imageB = context.createImage2d(newDirectIntBuffer(pixels.length), 128, 128, format); + final CLImage2d<IntBuffer> imageA = context.createImage2d(newDirectIntBuffer(pixels), 128, 128, format); + final CLImage2d<IntBuffer> imageB = context.createImage2d(newDirectIntBuffer(pixels.length), 128, 128, format); queue.putWriteImage(imageA, false) .putCopyImage(imageA, imageB) .putReadImage(imageB, true); - IntBuffer bufferA = imageA.getBuffer(); - IntBuffer bufferB = imageB.getBuffer(); + final IntBuffer bufferA = imageA.getBuffer(); + final IntBuffer bufferB = imageB.getBuffer(); while(bufferA.hasRemaining()) { assertEquals(bufferA.get(), bufferB.get()); @@ -141,14 +141,14 @@ public class CLImageTest extends UITestCase { @Test public void image2dKernelCopyTest() throws IOException { - CLDevice device = getCompatibleDevice(); + final CLDevice device = getCompatibleDevice(); if(device == null) { out.println("WARNING: can not test image api."); return; } - CLContext context = CLContext.create(device); + final CLContext context = CLContext.create(device); - String src = + final String src = "constant sampler_t imageSampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST; \n" + "kernel void image2dCopy(read_only image2d_t input, write_only image2d_t output) { \n" + " int2 coord = (int2)(get_global_id(0), get_global_id(1)); \n" + @@ -156,24 +156,24 @@ public class CLImageTest extends UITestCase { " write_imageui(output, coord, temp); \n" + "} \n"; - CLKernel kernel = context.createProgram(src).build().createCLKernel("image2dCopy"); + final CLKernel kernel = context.createProgram(src).build().createCLKernel("image2dCopy"); - CLCommandQueue queue = device.createCommandQueue(); + final CLCommandQueue queue = device.createCommandQueue(); try{ - CLImageFormat format = new CLImageFormat(RGBA, UNSIGNED_INT32); + final CLImageFormat format = new CLImageFormat(RGBA, UNSIGNED_INT32); - CLImage2d<IntBuffer> imageA = context.createImage2d(newDirectIntBuffer(pixels), 128, 128, format); - CLImage2d<IntBuffer> imageB = context.createImage2d(newDirectIntBuffer(pixels.length), 128, 128, format); + final CLImage2d<IntBuffer> imageA = context.createImage2d(newDirectIntBuffer(pixels), 128, 128, format); + final CLImage2d<IntBuffer> imageB = context.createImage2d(newDirectIntBuffer(pixels.length), 128, 128, format); kernel.putArgs(imageA, imageB); queue.putWriteImage(imageA, false) .put2DRangeKernel(kernel, 0, 0, 128, 128, 0, 0) .putReadImage(imageB, true); - IntBuffer bufferA = imageA.getBuffer(); - IntBuffer bufferB = imageB.getBuffer(); + final IntBuffer bufferA = imageA.getBuffer(); + final IntBuffer bufferB = imageB.getBuffer(); while(bufferA.hasRemaining()) { assertEquals(bufferA.get(), bufferB.get()); @@ -184,8 +184,8 @@ public class CLImageTest extends UITestCase { } } - public static void main(String[] args) throws IOException { - String tstname = CLImageTest.class.getName(); + public static void main(final String[] args) throws IOException { + final String tstname = CLImageTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/test/com/jogamp/opencl/CLProgramTest.java b/test/com/jogamp/opencl/CLProgramTest.java index cf74f4f2..e5baeb2c 100644 --- a/test/com/jogamp/opencl/CLProgramTest.java +++ b/test/com/jogamp/opencl/CLProgramTest.java @@ -70,7 +70,7 @@ public class CLProgramTest extends UITestCase { public void enumsTest() { // CLProgram enums - for (Status e : Status.values()) { + for (final Status e : Status.values()) { assertEquals(e, Status.valueOf(e.STATUS)); } } @@ -80,8 +80,8 @@ public class CLProgramTest extends UITestCase { out.println(" - - - CLProgramTest; rebuild program test - - - "); - CLContext context = CLContext.create(); - CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")); + final CLContext context = CLContext.create(); + final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")); // only test kernel creation error on unbuilt program if we're not on AMD -- as of // 3/8/2014, AMD drivers segfault on this instead of returning CL_INVALID_PROGRAM_EXECUTABLE @@ -89,7 +89,7 @@ public class CLProgramTest extends UITestCase { try{ program.createCLKernels(); fail("expected exception but got none :("); - }catch(CLException ex) { + }catch(final CLException ex) { out.println("got expected exception: "+ex.getCLErrorString()); assertEquals(ex.errorcode, CL.CL_INVALID_PROGRAM_EXECUTABLE); } @@ -123,16 +123,16 @@ public class CLProgramTest extends UITestCase { out.println(" - - - CLProgramTest; down-/upload binaries test - - - "); - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")) .build(ENABLE_MAD, WARNINGS_ARE_ERRORS); // obtain binaries - Map<CLDevice, byte[]> binaries = program.getBinaries(); + final Map<CLDevice, byte[]> binaries = program.getBinaries(); assertFalse(binaries.isEmpty()); - CLDevice[] devices = program.getCLDevices(); - for (CLDevice device : devices) { + final CLDevice[] devices = program.getCLDevices(); + for (final CLDevice device : devices) { assertTrue(binaries.containsKey(device)); } @@ -155,7 +155,7 @@ public class CLProgramTest extends UITestCase { assertEquals(program.getCLDevices().length, 0); { - Map<String, CLKernel> kernels = program.createCLKernels(); + final Map<String, CLKernel> kernels = program.createCLKernels(); assertNotNull(kernels); assertEquals(kernels.size(), 0); } @@ -181,9 +181,9 @@ public class CLProgramTest extends UITestCase { // 3/8/2014, AMD drivers segfault on this instead of returning CL_INVALID_PROGRAM_EXECUTABLE if(!context.getPlatform().isVendorAMD()) { try{ - Map<String, CLKernel> kernels = program.createCLKernels(); + final Map<String, CLKernel> kernels = program.createCLKernels(); fail("expected an exception from createCLKernels but got: "+kernels); - }catch(CLException ex) { + }catch(final CLException ex) { // expected, not built yet } } @@ -204,7 +204,7 @@ public class CLProgramTest extends UITestCase { public void builderTest() throws IOException, ClassNotFoundException, InterruptedException { out.println(" - - - CLProgramTest; program builder test - - - "); - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")); // same as program.build() @@ -223,7 +223,7 @@ public class CLProgramTest extends UITestCase { assertTrue(program.isExecutable()); // reusable builder - CLBuildConfiguration builder = CLProgramBuilder.createConfiguration() + final CLBuildConfiguration builder = CLProgramBuilder.createConfiguration() .withOption(ENABLE_MAD) .forDevices(context.getDevices()) .withDefine("RADIUS", 5) @@ -236,9 +236,9 @@ public class CLProgramTest extends UITestCase { final CountDownLatch countdown = new CountDownLatch(1); final CLProgram outerProgram = program; - CLBuildListener buildCallback = new CLBuildListener() { + final CLBuildListener buildCallback = new CLBuildListener() { @Override - public void buildFinished(CLProgram program) { + public void buildFinished(final CLProgram program) { assertEquals(outerProgram, program); countdown.countDown(); } @@ -251,14 +251,14 @@ public class CLProgramTest extends UITestCase { assertTrue(program.isExecutable()); // serialization test - File file = tmpFolder.newFile("foobar.builder"); - ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file)); + final File file = tmpFolder.newFile("foobar.builder"); + final ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file)); builder.save(oos); oos.close(); // build configuration ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file)); - CLBuildConfiguration buildConfig = CLProgramBuilder.loadConfiguration(ois); + final CLBuildConfiguration buildConfig = CLProgramBuilder.loadConfiguration(ois); ois.close(); assertEquals(builder, buildConfig); @@ -268,7 +268,7 @@ public class CLProgramTest extends UITestCase { // program configuration ois = new ObjectInputStream(new FileInputStream(file)); - CLProgramConfiguration programConfig = CLProgramBuilder.loadConfiguration(ois, context); + final CLProgramConfiguration programConfig = CLProgramBuilder.loadConfiguration(ois, context); assertNotNull(programConfig.getProgram()); ois.close(); program = programConfig.build(); @@ -284,18 +284,18 @@ public class CLProgramTest extends UITestCase { @Test public void kernelTest() { - String source = "__attribute__((reqd_work_group_size(1, 1, 1))) kernel void foo(float a, int b, short c) { }\n"; + final String source = "__attribute__((reqd_work_group_size(1, 1, 1))) kernel void foo(float a, int b, short c) { }\n"; - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); try{ - CLProgram program = context.createProgram(source).build(); + final CLProgram program = context.createProgram(source).build(); assertTrue(program.isExecutable()); - CLKernel kernel = program.createCLKernel("foo"); + final CLKernel kernel = program.createCLKernel("foo"); assertNotNull(kernel); - long[] wgs = kernel.getCompileWorkGroupSize(context.getDevices()[0]); + final long[] wgs = kernel.getCompileWorkGroupSize(context.getDevices()[0]); out.println("compile workgroup size: " + wgs[0]+" "+wgs[1]+" "+wgs[2]); @@ -318,7 +318,7 @@ public class CLProgramTest extends UITestCase { try{ kernel.putArg(3); fail("exception not thrown"); - }catch (IndexOutOfBoundsException expected){ } + }catch (final IndexOutOfBoundsException expected){ } assertEquals(3, kernel.position()); assertEquals(0, kernel.rewind().position()); @@ -332,16 +332,16 @@ public class CLProgramTest extends UITestCase { @Test public void createAllKernelsTest() { - String source = "kernel void foo(int a) { }\n"+ + final String source = "kernel void foo(int a) { }\n"+ "kernel void bar(float b) { }\n"; - CLContext context = CLContext.create(); + final CLContext context = CLContext.create(); try{ - CLProgram program = context.createProgram(source).build(); + final CLProgram program = context.createProgram(source).build(); assertTrue(program.isExecutable()); - Map<String, CLKernel> kernels = program.createCLKernels(); - for (CLKernel kernel : kernels.values()) { + final Map<String, CLKernel> kernels = program.createCLKernels(); + for (final CLKernel kernel : kernels.values()) { out.println("kernel: "+kernel.toString()); } @@ -367,8 +367,8 @@ public class CLProgramTest extends UITestCase { } } - public static void main(String[] args) throws IOException { - String tstname = CLProgramTest.class.getName(); + public static void main(final String[] args) throws IOException { + final String tstname = CLProgramTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/test/com/jogamp/opencl/HighLevelBindingTest.java b/test/com/jogamp/opencl/HighLevelBindingTest.java index a4ce8e74..aee6321c 100644 --- a/test/com/jogamp/opencl/HighLevelBindingTest.java +++ b/test/com/jogamp/opencl/HighLevelBindingTest.java @@ -40,6 +40,7 @@ import com.jogamp.opencl.CLDevice.LocalMemType; import com.jogamp.opencl.CLDevice.Type; import com.jogamp.opencl.CLDevice.Capabilities; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLDeviceBinding; import com.jogamp.opencl.test.util.MiscUtils; import com.jogamp.opencl.test.util.UITestCase; @@ -82,51 +83,51 @@ public class HighLevelBindingTest extends UITestCase { public void enumsTest() { // enum tests - final EnumSet<FPConfig> singleFPConfig = FPConfig.valuesOf(CL.CL_FP_DENORM | CL.CL_FP_ROUND_TO_INF); + final EnumSet<FPConfig> singleFPConfig = FPConfig.valuesOf(CLDeviceBinding.CL_FP_DENORM | CLDeviceBinding.CL_FP_ROUND_TO_INF); assertEquals(0, FPConfig.valuesOf(0).size()); assertTrue(singleFPConfig.contains(FPConfig.DENORM)); assertTrue(singleFPConfig.contains(FPConfig.ROUND_TO_INF)); // CLDevice enums - for (FPConfig e : FPConfig.values()) { - EnumSet<FPConfig> set = FPConfig.valuesOf(e.CONFIG); + for (final FPConfig e : FPConfig.values()) { + final EnumSet<FPConfig> set = FPConfig.valuesOf(e.CONFIG); assertTrue(set.contains(e)); } - for (GlobalMemCacheType e : GlobalMemCacheType.values()) { + for (final GlobalMemCacheType e : GlobalMemCacheType.values()) { assertEquals(e, GlobalMemCacheType.valueOf(e.TYPE)); } - for (LocalMemType e : LocalMemType.values()) { + for (final LocalMemType e : LocalMemType.values()) { assertEquals(e, LocalMemType.valueOf(e.TYPE)); } - for (Type e : Type.values()) { + for (final Type e : Type.values()) { assertEquals(e, Type.valueOf(e.TYPE)); } - for (Capabilities e : Capabilities.values()) { + for (final Capabilities e : Capabilities.values()) { assertEquals(e, Capabilities.valueOf(e.CAPS)); } // CLMemory enums - for (Mem e : Mem.values()) { + for (final Mem e : Mem.values()) { assertEquals(e, Mem.valueOf(e.CONFIG)); } - for (GLObjectType e : GLObjectType.values()) { + for (final GLObjectType e : GLObjectType.values()) { assertEquals(e, GLObjectType.valueOf(e.TYPE)); } // CLSampler enums - for (AddressingMode e : AddressingMode.values()) { + for (final AddressingMode e : AddressingMode.values()) { assertEquals(e, AddressingMode.valueOf(e.MODE)); } - for (FilteringMode e : FilteringMode.values()) { + for (final FilteringMode e : FilteringMode.values()) { assertEquals(e, FilteringMode.valueOf(e.MODE)); } // CLImage enums - for (ChannelOrder e : ChannelOrder.values()) { + for (final ChannelOrder e : ChannelOrder.values()) { assertEquals(e, ChannelOrder.valueOf(e.ORDER)); } - for (ChannelType e : ChannelType.values()) { + for (final ChannelType e : ChannelType.values()) { assertEquals(e, ChannelType.valueOf(e.TYPE)); } @@ -140,9 +141,9 @@ public class HighLevelBindingTest extends UITestCase { out.println(" - - - highLevelTest; contextless - - - "); // platform/device info tests - CLPlatform[] clPlatforms = CLPlatform.listCLPlatforms(); + final CLPlatform[] clPlatforms = CLPlatform.listCLPlatforms(); - for (CLPlatform platform : clPlatforms) { + for (final CLPlatform platform : clPlatforms) { out.println("platform info:"); out.println(" name: "+platform.getName()); @@ -154,8 +155,8 @@ public class HighLevelBindingTest extends UITestCase { out.println(" max FLOPS device: "+platform.getMaxFlopsDevice()); out.println(" extensions: "+platform.getExtensions()); - CLDevice[] clDevices = platform.listCLDevices(); - for (CLDevice device : clDevices) { + final CLDevice[] clDevices = platform.listCLDevices(); + for (final CLDevice device : clDevices) { out.println("device info:"); out.println(" name: "+device.getName()); out.println(" profile: "+device.getProfile()); @@ -207,8 +208,10 @@ public class HighLevelBindingTest extends UITestCase { @Test public void platformTest() { @SuppressWarnings("unchecked") + final CLPlatform platformGPU = CLPlatform.getDefault(version(CL_1_0), type(GPU)); @SuppressWarnings("unchecked") + final CLPlatform platformCPU = CLPlatform.getDefault(version(CL_1_0), type(CPU)); if(platformGPU != null) { @@ -225,9 +228,9 @@ public class HighLevelBindingTest extends UITestCase { out.println(" - - - highLevelTest; create context - - - "); - CLPlatform platform = CLPlatform.getDefault(); - CLDevice[] devices = platform.listCLDevices(); - int deviceCount = devices.length; + final CLPlatform platform = CLPlatform.getDefault(); + final CLDevice[] devices = platform.listCLDevices(); + final int deviceCount = devices.length; CLContext c = CLContext.create(); assertNotNull(c); @@ -239,7 +242,7 @@ public class HighLevelBindingTest extends UITestCase { assertEquals(deviceCount, c.getDevices().length); c.release(); - for (CLDevice device : devices) { + for (final CLDevice device : devices) { c = CLContext.create(device); assertNotNull(c); assertEquals(1, c.getDevices().length); @@ -261,19 +264,19 @@ public class HighLevelBindingTest extends UITestCase { try{ CLContext.create((CLDevice)null); fail("create with null device"); - }catch(IllegalArgumentException ex) { + }catch(final IllegalArgumentException ex) { // expected } try{ CLContext.create((CLDevice.Type)null); fail("create with null CLDevice.Type"); - }catch(IllegalArgumentException ex) { + }catch(final IllegalArgumentException ex) { // expected } try{ CLContext.create((CLPlatform)null, (CLDevice.Type)null); fail("create with null CLDevice.Type"); - }catch(IllegalArgumentException ex) { + }catch(final IllegalArgumentException ex) { // expected } @@ -284,38 +287,38 @@ public class HighLevelBindingTest extends UITestCase { out.println(" - - - highLevelTest; global memory kernel - - - "); - CLPlatform[] clPlatforms = CLPlatform.listCLPlatforms(); - CLContext context = CLContext.create(clPlatforms[0]); + final CLPlatform[] clPlatforms = CLPlatform.listCLPlatforms(); + final CLContext context = CLContext.create(clPlatforms[0]); - CLDevice[] contextDevices = context.getDevices(); + final CLDevice[] contextDevices = context.getDevices(); out.println("context devices:"); - for (CLDevice device : contextDevices) { + for (final CLDevice device : contextDevices) { out.println(" "+device.toString()); } out.println("max FLOPS device: " + context.getMaxFlopsDevice()); - InputStream stream = getClass().getResourceAsStream("testkernels.cl"); - CLProgram program = context.createProgram(stream).build(); + final InputStream stream = getClass().getResourceAsStream("testkernels.cl"); + final CLProgram program = context.createProgram(stream).build(); - CLDevice[] programDevices = program.getCLDevices(); - CLDevice device = programDevices[0]; + final CLDevice[] programDevices = program.getCLDevices(); + final CLDevice device = programDevices[0]; assertEquals(contextDevices.length, programDevices.length); out.println("build log:\n"+program.getBuildLog()); out.println("build status:\n"+program.getBuildStatus()); - String source = program.getSource(); + final String source = program.getSource(); assertFalse(source.trim().isEmpty()); // out.println("source:\n"+source); - Map<CLDevice, byte[]> binaries = program.getBinaries(); + final Map<CLDevice, byte[]> binaries = program.getBinaries(); assertFalse(binaries.isEmpty()); int elementCount = 11444777; // Length of float arrays to process (odd # for illustration) - int localWorkSize = device.getMaxWorkItemSizes()[0]; // set and log Global and Local work size dimensions + final int localWorkSize = device.getMaxWorkItemSizes()[0]; // set and log Global and Local work size dimensions int globalWorkSize = 0; ByteBuffer srcA = null; @@ -333,7 +336,7 @@ public class HighLevelBindingTest extends UITestCase { dest = newDirectByteBuffer(globalWorkSize*SIZEOF_INT); allocated = true; } - catch( OutOfMemoryError oome ) { + catch( final OutOfMemoryError oome ) { ++divisor; elementCount /= divisor; out.println("not enough direct buffer memory; retrying with smaller buffers"); @@ -343,18 +346,18 @@ public class HighLevelBindingTest extends UITestCase { fillBuffer(srcA, 23456); fillBuffer(srcB, 46987); - CLBuffer<ByteBuffer> clBufferA = context.createBuffer(srcA, Mem.READ_ONLY); - CLBuffer<ByteBuffer> clBufferB = context.createBuffer(srcB, Mem.READ_ONLY); - CLBuffer<ByteBuffer> clBufferC = context.createBuffer(dest, Mem.WRITE_ONLY); + final CLBuffer<ByteBuffer> clBufferA = context.createBuffer(srcA, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferB = context.createBuffer(srcB, Mem.READ_ONLY); + final CLBuffer<ByteBuffer> clBufferC = context.createBuffer(dest, Mem.WRITE_ONLY); - CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM"); + final CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM"); vectorAddKernel.setArg(0, clBufferA) .setArg(1, clBufferB) .setArg(2, clBufferC) .setArg(3, elementCount); - CLCommandQueue queue = device.createCommandQueue(); + final CLCommandQueue queue = device.createCommandQueue(); // Asynchronous write of data to GPU device, blocking read later queue.putWriteBuffer(clBufferA, false) @@ -387,8 +390,8 @@ public class HighLevelBindingTest extends UITestCase { context.release(); } - public static void main(String[] args) throws IOException { - String tstname = HighLevelBindingTest.class.getName(); + public static void main(final String[] args) throws IOException { + final String tstname = HighLevelBindingTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/test/com/jogamp/opencl/LowLevelBindingTest.java b/test/com/jogamp/opencl/LowLevelBindingTest.java index ef14534a..84aaa73e 100644 --- a/test/com/jogamp/opencl/LowLevelBindingTest.java +++ b/test/com/jogamp/opencl/LowLevelBindingTest.java @@ -33,6 +33,11 @@ import java.util.Random; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.llb.impl.BuildProgramCallback; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLContextBinding; +import com.jogamp.opencl.llb.CLDeviceBinding; +import com.jogamp.opencl.llb.CLMemObjBinding; +import com.jogamp.opencl.llb.CLPlatformBinding; +import com.jogamp.opencl.llb.CLProgramBinding; import com.jogamp.opencl.test.util.MiscUtils; import com.jogamp.opencl.test.util.UITestCase; @@ -104,64 +109,64 @@ public class LowLevelBindingTest extends UITestCase { out.println(" - - - lowLevelTest; contextless binding - - - "); - CL cl = CLPlatform.getLowLevelCLInterface(); + final CL cl = CLPlatform.getLowLevelCLInterface(); // System.out.println(((CLImpl)cl).clGetExtensionFunctionAddress("clCreateFromGLBuffer")); // System.out.println(((CLImpl)cl).clGetExtensionFunctionAddress("clEnqueueAcquireGLObjects")); int ret = CL.CL_SUCCESS; - IntBuffer intBuffer = newDirectIntBuffer(1); + final IntBuffer intBuffer = newDirectIntBuffer(1); // find all available OpenCL platforms ret = cl.clGetPlatformIDs(0, null, intBuffer); checkForError(ret); out.println("#platforms: "+intBuffer.get(0)); - PointerBuffer platformId = PointerBuffer.allocateDirect(intBuffer.get(0)); + final PointerBuffer platformId = PointerBuffer.allocateDirect(intBuffer.get(0)); ret = cl.clGetPlatformIDs(platformId.capacity(), platformId, null); checkForError(ret); // print platform info - PointerBuffer longBuffer = PointerBuffer.allocateDirect(1); - ByteBuffer bb = newDirectByteBuffer(128); + final PointerBuffer longBuffer = PointerBuffer.allocateDirect(1); + final ByteBuffer bb = newDirectByteBuffer(128); for (int i = 0; i < platformId.capacity(); i++) { - long platform = platformId.get(i); + final long platform = platformId.get(i); out.println("platform id: "+platform); - ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_PROFILE, bb.capacity(), bb, longBuffer); + ret = cl.clGetPlatformInfo(platform, CLPlatformBinding.CL_PLATFORM_PROFILE, bb.capacity(), bb, longBuffer); checkForError(ret); out.println(" profile: " + clString2JavaString(bb, (int)longBuffer.get(0))); - ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_VERSION, bb.capacity(), bb, longBuffer); + ret = cl.clGetPlatformInfo(platform, CLPlatformBinding.CL_PLATFORM_VERSION, bb.capacity(), bb, longBuffer); checkForError(ret); out.println(" version: " + clString2JavaString(bb, (int)longBuffer.get(0))); - ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_NAME, bb.capacity(), bb, longBuffer); + ret = cl.clGetPlatformInfo(platform, CLPlatformBinding.CL_PLATFORM_NAME, bb.capacity(), bb, longBuffer); checkForError(ret); out.println(" name: " + clString2JavaString(bb, (int)longBuffer.get(0))); - ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_VENDOR, bb.capacity(), bb, longBuffer); + ret = cl.clGetPlatformInfo(platform, CLPlatformBinding.CL_PLATFORM_VENDOR, bb.capacity(), bb, longBuffer); checkForError(ret); out.println(" vendor: " + clString2JavaString(bb, (int)longBuffer.get(0))); //find all devices - ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, 0, null, intBuffer); + ret = cl.clGetDeviceIDs(platform, CLDeviceBinding.CL_DEVICE_TYPE_ALL, 0, null, intBuffer); checkForError(ret); out.println("#devices: "+intBuffer.get(0)); - PointerBuffer devices = PointerBuffer.allocateDirect(intBuffer.get(0)); - ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, devices.capacity(), devices, null); + final PointerBuffer devices = PointerBuffer.allocateDirect(intBuffer.get(0)); + ret = cl.clGetDeviceIDs(platform, CLDeviceBinding.CL_DEVICE_TYPE_ALL, devices.capacity(), devices, null); //print device info for (int j = 0; j < devices.capacity(); j++) { - long device = devices.get(j); - ret = cl.clGetDeviceInfo(device, CL.CL_DEVICE_NAME, bb.capacity(), bb, longBuffer); + final long device = devices.get(j); + ret = cl.clGetDeviceInfo(device, CLDeviceBinding.CL_DEVICE_NAME, bb.capacity(), bb, longBuffer); checkForError(ret); out.println(" device: " + clString2JavaString(bb, (int)longBuffer.get(0))); - ret = cl.clGetDeviceInfo(device, CL.CL_DEVICE_TYPE, bb.capacity(), bb, longBuffer); + ret = cl.clGetDeviceInfo(device, CLDeviceBinding.CL_DEVICE_TYPE, bb.capacity(), bb, longBuffer); checkForError(ret); out.println(" type: " + CLDevice.Type.valueOf(bb.get())); bb.rewind(); @@ -176,37 +181,37 @@ public class LowLevelBindingTest extends UITestCase { out.println(" - - - createContextTest - - - "); - CL cl = CLPlatform.getLowLevelCLInterface(); + final CL cl = CLPlatform.getLowLevelCLInterface(); - IntBuffer intBuffer = newDirectIntBuffer(1); + final IntBuffer intBuffer = newDirectIntBuffer(1); // find all available OpenCL platforms int ret = cl.clGetPlatformIDs(0, null, intBuffer); checkForError(ret); out.println("#platforms: "+intBuffer.get(0)); - PointerBuffer pb = PointerBuffer.allocateDirect(intBuffer.get(0)); + final PointerBuffer pb = PointerBuffer.allocateDirect(intBuffer.get(0)); ret = cl.clGetPlatformIDs(pb.capacity(), pb, null); checkForError(ret); - long platform = pb.get(0); + final long platform = pb.get(0); //find all devices - ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, 0, null, intBuffer); + ret = cl.clGetDeviceIDs(platform, CLDeviceBinding.CL_DEVICE_TYPE_ALL, 0, null, intBuffer); checkForError(ret); out.println("#devices: "+intBuffer.get(0)); - PointerBuffer devices = PointerBuffer.allocateDirect(intBuffer.get(0)); - ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, devices.capacity(), devices, null); + final PointerBuffer devices = PointerBuffer.allocateDirect(intBuffer.get(0)); + ret = cl.clGetDeviceIDs(platform, CLDeviceBinding.CL_DEVICE_TYPE_ALL, devices.capacity(), devices, null); - long context = cl.clCreateContext(null, devices, null, intBuffer); + final long context = cl.clCreateContext(null, devices, null, intBuffer); checkError("on clCreateContext", intBuffer.get()); //get number of devices - PointerBuffer longBuffer = PointerBuffer.allocateDirect(1); - ret = cl.clGetContextInfo(context, CL.CL_CONTEXT_DEVICES, 0, null, longBuffer); + final PointerBuffer longBuffer = PointerBuffer.allocateDirect(1); + ret = cl.clGetContextInfo(context, CLContextBinding.CL_CONTEXT_DEVICES, 0, null, longBuffer); checkError("on clGetContextInfo", ret); - long contextDevices = longBuffer.get(0)/(is32Bit()?4:8); + final long contextDevices = longBuffer.get(0)/(is32Bit()?4:8); out.println("context created on " + contextDevices + " devices"); //check if equal @@ -221,40 +226,40 @@ public class LowLevelBindingTest extends UITestCase { out.println(" - - - lowLevelTest2; VectorAdd kernel - - - "); - CL cl = CLPlatform.getLowLevelCLInterface(); + final CL cl = CLPlatform.getLowLevelCLInterface(); int ret = CL.CL_SUCCESS; - IntBuffer intBuffer = newDirectIntBuffer(1); + final IntBuffer intBuffer = newDirectIntBuffer(1); // find all available OpenCL platforms ret = cl.clGetPlatformIDs(0, null, intBuffer); checkForError(ret); assertTrue(intBuffer.get(0) > 0); - PointerBuffer pb = PointerBuffer.allocateDirect(intBuffer.get(0)); + final PointerBuffer pb = PointerBuffer.allocateDirect(intBuffer.get(0)); ret = cl.clGetPlatformIDs(pb.capacity(), pb, null); checkForError(ret); - long platform = pb.get(0); - PointerBuffer properties = PointerBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM) + final long platform = pb.get(0); + final PointerBuffer properties = PointerBuffer.allocateDirect(3).put(CLContextBinding.CL_CONTEXT_PLATFORM) .put(platform).put(0) // 0 terminated array .rewind(); - long context = cl.clCreateContextFromType(properties, CL.CL_DEVICE_TYPE_ALL, null, null); + final long context = cl.clCreateContextFromType(properties, CLDeviceBinding.CL_DEVICE_TYPE_ALL, null, null); out.println("context handle: "+context); checkError("on clCreateContextFromType", ret); - PointerBuffer longBuffer = PointerBuffer.allocateDirect(1); - ret = cl.clGetContextInfo(context, CL.CL_CONTEXT_DEVICES, 0, null, longBuffer); + final PointerBuffer longBuffer = PointerBuffer.allocateDirect(1); + ret = cl.clGetContextInfo(context, CLContextBinding.CL_CONTEXT_DEVICES, 0, null, longBuffer); checkError("on clGetContextInfo", ret); - int deviceCount = (int) (longBuffer.get(0) / (is32Bit() ? 4 : 8)); + final int deviceCount = (int) (longBuffer.get(0) / (is32Bit() ? 4 : 8)); out.println("context created with " + deviceCount + " devices"); // Was originally 4096, but had to make this bigger or it would crash in UITestCase.oneTimeTearDown(){ System.gc() } // without even dumping a stack when using AMD drivers. Presumably the drivers would write past the end // of the block and mess up GC info somehow. - ByteBuffer bb = newDirectByteBuffer(32768); - ret = cl.clGetContextInfo(context, CL.CL_CONTEXT_DEVICES, bb.capacity(), bb, null); + final ByteBuffer bb = newDirectByteBuffer(32768); + ret = cl.clGetContextInfo(context, CLContextBinding.CL_CONTEXT_DEVICES, bb.capacity(), bb, null); checkError("on clGetContextInfo", ret); for (int i = 0; i < deviceCount; i++) { @@ -265,19 +270,19 @@ public class LowLevelBindingTest extends UITestCase { int offset = new Random().nextInt(deviceCount); out.println("using device# " + offset); offset *= (is32Bit() ? 4 : 8); - long device = is32Bit()?bb.getInt(offset):bb.getLong(offset); + final long device = is32Bit()?bb.getInt(offset):bb.getLong(offset); bb.rewind(); - ret = cl.clGetDeviceInfo(device, CL.CL_DEVICE_MAX_WORK_GROUP_SIZE, bb.capacity(), bb, null); + ret = cl.clGetDeviceInfo(device, CLDeviceBinding.CL_DEVICE_MAX_WORK_GROUP_SIZE, bb.capacity(), bb, null); checkError("on clGetDeviceInfo", ret); - int maxWGS = bb.getInt(); + final int maxWGS = bb.getInt(); out.println("max WGS: " + maxWGS); // Create a command-queue - long commandQueue = cl.clCreateCommandQueue(context, device, 0, intBuffer); + final long commandQueue = cl.clCreateCommandQueue(context, device, 0, intBuffer); checkError("on clCreateCommandQueue", intBuffer.get(0)); - int localWorkSize = Math.min(128, maxWGS); // set and log Global and Local work size dimensions + final int localWorkSize = Math.min(128, maxWGS); // set and log Global and Local work size dimensions int elementCount = ELEMENT_COUNT; int globalWorkSize = 0; @@ -296,7 +301,7 @@ public class LowLevelBindingTest extends UITestCase { dest = newDirectByteBuffer(globalWorkSize*SIZEOF_INT); allocated = true; } - catch( OutOfMemoryError oome ) { + catch( final OutOfMemoryError oome ) { ++divisor; elementCount /= divisor; out.println("not enough direct buffer memory; retrying with smaller buffers"); @@ -304,25 +309,25 @@ public class LowLevelBindingTest extends UITestCase { } // Allocate the OpenCL buffer memory objects for source and result on the device GMEM - long devSrcA = cl.clCreateBuffer(context, CL.CL_MEM_READ_ONLY, srcA.capacity(), null, intBuffer); + final long devSrcA = cl.clCreateBuffer(context, CLMemObjBinding.CL_MEM_READ_ONLY, srcA.capacity(), null, intBuffer); checkError("on clCreateBuffer", intBuffer.get(0)); - long devSrcB = cl.clCreateBuffer(context, CL.CL_MEM_READ_ONLY, srcB.capacity(), null, intBuffer); + final long devSrcB = cl.clCreateBuffer(context, CLMemObjBinding.CL_MEM_READ_ONLY, srcB.capacity(), null, intBuffer); checkError("on clCreateBuffer", intBuffer.get(0)); - long devDst = cl.clCreateBuffer(context, CL.CL_MEM_WRITE_ONLY, dest.capacity(), null, intBuffer); + final long devDst = cl.clCreateBuffer(context, CLMemObjBinding.CL_MEM_WRITE_ONLY, dest.capacity(), null, intBuffer); checkError("on clCreateBuffer", intBuffer.get(0)); // Create the program - PointerBuffer lengths = PointerBuffer.allocateDirect(1).put(programSource.length()).rewind(); + final PointerBuffer lengths = PointerBuffer.allocateDirect(1).put(programSource.length()).rewind(); final long program = cl.clCreateProgramWithSource(context, 1, new String[] {programSource}, lengths, intBuffer); out.println("program id: "+program); checkError("on clCreateProgramWithSource", intBuffer.get(0)); // tests if the callback is called final CountDownLatch latch = new CountDownLatch(1); - BuildProgramCallback callback = new BuildProgramCallback() { + final BuildProgramCallback callback = new BuildProgramCallback() { @Override - public void buildFinished(long cl_program) { + public void buildFinished(final long cl_program) { try{ assertEquals(program, cl_program); }finally{ @@ -344,40 +349,40 @@ public class LowLevelBindingTest extends UITestCase { // Read program infos bb.rewind(); - ret = cl.clGetProgramInfo(program, CL.CL_PROGRAM_NUM_DEVICES, bb.capacity(), bb, null); + ret = cl.clGetProgramInfo(program, CLProgramBinding.CL_PROGRAM_NUM_DEVICES, bb.capacity(), bb, null); checkError("on clGetProgramInfo1", ret); out.println("program associated with "+bb.getInt(0)+" device(s)"); - ret = cl.clGetProgramInfo(program, CL.CL_PROGRAM_SOURCE, 0, null, longBuffer); + ret = cl.clGetProgramInfo(program, CLProgramBinding.CL_PROGRAM_SOURCE, 0, null, longBuffer); checkError("on clGetProgramInfo CL_PROGRAM_SOURCE", ret); out.println("program source length (cl): "+longBuffer.get(0)); out.println("program source length (java): "+programSource.length()); bb.rewind(); - ret = cl.clGetProgramInfo(program, CL.CL_PROGRAM_SOURCE, bb.capacity(), bb, null); + ret = cl.clGetProgramInfo(program, CLProgramBinding.CL_PROGRAM_SOURCE, bb.capacity(), bb, null); checkError("on clGetProgramInfo CL_PROGRAM_SOURCE", ret); out.println("program source:\n" + clString2JavaString(bb, (int)longBuffer.get(0))); // Check program status bb.rewind(); - ret = cl.clGetProgramBuildInfo(program, device, CL.CL_PROGRAM_BUILD_STATUS, bb.capacity(), bb, null); + ret = cl.clGetProgramBuildInfo(program, device, CLProgramBinding.CL_PROGRAM_BUILD_STATUS, bb.capacity(), bb, null); checkError("on clGetProgramBuildInfo1", ret); out.println("program build status: " + CLProgram.Status.valueOf(bb.getInt(0))); - assertEquals("build status", CL.CL_BUILD_SUCCESS, bb.getInt(0)); + assertEquals("build status", CLProgramBinding.CL_BUILD_SUCCESS, bb.getInt(0)); // Read build log - ret = cl.clGetProgramBuildInfo(program, device, CL.CL_PROGRAM_BUILD_LOG, 0, null, longBuffer); + ret = cl.clGetProgramBuildInfo(program, device, CLProgramBinding.CL_PROGRAM_BUILD_LOG, 0, null, longBuffer); checkError("on clGetProgramBuildInfo2", ret); out.println("program log length: " + longBuffer.get(0)); bb.rewind(); - ret = cl.clGetProgramBuildInfo(program, device, CL.CL_PROGRAM_BUILD_LOG, bb.capacity(), bb, null); + ret = cl.clGetProgramBuildInfo(program, device, CLProgramBinding.CL_PROGRAM_BUILD_LOG, bb.capacity(), bb, null); checkError("on clGetProgramBuildInfo3", ret); out.println("log:\n" + clString2JavaString(bb, (int)longBuffer.get(0))); // Create the kernel - long kernel = cl.clCreateKernel(program, "VectorAdd", intBuffer); + final long kernel = cl.clCreateKernel(program, "VectorAdd", intBuffer); out.println("kernel id: "+kernel); checkError("on clCreateKernel", intBuffer.get(0)); @@ -402,8 +407,8 @@ public class LowLevelBindingTest extends UITestCase { checkError("on clEnqueueWriteBuffer", ret); // Launch kernel - PointerBuffer gWS = PointerBuffer.allocateDirect(1).put(globalWorkSize).rewind(); - PointerBuffer lWS = PointerBuffer.allocateDirect(1).put(localWorkSize).rewind(); + final PointerBuffer gWS = PointerBuffer.allocateDirect(1).put(globalWorkSize).rewind(); + final PointerBuffer lWS = PointerBuffer.allocateDirect(1).put(localWorkSize).rewind(); ret = cl.clEnqueueNDRangeKernel(commandQueue, kernel, 1, null, gWS, lWS, 0, null, null); checkError("on clEnqueueNDRangeKernel", ret); @@ -447,8 +452,8 @@ public class LowLevelBindingTest extends UITestCase { //for memory leak detection; e.g watch out for "out of host memory" errors out.println(" - - - loadTest - - - "); - ExecutorService pool = Executors.newFixedThreadPool(8); - List<Callable<Object>> tasks = new ArrayList<Callable<Object>>(); + final ExecutorService pool = Executors.newFixedThreadPool(8); + final List<Callable<Object>> tasks = new ArrayList<Callable<Object>>(); for(int i = 0; i < 100; i++) { final int n = i; @@ -457,11 +462,11 @@ public class LowLevelBindingTest extends UITestCase { public Object call() { try { out.println("###start iteration " + n); - LowLevelBindingTest test = new LowLevelBindingTest(); + final LowLevelBindingTest test = new LowLevelBindingTest(); test.ELEMENT_COUNT = 123456; test.lowLevelVectorAddTest(); out.println("###end iteration " + n); - } catch (InterruptedException ex) { + } catch (final InterruptedException ex) { throw new RuntimeException(ex); } return null; @@ -469,10 +474,10 @@ public class LowLevelBindingTest extends UITestCase { }); } - for (Future<Object> future : pool.invokeAll(tasks)) { + for (final Future<Object> future : pool.invokeAll(tasks)) { try { future.get(); - } catch (ExecutionException ex) { + } catch (final ExecutionException ex) { ex.printStackTrace(); pool.shutdown(); fail(); @@ -482,21 +487,21 @@ public class LowLevelBindingTest extends UITestCase { pool.awaitTermination(300, TimeUnit.SECONDS); } - private ByteBuffer wrap(long value) { + private ByteBuffer wrap(final long value) { return (ByteBuffer) newDirectByteBuffer(8).putLong(value).rewind(); } - private void checkForError(int ret) { + private void checkForError(final int ret) { this.checkError("", ret); } - private void checkError(String msg, int ret) { + private void checkError(final String msg, final int ret) { if(ret != CL.CL_SUCCESS) throw CLException.newException(ret, msg); } - public static void main(String[] args) throws IOException { - String tstname = LowLevelBindingTest.class.getName(); + public static void main(final String[] args) throws IOException { + final String tstname = LowLevelBindingTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/test/com/jogamp/opencl/TestJoclVersion.java b/test/com/jogamp/opencl/TestJoclVersion.java index 531ac343..45fd2e78 100644 --- a/test/com/jogamp/opencl/TestJoclVersion.java +++ b/test/com/jogamp/opencl/TestJoclVersion.java @@ -41,7 +41,7 @@ public class TestJoclVersion extends UITestCase { @Test public void testMain() throws InterruptedException { - JoclVersion j = JoclVersion.getInstance(); + final JoclVersion j = JoclVersion.getInstance(); System.out.println("Implementation-Version: "+j.getImplementationVersion()); System.out.println("Implementation-Build: "+j.getImplementationBuild()); System.out.println("Implementation-Branch: "+j.getImplementationBranch()); @@ -51,8 +51,8 @@ public class TestJoclVersion extends UITestCase { } - public static void main(String[] args) throws IOException { - String tstname = TestJoclVersion.class.getName(); + public static void main(final String[] args) throws IOException { + final String tstname = TestJoclVersion.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/test/com/jogamp/opencl/gl/CLGLTest.java b/test/com/jogamp/opencl/gl/CLGLTest.java index 0d1a8c3f..62e2b2bb 100644 --- a/test/com/jogamp/opencl/gl/CLGLTest.java +++ b/test/com/jogamp/opencl/gl/CLGLTest.java @@ -57,9 +57,11 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.IntBuffer; +import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; import javax.media.opengl.GLContext; +import javax.media.opengl.fixedfunc.GLPointerFunc; import org.junit.FixMethodOrder; import org.junit.Test; @@ -116,8 +118,10 @@ public class CLGLTest extends UITestCase { initGL(); @SuppressWarnings("unchecked") + final CLPlatform platform = CLPlatform.getDefault(CLPlatformFilters.glSharing()); @SuppressWarnings("unchecked") + final CLDevice device = platform.getMaxFlopsDevice(CLDeviceFilters.glSharing()); if(device == null) { @@ -133,7 +137,7 @@ public class CLGLTest extends UITestCase { makeGLCurrent(); assertTrue(glcontext.isCurrent()); - CLContext context = CLGLContext.create(glcontext, device); + final CLContext context = CLGLContext.create(glcontext, device); assertNotNull(context); try{ @@ -162,6 +166,7 @@ public class CLGLTest extends UITestCase { assertTrue(glcontext.isCurrent()); @SuppressWarnings("unchecked") + final CLPlatform platform = CLPlatform.getDefault(glSharing(glcontext)); if(platform == null) { out.println("test aborted"); @@ -169,40 +174,41 @@ public class CLGLTest extends UITestCase { } @SuppressWarnings("unchecked") + final CLDevice theChosenOne = platform.getMaxFlopsDevice(CLDeviceFilters.glSharing()); out.println(theChosenOne); - CLGLContext context = CLGLContext.create(glcontext, theChosenOne); + final CLGLContext context = CLGLContext.create(glcontext, theChosenOne); try{ out.println(context); - GL2 gl = glcontext.getGL().getGL2(); + final GL2 gl = glcontext.getGL().getGL2(); - int[] id = new int[1]; + final int[] id = new int[1]; gl.glGenBuffers(id.length, id, 0); - IntBuffer glData = Buffers.newDirectIntBuffer(new int[] {0,1,2,3,4,5,6,7,8}); + final IntBuffer glData = Buffers.newDirectIntBuffer(new int[] {0,1,2,3,4,5,6,7,8}); glData.rewind(); // create and write GL buffer - gl.glEnableClientState(GL2.GL_VERTEX_ARRAY); - gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, id[0]); - gl.glBufferData(GL2.GL_ARRAY_BUFFER, glData.capacity()*4, glData, GL2.GL_STATIC_DRAW); - gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0); - gl.glDisableClientState(GL2.GL_VERTEX_ARRAY); + gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY); + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, id[0]); + gl.glBufferData(GL.GL_ARRAY_BUFFER, glData.capacity()*4, glData, GL.GL_STATIC_DRAW); + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); + gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY); gl.glFinish(); // create CLGL buffer - IntBuffer clData = Buffers.newDirectIntBuffer(9); - CLGLBuffer<IntBuffer> clBuffer = context.createFromGLBuffer(clData, id[0], glData.capacity()*4, Mem.READ_ONLY); + final IntBuffer clData = Buffers.newDirectIntBuffer(9); + final CLGLBuffer<IntBuffer> clBuffer = context.createFromGLBuffer(clData, id[0], glData.capacity()*4, Mem.READ_ONLY); assertEquals(glData.capacity(), clBuffer.getCLCapacity()); assertEquals(glData.capacity()*4, clBuffer.getCLSize()); - CLCommandQueue queue = theChosenOne.createCommandQueue(); + final CLCommandQueue queue = theChosenOne.createCommandQueue(); // read gl buffer into cl nio buffer queue.putAcquireGLObject(clBuffer) @@ -238,52 +244,54 @@ public class CLGLTest extends UITestCase { assertTrue(glcontext.isCurrent()); @SuppressWarnings("unchecked") + final CLPlatform [] clplatforms = CLPlatform.listCLPlatforms(glSharing(glcontext)); if(clplatforms.length == 0) { out.println("no platform that supports OpenGL-OpenCL interoperability"); return; } - for(CLPlatform clplatform : clplatforms) { - + for(final CLPlatform clplatform : clplatforms) { + @SuppressWarnings("unchecked") + final CLDevice [] cldevices = clplatform.listCLDevices(CLDeviceFilters.glSharing()); - - for(CLDevice cldevice : cldevices) { + + for(final CLDevice cldevice : cldevices) { out.println(cldevice); textureSharingInner(cldevice); } } - + deinitGL(); } - public void textureSharingInner(CLDevice cldevice) { + public void textureSharingInner(final CLDevice cldevice) { - CLGLContext clglcontext = CLGLContext.create(glcontext, cldevice); + final CLGLContext clglcontext = CLGLContext.create(glcontext, cldevice); try { out.println(clglcontext); - GL2 gl = glcontext.getGL().getGL2(); + final GL2 gl = glcontext.getGL().getGL2(); // create and write GL texture - int[] id = new int[1]; + final int[] id = new int[1]; gl.glGenTextures(id.length, id, 0); - gl.glActiveTexture(GL2.GL_TEXTURE0); - gl.glBindTexture (GL2.GL_TEXTURE_2D, id[0]); - int texWidth = 2; - int texHeight = 2; - gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_RGBA, texWidth, texHeight, 0, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, null ); - gl.glBindTexture(GL2.GL_TEXTURE_2D, 0); + gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glBindTexture (GL.GL_TEXTURE_2D, id[0]); + final int texWidth = 2; + final int texHeight = 2; + gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, texWidth, texHeight, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null ); + gl.glBindTexture(GL.GL_TEXTURE_2D, 0); gl.glFinish(); // create CLGL buffer - ByteBuffer bufferCL = Buffers.newDirectByteBuffer(texWidth*texHeight*4); - CLGLTexture2d<ByteBuffer> clTexture = clglcontext.createFromGLTexture2d(bufferCL, GL2.GL_TEXTURE_2D, id[0], 0, CLBuffer.Mem.WRITE_ONLY); + final ByteBuffer bufferCL = Buffers.newDirectByteBuffer(texWidth*texHeight*4); + final CLGLTexture2d<ByteBuffer> clTexture = clglcontext.createFromGLTexture2d(bufferCL, GL.GL_TEXTURE_2D, id[0], 0, CLBuffer.Mem.WRITE_ONLY); // set texel values to a formula that can be read back and verified - String sourceCL = "__kernel void writeTexture (__write_only image2d_t imageTex, unsigned w, unsigned h ) \n" + + final String sourceCL = "__kernel void writeTexture (__write_only image2d_t imageTex, unsigned w, unsigned h ) \n" + "{ \n" + " for(unsigned y=1; y<=h; ++y) { \n" + " for(unsigned x=1; x<=w; ++x) { \n" + @@ -291,19 +299,19 @@ public class CLGLTest extends UITestCase { " } \n" + " } \n" + "}"; - CLProgram program = clglcontext.createProgram(sourceCL); + final CLProgram program = clglcontext.createProgram(sourceCL); program.build(); System.out.println(program.getBuildStatus()); System.out.println(program.getBuildLog()); assertTrue(program.isExecutable()); - CLKernel clkernel = program.createCLKernel("writeTexture") + final CLKernel clkernel = program.createCLKernel("writeTexture") .putArg(clTexture) .putArg(texWidth) .putArg(texHeight) .rewind(); - CLCommandQueue queue = cldevice.createCommandQueue(); + final CLCommandQueue queue = cldevice.createCommandQueue(); // write gl texture with cl kernel, then read it to host buffer queue.putAcquireGLObject(clTexture) @@ -314,12 +322,12 @@ public class CLGLTest extends UITestCase { for(int y = 1; y <= texHeight; y++) { for(int x = 1; x <= texWidth; x++) { - byte bX = bufferCL.get(); - byte bY = bufferCL.get(); - byte bZero = bufferCL.get(); - byte bMinusOne = bufferCL.get(); - byte bXCheck = (byte)(((float)x)/((float)(4*texWidth))*256); - byte bYCheck = (byte)(((float)y)/((float)(4*texHeight))*256); + final byte bX = bufferCL.get(); + final byte bY = bufferCL.get(); + final byte bZero = bufferCL.get(); + final byte bMinusOne = bufferCL.get(); + final byte bXCheck = (byte)(((float)x)/((float)(4*texWidth))*256); + final byte bYCheck = (byte)(((float)y)/((float)(4*texHeight))*256); assertEquals(bXCheck, bX); assertEquals(bYCheck, bY); assertEquals(0, bZero); @@ -343,17 +351,17 @@ public class CLGLTest extends UITestCase { try{ glcontext.makeCurrent(); break; - }catch(RuntimeException ex) { + }catch(final RuntimeException ex) { try { Thread.sleep(200); // I don't give up yet! - } catch (InterruptedException ignore) { } + } catch (final InterruptedException ignore) { } } } } - public static void main(String[] args) throws IOException { - String tstname = CLGLTest.class.getName(); + public static void main(final String[] args) throws IOException { + final String tstname = CLGLTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/test/com/jogamp/opencl/test/util/MiscUtils.java b/test/com/jogamp/opencl/test/util/MiscUtils.java index c91d8f21..85798a06 100644 --- a/test/com/jogamp/opencl/test/util/MiscUtils.java +++ b/test/com/jogamp/opencl/test/util/MiscUtils.java @@ -49,9 +49,9 @@ public class MiscUtils { public final static int NUM_ELEMENTS = 10000000; - public static final void fillBuffer(ByteBuffer buffer, int seed) { + public static final void fillBuffer(final ByteBuffer buffer, final int seed) { - Random rnd = new Random(seed); + final Random rnd = new Random(seed); while(buffer.remaining() != 0) buffer.putInt(rnd.nextInt()); @@ -59,8 +59,8 @@ public class MiscUtils { buffer.rewind(); } - public static final int roundUp(int groupSize, int globalSize) { - int r = globalSize % groupSize; + public static final int roundUp(final int groupSize, final int globalSize) { + final int r = globalSize % groupSize; if (r == 0) { return globalSize; } else { @@ -68,10 +68,10 @@ public class MiscUtils { } } - public static final void checkIfEqual(ByteBuffer a, ByteBuffer b, int elements) { + public static final void checkIfEqual(final ByteBuffer a, final ByteBuffer b, final int elements) { for(int i = 0; i < elements; i++) { - int aVal = a.getInt(); - int bVal = b.getInt(); + final int aVal = a.getInt(); + final int bVal = b.getInt(); if(aVal != bVal) { out.println("a: "+aVal); out.println("b: "+bVal); diff --git a/test/com/jogamp/opencl/test/util/UITestCase.java b/test/com/jogamp/opencl/test/util/UITestCase.java index a5392ee9..b27f2061 100644 --- a/test/com/jogamp/opencl/test/util/UITestCase.java +++ b/test/com/jogamp/opencl/test/util/UITestCase.java @@ -79,7 +79,7 @@ public abstract class UITestCase { return testSupported; } - public static void setTestSupported(boolean v) { + public static void setTestSupported(final boolean v) { System.err.println("setTestSupported: "+v); testSupported = v; } @@ -89,7 +89,7 @@ public abstract class UITestCase { int ml = 0; final TestClass tc = new TestClass(getClass()); final List<FrameworkMethod> testMethods = tc.getAnnotatedMethods(org.junit.Test.class); - for(Iterator<FrameworkMethod> iter=testMethods.iterator(); iter.hasNext(); ) { + for(final Iterator<FrameworkMethod> iter=testMethods.iterator(); iter.hasNext(); ) { final int l = iter.next().getName().length(); if( ml < l ) { ml = l; } } @@ -102,11 +102,11 @@ public abstract class UITestCase { return _unitTestName.getMethodName(); } - public final String getSimpleTestName(String separator) { + public final String getSimpleTestName(final String separator) { return getClass().getSimpleName()+separator+getTestMethodName(); } - public final String getFullTestName(String separator) { + public final String getFullTestName(final String separator) { return getClass().getName()+separator+getTestMethodName(); } @@ -146,12 +146,12 @@ public abstract class UITestCase { System.err.println("++++ UITestCase.tearDown: "+getFullTestName(" - ")); } - public static void waitForKey(String preMessage) { - BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); + public static void waitForKey(final String preMessage) { + final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); System.err.println(preMessage+"> Press enter to continue"); try { System.err.println(stdin.readLine()); - } catch (IOException e) { } + } catch (final IOException e) { } } static final String unsupportedTestMsg = "Test not supported on this platform."; diff --git a/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java b/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java index e1a59860..dea4c17d 100644 --- a/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java +++ b/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java @@ -49,19 +49,19 @@ public class CLMultiContextTest extends UITestCase { @Test public void createMultiContextTest() { - CLMultiContext mc = CLMultiContext.create(CLPlatform.listCLPlatforms()); + final CLMultiContext mc = CLMultiContext.create(CLPlatform.listCLPlatforms()); try{ - List<CLContext> contexts = mc.getContexts(); - List<CLDevice> devices = mc.getDevices(); + final List<CLContext> contexts = mc.getContexts(); + final List<CLDevice> devices = mc.getDevices(); assertFalse(contexts.isEmpty()); assertFalse(devices.isEmpty()); - for (CLContext context : contexts) { + for (final CLContext context : contexts) { out.println(context); } - for (CLDevice device : devices) { + for (final CLDevice device : devices) { out.println(device); } @@ -84,20 +84,20 @@ public class CLMultiContextTest extends UITestCase { private final Buffer data; - public CLTestTask(Buffer buffer) { + public CLTestTask(final Buffer buffer) { this.data = buffer; } - public Buffer execute(CLSimpleQueueContext qc) { + public Buffer execute(final CLSimpleQueueContext qc) { - CLCommandQueue queue = qc.getQueue(); - CLContext context = qc.getCLContext(); - CLKernel kernel = qc.getKernel("compute"); + final CLCommandQueue queue = qc.getQueue(); + final CLContext context = qc.getCLContext(); + final CLKernel kernel = qc.getKernel("compute"); CLBuffer<Buffer> buffer = null; try{ buffer = context.createBuffer(data); - int gws = buffer.getCLCapacity(); + final int gws = buffer.getCLCapacity(); kernel.putArg(buffer).putArg(gws).rewind(); @@ -118,12 +118,12 @@ public class CLMultiContextTest extends UITestCase { @Test public void commandQueuePoolTest() throws InterruptedException, ExecutionException { - CLMultiContext mc = CLMultiContext.create(CLPlatform.listCLPlatforms()); + final CLMultiContext mc = CLMultiContext.create(CLPlatform.listCLPlatforms()); try { CLSimpleContextFactory factory = CLQueueContextFactory.createSimple(programSource); - CLCommandQueuePool<CLSimpleQueueContext> pool = CLCommandQueuePool.create(factory, mc); + final CLCommandQueuePool<CLSimpleQueueContext> pool = CLCommandQueuePool.create(factory, mc); assertTrue(pool.getSize() > 0); @@ -131,12 +131,12 @@ public class CLMultiContextTest extends UITestCase { final int tasksPerQueue = 10; final int taskCount = pool.getSize() * tasksPerQueue; - IntBuffer data = Buffers.newDirectIntBuffer(slice*taskCount); + final IntBuffer data = Buffers.newDirectIntBuffer(slice*taskCount); - List<CLTestTask> tasks = new ArrayList<CLTestTask>(taskCount); + final List<CLTestTask> tasks = new ArrayList<CLTestTask>(taskCount); for (int i = 0; i < taskCount; i++) { - IntBuffer subBuffer = Buffers.slice(data, i*slice, slice); + final IntBuffer subBuffer = Buffers.slice(data, i*slice, slice); assertEquals(slice, subBuffer.capacity()); tasks.add(new CLTestTask(subBuffer)); } @@ -148,14 +148,14 @@ public class CLMultiContextTest extends UITestCase { checkBuffer(1, data); // submit blocking emediatly - for (CLTestTask task : tasks) { + for (final CLTestTask task : tasks) { pool.submit(task).get(); } checkBuffer(2, data); // submitAll using futures - List<Future<Buffer>> futures = pool.submitAll(tasks); - for (Future<Buffer> future : futures) { + final List<Future<Buffer>> futures = pool.submitAll(tasks); + for (final Future<Buffer> future : futures) { future.get(); } checkBuffer(3, data); @@ -172,15 +172,15 @@ public class CLMultiContextTest extends UITestCase { } } - private void checkBuffer(int expected, IntBuffer data) { + private void checkBuffer(final int expected, final IntBuffer data) { while(data.hasRemaining()) { assertEquals(expected, data.get()); } data.rewind(); } - public static void main(String[] args) throws IOException { - String tstname = CLMultiContextTest.class.getName(); + public static void main(final String[] args) throws IOException { + final String tstname = CLMultiContextTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); } |