summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/jogamp')
-rw-r--r--src/com/jogamp/opencl/CLBuffer.java55
-rw-r--r--src/com/jogamp/opencl/CLContext.java153
-rw-r--r--src/com/jogamp/opencl/CLDevice.java209
-rw-r--r--src/com/jogamp/opencl/CLProgram.java14
-rw-r--r--src/com/jogamp/opencl/CLProgramBuilder.java20
-rw-r--r--src/com/jogamp/opencl/impl/CLTLInfoAccessor.java47
-rw-r--r--src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java4
-rw-r--r--src/com/jogamp/opencl/spi/CLInfoAccessor.java8
8 files changed, 282 insertions, 228 deletions
diff --git a/src/com/jogamp/opencl/CLBuffer.java b/src/com/jogamp/opencl/CLBuffer.java
index 873256e8..56cbccda 100644
--- a/src/com/jogamp/opencl/CLBuffer.java
+++ b/src/com/jogamp/opencl/CLBuffer.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,17 +29,17 @@
package com.jogamp.opencl;
import com.jogamp.common.nio.Buffers;
+
import java.util.List;
+
import com.jogamp.common.nio.PointerBuffer;
-import com.jogamp.opencl.CLMemory.Mem;
import com.jogamp.opencl.llb.CL;
import com.jogamp.opencl.llb.CLBufferBinding;
+
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Collections;
-import static com.jogamp.opencl.CLException.*;
-
/**
* OpenCL buffer object wrapping an optional NIO buffer.
* @author Michael Bien, et al.
@@ -56,17 +56,17 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> {
super(context, directBuffer, size, id, flags);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("rawtypes")
static CLBuffer<?> create(CLContext context, int size, int flags) {
if(isHostPointerFlag(flags)) {
throw new IllegalArgumentException("no host pointer defined");
}
- CLBufferBinding binding = context.getPlatform().getBufferBinding();
- int[] result = new int[1];
- long id = binding.clCreateBuffer(context.ID, flags, size, null, result, 0);
- checkForError(result[0], "can not create cl buffer");
+ final CLBufferBinding binding = context.getPlatform().getBufferBinding();
+ final int[] result = new int[1];
+ final long id = binding.clCreateBuffer(context.ID, flags, size, null, result, 0);
+ CLException.checkForError(result[0], "can not create cl buffer");
return new CLBuffer(context, size, id, flags);
}
@@ -85,8 +85,8 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> {
int[] result = new int[1];
int size = Buffers.sizeOfBufferElem(directBuffer) * directBuffer.capacity();
long id = binding.clCreateBuffer(context.ID, flags, size, host_ptr, result, 0);
- checkForError(result[0], "can not create cl buffer");
-
+ CLException.checkForError(result[0], "can not create cl buffer");
+
return new CLBuffer<B>(context, directBuffer, size, id, flags);
}
@@ -101,24 +101,27 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> {
*/
public CLSubBuffer<B> createSubBuffer(int offset, int size, Mem... flags) {
- B slice = null;
+ final B slice;
if(buffer != null) {
slice = Buffers.slice(buffer, offset, size);
int elemSize = Buffers.sizeOfBufferElem(buffer);
offset *= elemSize;
size *= elemSize;
+ } else {
+ slice = null;
}
- PointerBuffer info = PointerBuffer.allocateDirect(2);
- info.put(offset).put(size).rewind();
- int bitset = Mem.flagsToInt(flags);
-
- CLBufferBinding binding = getPlatform().getBufferBinding();
- int[] err = new int[1];
- long subID = binding.clCreateSubBuffer(ID, bitset, CL.CL_BUFFER_CREATE_TYPE_REGION, info.getBuffer(), err, 0);
- checkForError(err[0], "can not create sub buffer");
+ final PointerBuffer info = PointerBuffer.allocateDirect(2);
+ info.put(0, offset);
+ info.put(1, size);
+ final int bitset = Mem.flagsToInt(flags);
+
+ final CLBufferBinding binding = getPlatform().getBufferBinding();
+ final int[] err = new int[1];
+ final long subID = binding.clCreateSubBuffer(ID, bitset, CL.CL_BUFFER_CREATE_TYPE_REGION, info.getBuffer(), err, 0);
+ CLException.checkForError(err[0], "can not create sub buffer");
- CLSubBuffer<B> clSubBuffer = new CLSubBuffer<B>(this, offset, size, slice, subID, bitset);
+ final CLSubBuffer<B> clSubBuffer = new CLSubBuffer<B>(this, offset, size, slice, subID, bitset);
if(childs == null) {
childs = new ArrayList<CLSubBuffer<B>>();
}
@@ -136,7 +139,7 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> {
super.release();
}
- void onReleaseSubBuffer(CLSubBuffer sub) {
+ void onReleaseSubBuffer(CLSubBuffer<?> sub) {
childs.remove(sub);
}
@@ -158,7 +161,7 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> {
public boolean isSubBuffer() {
return false;
}
-
+
@Override
public <T extends Buffer> CLBuffer<T> cloneWith(T directBuffer) {
return new CLBuffer<T>(context, directBuffer, size, ID, FLAGS);
diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java
index c3bd0e3f..e801c686 100644
--- a/src/com/jogamp/opencl/CLContext.java
+++ b/src/com/jogamp/opencl/CLContext.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.
@@ -28,14 +28,6 @@
package com.jogamp.opencl;
-import com.jogamp.opencl.llb.CL;
-import com.jogamp.common.nio.Buffers;
-import com.jogamp.opencl.CLDevice.Type;
-import com.jogamp.opencl.CLSampler.AddressingMode;
-import com.jogamp.opencl.CLSampler.FilteringMode;
-import com.jogamp.common.nio.PointerBuffer;
-import com.jogamp.opencl.llb.CLContextBinding;
-import com.jogamp.opencl.llb.impl.CLImageFormatImpl;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -47,22 +39,25 @@ import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
-
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import static java.lang.System.*;
-import static com.jogamp.opencl.CLException.*;
-import static com.jogamp.common.nio.Buffers.*;
-import static com.jogamp.common.os.Platform.*;
-import static com.jogamp.opencl.llb.CL.*;
-import static com.jogamp.opencl.CLBuffer.*;
-import static java.util.Collections.*;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.common.os.Platform;
+import com.jogamp.opencl.CLDevice.Type;
+import com.jogamp.opencl.CLMemory.Mem;
+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.impl.CLImageFormatImpl;
/**
* CLContext is responsible for managing objects such as command-queues, memory,
@@ -76,10 +71,10 @@ import static java.util.Collections.*;
* <p>
* For a code example see {@link CLPlatform}.
* <p/>
- *
+ *
* concurrency:<br/>
* CLContext is threadsafe.
- *
+ *
* @author Michael Bien, et al.
*/
public class CLContext extends CLObjectResource {
@@ -89,23 +84,23 @@ public class CLContext extends CLObjectResource {
protected final Set<CLProgram> programs;
protected final Set<CLSampler> samplers;
protected final Set<CLMemory<? extends Buffer>> memoryObjects;
-
+
protected final Map<CLDevice, List<CLCommandQueue>> queuesMap;
protected final CLPlatform platform;
-
+
private final ErrorDispatcher errorHandler;
protected CLContext(CLPlatform platform, long contextID, ErrorDispatcher dispatcher) {
super(contextID);
this.platform = platform;
-
- this.programs = synchronizedSet(new HashSet<CLProgram>());
- this.samplers = synchronizedSet(new HashSet<CLSampler>());
- this.memoryObjects = synchronizedSet(new HashSet<CLMemory<? extends Buffer>>());
-
+
+ this.programs = Collections.synchronizedSet(new HashSet<CLProgram>());
+ this.samplers = Collections.synchronizedSet(new HashSet<CLSampler>());
+ this.memoryObjects = Collections.synchronizedSet(new HashSet<CLMemory<? extends Buffer>>());
+
this.queuesMap = new HashMap<CLDevice, List<CLCommandQueue>>();
-
+
this.errorHandler = dispatcher;
/*
@@ -115,25 +110,25 @@ public class CLContext extends CLObjectResource {
}
});
*/
-
+
}
private synchronized void initDevices(CLContextBinding cl) {
-
+
if (devices == null) {
- PointerBuffer deviceCount = PointerBuffer.allocateDirect(1);
+ final PointerBuffer deviceCount = PointerBuffer.allocateDirect(1);
- int ret = cl.clGetContextInfo(ID, CL_CONTEXT_DEVICES, 0, null, deviceCount);
- checkForError(ret, "can not enumerate devices");
+ int ret = cl.clGetContextInfo(ID, CL.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_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null);
- checkForError(ret, "can not enumerate devices");
+ ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null);
+ CLException.checkForError(ret, "can not enumerate devices");
- devices = new CLDevice[deviceIDs.capacity() / (is32Bit() ? 4 : 8)];
+ devices = new CLDevice[deviceIDs.capacity() / (Platform.is32Bit() ? 4 : 8)];
for (int i = 0; i < devices.length; i++) {
- devices[i] = new CLDevice(this, is32Bit() ? deviceIDs.getInt() : deviceIDs.getLong());
+ devices[i] = new CLDevice(this, Platform.is32Bit() ? deviceIDs.getInt() : deviceIDs.getLong());
}
}
}
@@ -203,17 +198,17 @@ public class CLContext extends CLObjectResource {
}
protected static long createContextFromType(CLPlatform platform, CLErrorHandler handler, PointerBuffer properties, long deviceType) {
- IntBuffer status = newDirectIntBuffer(1);
+ IntBuffer status = Buffers.newDirectIntBuffer(1);
CLContextBinding cl = platform.getContextBinding();
long context = cl.clCreateContextFromType(properties, deviceType, handler, status);
- checkForError(status.get(), "can not create CL context");
+ 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 = newDirectIntBuffer(1);
+ IntBuffer status = Buffers.newDirectIntBuffer(1);
PointerBuffer pb = null;
if(devices != null && devices.length != 0) {
pb = PointerBuffer.allocateDirect(devices.length);
@@ -228,7 +223,7 @@ public class CLContext extends CLObjectResource {
CLContextBinding cl = platform.getContextBinding();
long context = cl.clCreateContext(properties, pb, handler, status);
- checkForError(status.get(), "can not create CL context");
+ CLException.checkForError(status.get(), "can not create CL context");
return context;
}
@@ -238,7 +233,7 @@ public class CLContext extends CLObjectResource {
throw new RuntimeException("no OpenCL installation found");
}
- return PointerBuffer.allocateDirect(3).put(CL_CONTEXT_PLATFORM)
+ return PointerBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM)
.put(platform.ID).put(0) // 0 terminated array
.rewind();
}
@@ -287,6 +282,7 @@ public class CLContext extends CLObjectResource {
*/
public CLProgram createProgram(Map<CLDevice, byte[]> binaries) {
CLProgram program = CLProgram.create(this, binaries);
+ program.setNoSource();
programs.add(program);
return program;
}
@@ -295,35 +291,35 @@ 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) {
- return createBuffer(newDirectShortBuffer(size), 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) {
- return createBuffer(newDirectIntBuffer(size), 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) {
- return createBuffer(newDirectLongBuffer(size), 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) {
- return createBuffer(newDirectFloatBuffer(size), 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) {
- return createBuffer(newDirectDoubleBuffer(size), flags);
+ return createBuffer(Buffers.newDirectDoubleBuffer(size), flags);
}
/**
@@ -337,7 +333,7 @@ public class CLContext extends CLObjectResource {
* Creates a CLBuffer with the specified flags and buffer size in bytes.
*/
public final CLBuffer<ByteBuffer> createByteBuffer(int size, int flags) {
- return createBuffer(newDirectByteBuffer(size), flags);
+ return createBuffer(Buffers.newDirectByteBuffer(size), flags);
}
/**
@@ -483,14 +479,11 @@ public class CLContext extends CLObjectResource {
public void removeCLErrorHandler(CLErrorHandler handler) {
errorHandler.removeHandler(handler);
}
-
+
private void release(Collection<? extends CLResource> resources) {
// resources remove themselves when released, see above
- if(!resources.isEmpty()) {
- CLResource[] array = resources.toArray(new CLResource[resources.size()]);
- for (CLResource resource : array) {
- resource.release();
- }
+ while(!resources.isEmpty()) {
+ resources.iterator().next().release();
}
}
@@ -509,14 +502,13 @@ public class CLContext extends CLObjectResource {
synchronized(queuesMap) {
final Collection<List<CLCommandQueue>> queuesList = queuesMap.values();
- for( Iterator<List<CLCommandQueue>> queuesI = queuesList.iterator(); queuesI.hasNext(); ) {
- release(queuesI.next());
- }
+ while(!queuesList.isEmpty())
+ release(queuesList.iterator().next());
}
} finally {
int ret = platform.getContextBinding().clReleaseContext(ID);
- checkForError(ret, "error releasing context");
+ CLException.checkForError(ret, "error releasing context");
}
}
@@ -531,8 +523,8 @@ public class CLContext extends CLObjectResource {
int[] entries = new int[1];
int ret = binding.clGetSupportedImageFormats(ID, flags, type, 0, null, entries, 0);
- if(ret != CL_SUCCESS) {
- throw newException(ret, "error calling clGetSupportedImageFormats");
+ if(ret != CL.CL_SUCCESS) {
+ throw CLException.newException(ret, "error calling clGetSupportedImageFormats");
}
int count = entries[0];
@@ -541,10 +533,10 @@ public class CLContext extends CLObjectResource {
}
CLImageFormat[] formats = new CLImageFormat[count];
- CLImageFormatImpl impl = CLImageFormatImpl.create(newDirectByteBuffer(count * CLImageFormatImpl.size()));
+ CLImageFormatImpl impl = CLImageFormatImpl.create(Buffers.newDirectByteBuffer(count * CLImageFormatImpl.size()));
ret = binding.clGetSupportedImageFormats(ID, flags, type, count, impl, null);
- if(ret != CL_SUCCESS) {
- throw newException(ret, "error calling clGetSupportedImageFormats");
+ if(ret != CL.CL_SUCCESS) {
+ throw CLException.newException(ret, "error calling clGetSupportedImageFormats");
}
ByteBuffer buffer = impl.getBuffer();
@@ -561,14 +553,14 @@ 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_MEM_OBJECT_IMAGE2D);
+ return getSupportedImageFormats(flags==null?0:Mem.flagsToInt(flags), CL.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_MEM_OBJECT_IMAGE3D);
+ return getSupportedImageFormats(flags==null?0:Mem.flagsToInt(flags), CL.CL_MEM_OBJECT_IMAGE3D);
}
/**
@@ -589,7 +581,7 @@ public class CLContext extends CLObjectResource {
*/
public List<CLProgram> getPrograms() {
synchronized(programs) {
- return unmodifiableList(new ArrayList<CLProgram>(programs));
+ return Collections.unmodifiableList(new ArrayList<CLProgram>(programs));
}
}
@@ -598,7 +590,7 @@ public class CLContext extends CLObjectResource {
*/
public List<CLMemory<? extends Buffer>> getMemoryObjects() {
synchronized(memoryObjects) {
- return unmodifiableList(new ArrayList<CLMemory<? extends Buffer>>(memoryObjects));
+ return Collections.unmodifiableList(new ArrayList<CLMemory<? extends Buffer>>(memoryObjects));
}
}
@@ -607,7 +599,7 @@ public class CLContext extends CLObjectResource {
*/
public List<CLSampler> getSamplers() {
synchronized(samplers) {
- return unmodifiableList(new ArrayList<CLSampler>(samplers));
+ return Collections.unmodifiableList(new ArrayList<CLSampler>(samplers));
}
}
@@ -631,6 +623,17 @@ public class CLContext extends CLObjectResource {
}
/**
+ * Returns the maximum {@link CLDevice#getMemBaseAddrAlign()} of all devices.
+ */
+ public long getMaxMemBaseAddrAlign() {
+ long maxAlignment = 0;
+ for (CLDevice device : getDevices()) {
+ maxAlignment = Math.max(maxAlignment, device.getMemBaseAddrAlign());
+ }
+ return maxAlignment;
+ }
+
+ /**
* Returns all devices associated with this CLContext.
*/
public CLDevice[] getDevices() {
@@ -722,13 +725,13 @@ public class CLContext extends CLObjectResource {
}
CLErrorHandler[] handlers = new CLErrorHandler[clientHandlers.length+1];
- arraycopy(clientHandlers, 0, handlers, 0, clientHandlers.length);
+ System.arraycopy(clientHandlers, 0, handlers, 0, clientHandlers.length);
handlers[handlers.length-1] = handler;
clientHandlers = handlers;
}
private synchronized void removeHandler(CLErrorHandler handler) {
-
+
if(handler == null) {
throw new IllegalArgumentException("handler was null.");
}
@@ -736,8 +739,8 @@ 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];
- arraycopy(clientHandlers, 0, handlers, 0, i);
- arraycopy(clientHandlers, i, handlers, 0, handlers.length-i);
+ System.arraycopy(clientHandlers, 0, handlers, 0, i);
+ System.arraycopy(clientHandlers, i, handlers, 0, handlers.length-i);
clientHandlers = handlers;
return;
}
diff --git a/src/com/jogamp/opencl/CLDevice.java b/src/com/jogamp/opencl/CLDevice.java
index b47deb2b..d8e90106 100644
--- a/src/com/jogamp/opencl/CLDevice.java
+++ b/src/com/jogamp/opencl/CLDevice.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.
@@ -28,8 +28,6 @@
package com.jogamp.opencl;
-import com.jogamp.opencl.util.CLUtil;
-import com.jogamp.opencl.spi.CLInfoAccessor;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collections;
@@ -40,7 +38,9 @@ import java.util.Map;
import java.util.Scanner;
import java.util.Set;
-import static com.jogamp.opencl.llb.CL.*;
+import com.jogamp.opencl.llb.CL;
+import com.jogamp.opencl.spi.CLInfoAccessor;
+import com.jogamp.opencl.util.CLUtil;
/**
* This object represents an OpenCL device.
@@ -48,7 +48,7 @@ import static com.jogamp.opencl.llb.CL.*;
* @see CLPlatform#getMaxFlopsDevice(com.jogamp.opencl.CLDevice.Type...)
* @see CLContext#getDevices()
* @see CLContext#getMaxFlopsDevice(com.jogamp.opencl.CLDevice.Type)
- * @author Michael Bien
+ * @author Michael Bien, et al.
*/
public class CLDevice extends CLObject {
@@ -108,7 +108,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_NAME")
public String getName() {
- return deviceInfo.getString(CL_DEVICE_NAME);
+ return deviceInfo.getString(CL.CL_DEVICE_NAME);
}
/**
@@ -116,7 +116,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_PROFILE")
public String getProfile() {
- return deviceInfo.getString(CL_DEVICE_PROFILE);
+ return deviceInfo.getString(CL.CL_DEVICE_PROFILE);
}
/**
@@ -124,7 +124,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_VENDOR")
public String getVendor() {
- return deviceInfo.getString(CL_DEVICE_VENDOR);
+ return deviceInfo.getString(CL.CL_DEVICE_VENDOR);
}
/**
@@ -132,7 +132,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_VENDOR_ID")
public long getVendorID() {
- return deviceInfo.getLong(CL_DEVICE_VENDOR_ID);
+ return deviceInfo.getLong(CL.CL_DEVICE_VENDOR_ID);
}
/**
@@ -140,7 +140,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_VERSION")
public CLVersion getVersion() {
- return new CLVersion(deviceInfo.getString(CL_DEVICE_VERSION));
+ return new CLVersion(deviceInfo.getString(CL.CL_DEVICE_VERSION));
}
/**
@@ -148,7 +148,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_OPENCL_C_VERSION")
public CLVersion getCVersion() {
- return new CLVersion(deviceInfo.getString(CL_DEVICE_OPENCL_C_VERSION));
+ return new CLVersion(deviceInfo.getString(CL.CL_DEVICE_OPENCL_C_VERSION));
}
/**
@@ -156,7 +156,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DRIVER_VERSION")
public String getDriverVersion() {
- return deviceInfo.getString(CL_DRIVER_VERSION);
+ return deviceInfo.getString(CL.CL_DRIVER_VERSION);
}
/**
@@ -164,7 +164,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_TYPE")
public Type getType() {
- return Type.valueOf((int)deviceInfo.getLong(CL_DEVICE_TYPE));
+ return Type.valueOf((int)deviceInfo.getLong(CL.CL_DEVICE_TYPE));
}
/**
@@ -173,7 +173,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_ADDRESS_BITS")
public int getAddressBits() {
- return (int)deviceInfo.getLong(CL_DEVICE_ADDRESS_BITS);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_ADDRESS_BITS);
}
/**
@@ -182,7 +182,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT")
public int getPreferredShortVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT);
}
/**
@@ -191,7 +191,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR")
public int getPreferredCharVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR);
}
/**
@@ -200,7 +200,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT")
public int getPreferredIntVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT);
}
/**
@@ -209,7 +209,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG")
public int getPreferredLongVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG);
}
/**
@@ -218,7 +218,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT")
public int getPreferredFloatVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT);
}
/**
@@ -227,7 +227,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE")
public int getPreferredDoubleVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE);
}
/**
@@ -236,7 +236,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR")
public int getNativeCharVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR);
}
/**
@@ -245,7 +245,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT")
public int getNativeShortVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT);
}
/**
@@ -254,7 +254,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_INT")
public int getNativeIntVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_NATIVE_VECTOR_WIDTH_INT);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_INT);
}
/**
@@ -263,7 +263,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG")
public int getNativeLongVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG);
}
/**
@@ -272,7 +272,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF")
public int getNativeHalfVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF);
}
/**
@@ -281,7 +281,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT")
public int getNativeFloatVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT);
}
/**
@@ -290,7 +290,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE")
public int getNativeDoubleVectorWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE);
}
/**
@@ -299,7 +299,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_COMPUTE_UNITS")
public int getMaxComputeUnits() {
- return (int) deviceInfo.getLong(CL_DEVICE_MAX_COMPUTE_UNITS);
+ return (int) deviceInfo.getLong(CL.CL_DEVICE_MAX_COMPUTE_UNITS);
}
/**
@@ -309,7 +309,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_WORK_GROUP_SIZE")
public int getMaxWorkGroupSize() {
- return (int) deviceInfo.getLong(CL_DEVICE_MAX_WORK_GROUP_SIZE);
+ return (int) deviceInfo.getLong(CL.CL_DEVICE_MAX_WORK_GROUP_SIZE);
}
/**
@@ -317,7 +317,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_CLOCK_FREQUENCY")
public int getMaxClockFrequency() {
- return (int) (deviceInfo.getLong(CL_DEVICE_MAX_CLOCK_FREQUENCY));
+ return (int) (deviceInfo.getLong(CL.CL_DEVICE_MAX_CLOCK_FREQUENCY));
}
/**
@@ -327,7 +327,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS")
public int getMaxWorkItemDimensions() {
- return (int) deviceInfo.getLong(CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS);
+ return (int) deviceInfo.getLong(CL.CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS);
}
/**
@@ -338,7 +338,7 @@ public class CLDevice extends CLObject {
@CLProperty("CL_DEVICE_MAX_WORK_ITEM_SIZES")
public int[] getMaxWorkItemSizes() {
int n = getMaxWorkItemDimensions();
- return deviceInfo.getInts(CL_DEVICE_MAX_WORK_ITEM_SIZES, n);
+ return deviceInfo.getInts(CL.CL_DEVICE_MAX_WORK_ITEM_SIZES, n);
}
/**
@@ -348,7 +348,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_PARAMETER_SIZE")
public long getMaxParameterSize() {
- return deviceInfo.getLong(CL_DEVICE_MAX_PARAMETER_SIZE);
+ return deviceInfo.getLong(CL.CL_DEVICE_MAX_PARAMETER_SIZE);
}
/**
@@ -356,7 +356,16 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_MEM_ALLOC_SIZE")
public long getMaxMemAllocSize() {
- return deviceInfo.getLong(CL_DEVICE_MAX_MEM_ALLOC_SIZE);
+ return deviceInfo.getLong(CL.CL_DEVICE_MAX_MEM_ALLOC_SIZE);
+ }
+
+ /**
+ * Returns the <code>uint32_t</code> memory base address alignment
+ * value reinterpreted as a <code>long</code> value.
+ */
+ @CLProperty("CL_DEVICE_MEM_BASE_ADDR_ALIGN")
+ public long getMemBaseAddrAlign() {
+ return deviceInfo.getUInt32Long(CL.CL_DEVICE_MEM_BASE_ADDR_ALIGN);
}
/**
@@ -364,7 +373,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_GLOBAL_MEM_SIZE")
public long getGlobalMemSize() {
- return deviceInfo.getLong(CL_DEVICE_GLOBAL_MEM_SIZE);
+ return deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_SIZE);
}
/**
@@ -374,7 +383,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_LOCAL_MEM_SIZE")
public long getLocalMemSize() {
- return deviceInfo.getLong(CL_DEVICE_LOCAL_MEM_SIZE);
+ return deviceInfo.getLong(CL.CL_DEVICE_LOCAL_MEM_SIZE);
}
/**
@@ -382,7 +391,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_HOST_UNIFIED_MEMORY")
public boolean isMemoryUnified() {
- return deviceInfo.getLong(CL_DEVICE_HOST_UNIFIED_MEMORY) == CL_TRUE;
+ return deviceInfo.getLong(CL.CL_DEVICE_HOST_UNIFIED_MEMORY) == CL.CL_TRUE;
}
/**
@@ -391,7 +400,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE")
public long getMaxConstantBufferSize() {
- return deviceInfo.getLong(CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE);
+ return deviceInfo.getLong(CL.CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE);
}
/**
@@ -399,7 +408,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE")
public long getGlobalMemCachelineSize() {
- return deviceInfo.getLong(CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE);
+ return deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE);
}
/**
@@ -407,7 +416,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_GLOBAL_MEM_CACHE_SIZE")
public long getGlobalMemCacheSize() {
- return deviceInfo.getLong(CL_DEVICE_GLOBAL_MEM_CACHE_SIZE);
+ return deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_CACHE_SIZE);
}
/**
@@ -416,7 +425,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_CONSTANT_ARGS")
public long getMaxConstantArgs() {
- return deviceInfo.getLong(CL_DEVICE_MAX_CONSTANT_ARGS);
+ return deviceInfo.getLong(CL.CL_DEVICE_MAX_CONSTANT_ARGS);
}
/**
@@ -424,7 +433,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_IMAGE_SUPPORT")
public boolean isImageSupportAvailable() {
- return deviceInfo.getLong(CL_DEVICE_IMAGE_SUPPORT) == CL_TRUE;
+ return deviceInfo.getLong(CL.CL_DEVICE_IMAGE_SUPPORT) == CL.CL_TRUE;
}
/**
@@ -433,7 +442,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_READ_IMAGE_ARGS")
public int getMaxReadImageArgs() {
- return (int)deviceInfo.getLong(CL_DEVICE_MAX_READ_IMAGE_ARGS);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_MAX_READ_IMAGE_ARGS);
}
/**
@@ -442,7 +451,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_WRITE_IMAGE_ARGS")
public int getMaxWriteImageArgs() {
- return (int)deviceInfo.getLong(CL_DEVICE_MAX_WRITE_IMAGE_ARGS);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_MAX_WRITE_IMAGE_ARGS);
}
/**
@@ -451,7 +460,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_IMAGE2D_MAX_WIDTH")
public int getMaxImage2dWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_IMAGE2D_MAX_WIDTH);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE2D_MAX_WIDTH);
}
/**
@@ -460,7 +469,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_IMAGE2D_MAX_HEIGHT")
public int getMaxImage2dHeight() {
- return (int)deviceInfo.getLong(CL_DEVICE_IMAGE2D_MAX_HEIGHT);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE2D_MAX_HEIGHT);
}
/**
@@ -469,7 +478,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_IMAGE3D_MAX_WIDTH")
public int getMaxImage3dWidth() {
- return (int)deviceInfo.getLong(CL_DEVICE_IMAGE3D_MAX_WIDTH);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE3D_MAX_WIDTH);
}
/**
@@ -478,7 +487,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_IMAGE3D_MAX_HEIGHT")
public int getMaxImage3dHeight() {
- return (int)deviceInfo.getLong(CL_DEVICE_IMAGE3D_MAX_HEIGHT);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE3D_MAX_HEIGHT);
}
/**
@@ -487,7 +496,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_IMAGE3D_MAX_DEPTH")
public int getMaxImage3dDepth() {
- return (int)deviceInfo.getLong(CL_DEVICE_IMAGE3D_MAX_DEPTH);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE3D_MAX_DEPTH);
}
/**
@@ -496,7 +505,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_MAX_SAMPLERS")
public int getMaxSamplers() {
- return (int)deviceInfo.getLong(CL_DEVICE_MAX_SAMPLERS);
+ return (int)deviceInfo.getLong(CL.CL_DEVICE_MAX_SAMPLERS);
}
/**
@@ -504,7 +513,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_PROFILING_TIMER_RESOLUTION")
public long getProfilingTimerResolution() {
- return deviceInfo.getLong(CL_DEVICE_PROFILING_TIMER_RESOLUTION);
+ return deviceInfo.getLong(CL.CL_DEVICE_PROFILING_TIMER_RESOLUTION);
}
/**
@@ -512,7 +521,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_EXECUTION_CAPABILITIES")
public EnumSet<Capabilities> getExecutionCapabilities() {
- return Capabilities.valuesOf((int)deviceInfo.getLong(CL_DEVICE_EXECUTION_CAPABILITIES));
+ return Capabilities.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_EXECUTION_CAPABILITIES));
}
/**
@@ -525,7 +534,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_DEVICE_HALF_FP_CONFIG));
+ return FPConfig.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_HALF_FP_CONFIG));
else
return EnumSet.noneOf(FPConfig.class);
}
@@ -538,7 +547,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_SINGLE_FP_CONFIG")
public EnumSet<FPConfig> getSingleFPConfig() {
- return FPConfig.valuesOf((int)deviceInfo.getLong(CL_DEVICE_SINGLE_FP_CONFIG));
+ return FPConfig.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_SINGLE_FP_CONFIG));
}
/**
@@ -551,7 +560,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_DEVICE_DOUBLE_FP_CONFIG));
+ return FPConfig.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_DOUBLE_FP_CONFIG));
else
return EnumSet.noneOf(FPConfig.class);
}
@@ -561,7 +570,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_LOCAL_MEM_TYPE")
public LocalMemType getLocalMemType() {
- return LocalMemType.valueOf((int)deviceInfo.getLong(CL_DEVICE_LOCAL_MEM_TYPE));
+ return LocalMemType.valueOf((int)deviceInfo.getLong(CL.CL_DEVICE_LOCAL_MEM_TYPE));
}
/**
@@ -569,15 +578,16 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_GLOBAL_MEM_CACHE_TYPE")
public GlobalMemCacheType getGlobalMemCacheType() {
- return GlobalMemCacheType.valueOf((int)deviceInfo.getLong(CL_DEVICE_GLOBAL_MEM_CACHE_TYPE));
+ return GlobalMemCacheType.valueOf((int)deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_CACHE_TYPE));
}
+
/**
* Returns the command-queue properties supported by the device.
*/
@CLProperty("CL_DEVICE_QUEUE_PROPERTIES")
public EnumSet<CLCommandQueue.Mode> getQueueProperties() {
- return CLCommandQueue.Mode.valuesOf((int)deviceInfo.getLong(CL_DEVICE_QUEUE_PROPERTIES));
+ return CLCommandQueue.Mode.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_QUEUE_PROPERTIES));
}
/**
@@ -585,7 +595,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_AVAILABLE")
public boolean isAvailable() {
- return deviceInfo.getLong(CL_DEVICE_AVAILABLE) == CL_TRUE;
+ return deviceInfo.getLong(CL.CL_DEVICE_AVAILABLE) == CL.CL_TRUE;
}
/**
@@ -595,7 +605,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_COMPILER_AVAILABLE")
public boolean isCompilerAvailable() {
- return deviceInfo.getLong(CL_DEVICE_COMPILER_AVAILABLE) == CL_TRUE;
+ return deviceInfo.getLong(CL.CL_DEVICE_COMPILER_AVAILABLE) == CL.CL_TRUE;
}
/**
@@ -603,7 +613,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_ENDIAN_LITTLE")
public boolean isLittleEndian() {
- return deviceInfo.getLong(CL_DEVICE_ENDIAN_LITTLE) == CL_TRUE;
+ return deviceInfo.getLong(CL.CL_DEVICE_ENDIAN_LITTLE) == CL.CL_TRUE;
}
/**
@@ -613,7 +623,7 @@ public class CLDevice extends CLObject {
*/
@CLProperty("CL_DEVICE_ERROR_CORRECTION_SUPPORT")
public boolean isErrorCorrectionSupported() {
- return deviceInfo.getLong(CL_DEVICE_ERROR_CORRECTION_SUPPORT) == CL_TRUE;
+ return deviceInfo.getLong(CL.CL_DEVICE_ERROR_CORRECTION_SUPPORT) == CL.CL_TRUE;
}
/**
@@ -635,6 +645,15 @@ public class CLDevice extends CLObject {
}
/**
+ * Returns {@link #isExtensionAvailable}("cl_khr_icd").
+ * @see #getExtensions()
+ */
+ @CLProperty("cl_khr_icd")
+ public boolean isICDAvailable() {
+ return isExtensionAvailable("cl_khr_icd");
+ }
+
+ /**
* Returns {@link #isExtensionAvailable}("cl_khr_gl_sharing") || {@link #isExtensionAvailable}("cl_APPLE_gl_sharing").
* @see #getExtensions()
*/
@@ -650,7 +669,7 @@ public class CLDevice extends CLObject {
public boolean isExtensionAvailable(String extension) {
return getExtensions().contains(extension);
}
-
+
/**
* Returns {@link ByteOrder#LITTLE_ENDIAN} or {@link ByteOrder#BIG_ENDIAN}.
*/
@@ -670,7 +689,7 @@ public class CLDevice extends CLObject {
if(extensions == null) {
extensions = new HashSet<String>();
- String ext = deviceInfo.getString(CL_DEVICE_EXTENSIONS);
+ String ext = deviceInfo.getString(CL.CL_DEVICE_EXTENSIONS);
Scanner scanner = new Scanner(ext);
while(scanner.hasNext())
@@ -732,12 +751,12 @@ public class CLDevice extends CLObject {
/**
* The OpenCL device can execute OpenCL kernels.
*/
- EXEC_KERNEL(CL_EXEC_KERNEL),
+ EXEC_KERNEL(CL.CL_EXEC_KERNEL),
/**
* The OpenCL device can execute native kernels.
*/
- EXEC_NATIVE_KERNEL(CL_EXEC_NATIVE_KERNEL);
+ EXEC_NATIVE_KERNEL(CL.CL_EXEC_NATIVE_KERNEL);
/**
* Value of wrapped OpenCL device type.
@@ -750,9 +769,9 @@ public class CLDevice extends CLObject {
public static Capabilities valueOf(int caps) {
switch(caps) {
- case(CL_EXEC_KERNEL):
+ case(CL.CL_EXEC_KERNEL):
return EXEC_KERNEL;
- case(CL_EXEC_NATIVE_KERNEL):
+ case(CL.CL_EXEC_NATIVE_KERNEL):
return EXEC_NATIVE_KERNEL;
}
return null;
@@ -780,25 +799,25 @@ public class CLDevice extends CLObject {
/**
* CL_DEVICE_TYPE_CPU
*/
- CPU(CL_DEVICE_TYPE_CPU),
+ CPU(CL.CL_DEVICE_TYPE_CPU),
/**
* CL_DEVICE_TYPE_GPU
*/
- GPU(CL_DEVICE_TYPE_GPU),
+ GPU(CL.CL_DEVICE_TYPE_GPU),
/**
* CL_DEVICE_TYPE_ACCELERATOR
*/
- ACCELERATOR(CL_DEVICE_TYPE_ACCELERATOR),
+ ACCELERATOR(CL.CL_DEVICE_TYPE_ACCELERATOR),
/**
* CL_DEVICE_TYPE_DEFAULT. This type can be used for creating a context on
* the default device, a single device can never have this type.
*/
- DEFAULT(CL_DEVICE_TYPE_DEFAULT),
+ DEFAULT(CL.CL_DEVICE_TYPE_DEFAULT),
/**
* CL_DEVICE_TYPE_ALL. This type can be used for creating a context on
* all devices, a single device can never have this type.
*/
- ALL(CL_DEVICE_TYPE_ALL);
+ ALL(CL.CL_DEVICE_TYPE_ALL);
/**
* Value of wrapped OpenCL device type.
@@ -811,17 +830,17 @@ public class CLDevice extends CLObject {
public static Type valueOf(long clDeviceType) {
- if(clDeviceType == CL_DEVICE_TYPE_ALL)
+ if(clDeviceType == CL.CL_DEVICE_TYPE_ALL)
return ALL;
switch((int)clDeviceType) {
- case(CL_DEVICE_TYPE_DEFAULT):
+ case(CL.CL_DEVICE_TYPE_DEFAULT):
return DEFAULT;
- case(CL_DEVICE_TYPE_CPU):
+ case(CL.CL_DEVICE_TYPE_CPU):
return CPU;
- case(CL_DEVICE_TYPE_GPU):
+ case(CL.CL_DEVICE_TYPE_GPU):
return GPU;
- case(CL_DEVICE_TYPE_ACCELERATOR):
+ case(CL.CL_DEVICE_TYPE_ACCELERATOR):
return ACCELERATOR;
}
return null;
@@ -837,32 +856,32 @@ public class CLDevice extends CLObject {
/**
* denorms are supported.
*/
- DENORM(CL_FP_DENORM),
+ DENORM(CL.CL_FP_DENORM),
/**
* INF and quiet NaNs are supported.
*/
- INF_NAN(CL_FP_INF_NAN),
+ INF_NAN(CL.CL_FP_INF_NAN),
/**
* round to nearest rounding mode supported.
*/
- ROUND_TO_NEAREST(CL_FP_ROUND_TO_NEAREST),
+ ROUND_TO_NEAREST(CL.CL_FP_ROUND_TO_NEAREST),
/**
- * round to +ve and –ve infinity rounding modes supported.
+ * round to positive and negative infinity rounding modes supported.
*/
- ROUND_TO_INF(CL_FP_ROUND_TO_INF),
+ ROUND_TO_INF(CL.CL_FP_ROUND_TO_INF),
/**
* round to zero rounding mode supported.
*/
- ROUND_TO_ZERO(CL_FP_ROUND_TO_ZERO),
+ ROUND_TO_ZERO(CL.CL_FP_ROUND_TO_ZERO),
/**
* IEEE754-2008 fused multiply-add is supported.
*/
- FMA(CL_FP_FMA);
+ FMA(CL.CL_FP_FMA);
/**
@@ -900,17 +919,17 @@ public class CLDevice extends CLObject {
/**
* Global memory cache not supported.
*/
- NONE(CL_NONE),
+ NONE(CL.CL_NONE),
/**
* Read only cache.
*/
- READ_ONLY(CL_READ_ONLY_CACHE),
+ READ_ONLY(CL.CL_READ_ONLY_CACHE),
/**
* Read-write cache.
*/
- READ_WRITE(CL_READ_WRITE_CACHE);
+ READ_WRITE(CL.CL_READ_WRITE_CACHE);
/**
@@ -943,12 +962,12 @@ public class CLDevice extends CLObject {
/**
* GLOBAL implies that no dedicated memory storage is available (global mem is used instead).
*/
- GLOBAL(CL_GLOBAL),
+ GLOBAL(CL.CL_GLOBAL),
/**
* LOCAL implies dedicated local memory storage such as SRAM.
*/
- LOCAL(CL_LOCAL);
+ LOCAL(CL.CL_LOCAL);
/**
* Value of wrapped OpenCL value.
@@ -963,9 +982,9 @@ public class CLDevice extends CLObject {
* Returns the matching LocalMemCacheType for the given cl type.
*/
public static LocalMemType valueOf(int clLocalCacheType) {
- if(clLocalCacheType == CL_GLOBAL)
+ if(clLocalCacheType == CL.CL_GLOBAL)
return GLOBAL;
- else if(clLocalCacheType == CL_LOCAL)
+ else if(clLocalCacheType == CL.CL_LOCAL)
return LOCAL;
return null;
}
diff --git a/src/com/jogamp/opencl/CLProgram.java b/src/com/jogamp/opencl/CLProgram.java
index 3919d374..9dd3db82 100644
--- a/src/com/jogamp/opencl/CLProgram.java
+++ b/src/com/jogamp/opencl/CLProgram.java
@@ -70,6 +70,8 @@ public class CLProgram extends CLObjectResource {
private boolean executable;
private boolean released;
+ /** 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) {
super(context, id);
@@ -592,10 +594,20 @@ public class CLProgram extends CLObjectResource {
}
/**
+ * Must set this if the program is created from binary so we know not to call getSource(),
+ * which can SIGSEGV on Macs if there is no source.
+ */
+ public void setNoSource() {
+ noSource = true;
+ }
+
+ /**
* Returns the source code of this program. Note: sources are not cached,
* each call of this method calls into Open
*/
public String getSource() {
+ if(noSource)
+ return "";
// some drivers return IVE codes if the program haven't been built from source.
try{
return getProgramInfoString(CL_PROGRAM_SOURCE);
@@ -810,7 +822,7 @@ public class CLProgram extends CLObjectResource {
public final static String UNSAFE_MATH = "-cl-unsafe-math-optimizations";
/**
- * Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or ±∞.
+ * Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or plus/minus infinity.
* This option may violate the OpenCL numerical compliance requirements defined in in section 7.4 for
* single-precision floating-point, section 9.3.9 for double-precision floating-point, and edge case behavior in section 7.5.
*/
diff --git a/src/com/jogamp/opencl/CLProgramBuilder.java b/src/com/jogamp/opencl/CLProgramBuilder.java
index e80b9923..dd0c64f9 100644
--- a/src/com/jogamp/opencl/CLProgramBuilder.java
+++ b/src/com/jogamp/opencl/CLProgramBuilder.java
@@ -276,14 +276,16 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
- String suffix = null;
+ String suffix = "";
if(!binariesMap.isEmpty()) {
- CLPlatform platform = binariesMap.keySet().iterator().next().getPlatform();
- suffix = platform.getICDSuffix();
+ CLDevice device = binariesMap.keySet().iterator().next();
+ if(device.isICDAvailable())
+ suffix = device.getPlatform().getICDSuffix();
}
- out.writeUTF(suffix); // null if we have no binaries or no devices specified
+ // 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()) {
@@ -299,22 +301,22 @@ public final class CLProgramBuilder implements CLProgramConfiguration, Serializa
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
- String suffix = in.readUTF();
+ String suffix = in.readUTF(); // empty string means no suffix was written; just picks first platform
CLPlatform platform = null;
for (CLPlatform p : CLPlatform.listCLPlatforms()) {
- if(p.getICDSuffix().equals(suffix)) {
+ if(suffix.isEmpty() || p.getICDSuffix().equals(suffix)) {
platform = p;
break;
}
}
-
+
this.binariesMap = new LinkedHashMap<CLDevice, byte[]>();
List<CLDevice> devices;
if(platform != null) {
- devices = new ArrayList(Arrays.asList(platform.listCLDevices()));
+ devices = new ArrayList<CLDevice>(Arrays.asList(platform.listCLDevices()));
}else{
- devices = Collections.EMPTY_LIST;
+ devices = Collections.emptyList();
}
int mapSize = in.readInt();
diff --git a/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java b/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java
index c31b22a6..f1419c7b 100644
--- a/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java
+++ b/src/com/jogamp/opencl/impl/CLTLInfoAccessor.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.
@@ -28,20 +28,21 @@
package com.jogamp.opencl.impl;
-import com.jogamp.opencl.spi.CLInfoAccessor;
-import com.jogamp.common.nio.PointerBuffer;
-import com.jogamp.common.os.Platform;
-import com.jogamp.opencl.util.CLUtil;
import java.nio.Buffer;
import java.nio.ByteBuffer;
-import static com.jogamp.common.nio.Buffers.*;
-import static com.jogamp.opencl.CLException.*;
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.Bitstream;
+import com.jogamp.opencl.CLException;
+import com.jogamp.opencl.spi.CLInfoAccessor;
+import com.jogamp.opencl.util.CLUtil;
/**
* Internal utility for common OpenCL clGetFooInfo calls.
* Threadsafe, threadlocal implementation.
- * @author Michael Bien
+ * @author Michael Bien, et al.
*/
public abstract class CLTLInfoAccessor implements CLInfoAccessor {
@@ -51,7 +52,7 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor {
@Override
protected ByteBuffer initialValue() {
- return newDirectByteBuffer(BB_SIZE);
+ return Buffers.newDirectByteBuffer(BB_SIZE);
}
};
@@ -65,27 +66,35 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor {
};
@Override
+ public final long getUInt32Long(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");
+ return Bitstream.toUInt32Long(buffer.getInt(0));
+ }
+
+ @Override
public final long getLong(int key) {
ByteBuffer buffer = getBB(8).putLong(0, 0);
int ret = getInfo(key, 8, buffer, null);
- checkForError(ret, "error while asking for info value");
+ CLException.checkForError(ret, "error while asking for info value");
return buffer.getLong(0);
}
@Override
public final String getString(int key) {
-
+
PointerBuffer sizeBuffer = getNSB();
int ret = getInfo(key, 0, null, sizeBuffer);
- checkForError(ret, "error while asking for info string");
+ CLException.checkForError(ret, "error while asking for info string");
int clSize = (int)sizeBuffer.get(0);
ByteBuffer buffer = getBB(clSize);
ret = getInfo(key, buffer.capacity(), buffer, null);
- checkForError(ret, "error while asking for info string");
+ CLException.checkForError(ret, "error while asking for info string");
byte[] array = new byte[clSize];
buffer.get(array).rewind();
@@ -96,10 +105,10 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor {
@Override
public final int[] getInts(int key, 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);
- checkForError(ret, "error while asking for info value");
+ CLException.checkForError(ret, "error while asking for info value");
int[] array = new int[n];
for(int i = 0; i < array.length; i++) {
@@ -116,7 +125,7 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor {
protected ByteBuffer getBB(int minCapacity) {
if(minCapacity > BB_SIZE) {
- return newDirectByteBuffer(minCapacity);
+ return Buffers.newDirectByteBuffer(minCapacity);
}else{
return localBB.get();
}
diff --git a/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java b/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java
index 36bc26f9..19d89fc1 100644
--- a/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java
+++ b/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java
@@ -135,12 +135,12 @@ public final class CLDynamicLibraryBundleInfo implements DynamicLibraryBundleInf
private static int Impl_len = Impl_str.length();
@Override
- public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) {
+ public final long toolGetProcAddress(final long toolGetProcAddressHandle, String funcName) {
//FIXME workaround to fix a gluegen issue
if( funcName.endsWith(Impl_str) ) {
funcName = funcName.substring(0, funcName.length() - Impl_len);
}
- if(funcName.endsWith("KHR") || funcName.endsWith("EXT")) {
+ if( funcName.endsWith("KHR") || funcName.endsWith("EXT") ) {
return CLImpl.clGetExtensionFunctionAddress(toolGetProcAddressHandle, funcName);
}
return 0; // on libs ..
diff --git a/src/com/jogamp/opencl/spi/CLInfoAccessor.java b/src/com/jogamp/opencl/spi/CLInfoAccessor.java
index 0ff0aeac..a02a38e8 100644
--- a/src/com/jogamp/opencl/spi/CLInfoAccessor.java
+++ b/src/com/jogamp/opencl/spi/CLInfoAccessor.java
@@ -6,13 +6,19 @@ package com.jogamp.opencl.spi;
/**
* Internal utility for common OpenCL clGetFooInfo calls.
* Provides common accessors to CL objects.
- * @author Michael Bien
+ * @author Michael Bien, et al.
*/
public interface CLInfoAccessor {
int[] getInts(int key, int n);
/**
+ * Returns the <code>uint32_t</code> value for the given key,
+ * reinterpreted as a <code>long</code> value.
+ */
+ long getUInt32Long(int key);
+
+ /**
* Returns the long value for the given key.
*/
long getLong(int key);