Package net.haesleinhuepf.clij.clearcl
Class ClearCLContext
- java.lang.Object
-
- net.haesleinhuepf.clij.clearcl.ClearCLContext
-
- All Implemented Interfaces:
Closeable,AutoCloseable,net.haesleinhuepf.clij.coremem.rgc.Cleanable
public class ClearCLContext extends Object implements net.haesleinhuepf.clij.coremem.rgc.Cleanable, Closeable
ClearCLContext is the ClearCL abstraction for OpenCl contexts.- Author:
- royer
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()ClearCLBuffercreateBuffer(HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeType, long pBufferLengthInElements)Creates an OpenCL buffer with a given access policy, data type and length.ClearCLBuffercreateBuffer(MemAllocMode pMemAllocMode, HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, long pNumberOfChannels, net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeType, long... pDimensions)Creates an OpenCL buffer with a given data type, memory allocation mode and access policy, memory allocation mode, native type, and dimensions.ClearCLBuffercreateBuffer(MemAllocMode pMemAllocMode, HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, ClearCLImage pTemplate)Creates an OpenCL buffer with a given memory allocation mode, host and kernel access and a template image to match for dimensions, data type and number of channels.ClearCLBuffercreateBuffer(MemAllocMode pMemAllocMode, HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeType, long pBufferLengthInElements)Creates an OpenCL buffer with a given data type, access policy, memory allocation mode, native type, and length.ClearCLBuffercreateBuffer(MemAllocMode pMemAllocMode, net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeType, long pBufferLengthInElements)Creates an OpenCL buffer with a given access policy, data type, memory allocation mode and length.ClearCLBuffercreateBuffer(net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeType, long pBufferLengthInElements)Creates an OpenCL buffer with a given data type and length.ClearCLImagecreateImage(ClearCLImage pImage)Creates an image with same parameters as the given image,ClearCLImagecreateImage(ClearCLImage pImage, ImageChannelDataType pChannelDataType)Creates an image with same parameters as the given image,ClearCLImagecreateImage(HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, ImageChannelOrder pImageChannelOrder, ImageChannelDataType pImageChannelType, long... pDimensions)Creates 1D, 2D, or 3D image with a given memory allocation and access policy, channel order, channel data type, and dimensions.ClearCLImagecreateImage(ImageChannelOrder pImageChannelOrder, ImageChannelDataType pImageChannelType, long... pDimensions)Creates 1D, 2D, or 3D image with a given channel order, channel data type, and dimensions.ClearCLImagecreateImage(MemAllocMode pMemAllocMode, HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, ImageChannelOrder pImageChannelOrder, ImageChannelDataType pImageChannelType, long... pDimensions)Creates 1D, 2D, or 3D image with a given memory allocation and access policy, channel order, channel data type, and dimensions.ClearCLProgramcreateProgram(Class<?> pClassForRessource, String... pRessourceNames)Creates a program given a list of resources locate relative to a reference class.ClearCLProgramcreateProgram(String... pSourceCode)Creates a program, with optional source codeClearCLQueuecreateQueue()Creates a queue.ClearCLImagecreateSingleChannelImage(HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, ImageChannelDataType pImageChannelType, long... pDimensions)Creates 1D, 2D, or 3D single channel image with a given memory allocation and access policy, channel data type, and dimensions.ClearCLImagecreateSingleChannelImage(ImageChannelDataType pImageChannelType, long... pDimensions)Creates 1D, 2D, or 3D single channel images with a given channel data type, and dimensions.ClearCLBackendInterfacegetBackend()Returns the backendnet.haesleinhuepf.clij.coremem.rgc.CleanergetCleaner()ClearCLQueuegetDefaultQueue()Returns the default queue.ClearCLDevicegetDevice()Returns context's deviceClearCLRecyclablePeerPointergetPeerPointer()Sets the peer pointerbooleanisDebugNotifyAllocation()Returns the boolean flag that decides whether to print a message with a stack trace every time a buffer or image is allocated.voidreleaseImages()Empty memory by releasing all images and buffers.StringreportAboutAllocatedImages()Report about allocated imagesvoidsetDebugNotifyAllocation(boolean pDebugNotifyAllocation)Sets the debug allocation notification flag.voidsetPeerPointer(ClearCLRecyclablePeerPointer pPeerPointer)Sets the peer pointerStringtoString()
-
-
-
Method Detail
-
getBackend
public ClearCLBackendInterface getBackend()
Returns the backend- Returns:
- backend
-
setPeerPointer
public void setPeerPointer(ClearCLRecyclablePeerPointer pPeerPointer)
Sets the peer pointer- Parameters:
pPeerPointer- peer pointer
-
getPeerPointer
public ClearCLRecyclablePeerPointer getPeerPointer()
Sets the peer pointer- Returns:
- peer pointer
-
getDevice
public ClearCLDevice getDevice()
Returns context's device- Returns:
- device
-
getDefaultQueue
public ClearCLQueue getDefaultQueue()
Returns the default queue. All devices are created with a default queue.- Returns:
- default queue
-
createQueue
public ClearCLQueue createQueue()
Creates a queue.- Returns:
- queue
-
createBuffer
public ClearCLBuffer createBuffer(MemAllocMode pMemAllocMode, HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, ClearCLImage pTemplate)
Creates an OpenCL buffer with a given memory allocation mode, host and kernel access and a template image to match for dimensions, data type and number of channels.- Parameters:
pMemAllocMode- allocation modepHostAccessType- host access typepKernelAccessType- kernel access typepTemplate- image to use as template- Returns:
- created buffer
-
createBuffer
public ClearCLBuffer createBuffer(net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeType, long pBufferLengthInElements)
Creates an OpenCL buffer with a given data type and length. The host and kernel access policy is read and write access for both.- Parameters:
pNativeType- native typepBufferLengthInElements- length in elements- Returns:
- created buffer
-
createBuffer
public ClearCLBuffer createBuffer(HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeType, long pBufferLengthInElements)
Creates an OpenCL buffer with a given access policy, data type and length.- Parameters:
pHostAccessType- host access typepKernelAccessType- kernel access typepNativeType- data typepBufferLengthInElements- length in elements- Returns:
- created buffer
-
createBuffer
public ClearCLBuffer createBuffer(MemAllocMode pMemAllocMode, net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeType, long pBufferLengthInElements)
Creates an OpenCL buffer with a given access policy, data type, memory allocation mode and length. The host and kernel access policy is read and write access for both.- Parameters:
pMemAllocMode- memory allocation modepNativeType- native typepBufferLengthInElements- length in elements- Returns:
- created buffer
-
createBuffer
public ClearCLBuffer createBuffer(MemAllocMode pMemAllocMode, HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeType, long pBufferLengthInElements)
Creates an OpenCL buffer with a given data type, access policy, memory allocation mode, native type, and length.- Parameters:
pMemAllocMode- memory allocation modepHostAccessType- host access typepKernelAccessType- kernel access typepNativeType- native data typepBufferLengthInElements- length in elements- Returns:
- created buffer
-
createBuffer
public ClearCLBuffer createBuffer(MemAllocMode pMemAllocMode, HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, long pNumberOfChannels, net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeType, long... pDimensions)
Creates an OpenCL buffer with a given data type, memory allocation mode and access policy, memory allocation mode, native type, and dimensions. In this case the buffer can be interpreted as an image.- Parameters:
pMemAllocMode- memory allocation modepHostAccessType- host access typepKernelAccessType- kernel access typepNumberOfChannels- number of channels perpNativeType- native type per channel per pixel/voxelpDimensions- image buffer dimensions- Returns:
- created buffer
-
createImage
public ClearCLImage createImage(ClearCLImage pImage)
Creates an image with same parameters as the given image,- Parameters:
pImage- template image to use- Returns:
- created image
-
createImage
public ClearCLImage createImage(ClearCLImage pImage, ImageChannelDataType pChannelDataType)
Creates an image with same parameters as the given image,- Parameters:
pImage- template image to usepChannelDataType- Overrides channel data type, if null the original channel data type is used- Returns:
- created image
-
createSingleChannelImage
public ClearCLImage createSingleChannelImage(ImageChannelDataType pImageChannelType, long... pDimensions)
Creates 1D, 2D, or 3D single channel images with a given channel data type, and dimensions. The host and kernel access policy is read and write access for both.- Parameters:
pImageChannelType- channel data typepDimensions- dimensions- Returns:
- 1D,2D, or 3D image
-
createImage
public ClearCLImage createImage(ImageChannelOrder pImageChannelOrder, ImageChannelDataType pImageChannelType, long... pDimensions)
Creates 1D, 2D, or 3D image with a given channel order, channel data type, and dimensions. The host and kernel access policy is read and write access for both.- Parameters:
pImageChannelOrder- channel orderpImageChannelType- channel data typepDimensions- dimensions- Returns:
- 1D,2D, or 3D image
-
createSingleChannelImage
public ClearCLImage createSingleChannelImage(HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, ImageChannelDataType pImageChannelType, long... pDimensions)
Creates 1D, 2D, or 3D single channel image with a given memory allocation and access policy, channel data type, and dimensions.- Parameters:
pHostAccessType- host access typepKernelAccessType- kernel access typepImageChannelType- channel data typepDimensions- dimensions- Returns:
- 1D,2D, or 3D image
-
createImage
public ClearCLImage createImage(HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, ImageChannelOrder pImageChannelOrder, ImageChannelDataType pImageChannelType, long... pDimensions)
Creates 1D, 2D, or 3D image with a given memory allocation and access policy, channel order, channel data type, and dimensions.- Parameters:
pHostAccessType- host access typepKernelAccessType- kernel access typepImageChannelOrder- channel orderpImageChannelType- channel data typepDimensions- dimensions- Returns:
- 1D,2D, or 3D image
-
createImage
public ClearCLImage createImage(MemAllocMode pMemAllocMode, HostAccessType pHostAccessType, KernelAccessType pKernelAccessType, ImageChannelOrder pImageChannelOrder, ImageChannelDataType pImageChannelType, long... pDimensions)
Creates 1D, 2D, or 3D image with a given memory allocation and access policy, channel order, channel data type, and dimensions.- Parameters:
pMemAllocMode- memory allocation modepHostAccessType- host access typepKernelAccessType- kernel access typepImageChannelOrder- channel orderpImageChannelType- channel data typepDimensions- dimensions- Returns:
- 1D,2D, or 3D image
-
createProgram
public ClearCLProgram createProgram(String... pSourceCode)
Creates a program, with optional source code- Parameters:
pSourceCode- optional varargs of source code strings.- Returns:
- program
-
createProgram
public ClearCLProgram createProgram(Class<?> pClassForRessource, String... pRessourceNames) throws IOException
Creates a program given a list of resources locate relative to a reference class.- Parameters:
pClassForRessource- reference class to locate resourcespRessourceNames- Resource file names (relative to reference class)- Returns:
- program
- Throws:
IOException- if IO problem while accessing resources
-
isDebugNotifyAllocation
public boolean isDebugNotifyAllocation()
Returns the boolean flag that decides whether to print a message with a stack trace every time a buffer or image is allocated. this is practical to detect OpenCl memory trashing/leaking- Returns:
- true debug messages, false no debug messages
-
setDebugNotifyAllocation
public void setDebugNotifyAllocation(boolean pDebugNotifyAllocation)
Sets the debug allocation notification flag.- Parameters:
pDebugNotifyAllocation- true debug messages, false no debug messages
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
reportAboutAllocatedImages
public String reportAboutAllocatedImages()
Report about allocated images- Returns:
- human readable text listing all allocated images and buffers.
-
releaseImages
public void releaseImages()
Empty memory by releasing all images and buffers.
-
getCleaner
public net.haesleinhuepf.clij.coremem.rgc.Cleaner getCleaner()
- Specified by:
getCleanerin interfacenet.haesleinhuepf.clij.coremem.rgc.Cleanable
-
-