java.lang.Object
api.Native
au.notzed.zcl.CLObject
au.notzed.zcl.CLExtendable
au.notzed.zcl.CLContext
public class CLContext extends CLExtendable
Interface for cl_context
-
Field Summary
Fields inherited from class au.notzed.zcl.CLExtendable
platform
-
Constructor Summary
Constructors Constructor Description CLContext(jdk.incubator.foreign.MemoryAddress p)
-
Method Summary
Modifier and Type Method Description CLBuffer
createBuffer(long flags, byte[] hostp)
Calls clCreateBuffer with the array as the host pointer.CLBuffer
createBuffer(long flags, float[] hostp)
CLBuffer
createBuffer(long flags, long size)
Calls clCreateBuffer with an empty host pointer.CLBuffer
createBuffer(long flags, long size, java.nio.ByteBuffer hostp)
Calls clCreateBuffer.CLBuffer
createBuffer(long flags, long size, jdk.incubator.foreign.MemorySegment hostseg)
Calls clCreateBuffer.CLBuffer
createBuffer(long flags, java.nio.ByteBuffer hostp)
Call clCreateBuffer() with sized buffer.CLBuffer
createBuffer(long flags, jdk.incubator.foreign.MemorySegment hostp)
Call clCreateBuffer() with sized buffer.CLCommandQueue
createCommandQueue(CLDevice dev, long properties)
Calls clCreateCommandQueue.CLCommandQueue
createCommandQueue(CLDevice dev, CLQueueProperty[] properties)
Calls clCreateCommandQueueWithProperties.static CLContext
createContext(CLContextProperty[] properties, CLDevice[] devices)
static CLContext
createContext(CLContextProperty[] properties, CLDevice[] devices, CLContextNotify notify)
Calls clCreateContext.static CLContext
createContextFromType(CLContextProperty[] properties, long device_type, CLContextNotify notify)
Calls clCreateContextFromType.CLImage
createImage(long flags, CLImageFormat fmt, CLImageDesc desc)
CLImage
createImage(long flags, CLImageFormat fmt, CLImageDesc desc, byte[] hostp)
CLImage
createImage(long flags, CLImageFormat fmt, CLImageDesc desc, float[] hostp)
CLImage
createImage(long flags, CLImageFormat fmt, CLImageDesc desc, java.nio.ByteBuffer hostp)
CLImage
createImage(long flags, CLImageFormat fmt, CLImageDesc desc, jdk.incubator.foreign.MemorySegment hostseg)
Calls clCreateImage, or clCreateImageXD on OpenCL 1.1 or less.CLPipe
createPipe(long flags, int packetSize, int maxPackets, CLPipeProperty[] properties)
Calls clCreatePipeCLProgram
createProgramWithBinary(CLDevice[] devices, byte[][] binaries, int[] status)
Calls clCreateProgramWithBinary.CLProgram
createProgramWithBuiltInKernels(CLDevice[] devices, java.lang.String names)
Calls clCreateProgramWithBuiltInKernels.CLProgram
createProgramWithIL(byte[] il)
Calls clCreateProgramWithILCLProgram
createProgramWithSource(byte[]... strings)
Calls clCreateProgramWithSource.CLProgram
createProgramWithSource(java.io.InputStream is)
CLProgram
createProgramWithSource(java.lang.String... strings)
CLSampler
createSampler(boolean norm, int addr_mode, int filter_mode)
Calls clCreateSampler.CLSampler
createSampler(CLSamplerProperty[] props)
Calls clCreateSamplerWithPropertiesCLEvent
createUserEvent()
Calls clCreateUserEvent.CLDevice[]
getDevices()
gets CL_CONTEXT_DEVICES.int
getNumDevices()
gets CL_CONTEXT_NUM_DEVICES.CLContextProperty[]
getProperties()
gets CL_CONTEXT_PROPERTIESCLImageFormat[]
getSupportedImageFormats(long flags, int type)
Calls clGetSupportedImageFormats.protected CLPlatform
initPlatform()
Retrieve the platform.static CLContextProperty
INTEROP_USER_SYNC(boolean sync)
Creates a property representing CL_CONTEXT_INTEROP_USER_SYNC.CLProgram
linkProgram(CLDevice[] devices, java.lang.String options, CLProgram[] programs, CLNotify<CLProgram> notify)
Calls clLinkProgram.static CLContextProperty
PLATFORM(CLPlatform platform)
Creates a property representing CL_CONTEXT_PLATFORM.void
setDefaultDeviceCommandQueue(CLDevice dev, CLCommandQueue q)
java.nio.ByteBuffer
SVMAlloc(long flags, long size, int alignment)
Allocate shared virtual memory.void
SVMFree(java.nio.ByteBuffer mem)
Free memory allocated by SVMAlloc.java.lang.String
toString()
Methods inherited from class au.notzed.zcl.CLExtendable
getAPIVersion, getExtension, getPlatform, haveAPIVersion, requireAPIVersion
Methods inherited from class au.notzed.zcl.CLObject
getInfo, getInfo, getInfo, getInfoAny, getInfoAny, getInfoAny, getInfoAny, getInfoAnyV, getInfoByteV, getInfoByteV, getInfoInt, getInfoInt, getInfoInt, getInfoInt, getInfoJava, getInfoLong, getInfoLong, getInfoLong, getInfoLong, getInfoLongV, getInfoLongV, getInfoPropertyV, getInfoSizeT, getInfoSizeT, getInfoSizeT, getInfoSizeTA, getInfoString, getInfoString, getInfoString, getInfoString, release, release
Methods inherited from class api.Native
addr, addr, addr, debugDumpReachable, debugFlushAll, downcallHandle, downcallHandle, dumpSignature, freeUpcallStub, getAddr, getAddr, getByte, getByte, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, loadLibraries, parseStruct, parseUnion, release, release, release, resolve, setAddr, setAddr, setByte, setByte, setDouble, setDouble, setFloat, setFloat, setInt, setInt, setLong, setLong, setShort, setShort, toAddrV, toAddrV, toAddrV, toByteV, toByteV, toLongV, toLongV, toObjectV, toObjectV, toString, upcallStub
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
CLContext
public CLContext(jdk.incubator.foreign.MemoryAddress p)
-
-
Method Details
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
PLATFORM
Creates a property representing CL_CONTEXT_PLATFORM.- Parameters:
platform
- target value.- Returns:
- new property
-
INTEROP_USER_SYNC
Creates a property representing CL_CONTEXT_INTEROP_USER_SYNC.- Parameters:
sync
-- Returns:
- new property
-
createContext
public static CLContext createContext(CLContextProperty[] properties, CLDevice[] devices, CLContextNotify notify) throws CLRuntimeExceptionCalls clCreateContext.- Parameters:
properties
-devices
-notify
-- Returns:
- Newly allocated context.
release() should be called when it is no longer needed.
- Throws:
CLRuntimeException
-
createContext
public static CLContext createContext(CLContextProperty[] properties, CLDevice[] devices) throws CLRuntimeException- Throws:
CLRuntimeException
-
createContextFromType
public static CLContext createContextFromType(CLContextProperty[] properties, long device_type, CLContextNotify notify) throws CLRuntimeExceptionCalls clCreateContextFromType.- Parameters:
properties
-device_type
-notify
-- Returns:
- Newly allocated context.
release() should be called when it is no longer needed.
- Throws:
CLRuntimeException
-
createCommandQueue
Calls clCreateCommandQueue.- Parameters:
dev
-properties
-- Returns:
- Newly created command queue.
release() should be called when it is no longer needed.
- Throws:
CLRuntimeException
- deprecated as of OpenCL 2.0
-
createCommandQueue
public CLCommandQueue createCommandQueue(CLDevice dev, CLQueueProperty[] properties) throws CLRuntimeExceptionCalls clCreateCommandQueueWithProperties.- Parameters:
dev
-properties
-- Returns:
- Throws:
CLRuntimeException
- Since:
- OpenCL 2.0
-
setDefaultDeviceCommandQueue
- Parameters:
dev
-q
-- Throws:
CLException
- Since:
- OpenCL 2.1
-
createBuffer
Calls clCreateBuffer with an empty host pointer.- Parameters:
flags
- CL_MEM_* flags.size
- Size in bytes.- Throws:
CLRuntimeException
-
createBuffer
public CLBuffer createBuffer(long flags, long size, jdk.incubator.foreign.MemorySegment hostseg) throws CLRuntimeExceptionCalls clCreateBuffer. If flags contains CL_MEM_USE_HOST_PTR then hostp must not be null. Currently in this case the CLBuffer must be explicitly released() on the caller thread.- Parameters:
flags
- CL_MEM_* flags.size
- Size in bytes.hostseg
- Optional host memory pointer.- Returns:
- Newly allocated buffer.
- Throws:
CLRuntimeException
-
createBuffer
public CLBuffer createBuffer(long flags, long size, java.nio.ByteBuffer hostp) throws CLRuntimeExceptionCalls clCreateBuffer. If flags contains CL_MEM_USE_HOST_PTR then hostp must not be null. Currently the CLBuffer must be explicitly released() on the caller thread.- Parameters:
flags
- CL_MEM_* flags.size
- Size in bytes.hostp
- Optional host memory pointer.- Returns:
- Newly allocated buffer.
- Throws:
CLRuntimeException
-
createBuffer
public CLBuffer createBuffer(long flags, jdk.incubator.foreign.MemorySegment hostp) throws CLRuntimeExceptionCall clCreateBuffer() with sized buffer.- Parameters:
flags
-hostp
- must not be null.- Returns:
- Throws:
CLRuntimeException
-
createBuffer
Call clCreateBuffer() with sized buffer.- Parameters:
flags
-hostp
- must not be null. only capacity is honoured.- Returns:
- Throws:
CLRuntimeException
-
createBuffer
Calls clCreateBuffer with the array as the host pointer.- Parameters:
flags
- If CL_MEM_COPY_HOST_PTR is set and hostp is non-null then the array is copied to device memory. If CL_MEM_COPY_HOST_PTR is not set and hostp is non-null then the size is taken from the array.hostp
- an array. Not null.- Returns:
- Throws:
CLRuntimeException
- if the clCreateBuffer fails, or with CL_INVALID_VALUE if CL_MEM_USE_HOST_PTR is specified in flags.java.lang.NullPointerException
- if hostp is null.
-
createBuffer
- Throws:
CLRuntimeException
-
createImage
public CLImage createImage(long flags, CLImageFormat fmt, CLImageDesc desc) throws CLRuntimeException, java.lang.UnsupportedOperationException- Throws:
CLRuntimeException
java.lang.UnsupportedOperationException
-
createImage
public CLImage createImage(long flags, CLImageFormat fmt, CLImageDesc desc, jdk.incubator.foreign.MemorySegment hostseg) throws CLRuntimeException, java.lang.UnsupportedOperationExceptionCalls clCreateImage, or clCreateImageXD on OpenCL 1.1 or less.- Parameters:
flags
- CL_MEM_* flags.fmt
- Image format.desc
- Image descriptor. For OpenCL 1.2, only CL_MEM_OBJECT_IMAGE2D and CL_MEM_OBJECT_IMAGE3D are allowed.hostseg
-- Returns:
- Newly allocated image.
release() should be called when it is no longer needed.
- Throws:
CLRuntimeException
java.lang.UnsupportedOperationException
-
createImage
public CLImage createImage(long flags, CLImageFormat fmt, CLImageDesc desc, java.nio.ByteBuffer hostp) throws CLRuntimeException, java.lang.UnsupportedOperationException- Throws:
CLRuntimeException
java.lang.UnsupportedOperationException
-
createImage
public CLImage createImage(long flags, CLImageFormat fmt, CLImageDesc desc, byte[] hostp) throws CLRuntimeException, java.lang.UnsupportedOperationException- Throws:
CLRuntimeException
java.lang.UnsupportedOperationException
-
createImage
public CLImage createImage(long flags, CLImageFormat fmt, CLImageDesc desc, float[] hostp) throws CLRuntimeException, java.lang.UnsupportedOperationException- Throws:
CLRuntimeException
java.lang.UnsupportedOperationException
-
createPipe
public CLPipe createPipe(long flags, int packetSize, int maxPackets, CLPipeProperty[] properties) throws CLRuntimeException, java.lang.UnsupportedOperationExceptionCalls clCreatePipe- Parameters:
flags
-packetSize
-maxPackets
-properties
-- Returns:
- Throws:
CLRuntimeException
java.lang.UnsupportedOperationException
- Since:
- OpenCL 2.0
-
getSupportedImageFormats
Calls clGetSupportedImageFormats.- Parameters:
flags
-type
-- Returns:
- List of supported image formats.
- Throws:
CLRuntimeException
-
SVMAlloc
public java.nio.ByteBuffer SVMAlloc(long flags, long size, int alignment) throws CLRuntimeExceptionAllocate shared virtual memory.Memory must be explicity freed using CLContext.SVMFree.
- Parameters:
flags
-size
-alignment
-- Returns:
- Throws:
CLRuntimeException
- Since:
- OpenCL 2.0
-
SVMFree
Free memory allocated by SVMAlloc. It is up to the caller to ensure the memory is not in use.- Parameters:
mem
-- Throws:
CLRuntimeException
- Since:
- OpenCL 2.0
-
createSampler
public CLSampler createSampler(boolean norm, int addr_mode, int filter_mode) throws CLRuntimeExceptionCalls clCreateSampler.- Parameters:
norm
- Normalised coordinates.addr_mode
- CL_ADDRESS_filter_mode
- CL_FILTER_- Returns:
- Newly created sampler.
release() should be called when it is no longer needed.
- Throws:
CLRuntimeException
- xdeprecated as of OpenCL 2.0
-
createSampler
Calls clCreateSamplerWithProperties- Parameters:
props
- list of propertyes- Returns:
- Throws:
CLRuntimeException
- Since:
- OpenCL 2.0
-
createProgramWithSource
Calls clCreateProgramWithSource.- Parameters:
strings
- Source strings as byte array blocks.- Returns:
- Newly created program.
release() should be called when it is no longer needed or allow for GC cleanup.
- Throws:
CLException
-
createProgramWithSource
- Throws:
CLException
-
createProgramWithSource
- Throws:
CLException
-
createProgramWithIL
Calls clCreateProgramWithIL- Parameters:
il
-- Returns:
- Throws:
CLException
-
createProgramWithBinary
public CLProgram createProgramWithBinary(CLDevice[] devices, byte[][] binaries, int[] status) throws CLExceptionCalls clCreateProgramWithBinary.- Parameters:
devices
-binaries
-status
-- Returns:
- Newly created program.
release() should be called when it is no longer needed.
- Throws:
CLException
-
createProgramWithBuiltInKernels
public CLProgram createProgramWithBuiltInKernels(CLDevice[] devices, java.lang.String names) throws CLException, java.lang.UnsupportedOperationExceptionCalls clCreateProgramWithBuiltInKernels.- Parameters:
devices
-names
- semi-colon separated list of kernel names- Returns:
- Newly created program. release() should be called when it is no longer needed.
- Throws:
CLException
java.lang.UnsupportedOperationException
- Since:
- OpenCL 1.2
-
linkProgram
public CLProgram linkProgram(CLDevice[] devices, java.lang.String options, CLProgram[] programs, CLNotify<CLProgram> notify) throws CLException, java.lang.UnsupportedOperationExceptionCalls clLinkProgram.- Parameters:
devices
-options
-programs
-notify
-- Returns:
- Newly created program.
release() should be called when it is no longer needed.
- Throws:
CLException
java.lang.UnsupportedOperationException
- Since:
- OpenCL 1.2
-
createUserEvent
Calls clCreateUserEvent.- Returns:
- Newly created user event.
release() should be called when it is no longer needed.
- Throws:
CLRuntimeException
CLException
- Since:
- OpenCL 1.1
-
getNumDevices
public int getNumDevices()gets CL_CONTEXT_NUM_DEVICES.- Returns:
- Number of devices.
-
getDevices
gets CL_CONTEXT_DEVICES.- Returns:
- List of devices.
-
getProperties
gets CL_CONTEXT_PROPERTIES- Returns:
- List of properties used at create time.
-
initPlatform
Description copied from class:CLExtendable
Retrieve the platform. This should not cache the lookup. It cannot return null by definition. This should not be called by any implementing class.- Specified by:
initPlatform
in classCLExtendable
- Returns:
-