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 Summary
Constructors Modifier Constructor Description protected
CLObject(jdk.incubator.foreign.MemoryAddress p)
-
Method Summary
Modifier and Type Method Description protected jdk.incubator.foreign.MemoryAddress
getInfo(int index, int id, java.lang.invoke.MethodHandle getInfo, Allocator a, long size)
protected static jdk.incubator.foreign.MemoryAddress
getInfo(jdk.incubator.foreign.MemoryAddress self, int id, java.lang.invoke.MethodHandle getInfo, Allocator frame, long size)
protected <T extends CLObject>
jdk.incubator.foreign.MemoryAddressgetInfo(T ctx, int id, java.lang.invoke.MethodHandle getInfo, Allocator a, long size)
protected jdk.incubator.foreign.MemorySegment
getInfoAny(int index, int id, java.lang.invoke.MethodHandle getInfo, Allocator a)
protected jdk.incubator.foreign.MemorySegment
getInfoAny(int id, java.lang.invoke.MethodHandle getInfo, Allocator a)
protected <T extends CLObject>
TgetInfoAny(int id, java.lang.invoke.MethodHandle getInfo, java.util.function.Function<jdk.incubator.foreign.MemoryAddress,T> create)
protected <T extends CLObject>
jdk.incubator.foreign.MemorySegmentgetInfoAny(T ctx, int id, java.lang.invoke.MethodHandle getInfo, Allocator a)
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)
protected byte[]
getInfoByteV(int id, java.lang.invoke.MethodHandle getInfo)
protected <T extends CLObject>
byte[]getInfoByteV(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
int
getInfoInt(int param)
Retrieve an int field.protected int
getInfoInt(int index, int id, java.lang.invoke.MethodHandle getInfo)
protected int
getInfoInt(int id, java.lang.invoke.MethodHandle getInfo)
protected <T extends CLObject>
intgetInfoInt(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
protected <T> T
getInfoJava(int id, java.lang.invoke.MethodHandle getInfo, java.util.function.Function<jdk.incubator.foreign.MemoryAddress,T> create)
long
getInfoLong(int param)
Retrieves a long field.protected long
getInfoLong(int index, int id, java.lang.invoke.MethodHandle getInfo)
protected long
getInfoLong(int id, java.lang.invoke.MethodHandle getInfo)
protected <T extends CLObject>
longgetInfoLong(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
protected long[]
getInfoLongV(int id, java.lang.invoke.MethodHandle getInfo)
protected <T extends CLObject>
long[]getInfoLongV(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
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)
long
getInfoSizeT(int param)
Retrieves a size_t field.protected long
getInfoSizeT(int id, java.lang.invoke.MethodHandle getInfo)
protected <T extends CLObject>
longgetInfoSizeT(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
long[]
getInfoSizeTA(int param)
Retrieves an array of size_t fields.java.lang.String
getInfoString(int param)
Retrieves a char * field as a UTF8 string.protected java.lang.String
getInfoString(int index, int id, java.lang.invoke.MethodHandle getInfo)
protected java.lang.String
getInfoString(int id, java.lang.invoke.MethodHandle getInfo)
protected <T extends CLObject>
java.lang.StringgetInfoString(T ctx, int id, java.lang.invoke.MethodHandle getInfo)
static void
release(CLObject list)
static void
release(CLObject... list)
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, toString, wait, wait, wait
-
Constructor Details
-
CLObject
protected CLObject(jdk.incubator.foreign.MemoryAddress p)
-
-
Method Details
-
release
-
release
-
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:
-