Module notzed.zcl
Package au.notzed.zcl

Class CLObject

java.lang.Object
api.Native
au.notzed.zcl.CLObject
Direct Known Subclasses:
CLEvent, CLExtendable, CLExtension, CLKernel, CLMemory, CLPlatform, CLProgram, CLSampler

public abstract class CLObject
extends Native
Base class for all OpenCL types which can be represented as objects. That is, those that are defined by anonymous pointer types in cl.h.

Each object has a single memory pointer which is stored in the p field. For most objects this is the only value retained and all get methods defer to the OpenCL runtime. OpenCL objects with the same pointer are guarnateed to map to the same Java instance. Objects are considered equal if their p value is identical.

To reduce the code-size, retain(), release(), getInfo() and object-specific getInfo() variants have been implemented in a polymorphic fashion. For getInfo(), the getInfoFunc() returns the method handle of the native function used to retrieve the information.

Memory management is automatic but can also be explicit at application discretion. Use the release() methods for explicit deallocation.

  • Constructor Details

    • CLObject

      protected CLObject​(jdk.incubator.foreign.MemoryAddress p)
  • Method Details

    • release

      public static void release​(CLObject list)
    • release

      public static void release​(CLObject... list)
    • getInfo

      protected static jdk.incubator.foreign.MemoryAddress getInfo​(jdk.incubator.foreign.MemoryAddress self, int id, java.lang.invoke.MethodHandle getInfo, Allocator frame, long size) throws CLRuntimeException
      Throws:
      CLRuntimeException
    • getInfoInt

      protected int getInfoInt​(int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoLong

      protected long getInfoLong​(int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoSizeT

      protected long getInfoSizeT​(int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoAny

      protected <T extends CLObject> T getInfoAny​(int id, java.lang.invoke.MethodHandle getInfo, java.util.function.Function<jdk.incubator.foreign.MemoryAddress,​T> create)
    • getInfoJava

      protected <T> T getInfoJava​(int id, java.lang.invoke.MethodHandle getInfo, java.util.function.Function<jdk.incubator.foreign.MemoryAddress,​T> create)
    • getInfoAny

      protected jdk.incubator.foreign.MemorySegment getInfoAny​(int id, java.lang.invoke.MethodHandle getInfo, Allocator a) throws CLRuntimeException
      Throws:
      CLRuntimeException
    • getInfoByteV

      protected byte[] getInfoByteV​(int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoString

      protected java.lang.String getInfoString​(int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoPropertyV

      protected <T extends CLProperty> T[] getInfoPropertyV​(int id, java.lang.invoke.MethodHandle getInfo, java.util.function.BiFunction<java.lang.Long,​java.lang.Long,​T> create, java.util.function.IntFunction<T[]> createArray)
    • getInfoLongV

      protected long[] getInfoLongV​(int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoAnyV

      protected <T extends CLObject> T[] getInfoAnyV​(int id, java.lang.invoke.MethodHandle getInfo, java.util.function.Function<jdk.incubator.foreign.MemoryAddress,​T> create, java.util.function.IntFunction<T[]> createArray)
    • getInfo

      protected <T extends CLObject> jdk.incubator.foreign.MemoryAddress getInfo​(T ctx, int id, java.lang.invoke.MethodHandle getInfo, Allocator a, long size) throws CLRuntimeException
      Throws:
      CLRuntimeException
    • getInfoInt

      protected <T extends CLObject> int getInfoInt​(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoLong

      protected <T extends CLObject> long getInfoLong​(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoSizeT

      protected <T extends CLObject> long getInfoSizeT​(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoAny

      protected <T extends CLObject> jdk.incubator.foreign.MemorySegment getInfoAny​(T ctx, int id, java.lang.invoke.MethodHandle getInfo, Allocator a) throws CLRuntimeException
      Throws:
      CLRuntimeException
    • getInfoByteV

      protected <T extends CLObject> byte[] getInfoByteV​(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoString

      protected <T extends CLObject> java.lang.String getInfoString​(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoLongV

      protected <T extends CLObject> long[] getInfoLongV​(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
    • getInfo

      protected jdk.incubator.foreign.MemoryAddress getInfo​(int index, int id, java.lang.invoke.MethodHandle getInfo, Allocator a, long size) throws CLRuntimeException
      Throws:
      CLRuntimeException
    • getInfoInt

      protected int getInfoInt​(int index, int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoLong

      protected long getInfoLong​(int index, int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoAny

      protected jdk.incubator.foreign.MemorySegment getInfoAny​(int index, int id, java.lang.invoke.MethodHandle getInfo, Allocator a) throws CLRuntimeException
      Throws:
      CLRuntimeException
    • getInfoString

      protected java.lang.String getInfoString​(int index, int id, java.lang.invoke.MethodHandle getInfo)
    • getInfoInt

      public int getInfoInt​(int param)
      Retrieve an int field.
      Parameters:
      param -
      Returns:
    • getInfoLong

      public long getInfoLong​(int param)
      Retrieves a long field.
      Parameters:
      param -
      Returns:
    • getInfoSizeT

      public long getInfoSizeT​(int param)
      Retrieves a size_t field.
      Parameters:
      param -
      Returns:
      Value of parameter.
      Throws:
      CLRuntimeException
    • getInfoSizeTA

      public long[] getInfoSizeTA​(int param)
      Retrieves an array of size_t fields.
      Parameters:
      param -
      Returns:
      The parameter value.
      Throws:
      CLRuntimeException
    • getInfoString

      public java.lang.String getInfoString​(int param)
      Retrieves a char * field as a UTF8 string.
      Parameters:
      param -
      Returns: