Module notzed.zcl
Package au.notzed.zcl

Class CLContext

java.lang.Object

public class CLContext
extends CLExtendable
Interface for cl_context
  • Constructor Details

    • CLContext

      public CLContext​(jdk.incubator.foreign.MemoryAddress p)
  • Method Details

    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • PLATFORM

      public static CLContextProperty PLATFORM​(CLPlatform platform)
      Creates a property representing CL_CONTEXT_PLATFORM.
      Parameters:
      platform - target value.
      Returns:
      new property
    • INTEROP_USER_SYNC

      public static CLContextProperty INTEROP_USER_SYNC​(boolean 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 CLRuntimeException
      Calls 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 CLRuntimeException
      Calls clCreateContextFromType.
      Parameters:
      properties -
      device_type -
      notify -
      Returns:
      Newly allocated context.

      release() should be called when it is no longer needed.

      Throws:
      CLRuntimeException
    • createCommandQueue

      public CLCommandQueue createCommandQueue​(CLDevice dev, long properties) throws CLRuntimeException
      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 CLRuntimeException
      Calls clCreateCommandQueueWithProperties.
      Parameters:
      dev -
      properties -
      Returns:
      Throws:
      CLRuntimeException
      Since:
      OpenCL 2.0
    • setDefaultDeviceCommandQueue

      public void setDefaultDeviceCommandQueue​(CLDevice dev, CLCommandQueue q) throws CLException
      Parameters:
      dev -
      q -
      Throws:
      CLException
      Since:
      OpenCL 2.1
    • createBuffer

      public CLBuffer createBuffer​(long flags, long size) throws CLRuntimeException
      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 CLRuntimeException
      Calls 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 CLRuntimeException
      Calls 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 CLRuntimeException
      Call clCreateBuffer() with sized buffer.
      Parameters:
      flags -
      hostp - must not be null.
      Returns:
      Throws:
      CLRuntimeException
    • createBuffer

      public CLBuffer createBuffer​(long flags, java.nio.ByteBuffer hostp) throws CLRuntimeException
      Call clCreateBuffer() with sized buffer.
      Parameters:
      flags -
      hostp - must not be null. only capacity is honoured.
      Returns:
      Throws:
      CLRuntimeException
    • createBuffer

      public CLBuffer createBuffer​(long flags, byte[] hostp) throws CLRuntimeException
      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

      public CLBuffer createBuffer​(long flags, float[] hostp) throws CLRuntimeException
      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.UnsupportedOperationException
      Calls 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.UnsupportedOperationException
      Calls clCreatePipe
      Parameters:
      flags -
      packetSize -
      maxPackets -
      properties -
      Returns:
      Throws:
      CLRuntimeException
      java.lang.UnsupportedOperationException
      Since:
      OpenCL 2.0
    • getSupportedImageFormats

      public CLImageFormat[] getSupportedImageFormats​(long flags, int type) throws CLRuntimeException
      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 CLRuntimeException
      Allocate shared virtual memory.

      Memory must be explicity freed using CLContext.SVMFree.

      Parameters:
      flags -
      size -
      alignment -
      Returns:
      Throws:
      CLRuntimeException
      Since:
      OpenCL 2.0
    • SVMFree

      public void SVMFree​(java.nio.ByteBuffer mem) throws CLRuntimeException
      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 CLRuntimeException
      Calls 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

      public CLSampler createSampler​(CLSamplerProperty[] props) throws CLRuntimeException
      Calls clCreateSamplerWithProperties
      Parameters:
      props - list of propertyes
      Returns:
      Throws:
      CLRuntimeException
      Since:
      OpenCL 2.0
    • createProgramWithSource

      public CLProgram createProgramWithSource​(byte[]... strings) throws CLException
      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

      public CLProgram createProgramWithSource​(java.lang.String... strings) throws CLException
      Throws:
      CLException
    • createProgramWithSource

      public CLProgram createProgramWithSource​(java.io.InputStream is) throws CLException
      Throws:
      CLException
    • createProgramWithIL

      public CLProgram createProgramWithIL​(byte[] il) throws CLException
      Calls clCreateProgramWithIL
      Parameters:
      il -
      Returns:
      Throws:
      CLException
    • createProgramWithBinary

      public CLProgram createProgramWithBinary​(CLDevice[] devices, byte[][] binaries, int[] status) throws CLException
      Calls 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.UnsupportedOperationException
      Calls 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.UnsupportedOperationException
      Calls 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

      public CLEvent createUserEvent() throws CLException
      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

      public CLDevice[] getDevices()
      gets CL_CONTEXT_DEVICES.
      Returns:
      List of devices.
    • getProperties

      public CLContextProperty[] getProperties()
      gets CL_CONTEXT_PROPERTIES
      Returns:
      List of properties used at create time.
    • initPlatform

      protected CLPlatform 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 class CLExtendable
      Returns: