diff options
Diffstat (limited to 'src/com')
30 files changed, 272 insertions, 590 deletions
diff --git a/src/com/jogamp/opencl/CLBuffer.java b/src/com/jogamp/opencl/CLBuffer.java index 21338b05..065de079 100644 --- a/src/com/jogamp/opencl/CLBuffer.java +++ b/src/com/jogamp/opencl/CLBuffer.java @@ -34,7 +34,6 @@ import java.util.List; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.llb.CL; -import com.jogamp.opencl.llb.CLBufferBinding; import java.nio.Buffer; import java.util.ArrayList; @@ -63,7 +62,7 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { throw new IllegalArgumentException("no host pointer defined"); } - final CLBufferBinding binding = context.getPlatform().getBufferBinding(); + final CL binding = context.getPlatform().getCLBinding(); 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"); @@ -81,7 +80,7 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { host_ptr = directBuffer; } - final CLBufferBinding binding = context.getPlatform().getBufferBinding(); + final CL binding = context.getPlatform().getCLBinding(); 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); @@ -116,7 +115,7 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { info.put(1, size); final int bitset = Mem.flagsToInt(flags); - final CLBufferBinding binding = getPlatform().getBufferBinding(); + final CL binding = getPlatform().getCLBinding(); 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"); diff --git a/src/com/jogamp/opencl/CLCommandQueue.java b/src/com/jogamp/opencl/CLCommandQueue.java index 6e9e2951..f95576b6 100644 --- a/src/com/jogamp/opencl/CLCommandQueue.java +++ b/src/com/jogamp/opencl/CLCommandQueue.java @@ -31,8 +31,8 @@ package com.jogamp.opencl; import static com.jogamp.opencl.CLException.checkForError; import static com.jogamp.opencl.CLException.newException; import static com.jogamp.opencl.llb.CL.CL_SUCCESS; -import static com.jogamp.opencl.llb.CLCommandQueueBinding.CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; -import static com.jogamp.opencl.llb.CLCommandQueueBinding.CL_QUEUE_PROFILING_ENABLE; +import static com.jogamp.opencl.llb.CL.CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; +import static com.jogamp.opencl.llb.CL.CL_QUEUE_PROFILING_ENABLE; import static com.jogamp.opencl.util.CLUtil.clBoolean; import java.nio.Buffer; @@ -46,8 +46,7 @@ import java.util.List; import com.jogamp.common.nio.CachedBufferFactory; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.gl.CLGLObject; -import com.jogamp.opencl.llb.CLCommandQueueBinding; -import com.jogamp.opencl.llb.gl.CLGL; +import com.jogamp.opencl.llb.CL; /** * The command queue is used to queue a set of operations for a specific {@link CLDevice}. @@ -64,7 +63,7 @@ import com.jogamp.opencl.llb.gl.CLGL; */ public class CLCommandQueue extends CLObjectResource { - private final CLCommandQueueBinding cl; + private final CL cl; private final CLDevice device; private final long properties; @@ -81,7 +80,7 @@ public class CLCommandQueue extends CLObjectResource { this.device = device; this.properties = properties; - this.cl = context.getPlatform().getCommandQueueBinding(); + this.cl = context.getPlatform().getCLBinding(); final int pbsize = PointerBuffer.ELEMENT_SIZE; final CachedBufferFactory factory = CachedBufferFactory.create(9*pbsize + 4, true); @@ -96,7 +95,7 @@ public class CLCommandQueue extends CLObjectResource { 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 CL binding = context.getPlatform().getCLBinding(); final long id = binding.clCreateCommandQueue(context.ID, device.ID, properties, status, 0); if(status[0] != CL_SUCCESS) { @@ -1701,9 +1700,7 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - final CLGL xl = (CLGL) cl; - - final int ret = xl.clEnqueueAcquireGLObjects(ID, glObjectIDs.remaining(), glObjectIDs, + final int ret = cl.clEnqueueAcquireGLObjects(ID, glObjectIDs.remaining(), glObjectIDs, conditions, conditionIDs, events==null ? null : events.IDs); @@ -1770,9 +1767,7 @@ public class CLCommandQueue extends CLObjectResource { conditions = condition.size; } - final CLGL xl = (CLGL) cl; - - final int ret = xl.clEnqueueReleaseGLObjects(ID, glObjectIDs.remaining(), glObjectIDs, + final int ret = cl.clEnqueueReleaseGLObjects(ID, glObjectIDs.remaining(), glObjectIDs, conditions, conditionIDs, events==null ? null : events.IDs); diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java index dc921722..310a36b1 100644 --- a/src/com/jogamp/opencl/CLContext.java +++ b/src/com/jogamp/opencl/CLContext.java @@ -56,8 +56,6 @@ 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.CLMemObjBinding; import com.jogamp.opencl.llb.impl.CLImageFormatImpl; /** @@ -114,17 +112,17 @@ public class CLContext extends CLObjectResource { } - private synchronized void initDevices(final CLContextBinding cl) { + private synchronized void initDevices(final CL cl) { if (devices == null) { final PointerBuffer deviceCount = PointerBuffer.allocateDirect(1); - int ret = cl.clGetContextInfo(ID, CLContextBinding.CL_CONTEXT_DEVICES, 0, null, deviceCount); + int ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, 0, null, deviceCount); CLException.checkForError(ret, "can not enumerate devices"); final ByteBuffer deviceIDs = Buffers.newDirectByteBuffer((int)deviceCount.get()); - ret = cl.clGetContextInfo(ID, CLContextBinding.CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null); + ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null); CLException.checkForError(ret, "can not enumerate devices"); devices = new CLDevice[deviceIDs.capacity() / (Platform.is32Bit() ? 4 : 8)]; @@ -200,7 +198,7 @@ public class CLContext extends CLObjectResource { 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 CL cl = platform.getCLBinding(); final long context = cl.clCreateContextFromType(properties, deviceType, handler, status); CLException.checkForError(status.get(), "can not create CL context"); @@ -221,7 +219,7 @@ public class CLContext extends CLObjectResource { pb.put(i, device.ID); } } - final CLContextBinding cl = platform.getContextBinding(); + final CL cl = platform.getCLBinding(); final long context = cl.clCreateContext(properties, pb, handler, status); CLException.checkForError(status.get(), "can not create CL context"); @@ -234,7 +232,7 @@ public class CLContext extends CLObjectResource { throw new RuntimeException("no OpenCL installation found"); } - return PointerBuffer.allocateDirect(3).put(CLContextBinding.CL_CONTEXT_PLATFORM) + return PointerBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM) .put(platform.ID).put(0) // 0 terminated array .rewind(); } @@ -508,7 +506,7 @@ public class CLContext extends CLObjectResource { } } finally { - final int ret = platform.getContextBinding().clReleaseContext(ID); + final int ret = platform.getCLBinding().clReleaseContext(ID); CLException.checkForError(ret, "error releasing context"); } @@ -520,7 +518,7 @@ public class CLContext extends CLObjectResource { private CLImageFormat[] getSupportedImageFormats(final int flags, final int type) { - final CLContextBinding binding = platform.getContextBinding(); + final CL binding = platform.getCLBinding(); final int[] entries = new int[1]; int ret = binding.clGetSupportedImageFormats(ID, flags, type, 0, null, entries, 0); @@ -554,14 +552,14 @@ public class CLContext extends CLObjectResource { * Returns all supported 2d image formats with the (optional) memory allocation flags. */ public CLImageFormat[] getSupportedImage2dFormats(final Mem... flags) { - return getSupportedImageFormats(flags==null?0:Mem.flagsToInt(flags), CLMemObjBinding.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(final Mem... flags) { - return getSupportedImageFormats(flags==null?0:Mem.flagsToInt(flags), CLMemObjBinding.CL_MEM_OBJECT_IMAGE3D); + return getSupportedImageFormats(flags==null?0:Mem.flagsToInt(flags), CL.CL_MEM_OBJECT_IMAGE3D); } /** @@ -638,7 +636,7 @@ public class CLContext extends CLObjectResource { * Returns all devices associated with this CLContext. */ public CLDevice[] getDevices() { - initDevices(platform.getContextBinding()); + initDevices(platform.getCLBinding()); return devices; } diff --git a/src/com/jogamp/opencl/CLDevice.java b/src/com/jogamp/opencl/CLDevice.java index bac93cca..e33579b1 100644 --- a/src/com/jogamp/opencl/CLDevice.java +++ b/src/com/jogamp/opencl/CLDevice.java @@ -39,7 +39,6 @@ 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; @@ -61,13 +60,13 @@ public class CLDevice extends CLObject { protected CLDevice(final CLPlatform platform, final long id) { super(id); this.platform = platform; - this.deviceInfo = platform.getAccessorFactory().createDeviceInfoAccessor(platform.getDeviceBinding(), id); + this.deviceInfo = platform.getAccessorFactory().createDeviceInfoAccessor(platform.getCLBinding(), id); } protected CLDevice(final CLContext context, final long id) { super(context, id); this.platform = context.getPlatform(); - this.deviceInfo = platform.getAccessorFactory().createDeviceInfoAccessor(platform.getDeviceBinding(), id); + this.deviceInfo = platform.getAccessorFactory().createDeviceInfoAccessor(platform.getCLBinding(), id); } public CLCommandQueue createCommandQueue() { @@ -109,7 +108,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NAME") public String getName() { - return deviceInfo.getString(CLDeviceBinding.CL_DEVICE_NAME); + return deviceInfo.getString(CL.CL_DEVICE_NAME); } /** @@ -117,7 +116,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PROFILE") public String getProfile() { - return deviceInfo.getString(CLDeviceBinding.CL_DEVICE_PROFILE); + return deviceInfo.getString(CL.CL_DEVICE_PROFILE); } /** @@ -125,7 +124,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_VENDOR") public String getVendor() { - return deviceInfo.getString(CLDeviceBinding.CL_DEVICE_VENDOR); + return deviceInfo.getString(CL.CL_DEVICE_VENDOR); } /** @@ -133,7 +132,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_VENDOR_ID") public long getVendorID() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_VENDOR_ID); + return deviceInfo.getLong(CL.CL_DEVICE_VENDOR_ID); } /** @@ -141,7 +140,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_VERSION") public CLVersion getVersion() { - return new CLVersion(deviceInfo.getString(CLDeviceBinding.CL_DEVICE_VERSION)); + return new CLVersion(deviceInfo.getString(CL.CL_DEVICE_VERSION)); } /** @@ -149,7 +148,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_OPENCL_C_VERSION") public CLVersion getCVersion() { - return new CLVersion(deviceInfo.getString(CLDeviceBinding.CL_DEVICE_OPENCL_C_VERSION)); + return new CLVersion(deviceInfo.getString(CL.CL_DEVICE_OPENCL_C_VERSION)); } /** @@ -165,7 +164,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_TYPE") public Type getType() { - return Type.valueOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_TYPE)); + return Type.valueOf((int)deviceInfo.getLong(CL.CL_DEVICE_TYPE)); } /** @@ -174,7 +173,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_ADDRESS_BITS") public int getAddressBits() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_ADDRESS_BITS); + return (int)deviceInfo.getLong(CL.CL_DEVICE_ADDRESS_BITS); } /** @@ -183,7 +182,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT") public int getPreferredShortVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT); + return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT); } /** @@ -192,7 +191,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR") public int getPreferredCharVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR); + return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR); } /** @@ -201,7 +200,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT") public int getPreferredIntVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT); + return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT); } /** @@ -210,7 +209,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG") public int getPreferredLongVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG); + return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG); } /** @@ -219,7 +218,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT") public int getPreferredFloatVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT); + return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT); } /** @@ -228,7 +227,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE") public int getPreferredDoubleVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE); + return (int)deviceInfo.getLong(CL.CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE); } /** @@ -237,7 +236,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR") public int getNativeCharVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR); + return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR); } /** @@ -246,7 +245,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT") public int getNativeShortVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT); + return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT); } /** @@ -255,7 +254,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_INT") public int getNativeIntVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_INT); + return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_INT); } /** @@ -264,7 +263,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG") public int getNativeLongVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG); + return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG); } /** @@ -273,7 +272,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF") public int getNativeHalfVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF); + return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF); } /** @@ -282,7 +281,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT") public int getNativeFloatVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT); + return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT); } /** @@ -291,7 +290,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE") public int getNativeDoubleVectorWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE); + return (int)deviceInfo.getLong(CL.CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE); } /** @@ -300,7 +299,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_COMPUTE_UNITS") public int getMaxComputeUnits() { - return (int) deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_COMPUTE_UNITS); + return (int) deviceInfo.getLong(CL.CL_DEVICE_MAX_COMPUTE_UNITS); } /** @@ -310,7 +309,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_WORK_GROUP_SIZE") public int getMaxWorkGroupSize() { - return (int) deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_WORK_GROUP_SIZE); + return (int) deviceInfo.getLong(CL.CL_DEVICE_MAX_WORK_GROUP_SIZE); } /** @@ -318,7 +317,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_CLOCK_FREQUENCY") public int getMaxClockFrequency() { - return (int) (deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_CLOCK_FREQUENCY)); + return (int) (deviceInfo.getLong(CL.CL_DEVICE_MAX_CLOCK_FREQUENCY)); } /** @@ -328,7 +327,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS") public int getMaxWorkItemDimensions() { - return (int) deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS); + return (int) deviceInfo.getLong(CL.CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS); } /** @@ -339,7 +338,7 @@ public class CLDevice extends CLObject { @CLProperty("CL_DEVICE_MAX_WORK_ITEM_SIZES") public int[] getMaxWorkItemSizes() { final int n = getMaxWorkItemDimensions(); - return deviceInfo.getInts(CLDeviceBinding.CL_DEVICE_MAX_WORK_ITEM_SIZES, n); + return deviceInfo.getInts(CL.CL_DEVICE_MAX_WORK_ITEM_SIZES, n); } /** @@ -349,7 +348,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_PARAMETER_SIZE") public long getMaxParameterSize() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_PARAMETER_SIZE); + return deviceInfo.getLong(CL.CL_DEVICE_MAX_PARAMETER_SIZE); } /** @@ -357,7 +356,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_MEM_ALLOC_SIZE") public long getMaxMemAllocSize() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_MEM_ALLOC_SIZE); + return deviceInfo.getLong(CL.CL_DEVICE_MAX_MEM_ALLOC_SIZE); } /** @@ -366,7 +365,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MEM_BASE_ADDR_ALIGN") public long getMemBaseAddrAlign() { - return deviceInfo.getUInt32Long(CLDeviceBinding.CL_DEVICE_MEM_BASE_ADDR_ALIGN); + return deviceInfo.getUInt32Long(CL.CL_DEVICE_MEM_BASE_ADDR_ALIGN); } /** @@ -374,7 +373,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_GLOBAL_MEM_SIZE") public long getGlobalMemSize() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_GLOBAL_MEM_SIZE); + return deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_SIZE); } /** @@ -384,7 +383,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_LOCAL_MEM_SIZE") public long getLocalMemSize() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_LOCAL_MEM_SIZE); + return deviceInfo.getLong(CL.CL_DEVICE_LOCAL_MEM_SIZE); } /** @@ -392,7 +391,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_HOST_UNIFIED_MEMORY") public boolean isMemoryUnified() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_HOST_UNIFIED_MEMORY) == CL.CL_TRUE; + return deviceInfo.getLong(CL.CL_DEVICE_HOST_UNIFIED_MEMORY) == CL.CL_TRUE; } /** @@ -401,7 +400,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE") public long getMaxConstantBufferSize() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE); + return deviceInfo.getLong(CL.CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE); } /** @@ -409,7 +408,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE") public long getGlobalMemCachelineSize() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE); + return deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE); } /** @@ -417,7 +416,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_GLOBAL_MEM_CACHE_SIZE") public long getGlobalMemCacheSize() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_GLOBAL_MEM_CACHE_SIZE); + return deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_CACHE_SIZE); } /** @@ -426,7 +425,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_CONSTANT_ARGS") public long getMaxConstantArgs() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_CONSTANT_ARGS); + return deviceInfo.getLong(CL.CL_DEVICE_MAX_CONSTANT_ARGS); } /** @@ -434,7 +433,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE_SUPPORT") public boolean isImageSupportAvailable() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE_SUPPORT) == CL.CL_TRUE; + return deviceInfo.getLong(CL.CL_DEVICE_IMAGE_SUPPORT) == CL.CL_TRUE; } /** @@ -443,7 +442,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_READ_IMAGE_ARGS") public int getMaxReadImageArgs() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_READ_IMAGE_ARGS); + return (int)deviceInfo.getLong(CL.CL_DEVICE_MAX_READ_IMAGE_ARGS); } /** @@ -452,7 +451,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_WRITE_IMAGE_ARGS") public int getMaxWriteImageArgs() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_WRITE_IMAGE_ARGS); + return (int)deviceInfo.getLong(CL.CL_DEVICE_MAX_WRITE_IMAGE_ARGS); } /** @@ -461,7 +460,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE2D_MAX_WIDTH") public int getMaxImage2dWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE2D_MAX_WIDTH); + return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE2D_MAX_WIDTH); } /** @@ -470,7 +469,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE2D_MAX_HEIGHT") public int getMaxImage2dHeight() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE2D_MAX_HEIGHT); + return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE2D_MAX_HEIGHT); } /** @@ -479,7 +478,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE3D_MAX_WIDTH") public int getMaxImage3dWidth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE3D_MAX_WIDTH); + return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE3D_MAX_WIDTH); } /** @@ -488,7 +487,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE3D_MAX_HEIGHT") public int getMaxImage3dHeight() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE3D_MAX_HEIGHT); + return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE3D_MAX_HEIGHT); } /** @@ -497,7 +496,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_IMAGE3D_MAX_DEPTH") public int getMaxImage3dDepth() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_IMAGE3D_MAX_DEPTH); + return (int)deviceInfo.getLong(CL.CL_DEVICE_IMAGE3D_MAX_DEPTH); } /** @@ -506,7 +505,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_MAX_SAMPLERS") public int getMaxSamplers() { - return (int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_MAX_SAMPLERS); + return (int)deviceInfo.getLong(CL.CL_DEVICE_MAX_SAMPLERS); } /** @@ -514,7 +513,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_PROFILING_TIMER_RESOLUTION") public long getProfilingTimerResolution() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_PROFILING_TIMER_RESOLUTION); + return deviceInfo.getLong(CL.CL_DEVICE_PROFILING_TIMER_RESOLUTION); } /** @@ -522,7 +521,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_EXECUTION_CAPABILITIES") public EnumSet<Capabilities> getExecutionCapabilities() { - return Capabilities.valuesOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_EXECUTION_CAPABILITIES)); + return Capabilities.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_EXECUTION_CAPABILITIES)); } /** @@ -535,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(CLDeviceBinding.CL_DEVICE_HALF_FP_CONFIG)); + return FPConfig.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_HALF_FP_CONFIG)); else return EnumSet.noneOf(FPConfig.class); } @@ -548,7 +547,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_SINGLE_FP_CONFIG") public EnumSet<FPConfig> getSingleFPConfig() { - return FPConfig.valuesOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_SINGLE_FP_CONFIG)); + return FPConfig.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_SINGLE_FP_CONFIG)); } /** @@ -561,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(CLDeviceBinding.CL_DEVICE_DOUBLE_FP_CONFIG)); + return FPConfig.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_DOUBLE_FP_CONFIG)); else return EnumSet.noneOf(FPConfig.class); } @@ -571,7 +570,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_LOCAL_MEM_TYPE") public LocalMemType getLocalMemType() { - return LocalMemType.valueOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_LOCAL_MEM_TYPE)); + return LocalMemType.valueOf((int)deviceInfo.getLong(CL.CL_DEVICE_LOCAL_MEM_TYPE)); } /** @@ -579,7 +578,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_GLOBAL_MEM_CACHE_TYPE") public GlobalMemCacheType getGlobalMemCacheType() { - return GlobalMemCacheType.valueOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_GLOBAL_MEM_CACHE_TYPE)); + return GlobalMemCacheType.valueOf((int)deviceInfo.getLong(CL.CL_DEVICE_GLOBAL_MEM_CACHE_TYPE)); } @@ -588,7 +587,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_QUEUE_PROPERTIES") public EnumSet<CLCommandQueue.Mode> getQueueProperties() { - return CLCommandQueue.Mode.valuesOf((int)deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_QUEUE_PROPERTIES)); + return CLCommandQueue.Mode.valuesOf((int)deviceInfo.getLong(CL.CL_DEVICE_QUEUE_PROPERTIES)); } /** @@ -596,7 +595,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_AVAILABLE") public boolean isAvailable() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_AVAILABLE) == CL.CL_TRUE; + return deviceInfo.getLong(CL.CL_DEVICE_AVAILABLE) == CL.CL_TRUE; } /** @@ -606,7 +605,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_COMPILER_AVAILABLE") public boolean isCompilerAvailable() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_COMPILER_AVAILABLE) == CL.CL_TRUE; + return deviceInfo.getLong(CL.CL_DEVICE_COMPILER_AVAILABLE) == CL.CL_TRUE; } /** @@ -614,7 +613,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_ENDIAN_LITTLE") public boolean isLittleEndian() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_ENDIAN_LITTLE) == CL.CL_TRUE; + return deviceInfo.getLong(CL.CL_DEVICE_ENDIAN_LITTLE) == CL.CL_TRUE; } /** @@ -624,7 +623,7 @@ public class CLDevice extends CLObject { */ @CLProperty("CL_DEVICE_ERROR_CORRECTION_SUPPORT") public boolean isErrorCorrectionSupported() { - return deviceInfo.getLong(CLDeviceBinding.CL_DEVICE_ERROR_CORRECTION_SUPPORT) == CL.CL_TRUE; + return deviceInfo.getLong(CL.CL_DEVICE_ERROR_CORRECTION_SUPPORT) == CL.CL_TRUE; } /** @@ -690,7 +689,7 @@ public class CLDevice extends CLObject { if(extensions == null) { extensions = new HashSet<String>(); - final String ext = deviceInfo.getString(CLDeviceBinding.CL_DEVICE_EXTENSIONS); + final String ext = deviceInfo.getString(CL.CL_DEVICE_EXTENSIONS); final Scanner scanner = new Scanner(ext); while(scanner.hasNext()) @@ -831,17 +830,17 @@ public class CLDevice extends CLObject { public static Type valueOf(final long clDeviceType) { - if(clDeviceType == CLDeviceBinding.CL_DEVICE_TYPE_ALL) + if(clDeviceType == CL.CL_DEVICE_TYPE_ALL) return ALL; switch((int)clDeviceType) { - case(CLDeviceBinding.CL_DEVICE_TYPE_DEFAULT): + case(CL.CL_DEVICE_TYPE_DEFAULT): return DEFAULT; - case(CLDeviceBinding.CL_DEVICE_TYPE_CPU): + case(CL.CL_DEVICE_TYPE_CPU): return CPU; - case(CLDeviceBinding.CL_DEVICE_TYPE_GPU): + case(CL.CL_DEVICE_TYPE_GPU): return GPU; - case(CLDeviceBinding.CL_DEVICE_TYPE_ACCELERATOR): + case(CL.CL_DEVICE_TYPE_ACCELERATOR): return ACCELERATOR; } return null; @@ -983,9 +982,9 @@ public class CLDevice extends CLObject { * Returns the matching LocalMemCacheType for the given cl type. */ public static LocalMemType valueOf(final int clLocalCacheType) { - if(clLocalCacheType == CLDeviceBinding.CL_GLOBAL) + if(clLocalCacheType == CL.CL_GLOBAL) return GLOBAL; - else if(clLocalCacheType == CLDeviceBinding.CL_LOCAL) + else if(clLocalCacheType == CL.CL_LOCAL) return LOCAL; return null; } diff --git a/src/com/jogamp/opencl/CLEvent.java b/src/com/jogamp/opencl/CLEvent.java index 2d0e5568..af22e24a 100644 --- a/src/com/jogamp/opencl/CLEvent.java +++ b/src/com/jogamp/opencl/CLEvent.java @@ -29,7 +29,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.impl.CLTLInfoAccessor; -import com.jogamp.opencl.llb.CLEventBinding; +import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.llb.impl.CLEventCallback; import com.jogamp.common.nio.PointerBuffer; import java.nio.Buffer; @@ -49,11 +49,11 @@ public class CLEvent extends CLObjectResource { private final CLEventInfoAccessor eventInfo; private final CLEventProfilingInfoAccessor eventProfilingInfo; - private final CLEventBinding binding; + private final CL binding; CLEvent(final CLContext context, final long id) { super(context, id); - binding = context.getPlatform().getEventBinding(); + binding = context.getPlatform().getCLBinding(); this.eventInfo = new CLEventInfoAccessor(); this.eventProfilingInfo = new CLEventProfilingInfoAccessor(); } diff --git a/src/com/jogamp/opencl/CLEventList.java b/src/com/jogamp/opencl/CLEventList.java index b415da09..806a0661 100644 --- a/src/com/jogamp/opencl/CLEventList.java +++ b/src/com/jogamp/opencl/CLEventList.java @@ -108,7 +108,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL */ public void waitForEvents() { if(size > 0) { - events[0].getPlatform().getEventBinding().clWaitForEvents(size, IDsView); + events[0].getPlatform().getCLBinding().clWaitForEvents(size, IDsView); } } @@ -122,7 +122,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL } final PointerBuffer view = getEventBuffer(start); - getEvent(start).getPlatform().getEventBinding().clWaitForEvents(range, view); + getEvent(start).getPlatform().getCLBinding().clWaitForEvents(range, view); } /** @@ -130,7 +130,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL */ public void waitForEvent(final int index) { final PointerBuffer view = getEventBuffer(index); - getEvent(index).getPlatform().getEventBinding().clWaitForEvents(1, view); + getEvent(index).getPlatform().getCLBinding().clWaitForEvents(1, view); } /** diff --git a/src/com/jogamp/opencl/CLException.java b/src/com/jogamp/opencl/CLException.java index c74b99bc..890c2036 100644 --- a/src/com/jogamp/opencl/CLException.java +++ b/src/com/jogamp/opencl/CLException.java @@ -28,13 +28,7 @@ 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). @@ -102,18 +96,18 @@ public class CLException extends RuntimeException { */ public static String resolveErrorCode(final int error) { switch(error) { - 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_DEVICE_NOT_FOUND: return "CL_DEVICE_NOT_FOUND"; + case CL.CL_DEVICE_NOT_AVAILABLE: return "CL_DEVICE_NOT_AVAILABLE"; case CL.CL_COMPILER_NOT_AVAILABLE: return "CL_COMPILER_NOT_AVAILABLE"; - case CLMemObjBinding.CL_MEM_OBJECT_ALLOCATION_FAILURE: return "CL_MEM_OBJECT_ALLOCATION_FAILURE"; + case CL.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 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_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 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"; @@ -148,29 +142,29 @@ 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 CLPlatformBinding.CL_PLATFORM_NOT_FOUND_KHR: return "CL_PLATFORM_NOT_FOUND_KHR"; + case CL.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"; - case CLGL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR: return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR"; + case CL.CL_INVALID_GL_OBJECT: return "CL_INVALID_GL_OBJECT"; + case CL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR: return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR"; default: return null; } } private static CLException createSpecificException(final int error, final String message) { switch(error) { - case CLDeviceBinding.CL_DEVICE_NOT_FOUND: return new CLDeviceNotFoundException(message); - case CLDeviceBinding.CL_DEVICE_NOT_AVAILABLE: return new CLDeviceNotAvailableException(message); + case CL.CL_DEVICE_NOT_FOUND: return new CLDeviceNotFoundException(message); + case CL.CL_DEVICE_NOT_AVAILABLE: return new CLDeviceNotAvailableException(message); case CL.CL_COMPILER_NOT_AVAILABLE: return new CLCompilerNotAvailableException(message); - case CLMemObjBinding.CL_MEM_OBJECT_ALLOCATION_FAILURE: return new CLMemObjectAllocationFailureException(message); + case CL.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 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_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 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); @@ -205,11 +199,11 @@ 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 CLPlatformBinding.CL_PLATFORM_NOT_FOUND_KHR: return new CLPlatformNotFoundKhrException(message); + case CL.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); - case CLGL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR: return new CLInvalidGLSharegroupReferenceKhrException(message); + case CL.CL_INVALID_GL_OBJECT: return new CLInvalidGLObjectException(message); + case CL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR: return new CLInvalidGLSharegroupReferenceKhrException(message); default: return null; } } @@ -220,7 +214,7 @@ 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(final String message) { - super(CLDeviceBinding.CL_DEVICE_NOT_FOUND, "CL_DEVICE_NOT_FOUND", message); + super(CL.CL_DEVICE_NOT_FOUND, "CL_DEVICE_NOT_FOUND", message); } } @@ -230,7 +224,7 @@ 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(final String message) { - super(CLDeviceBinding.CL_DEVICE_NOT_AVAILABLE, "CL_DEVICE_NOT_AVAILABLE", message); + super(CL.CL_DEVICE_NOT_AVAILABLE, "CL_DEVICE_NOT_AVAILABLE", message); } } @@ -250,7 +244,7 @@ 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(final String message) { - super(CLMemObjBinding.CL_MEM_OBJECT_ALLOCATION_FAILURE, "CL_MEM_OBJECT_ALLOCATION_FAILURE", message); + super(CL.CL_MEM_OBJECT_ALLOCATION_FAILURE, "CL_MEM_OBJECT_ALLOCATION_FAILURE", message); } } @@ -290,7 +284,7 @@ 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(final String message) { - super(CLMemObjBinding.CL_MEM_COPY_OVERLAP, "CL_MEM_COPY_OVERLAP", message); + super(CL.CL_MEM_COPY_OVERLAP, "CL_MEM_COPY_OVERLAP", message); } } @@ -300,7 +294,7 @@ 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(final String message) { - super(CLImageBinding.CL_IMAGE_FORMAT_MISMATCH, "CL_IMAGE_FORMAT_MISMATCH", message); + super(CL.CL_IMAGE_FORMAT_MISMATCH, "CL_IMAGE_FORMAT_MISMATCH", message); } } @@ -310,7 +304,7 @@ 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(final String message) { - super(CLImageBinding.CL_IMAGE_FORMAT_NOT_SUPPORTED, "CL_IMAGE_FORMAT_NOT_SUPPORTED", message); + super(CL.CL_IMAGE_FORMAT_NOT_SUPPORTED, "CL_IMAGE_FORMAT_NOT_SUPPORTED", message); } } @@ -320,7 +314,7 @@ 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(final String message) { - super(CLProgramBinding.CL_BUILD_PROGRAM_FAILURE, "CL_BUILD_PROGRAM_FAILURE", message); + super(CL.CL_BUILD_PROGRAM_FAILURE, "CL_BUILD_PROGRAM_FAILURE", message); } } @@ -330,7 +324,7 @@ 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(final String message) { - super(CLMemObjBinding.CL_MAP_FAILURE, "CL_MAP_FAILURE", message); + super(CL.CL_MAP_FAILURE, "CL_MAP_FAILURE", message); } } @@ -669,9 +663,9 @@ public class CLException extends RuntimeException { * */ public final static class CLInvalidGLObjectException extends CLException { - private static final long serialVersionUID = CLException.serialVersionUID+CLGL.CL_INVALID_GL_OBJECT; + private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_GL_OBJECT; public CLInvalidGLObjectException(final String message) { - super(CLGL.CL_INVALID_GL_OBJECT, "CL_INVALID_GL_OBJECT", message); + super(CL.CL_INVALID_GL_OBJECT, "CL_INVALID_GL_OBJECT", message); } } @@ -724,9 +718,9 @@ public class CLException extends RuntimeException { * */ public final static class CLInvalidGLSharegroupReferenceKhrException extends CLException { - private static final long serialVersionUID = CLException.serialVersionUID+CLGL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR; + private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR; public CLInvalidGLSharegroupReferenceKhrException(final String message) { - super(CLGL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR, "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR", message); + super(CL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR, "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR", message); } } @@ -737,7 +731,7 @@ public class CLException extends RuntimeException { public final static class CLPlatformNotFoundKhrException extends CLException { private static final long serialVersionUID = CLException.serialVersionUID+CL.CL_PLATFORM_NOT_FOUND_KHR; public CLPlatformNotFoundKhrException(final String message) { - super(CLPlatformBinding.CL_PLATFORM_NOT_FOUND_KHR, "CL_PLATFORM_NOT_FOUND_KHR", message); + super(CL.CL_PLATFORM_NOT_FOUND_KHR, "CL_PLATFORM_NOT_FOUND_KHR", message); } } diff --git a/src/com/jogamp/opencl/CLImage.java b/src/com/jogamp/opencl/CLImage.java index 497850fd..9dd19c76 100644 --- a/src/com/jogamp/opencl/CLImage.java +++ b/src/com/jogamp/opencl/CLImage.java @@ -30,7 +30,7 @@ package com.jogamp.opencl; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.impl.CLTLInfoAccessor; -import com.jogamp.opencl.llb.CLImageBinding; +import com.jogamp.opencl.llb.CL; import java.nio.Buffer; import static com.jogamp.opencl.llb.CL.*; @@ -61,7 +61,7 @@ public abstract class CLImage<B extends Buffer> extends CLMemory<B> { } private static CLImageInfoAccessor createAccessor(final CLContext context, final long id) { - return new CLImageInfoAccessor(context.getPlatform().getImageBinding(), id); + return new CLImageInfoAccessor(context.getPlatform().getCLBinding(), id); } protected static CLImageFormat createUninitializedImageFormat() { @@ -109,9 +109,9 @@ public abstract class CLImage<B extends Buffer> extends CLMemory<B> { protected final static class CLImageInfoAccessor extends CLTLInfoAccessor { private final long id; - private final CLImageBinding cl; + private final CL cl; - public CLImageInfoAccessor(final CLImageBinding cl, final long id) { + public CLImageInfoAccessor(final CL cl, final long id) { this.cl = cl; this.id = id; } diff --git a/src/com/jogamp/opencl/CLImage2d.java b/src/com/jogamp/opencl/CLImage2d.java index f60bb23d..c684e99c 100644 --- a/src/com/jogamp/opencl/CLImage2d.java +++ b/src/com/jogamp/opencl/CLImage2d.java @@ -29,7 +29,7 @@ package com.jogamp.opencl; import com.jogamp.common.nio.Buffers; -import com.jogamp.opencl.llb.CLImageBinding; +import com.jogamp.opencl.llb.CL; import java.nio.Buffer; import java.nio.IntBuffer; @@ -52,7 +52,7 @@ public class CLImage2d<B extends Buffer> extends CLImage<B> { 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) { - final CLImageBinding cl = context.getPlatform().getImageBinding(); + final CL cl = context.getPlatform().getCLBinding(); final IntBuffer err = Buffers.newDirectIntBuffer(1); B host_ptr = null; if(isHostPointerFlag(flags)) { diff --git a/src/com/jogamp/opencl/CLImage3d.java b/src/com/jogamp/opencl/CLImage3d.java index 9b1c7fcc..6d096e55 100644 --- a/src/com/jogamp/opencl/CLImage3d.java +++ b/src/com/jogamp/opencl/CLImage3d.java @@ -29,7 +29,7 @@ package com.jogamp.opencl; import com.jogamp.common.nio.Buffers; -import com.jogamp.opencl.llb.CLImageBinding; +import com.jogamp.opencl.llb.CL; import java.nio.Buffer; import java.nio.IntBuffer; @@ -58,7 +58,7 @@ public class CLImage3d<B extends Buffer> extends CLImage<B> { 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 CL cl = context.getPlatform().getCLBinding(); final IntBuffer err = Buffers.newDirectIntBuffer(1); B host_ptr = null; if(isHostPointerFlag(flags)) { diff --git a/src/com/jogamp/opencl/CLKernel.java b/src/com/jogamp/opencl/CLKernel.java index 26f7f1d3..c3031ae9 100644 --- a/src/com/jogamp/opencl/CLKernel.java +++ b/src/com/jogamp/opencl/CLKernel.java @@ -31,7 +31,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.util.CLUtil; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; -import com.jogamp.opencl.llb.CLKernelBinding; +import com.jogamp.opencl.llb.CL; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -56,7 +56,7 @@ public class CLKernel extends CLObjectResource implements Cloneable { public final int numArgs; private final CLProgram program; - private final CLKernelBinding binding; + private final CL binding; private final ByteBuffer buffer; @@ -73,7 +73,7 @@ public class CLKernel extends CLObjectResource implements Cloneable { this.program = program; this.buffer = Buffers.newDirectByteBuffer((is32Bit()?4:8)*3); - binding = program.getPlatform().getKernelBinding(); + binding = program.getPlatform().getCLBinding(); if(name == null) { // get function name diff --git a/src/com/jogamp/opencl/CLMemory.java b/src/com/jogamp/opencl/CLMemory.java index 9fb81e7e..6a28d0a5 100644 --- a/src/com/jogamp/opencl/CLMemory.java +++ b/src/com/jogamp/opencl/CLMemory.java @@ -28,7 +28,6 @@ package com.jogamp.opencl; -import com.jogamp.opencl.llb.CLMemObjBinding; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.llb.CL; @@ -40,7 +39,7 @@ import java.util.EnumSet; import java.util.List; import static com.jogamp.opencl.CLException.*; -import static com.jogamp.opencl.llb.gl.CLGL.*; +import static com.jogamp.opencl.llb.CL.*; /** * Common superclass for all OpenCL memory types. @@ -57,7 +56,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { protected int elementSize; protected int clCapacity; - private final CLMemObjBinding binding; + private final CL binding; protected <Buffer> CLMemory(final CLContext context, final long size, final long id, final int flags) { this(context, null, size, id, flags); @@ -68,7 +67,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { this.buffer = directBuffer; this.FLAGS = flags; this.size = size; - this.binding = context.getPlatform().getMemObjectBinding(); + this.binding = context.getPlatform().getCLBinding(); initElementSize(); initCLCapacity(); } @@ -91,7 +90,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObjectResource { 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 CL binding = context.getPlatform().getCLBinding(); // 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(); diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java index 26cdbc8a..f64df614 100644 --- a/src/com/jogamp/opencl/CLPlatform.java +++ b/src/com/jogamp/opencl/CLPlatform.java @@ -28,27 +28,18 @@ package com.jogamp.opencl; -import com.jogamp.opencl.llb.CLPlatformBinding; -import com.jogamp.opencl.llb.CLProgramBinding; -import com.jogamp.opencl.llb.CLSamplerBinding; -import com.jogamp.opencl.llb.CLKernelBinding; -import com.jogamp.opencl.llb.CLImageBinding; import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.impl.CLTLAccessorFactory; import com.jogamp.common.nio.Buffers; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.nio.PointerBuffer; -import com.jogamp.opencl.llb.CLBufferBinding; -import com.jogamp.opencl.llb.CLCommandQueueBinding; -import com.jogamp.opencl.llb.CLContextBinding; -import com.jogamp.opencl.llb.CLDeviceBinding; -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.llb.impl.CLImpl11; +import com.jogamp.opencl.llb.impl.CLImpl12; +import com.jogamp.opencl.llb.impl.CLImpl20; import com.jogamp.opencl.spi.CLAccessorFactory; +import com.jogamp.opencl.spi.CLInfoAccessor; import com.jogamp.opencl.util.Filter; import java.nio.IntBuffer; @@ -145,7 +136,7 @@ public class CLPlatform { * @returns true if OpenCL is available on this machine, * i.e. all native libraries could be loaded (CL and CL/JNI). */ - public static boolean isAvailable() { return CLAbstractImpl.isAvailable(); } + public static boolean isAvailable() { return CLImpl11.isAvailable(); } /** * Eagerly initializes JOCL. Subsequent calls do nothing. @@ -176,10 +167,10 @@ public class CLPlatform { } } - if( !CLAbstractImpl.isAvailable() ) { + if( !CLImpl11.isAvailable() ) { throw new JogampRuntimeException("JOCL is not available"); } - cl = new CLImpl(); + cl = new CLImpl11(); } /** @@ -249,7 +240,7 @@ public class CLPlatform { } /** - * Returns the low level binding interface to the OpenCL APIs. + * Returns the low level binding interface to the OpenCL APIs. This interface is always for OpenCL 1.1. */ public static CL getLowLevelCLInterface() { initialize(); @@ -257,6 +248,25 @@ public class CLPlatform { } /** + * Returns the low level binding interface to the OpenCL APIs for the specified device. This interface + * is the newest one the device supports. + */ + public static CL getLowLevelCLInterfaceForDevice(final long device) { + initialize(); + + CLInfoAccessor deviceInfo = defaultFactory.createDeviceInfoAccessor(cl, device); + CLVersion version = new CLVersion(deviceInfo.getString(CL_DEVICE_VERSION)); + + if(version.isEqual(CLVersion.CL_1_2)) + return new CLImpl12(); + + if(version.isEqual(CLVersion.CL_2_0)) + return new CLImpl20(); + + return cl; + } + + /** * Hint to allow the implementation to release the resources allocated by the OpenCL compiler. * Calls to {@link CLProgram#build()} after unloadCompiler will reload the compiler if necessary. */ @@ -463,6 +473,14 @@ public class CLPlatform { public boolean isVendorAMD() { return getVendor().contains("Advanced Micro Devices"); } + + /** + * @return true if the vendor is Intel. + */ + public boolean isVendorIntel() { + return getVendor().contains("Intel"); + } + /** * Returns the ICD suffix. */ @@ -522,50 +540,6 @@ public class CLPlatform { return info; } - protected CLBufferBinding getBufferBinding() { - return cl; - } - - protected CLCommandQueueBinding getCommandQueueBinding() { - return cl; - } - - protected CLContextBinding getContextBinding() { - return cl; - } - - protected CLDeviceBinding getDeviceBinding() { - return cl; - } - - protected CLEventBinding getEventBinding() { - return cl; - } - - protected CLImageBinding getImageBinding() { - return cl; - } - - protected CLKernelBinding getKernelBinding() { - return cl; - } - - protected CLMemObjBinding getMemObjectBinding() { - return cl; - } - - protected CLPlatformBinding getPlatformBinding() { - return cl; - } - - protected CLProgramBinding getProgramBinding() { - return cl; - } - - protected CLSamplerBinding getSamplerBinding() { - return cl; - } - protected CL getCLBinding() { return cl; } diff --git a/src/com/jogamp/opencl/CLProgram.java b/src/com/jogamp/opencl/CLProgram.java index 7e1ef6cf..3c68fa35 100644 --- a/src/com/jogamp/opencl/CLProgram.java +++ b/src/com/jogamp/opencl/CLProgram.java @@ -29,12 +29,11 @@ package com.jogamp.opencl; import com.jogamp.common.nio.CachedBufferFactory; -import com.jogamp.opencl.llb.CLProgramBinding; import com.jogamp.opencl.util.CLProgramConfiguration; import com.jogamp.opencl.util.CLUtil; import com.jogamp.common.os.Platform; import com.jogamp.common.nio.PointerBuffer; -import com.jogamp.opencl.llb.CLKernelBinding; +import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.llb.impl.BuildProgramCallback; import com.jogamp.opencl.util.CLBuildListener; import java.nio.ByteBuffer; @@ -46,7 +45,7 @@ import java.util.LinkedHashMap; import java.util.Map.Entry; import java.util.Set; import java.util.Map; -import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.Semaphore; import static com.jogamp.opencl.CLException.*; import static com.jogamp.opencl.llb.CL.*; @@ -62,8 +61,10 @@ import static com.jogamp.common.nio.Buffers.*; */ public class CLProgram extends CLObjectResource { - private final static ReentrantLock buildLock = new ReentrantLock(); - private final CLProgramBinding binding; + // must use a semaphore instead of a reentrant lock because the CL implementation can call + // our notifier function from a different thread than the one that calls clBuildProgram + private final static Semaphore buildLock = new Semaphore(1, true); + private final CL binding; private final Set<CLKernel> kernels; private Map<CLDevice, Status> buildStatusMap; @@ -76,7 +77,7 @@ public class CLProgram extends CLObjectResource { private CLProgram(final CLContext context, final long id) { super(context, id); this.kernels = new HashSet<CLKernel>(); - this.binding = context.getPlatform().getProgramBinding(); + this.binding = context.getPlatform().getCLBinding(); } static CLProgram create(final CLContext context, final String src) { @@ -87,7 +88,7 @@ public class CLProgram extends CLObjectResource { final String[] srcArray = new String[] {src}; // Create the program - final CLProgramBinding binding = context.getPlatform().getProgramBinding(); + final CL binding = context.getPlatform().getCLBinding(); final long id = binding.clCreateProgramWithSource(context.ID, 1, srcArray, length, status); final int err = status.get(); @@ -133,7 +134,7 @@ public class CLProgram extends CLObjectResource { final IntBuffer errBuffer = bf.newDirectIntBuffer(1); // IntBuffer status = newDirectByteBuffer(binaries.size()*4).asIntBuffer(); - final CLProgramBinding binding = context.getPlatform().getProgramBinding(); + final CL binding = context.getPlatform().getCLBinding(); final long id = binding.clCreateProgramWithBinary(context.ID, devices.capacity(), devices, lengths, codeBuffers, /*status*/null, errBuffer); // while(status.remaining() != 0) { @@ -151,18 +152,16 @@ public class CLProgram extends CLObjectResource { private void initBuildStatus() { if(buildStatusMap == null) { -// synchronized(buildLock) { - 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; - } - map.put(device, status); + 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; } - this.buildStatusMap = Collections.unmodifiableMap(map); -// } + map.put(device, status); + } + this.buildStatusMap = Collections.unmodifiableMap(map); } } @@ -218,10 +217,6 @@ public class CLProgram extends CLObjectResource { return buffer.getInt(); } - private CLKernelBinding getKernelBinding() { - return getPlatform().getKernelBinding(); - } - /** * Builds this program for all devices associated with the context. * @return this @@ -364,7 +359,7 @@ public class CLProgram extends CLObjectResource { callback = new BuildProgramCallback() { @Override public void buildFinished(final long cl_program) { - buildLock.unlock(); + buildLock.release(); listener.buildFinished(CLProgram.this); } }; @@ -376,14 +371,19 @@ public class CLProgram extends CLObjectResource { // spec: building programs is not threadsafe, we are locking the API call to // make sure only one thread calls it at a time until it completes (asynchronous or synchronously). { - buildLock.lock(); + try { + buildLock.acquire(); + } catch(InterruptedException e) { + throw newException(ret, "\nInterrupted while waiting to get build lock"); + } + boolean exception = true; try{ ret = binding.clBuildProgram(ID, count, deviceIDs, options, callback); exception = false; }finally{ if(callback == null || exception) { - buildLock.unlock(); + buildLock.release(); } } } @@ -412,7 +412,7 @@ public class CLProgram extends CLObjectResource { } final int[] err = new int[1]; - final long id = getKernelBinding().clCreateKernel(ID, kernelName, err, 0); + final long id = binding.clCreateKernel(ID, kernelName, err, 0); if(err[0] != CL_SUCCESS) { throw newException(err[0], "unable to create Kernel with name: "+kernelName); } @@ -434,8 +434,7 @@ public class CLProgram extends CLObjectResource { final HashMap<String, CLKernel> newKernels = new HashMap<String, CLKernel>(); final IntBuffer numKernels = newDirectByteBuffer(4).asIntBuffer(); - final CLKernelBinding kernelBinding = getKernelBinding(); - int ret = kernelBinding.clCreateKernelsInProgram(ID, 0, null, numKernels); + int ret = binding.clCreateKernelsInProgram(ID, 0, null, numKernels); if(ret != CL_SUCCESS) { throw newException(ret, "can not create kernels for "+this); } @@ -443,7 +442,7 @@ public class CLProgram extends CLObjectResource { if(numKernels.get(0) > 0) { final PointerBuffer kernelIDs = PointerBuffer.allocateDirect(numKernels.get(0)); - ret = kernelBinding.clCreateKernelsInProgram(ID, kernelIDs.capacity(), kernelIDs, null); + ret = binding.clCreateKernelsInProgram(ID, kernelIDs.capacity(), kernelIDs, null); if(ret != CL_SUCCESS) { throw newException(ret, "can not create "+kernelIDs.capacity()+" kernels for "+this); } diff --git a/src/com/jogamp/opencl/CLSampler.java b/src/com/jogamp/opencl/CLSampler.java index f3de5ffe..f6fe30bf 100644 --- a/src/com/jogamp/opencl/CLSampler.java +++ b/src/com/jogamp/opencl/CLSampler.java @@ -30,7 +30,7 @@ package com.jogamp.opencl; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.impl.CLTLInfoAccessor; -import com.jogamp.opencl.llb.CLSamplerBinding; +import com.jogamp.opencl.llb.CL; import java.nio.Buffer; @@ -46,18 +46,18 @@ import static com.jogamp.opencl.util.CLUtil.*; public class CLSampler extends CLObjectResource { private final CLSamplerInfoAccessor samplerInfo; - private final CLSamplerBinding binding; + private final CL binding; 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.binding = context.getPlatform().getCLBinding(); this.samplerInfo = new CLSamplerInfoAccessor(); } static CLSampler create(final CLContext context, final AddressingMode addrMode, final FilteringMode filtMode, final boolean normalizedCoords) { final int[] error = new int[1]; - final CLSamplerBinding binding = context.getPlatform().getSamplerBinding(); + final CL binding = context.getPlatform().getCLBinding(); final long id = binding.clCreateSampler(context.ID, clBoolean(normalizedCoords), addrMode.MODE, filtMode.MODE, error, 0); checkForError(error[0], "can not create sampler"); diff --git a/src/com/jogamp/opencl/CLUserEvent.java b/src/com/jogamp/opencl/CLUserEvent.java index cff3701c..c1528366 100644 --- a/src/com/jogamp/opencl/CLUserEvent.java +++ b/src/com/jogamp/opencl/CLUserEvent.java @@ -34,7 +34,7 @@ package com.jogamp.opencl; import static com.jogamp.opencl.CLException.*; import static com.jogamp.opencl.llb.CL.*; -import com.jogamp.opencl.llb.CLEventBinding; +import com.jogamp.opencl.llb.CL; /** * Custom, user controlled event. @@ -51,7 +51,7 @@ public class CLUserEvent extends CLEvent { * Creates a new user event. */ public static CLUserEvent create(final CLContext context) { - final CLEventBinding binding = context.getPlatform().getEventBinding(); + final CL binding = context.getPlatform().getCLBinding(); final int[] error = new int[1]; final long ID = binding.clCreateUserEvent(context.ID, error, 0); checkForError(error[0], "can not create user event."); @@ -63,7 +63,7 @@ public class CLUserEvent extends CLEvent { * Calls {@native clSetUserEventStatus}. */ public CLUserEvent setStatus(final CLEvent.ExecutionStatus status) { - final CLEventBinding binding = getPlatform().getEventBinding(); + final CL binding = getPlatform().getCLBinding(); 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 3a48f0b7..fc2419c7 100644 --- a/src/com/jogamp/opencl/CLVersion.java +++ b/src/com/jogamp/opencl/CLVersion.java @@ -45,6 +45,9 @@ public class CLVersion implements Comparable<CLVersion> { public final static CLVersion CL_1_0 = new CLVersion("OpenCL 1.0"); public final static CLVersion CL_1_1 = new CLVersion("OpenCL 1.1"); + public final static CLVersion CL_1_2 = new CLVersion("OpenCL 1.2"); + public final static CLVersion CL_2_0 = new CLVersion("OpenCL 2.0"); + public final static CLVersion CL_2_1 = new CLVersion("OpenCL 2.1"); /** * The full version String is defined as: diff --git a/src/com/jogamp/opencl/gl/CLGLBuffer.java b/src/com/jogamp/opencl/gl/CLGLBuffer.java index 59aacd9f..660f243f 100644 --- a/src/com/jogamp/opencl/gl/CLGLBuffer.java +++ b/src/com/jogamp/opencl/gl/CLGLBuffer.java @@ -32,10 +32,10 @@ import com.jogamp.opencl.CLBuffer; import com.jogamp.opencl.CLCommandQueue; import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLException; -import com.jogamp.opencl.llb.gl.CLGL; +import com.jogamp.opencl.llb.CL; import java.nio.Buffer; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GLContext; /** @@ -59,10 +59,9 @@ public final class CLGLBuffer<B extends Buffer> extends CLBuffer<B> implements C 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); - final CLGL clgli = (CLGL)getCL(context); - + final CL cl = getCL(context); final int[] result = new int[1]; - final long id = clgli.clCreateFromGLBuffer(context.ID, flags, glBuffer, result, 0); + final long id = cl.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); diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java index 2564a82d..44f349cd 100644 --- a/src/com/jogamp/opencl/gl/CLGLContext.java +++ b/src/com/jogamp/opencl/gl/CLGLContext.java @@ -30,7 +30,7 @@ package com.jogamp.opencl.gl; import java.nio.Buffer; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GLContext; import jogamp.opengl.GLContextImpl; import jogamp.opengl.egl.EGLContext; @@ -45,8 +45,6 @@ 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; /** * OpenCL Context supporting JOGL-JOCL interoperablity. @@ -165,9 +163,9 @@ public final class CLGLContext extends CLContext { // create the OpenGL context." properties = PointerBuffer.allocateDirect(7); final long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); - properties.put(CLGL.CL_GL_CONTEXT_KHR).put(glID[0]) + properties.put(CL.CL_GL_CONTEXT_KHR).put(glID[0]) .put(CL.CL_GLX_DISPLAY_KHR).put(displayHandle) - .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CL.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 @@ -175,9 +173,9 @@ public final class CLGLContext extends CLContext { // HDC handle of the display used to create the OpenGL context." properties = PointerBuffer.allocateDirect(7); final long surfaceHandle = ctxImpl.getDrawableImpl().getNativeSurface().getSurfaceHandle(); - properties.put(CLGL.CL_GL_CONTEXT_KHR).put(glID[0]) + properties.put(CL.CL_GL_CONTEXT_KHR).put(glID[0]) .put(CL.CL_WGL_HDC_KHR).put(surfaceHandle) - .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CL.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 @@ -192,8 +190,8 @@ public final class CLGLContext extends CLContext { 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(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); + properties.put(CL.CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE).put(group) + .put(CL.CL_CONTEXT_PLATFORM).put(platform.ID); }else if(glContext instanceof EGLContext) { // TODO test EGL // spec: "When the EGL binding API is supported, the attribute @@ -203,9 +201,9 @@ public final class CLGLContext extends CLContext { // display used to create the OpenGL ES or OpenGL context." properties = PointerBuffer.allocateDirect(7); final long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); - properties.put(CLGL.CL_GL_CONTEXT_KHR).put(glID[0]) + properties.put(CL.CL_GL_CONTEXT_KHR).put(glID[0]) .put(CL.CL_EGL_DISPLAY_KHR).put(displayHandle) - .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CL.CL_CONTEXT_PLATFORM).put(platform.ID); }else{ throw new RuntimeException("unsupported GLContext: "+glContext); } @@ -319,8 +317,8 @@ public final class CLGLContext extends CLContext { * Return the low level OpenCL interface with OpenGL interoperability. */ @Override - public CLGL getCL() { - return (CLGL)super.getCL(); + public CL getCL() { + return super.getCL(); } /** diff --git a/src/com/jogamp/opencl/gl/CLGLImage2d.java b/src/com/jogamp/opencl/gl/CLGLImage2d.java index 19cd51bf..2422af93 100644 --- a/src/com/jogamp/opencl/gl/CLGLImage2d.java +++ b/src/com/jogamp/opencl/gl/CLGLImage2d.java @@ -29,8 +29,6 @@ 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; import com.jogamp.opencl.CLImage2d; @@ -39,7 +37,7 @@ import com.jogamp.opencl.llb.impl.CLImageFormatImpl; import java.nio.Buffer; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GLContext; /** * 2D OpenCL image representing an OpenGL renderbuffer. @@ -63,9 +61,8 @@ public class CLGLImage2d<B extends Buffer> extends CLImage2d<B> implements CLGLO final CL cl = getCL(context); final int[] result = new int[1]; - final CLGL clgli = (CLGL)cl; - final long id = clgli.clCreateFromGLRenderbuffer(context.ID, flags, renderbuffer, result, 0); + final long id = cl.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); @@ -75,10 +72,10 @@ public class CLGLImage2d<B extends Buffer> extends CLImage2d<B> implements CLGLO final CLImageInfoAccessor accessor = new CLImageInfoAccessor(getCL(context), id); final CLImageFormat format = createUninitializedImageFormat(); - accessor.getInfo(CLImageBinding.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); + accessor.getInfo(CL.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); - final int width = (int)accessor.getLong(CLImageBinding.CL_IMAGE_WIDTH); - final int height = (int)accessor.getLong(CLImageBinding.CL_IMAGE_HEIGHT); + final int width = (int)accessor.getLong(CL.CL_IMAGE_WIDTH); + final int height = (int)accessor.getLong(CL.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 6e86a810..0898cbc1 100644 --- a/src/com/jogamp/opencl/gl/CLGLObject.java +++ b/src/com/jogamp/opencl/gl/CLGLObject.java @@ -32,7 +32,7 @@ package com.jogamp.opencl.gl; import com.jogamp.opencl.CLMemory.GLObjectType; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GLContext; /** * diff --git a/src/com/jogamp/opencl/gl/CLGLTexture2d.java b/src/com/jogamp/opencl/gl/CLGLTexture2d.java index 30b8164e..7cc591fa 100644 --- a/src/com/jogamp/opencl/gl/CLGLTexture2d.java +++ b/src/com/jogamp/opencl/gl/CLGLTexture2d.java @@ -29,12 +29,10 @@ 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; import com.jogamp.opencl.llb.impl.CLImageFormatImpl; -import com.jogamp.opencl.llb.gl.CLGL; import java.nio.Buffer; @@ -60,18 +58,17 @@ public class CLGLTexture2d<B extends Buffer> extends CLGLImage2d<B> implements C final CL cl = getCL(context); final int[] result = new int[1]; - final CLGL clgli = (CLGL)cl; - final long id = clgli.clCreateFromGLTexture2D(context.ID, flags, target, mipLevel, texture, result, 0); + final long id = cl.clCreateFromGLTexture2D(context.ID, flags, target, mipLevel, texture, result, 0); CLException.checkForError(result[0], "can not create CLGLTexture2d from texture #"+texture+"."); final CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id); final CLImageFormat format = createUninitializedImageFormat(); - accessor.getInfo(CLImageBinding.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); + accessor.getInfo(CL.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); - final int width = (int)accessor.getLong(CLImageBinding.CL_IMAGE_WIDTH); - final int height = (int)accessor.getLong(CLImageBinding.CL_IMAGE_HEIGHT); + final int width = (int)accessor.getLong(CL.CL_IMAGE_WIDTH); + final int height = (int)accessor.getLong(CL.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 6d832479..d61c4553 100644 --- a/src/com/jogamp/opencl/gl/CLGLTexture3d.java +++ b/src/com/jogamp/opencl/gl/CLGLTexture3d.java @@ -28,9 +28,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; @@ -39,7 +37,7 @@ import com.jogamp.opencl.llb.impl.CLImageFormatImpl; import java.nio.Buffer; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GLContext; /** * 3D OpenCL image representing an 3D OpenGL texture. @@ -69,19 +67,18 @@ public class CLGLTexture3d<B extends Buffer> extends CLImage3d<B> implements CLG final CL cl = getCL(context); final int[] result = new int[1]; - final CLGL clgli = (CLGL)cl; - final long id = clgli.clCreateFromGLTexture3D(context.ID, flags, target, mipLevel, texture, result, 0); + final long id = cl.clCreateFromGLTexture3D(context.ID, flags, target, mipLevel, texture, result, 0); CLException.checkForError(result[0], "can not create CLGLTexture3d from texture #"+texture+"."); final CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id); final CLImageFormat format = createUninitializedImageFormat(); - accessor.getInfo(CLImageBinding.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); + accessor.getInfo(CL.CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); - 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); + final int width = (int)accessor.getLong(CL.CL_IMAGE_WIDTH); + final int height = (int)accessor.getLong(CL.CL_IMAGE_HEIGHT); + final int depth = (int)accessor.getLong(CL.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 8422c4ad..7195d592 100644 --- a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java +++ b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java @@ -35,7 +35,6 @@ package com.jogamp.opencl.impl; import java.nio.IntBuffer; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.llb.CL; -import com.jogamp.opencl.llb.CLDeviceBinding; import com.jogamp.opencl.spi.CLAccessorFactory; import com.jogamp.opencl.spi.CLInfoAccessor; import com.jogamp.opencl.spi.CLPlatformInfoAccessor; @@ -50,7 +49,7 @@ import static com.jogamp.opencl.CLException.*; public class CLTLAccessorFactory implements CLAccessorFactory { @Override - public CLInfoAccessor createDeviceInfoAccessor(final CLDeviceBinding cl, final long id) { + public CLInfoAccessor createDeviceInfoAccessor(final CL cl, final long id) { return new CLDeviceInfoAccessor(cl, id); } @@ -61,10 +60,10 @@ public class CLTLAccessorFactory implements CLAccessorFactory { private final static class CLDeviceInfoAccessor extends CLTLInfoAccessor { - private final CLDeviceBinding cl; + private final CL cl; private final long ID; - private CLDeviceInfoAccessor(final CLDeviceBinding cl, final long id) { + private CLDeviceInfoAccessor(final CL cl, final long id) { this.cl = cl; this.ID = id; } @@ -99,7 +98,7 @@ public class CLTLAccessorFactory implements CLAccessorFactory { final int count = buffer.get(0); // return an empty buffer rather than throwing an exception - if(ret == CLDeviceBinding.CL_DEVICE_NOT_FOUND || count == 0) { + if(ret == CL.CL_DEVICE_NOT_FOUND || count == 0) { return new long[0]; }else{ checkForError(ret, "error while enumerating devices"); diff --git a/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java b/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java index 59bb0723..b48cb47c 100644 --- a/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java +++ b/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java @@ -96,6 +96,16 @@ public final class CLDynamicLibraryBundleInfo implements DynamicLibraryBundleInf } @Override + public final boolean searchToolLibInSystemPath() { + return true; + } + + @Override + public final boolean searchToolLibSystemPathFirst() { + return true; + } + + @Override public final List<List<String>> getToolLibNames() { final List<List<String>> libNamesList = new ArrayList<List<String>>(); @@ -143,7 +153,7 @@ public final class CLDynamicLibraryBundleInfo implements DynamicLibraryBundleInf funcName = funcName.substring(0, funcName.length() - Impl_len); } if( funcName.endsWith("KHR") || funcName.endsWith("EXT") ) { - return CLAbstractImpl.clGetExtensionFunctionAddress(toolGetProcAddressHandle, funcName); + return CLImpl11.clGetExtensionFunctionAddress(toolGetProcAddressHandle, funcName); } return 0; // on libs .. } diff --git a/src/com/jogamp/opencl/llb/impl/CLImpl.java b/src/com/jogamp/opencl/llb/impl/CLImpl.java deleted file mode 100644 index 6eb9cde5..00000000 --- a/src/com/jogamp/opencl/llb/impl/CLImpl.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) 2009 JogAmp Community. All rights reserved. - * - * 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 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * 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. - */ - -/* - * Created on Monday, June 07 2010 at 04:25 - */ -package com.jogamp.opencl.llb.impl; - -import com.jogamp.common.nio.PointerBuffer; -import com.jogamp.common.util.LongLongHashMap; -import com.jogamp.opencl.CLErrorHandler; -import com.jogamp.opencl.CLException; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; - -import static com.jogamp.common.nio.Buffers.*; - -/** - * Java bindings to OpenCL, the Open Computing Language. - * @author Michael Bien, et al. - */ -public class CLImpl extends CLAbstractImpl { - - //maps the context id to its error handler's global object pointer - private final LongLongHashMap contextCallbackMap; - - public CLImpl() { - super(); - this.contextCallbackMap = new LongLongHashMap(); - this.contextCallbackMap.setKeyNotFoundValue(0); - } - - @Override - 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"); - } - - if (errcode_ret != null && !errcode_ret.isDirect()) { - throw new RuntimeException("Argument \"errcode_ret\" was not a direct buffer"); - } - - final long address = addressTable._addressof_clCreateContext; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - - 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); - - if (pfn_notify != null && global[0] != 0) { - synchronized (contextCallbackMap) { - contextCallbackMap.put(ctx, global[0]); - } - } - return ctx; - } - - 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(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"); - } - - if (errcode_ret != null && !errcode_ret.isDirect()) { - throw new RuntimeException("Argument \"errcode_ret\" was not a direct buffer"); - } - - final long address = addressTable._addressof_clCreateContextFromType; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - - 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); - - if (pfn_notify != null && global[0] != 0) { - synchronized (contextCallbackMap) { - contextCallbackMap.put(ctx, global[0]); - } - } - return ctx; - } - - 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(final long context) { - long global = 0; - synchronized (contextCallbackMap) { - global = contextCallbackMap.remove(context); - } - - final long address = addressTable._addressof_clReleaseContext; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - return clReleaseContextImpl(context, global, address); - } - - /** Interface to C language function: <br> <code> int32_t {@native clReleaseContext}(cl_context context); </code> */ - public native int clReleaseContextImpl(long context, long global, long address); - - /** 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(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"); - } - - final long address = addressTable._addressof_clBuildProgram; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - return clBuildProgram0(program, deviceCount, deviceList != null ? deviceList.getBuffer() : null, - getDirectBufferByteOffset(deviceList), options, cb, address); - } - - /** Entry point to C language function: <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); </code> */ - private native int clBuildProgram0(long program, int deviceCount, Object deviceList, int deviceListOffset, String options, BuildProgramCallback cb, long address); - - - @Override - 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"); - } - return clSetEventCallback0(event, trigger, callback, address); - } - - private native int clSetEventCallback0(long event, int type, CLEventCallback cb, long address); - - - @Override - public int clSetMemObjectDestructorCallback(final long memObjID, final CLMemObjectDestructorCallback cb) { - final long address = addressTable._addressof_clSetMemObjectDestructorCallback; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - return clSetMemObjectDestructorCallback0(memObjID, cb, address); - } - - private native int clSetMemObjectDestructorCallback0(long memObjID, CLMemObjectDestructorCallback cb, long address); - - - /** Interface to C language function: <br> <code> void * {@native clEnqueueMapImage}(cl_command_queue command_queue, cl_mem image, uint32_t blocking_map, uint64_t map_flags, const size_t * , const size_t * , size_t * image_row_pitch, size_t * image_slice_pitch, uint32_t num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, int32_t * errcode_ret); </code> - @param origin a direct {@link com.jogamp.common.nio.PointerBuffer} - @param range a direct {@link com.jogamp.common.nio.PointerBuffer} - @param image_row_pitch a direct {@link com.jogamp.common.nio.PointerBuffer} - @param image_slice_pitch a direct {@link com.jogamp.common.nio.PointerBuffer} - @param event_wait_list a direct {@link com.jogamp.common.nio.PointerBuffer} - @param event a direct {@link com.jogamp.common.nio.PointerBuffer} - @param errcode_ret a direct {@link java.nio.IntBuffer} */ - @Override - 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"); - } - if (range != null && !range.isDirect()) { - throw new CLException("Argument \"range\" was not a direct buffer"); - } - if (image_row_pitch != null && !image_row_pitch.isDirect()) { - throw new CLException("Argument \"image_row_pitch\" was not a direct buffer"); - } - if (image_slice_pitch != null && !image_slice_pitch.isDirect()) { - throw new CLException("Argument \"image_slice_pitch\" was not a direct buffer"); - } - if (event_wait_list != null && !event_wait_list.isDirect()) { - throw new CLException("Argument \"event_wait_list\" was not a direct buffer"); - } - if (event != null && !event.isDirect()) { - throw new CLException("Argument \"event\" was not a direct buffer"); - } - if (errcode_ret != null && !errcode_ret.isDirect()) { - throw new CLException("Argument \"errcode_ret\" was not a direct buffer"); - } - - final long getImageInfoAddress = addressTable._addressof_clGetImageInfo; - if (getImageInfoAddress == 0) { - throw new UnsupportedOperationException("Method not available"); - } - final long mapImageAddress = addressTable._addressof_clEnqueueMapImage; - if (mapImageAddress == 0) { - throw new UnsupportedOperationException("Method not available"); - } - ByteBuffer _res; - _res = clEnqueueMapImage0(command_queue, image, blocking_map, map_flags, origin != null ? origin.getBuffer() : null, - getDirectBufferByteOffset(origin), range != null ? range.getBuffer() : null, - getDirectBufferByteOffset(range), image_row_pitch != null ? image_row_pitch.getBuffer() : null, - getDirectBufferByteOffset(image_row_pitch), image_slice_pitch != null ? image_slice_pitch.getBuffer() : null, - getDirectBufferByteOffset(image_slice_pitch), num_events_in_wait_list, - event_wait_list != null ? event_wait_list.getBuffer() : null, getDirectBufferByteOffset(event_wait_list), - event != null ? event.getBuffer() : null, getDirectBufferByteOffset(event), errcode_ret, - getDirectBufferByteOffset(errcode_ret), getImageInfoAddress, mapImageAddress); - if (_res == null) { - return null; - } - nativeOrder(_res); - return _res; - } - - /** Entry point to C language function: <code> void * {@native clEnqueueMapImage}(cl_command_queue command_queue, cl_mem image, uint32_t blocking_map, uint64_t map_flags, const size_t * , const size_t * , size_t * image_row_pitch, size_t * image_slice_pitch, uint32_t num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, int32_t * errcode_ret); </code> - @param origin a direct {@link com.jogamp.common.nio.PointerBuffer} - @param range a direct {@link com.jogamp.common.nio.PointerBuffer} - @param image_row_pitch a direct {@link com.jogamp.common.nio.PointerBuffer} - @param image_slice_pitch a direct {@link com.jogamp.common.nio.PointerBuffer} - @param event_wait_list a direct {@link com.jogamp.common.nio.PointerBuffer} - @param event a direct {@link com.jogamp.common.nio.PointerBuffer} - @param errcode_ret a direct {@link java.nio.IntBuffer} */ - private native ByteBuffer clEnqueueMapImage0(long command_queue, long image, int blocking_map, long map_flags, - Object origin, int origin_byte_offset, Object range, int range_byte_offset, Object image_row_pitch, - int image_row_pitch_byte_offset, Object image_slice_pitch, int image_slice_pitch_byte_offset, - int num_events_in_wait_list, Object event_wait_list, int event_wait_list_byte_offset, Object event, - int event_byte_offset, Object errcode_ret, int errcode_ret_byte_offset, - long getImageInfoAddress, long mapImageAddress); - - public CLProcAddressTable getAddressTable() { - return addressTable; - } - - /* - private static void convert32To64(long[] values) { - if (values.length % 2 == 1) { - values[values.length - 1] = values[values.length / 2] >>> 32; - } - for (int i = values.length - 1 - values.length % 2; i >= 0; i -= 2) { - long temp = values[i / 2]; - values[i - 1] = temp >>> 32; - values[i] = temp & 0x00000000FFFFFFFFL; - } - } - */ - - - -} diff --git a/src/com/jogamp/opencl/spi/CLAccessorFactory.java b/src/com/jogamp/opencl/spi/CLAccessorFactory.java index 4bafe933..752891b4 100644 --- a/src/com/jogamp/opencl/spi/CLAccessorFactory.java +++ b/src/com/jogamp/opencl/spi/CLAccessorFactory.java @@ -4,7 +4,6 @@ package com.jogamp.opencl.spi; import com.jogamp.opencl.llb.CL; -import com.jogamp.opencl.llb.CLDeviceBinding; /** * Implementations of this interface are factories responsible for creating CLAccessors. @@ -12,7 +11,7 @@ import com.jogamp.opencl.llb.CLDeviceBinding; */ public interface CLAccessorFactory { - CLInfoAccessor createDeviceInfoAccessor(CLDeviceBinding cl, long id); + CLInfoAccessor createDeviceInfoAccessor(CL cl, long id); CLPlatformInfoAccessor createPlatformInfoAccessor(CL cl, long id); diff --git a/src/com/jogamp/opencl/util/CLInfo.java b/src/com/jogamp/opencl/util/CLInfo.java index 2dfbb5e9..cd97d6e2 100644 --- a/src/com/jogamp/opencl/util/CLInfo.java +++ b/src/com/jogamp/opencl/util/CLInfo.java @@ -34,7 +34,7 @@ package com.jogamp.opencl.util; import com.jogamp.common.os.Platform; import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLPlatform; -import com.jogamp.opencl.llb.impl.CLImpl; +import com.jogamp.opencl.llb.impl.CLImpl11; import java.util.Map; @@ -58,7 +58,7 @@ public class CLInfo { // binding sb.append("CL_BINDING_UNAVAILABLE_FUNCTIONS: "); - sb.append(((CLImpl) CLPlatform.getLowLevelCLInterface()).getAddressTable().getNullPointerFunctions()); + sb.append(CLImpl11.getAddressTable().getNullPointerFunctions()); sb.append("\n"); // OpenCL diff --git a/src/com/jogamp/opencl/util/CLPlatformFilters.java b/src/com/jogamp/opencl/util/CLPlatformFilters.java index 8c22306a..46a7295b 100644 --- a/src/com/jogamp/opencl/util/CLPlatformFilters.java +++ b/src/com/jogamp/opencl/util/CLPlatformFilters.java @@ -33,8 +33,8 @@ import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLPlatform; import com.jogamp.opencl.CLVersion; import java.util.Arrays; -import javax.media.opengl.GL; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLContext; /** * Pre-defined filters. diff --git a/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java b/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java index dcd052cf..aa031d2b 100644 --- a/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java +++ b/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java @@ -3,6 +3,7 @@ */ package com.jogamp.opencl.util.concurrent; +import com.jogamp.common.util.InterruptSource; import com.jogamp.opencl.CLCommandQueue; import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLResource; @@ -235,7 +236,7 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource } - private static class QueueThread extends Thread { + private static class QueueThread extends InterruptSource.Thread { private final CLQueueContext context; public QueueThread(final ThreadGroup group, final Runnable runnable, final CLQueueContext context, final int index) { super(group, runnable, "queue-worker-thread-"+index+"["+context+"]"); |