public class CLContext extends CLObject
Must be released if no longer used to free native resources. release()
will
also free all associated CLResource
like programs, samplers, command queues and memory
objects.
For a code example see CLPlatform
.
Modifier and Type | Class and Description |
---|---|
protected static class |
CLContext.ErrorDispatcher |
Modifier and Type | Field and Description |
---|---|
protected CLDevice[] |
devices |
protected Set<CLMemory<? extends Buffer>> |
memoryObjects |
protected CLPlatform |
platform |
protected Set<CLProgram> |
programs |
protected Map<CLDevice,List<CLCommandQueue>> |
queuesMap |
protected Set<CLSampler> |
samplers |
Modifier | Constructor and Description |
---|---|
protected |
CLContext(CLPlatform platform,
long contextID,
CLContext.ErrorDispatcher dispatcher) |
Modifier and Type | Method and Description |
---|---|
void |
addCLErrorHandler(CLErrorHandler handler) |
void |
close()
Deprecated.
This method is not intended to be called from client code.
|
static CLContext |
create()
Creates a context on all available devices (CL_DEVICE_TYPE_ALL).
|
static CLContext |
create(CLDevice... devices)
Creates a context on the specified devices.
|
static CLContext |
create(CLDevice.Type... deviceTypes)
Creates a context on the specified device types.
|
static CLContext |
create(CLPlatform platform)
Creates a context on the specified platform on all available devices (CL_DEVICE_TYPE_ALL).
|
static CLContext |
create(CLPlatform platform,
CLDevice.Type... deviceTypes)
Creates a context on the specified platform and with the specified
device types.
|
<B extends Buffer> |
createBuffer(B directBuffer,
CLMemory.Mem... flags)
Creates a CLBuffer with the specified flags.
|
<B extends Buffer> |
createBuffer(B directBuffer,
int flags)
Creates a CLBuffer with the specified flags.
|
CLBuffer<?> |
createBuffer(int size,
CLMemory.Mem... flags)
Creates a CLBuffer with the specified flags.
|
CLBuffer<?> |
createBuffer(int size,
int flags)
Creates a CLBuffer with the specified flags.
|
CLBuffer<ByteBuffer> |
createByteBuffer(int size,
CLMemory.Mem... flags)
Creates a CLBuffer with the specified flags and buffer size in bytes.
|
CLBuffer<ByteBuffer> |
createByteBuffer(int size,
int flags)
Creates a CLBuffer with the specified flags and buffer size in bytes.
|
protected static long |
createContext(CLPlatform platform,
CLErrorHandler handler,
PointerBuffer properties,
CLDevice... devices) |
protected static long |
createContextFromType(CLPlatform platform,
CLErrorHandler handler,
PointerBuffer properties,
long deviceType) |
CLBuffer<DoubleBuffer> |
createDoubleBuffer(int size,
CLMemory.Mem... flags)
Creates a CLBuffer with the specified flags and element count.
|
protected static CLContext.ErrorDispatcher |
createErrorHandler() |
CLBuffer<FloatBuffer> |
createFloatBuffer(int size,
CLMemory.Mem... flags)
Creates a CLBuffer with the specified flags and element count.
|
<B extends Buffer> |
createImage2d(B directBuffer,
int width,
int height,
CLImageFormat format,
CLMemory.Mem... flags)
Creates a CLImage2d with the specified format, dimension and flags.
|
<B extends Buffer> |
createImage2d(B directBuffer,
int width,
int height,
int rowPitch,
CLImageFormat format,
CLMemory.Mem... flags)
Creates a CLImage2d with the specified format, dimension and flags.
|
CLImage2d<?> |
createImage2d(int width,
int height,
CLImageFormat format,
CLMemory.Mem... flags)
Creates a CLImage2d with the specified format, dimension and flags.
|
CLImage2d<?> |
createImage2d(int width,
int height,
int rowPitch,
CLImageFormat format,
CLMemory.Mem... flags)
Creates a CLImage2d with the specified format, dimension and flags.
|
<B extends Buffer> |
createImage3d(B directBuffer,
int width,
int height,
int depth,
CLImageFormat format,
CLMemory.Mem... flags)
Creates a CLImage3d with the specified format, dimension and flags.
|
<B extends Buffer> |
createImage3d(B directBuffer,
int width,
int height,
int depth,
int rowPitch,
int slicePitch,
CLImageFormat format,
CLMemory.Mem... flags)
Creates a CLImage3d with the specified format, dimension and flags.
|
CLImage3d<?> |
createImage3d(int width,
int height,
int depth,
CLImageFormat format,
CLMemory.Mem... flags)
Creates a CLImage3d with the specified format, dimension and flags.
|
CLImage3d<?> |
createImage3d(int width,
int height,
int depth,
int rowPitch,
int slicePitch,
CLImageFormat format,
CLMemory.Mem... flags)
Creates a CLImage3d with the specified format, dimension and flags.
|
CLBuffer<IntBuffer> |
createIntBuffer(int size,
CLMemory.Mem... flags)
Creates a CLBuffer with the specified flags and element count.
|
CLBuffer<LongBuffer> |
createLongBuffer(int size,
CLMemory.Mem... flags)
Creates a CLBuffer with the specified flags and element count.
|
CLProgram |
createProgram(InputStream source)
Creates a program and reads the source from stream, the returned program is not build yet.
|
CLProgram |
createProgram(Map<CLDevice,byte[]> binaries)
Creates a program from the given binaries, the program is not build yet.
|
CLProgram |
createProgram(String src)
Creates a program from the given sources, the returned program is not build yet.
|
CLSampler |
createSampler(CLSampler.AddressingMode addrMode,
CLSampler.FilteringMode filtMode,
boolean normalizedCoords) |
CLBuffer<ShortBuffer> |
createShortBuffer(int size,
CLMemory.Mem... flags)
Creates a CLBuffer with the specified flags and element count.
|
boolean |
equals(Object obj) |
CL |
getCL()
Return the low level OpenCL interface.
|
CLContext |
getContext()
Returns the context for this OpenCL object.
|
CLDevice[] |
getDevices()
Returns all devices associated with this CLContext.
|
CLDevice |
getMaxFlopsDevice()
Returns the device with maximal FLOPS from this context.
|
CLDevice |
getMaxFlopsDevice(CLDevice.Type type)
Returns the device with maximal FLOPS of the specified device type from this context.
|
long |
getMaxMemBaseAddrAlign()
Returns the maximum
CLDevice.getMemBaseAddrAlign() of all devices. |
List<CLMemory<? extends Buffer>> |
getMemoryObjects()
Returns a read only shapshot of all allocated memory objects associated with this context.
|
CLPlatform |
getPlatform()
Returns the CLPlatform this context is running on.
|
List<CLProgram> |
getPrograms()
Returns a read only shapshot of all programs associated with this context.
|
List<CLSampler> |
getSamplers()
Returns a read only shapshot of all samplers associated with this context.
|
CLImageFormat[] |
getSupportedImage2dFormats(CLMemory.Mem... flags)
Returns all supported 2d image formats with the (optional) memory allocation flags.
|
CLImageFormat[] |
getSupportedImage3dFormats(CLMemory.Mem... flags)
Returns all supported 3d image formats with the (optional) memory allocation flags.
|
int |
hashCode() |
boolean |
isReleased()
Returns true if
CLResource.release() has been called. |
protected void |
overrideContext(CLDevice device) |
void |
release()
Releases this context and all resources.
|
void |
removeCLErrorHandler(CLErrorHandler handler) |
protected static long |
toDeviceBitmap(CLDevice.Type[] deviceTypes) |
String |
toString() |
protected CLDevice[] devices
protected final Map<CLDevice,List<CLCommandQueue>> queuesMap
protected final CLPlatform platform
protected CLContext(CLPlatform platform, long contextID, CLContext.ErrorDispatcher dispatcher)
public static CLContext create()
public static CLContext create(CLDevice.Type... deviceTypes)
public static CLContext create(CLPlatform platform)
public static CLContext create(CLPlatform platform, CLDevice.Type... deviceTypes)
public static CLContext create(CLDevice... devices)
protected static long createContextFromType(CLPlatform platform, CLErrorHandler handler, PointerBuffer properties, long deviceType)
protected static long createContext(CLPlatform platform, CLErrorHandler handler, PointerBuffer properties, CLDevice... devices)
public CLProgram createProgram(String src)
public CLProgram createProgram(InputStream source) throws IOException
IOException
- when a IOException occurred while reading or closing the stream.public CLProgram createProgram(Map<CLDevice,byte[]> binaries)
public final CLBuffer<ShortBuffer> createShortBuffer(int size, CLMemory.Mem... flags)
public final CLBuffer<IntBuffer> createIntBuffer(int size, CLMemory.Mem... flags)
public final CLBuffer<LongBuffer> createLongBuffer(int size, CLMemory.Mem... flags)
public final CLBuffer<FloatBuffer> createFloatBuffer(int size, CLMemory.Mem... flags)
public final CLBuffer<DoubleBuffer> createDoubleBuffer(int size, CLMemory.Mem... flags)
public final CLBuffer<ByteBuffer> createByteBuffer(int size, CLMemory.Mem... flags)
public final CLBuffer<ByteBuffer> createByteBuffer(int size, int flags)
public final CLBuffer<?> createBuffer(int size, CLMemory.Mem... flags)
public final CLBuffer<?> createBuffer(int size, int flags)
public final <B extends Buffer> CLBuffer<B> createBuffer(B directBuffer, CLMemory.Mem... flags)
public final <B extends Buffer> CLBuffer<B> createBuffer(B directBuffer, int flags)
public final CLImage2d<?> createImage2d(int width, int height, CLImageFormat format, CLMemory.Mem... flags)
public final CLImage2d<?> createImage2d(int width, int height, int rowPitch, CLImageFormat format, CLMemory.Mem... flags)
public final <B extends Buffer> CLImage2d<B> createImage2d(B directBuffer, int width, int height, CLImageFormat format, CLMemory.Mem... flags)
public final <B extends Buffer> CLImage2d<B> createImage2d(B directBuffer, int width, int height, int rowPitch, CLImageFormat format, CLMemory.Mem... flags)
public final CLImage3d<?> createImage3d(int width, int height, int depth, CLImageFormat format, CLMemory.Mem... flags)
public final CLImage3d<?> createImage3d(int width, int height, int depth, int rowPitch, int slicePitch, CLImageFormat format, CLMemory.Mem... flags)
public final <B extends Buffer> CLImage3d<B> createImage3d(B directBuffer, int width, int height, int depth, CLImageFormat format, CLMemory.Mem... flags)
public final <B extends Buffer> CLImage3d<B> createImage3d(B directBuffer, int width, int height, int depth, int rowPitch, int slicePitch, CLImageFormat format, CLMemory.Mem... flags)
public CLSampler createSampler(CLSampler.AddressingMode addrMode, CLSampler.FilteringMode filtMode, boolean normalizedCoords)
public void addCLErrorHandler(CLErrorHandler handler)
public void removeCLErrorHandler(CLErrorHandler handler)
public void release()
release
in interface CLResource
protected void overrideContext(CLDevice device)
public CLImageFormat[] getSupportedImage2dFormats(CLMemory.Mem... flags)
public CLImageFormat[] getSupportedImage3dFormats(CLMemory.Mem... flags)
public CLPlatform getPlatform()
getPlatform
in class CLObject
public CLContext getContext()
CLObject
getContext
in class CLObject
public List<CLProgram> getPrograms()
public List<CLMemory<? extends Buffer>> getMemoryObjects()
public List<CLSampler> getSamplers()
public CLDevice getMaxFlopsDevice()
public CLDevice getMaxFlopsDevice(CLDevice.Type type)
public long getMaxMemBaseAddrAlign()
CLDevice.getMemBaseAddrAlign()
of all devices.public CLDevice[] getDevices()
public CL getCL()
protected static long toDeviceBitmap(CLDevice.Type[] deviceTypes)
protected static CLContext.ErrorDispatcher createErrorHandler()
@Deprecated public final void close()
AutoCloseable
.
Might be remove as soon we have extension methods, but shall validate with Java 1.5 specs.close
in interface AutoCloseable
AutoCloseable
public boolean isReleased()
CLResource
CLResource.release()
has been called.isReleased
in interface CLResource