Class 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 Detail

      • setPeerPointer

        public void setPeerPointer​(ClearCLRecyclablePeerPointer pPeerPointer)
        Sets the peer pointer
        Parameters:
        pPeerPointer - 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 mode
        pHostAccessType - host access type
        pKernelAccessType - kernel access type
        pTemplate - 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 type
        pBufferLengthInElements - 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 type
        pKernelAccessType - kernel access type
        pNativeType - data type
        pBufferLengthInElements - 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 mode
        pNativeType - native type
        pBufferLengthInElements - 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 mode
        pHostAccessType - host access type
        pKernelAccessType - kernel access type
        pNativeType - native data type
        pBufferLengthInElements - 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 mode
        pHostAccessType - host access type
        pKernelAccessType - kernel access type
        pNumberOfChannels - number of channels per
        pNativeType - native type per channel per pixel/voxel
        pDimensions - 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 use
        pChannelDataType - 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 type
        pDimensions - 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 order
        pImageChannelType - channel data type
        pDimensions - 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 type
        pKernelAccessType - kernel access type
        pImageChannelType - channel data type
        pDimensions - 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 type
        pKernelAccessType - kernel access type
        pImageChannelOrder - channel order
        pImageChannelType - channel data type
        pDimensions - 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 mode
        pHostAccessType - host access type
        pKernelAccessType - kernel access type
        pImageChannelOrder - channel order
        pImageChannelType - channel data type
        pDimensions - 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 resources
        pRessourceNames - 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
      • 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:
        getCleaner in interface net.haesleinhuepf.clij.coremem.rgc.Cleanable