Package com.jogamp.opencl
Class CLKernel
- java.lang.Object
-
- com.jogamp.opencl.CLObject
-
- com.jogamp.opencl.CLKernel
-
- All Implemented Interfaces:
AutoCloseable,CLResource,Cloneable
public class CLKernel extends CLObject implements Cloneable
High level abstraction for an OpenCL Kernel. A kernel is a function declared in a program. A kernel is identified by thekernelqualifier applied to any function in a program. A kernel object encapsulates the specifickernelfunction declared in a program and the argument values to be used when executing thiskernelfunction. CLKernel is not threadsafe.- Author:
- Michael Bien, et al.
- See Also:
CLProgram.createCLKernel(java.lang.String),CLProgram.createCLKernels()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CLKernelclone()Returns a new instance of this kernel with uninitialized arguments.voidclose()Deprecated.This method is not intended to be called from client code.booleanequals(Object obj)long[]getCompileWorkGroupSize(CLDevice device)Returns the work-group size specified by the__attribute__((reqd_work_group_size(X, Y, Z)))qualifier in kernel sources.longgetLocalMemorySize(CLDevice device)Returns the amount of local memory in bytes being used by a kernel.longgetPreferredWorkGroupSizeMultiple(CLDevice device)Returns the preferred multiple of workgroup size to use for kernel launch.longgetPrivateMemSize(CLDevice device)Returns the number of bytes of private memory used by each work item in the kernel.CLProgramgetProgram()longgetWorkGroupSize(CLDevice device)Returns the work group size for this kernel on the given device.inthashCode()booleanisForce32BitArgsEnabled()booleanisReleased()Returns true ifCLResource.release()has been called.intposition()Returns the argument index used in the relative putArt(...) methods.CLKernelputArg(double value)CLKernelputArg(float value)CLKernelputArg(int value)CLKernelputArg(long value)CLKernelputArg(short value)CLKernelputArg(CLMemory<?> value)CLKernelputArgs(CLMemory<?>... values)CLKernelputNullArg(int size)voidrelease()Releases all resources of this kernel from its context.CLKernelrewind()Resets the argument index to 0.CLKernelsetArg(int argumentIndex, double value)CLKernelsetArg(int argumentIndex, float value)CLKernelsetArg(int argumentIndex, int value)CLKernelsetArg(int argumentIndex, long value)CLKernelsetArg(int argumentIndex, short value)CLKernelsetArg(int argumentIndex, CLMemory<?> value)CLKernelsetArgs(CLMemory<?>... values)CLKernelsetArgs(Object... values)CLKernelsetForce32BitArgs(boolean force)Forces double and long arguments to be passed as float and int to the OpenCL kernel.CLKernelsetNullArg(int argumentIndex, int size)StringtoString()-
Methods inherited from class com.jogamp.opencl.CLObject
getContext, getID, getPlatform
-
-
-
-
Field Detail
-
name
public final String name
-
numArgs
public final int numArgs
-
-
Method Detail
-
putArg
public CLKernel putArg(short value)
-
putArg
public CLKernel putArg(int value)
-
putArg
public CLKernel putArg(long value)
-
putArg
public CLKernel putArg(float value)
-
putArg
public CLKernel putArg(double value)
-
putNullArg
public CLKernel putNullArg(int size)
-
rewind
public CLKernel rewind()
Resets the argument index to 0.
-
position
public int position()
Returns the argument index used in the relative putArt(...) methods.
-
setArg
public CLKernel setArg(int argumentIndex, short value)
-
setArg
public CLKernel setArg(int argumentIndex, int value)
-
setArg
public CLKernel setArg(int argumentIndex, long value)
-
setArg
public CLKernel setArg(int argumentIndex, float value)
-
setArg
public CLKernel setArg(int argumentIndex, double value)
-
setNullArg
public CLKernel setNullArg(int argumentIndex, int size)
-
setForce32BitArgs
public CLKernel setForce32BitArgs(boolean force)
Forces double and long arguments to be passed as float and int to the OpenCL kernel. This can be used in applications which want to mix kernels with different floating point precision.
-
getProgram
public CLProgram getProgram()
-
isForce32BitArgsEnabled
public boolean isForce32BitArgsEnabled()
- See Also:
setForce32BitArgs(boolean)
-
getLocalMemorySize
public long getLocalMemorySize(CLDevice device)
Returns the amount of local memory in bytes being used by a kernel. This includes local memory that may be needed by an implementation to execute the kernel, variables declared inside the kernel with the__localaddress qualifier and local memory to be allocated for arguments to the kernel declared as pointers with the__localaddress qualifier and whose size is specified with clSetKernelArg. If the local memory size, for any pointer argument to the kernel declared with the__localaddress qualifier, is not specified, its size is assumed to be 0.
-
getWorkGroupSize
public long getWorkGroupSize(CLDevice device)
Returns the work group size for this kernel on the given device. This provides a mechanism for the application to query the work-group size that can be used to execute a kernel on a specific device given by device. The OpenCL implementation uses the resource requirements of the kernel (register usage etc.) to determine what this work-group size should be.
-
getCompileWorkGroupSize
public long[] getCompileWorkGroupSize(CLDevice device)
Returns the work-group size specified by the__attribute__((reqd_work_group_size(X, Y, Z)))qualifier in kernel sources. If the work-group size is not specified using the above attribute qualifiernew long[]{(0, 0, 0)}is returned. The returned array has always three elements.
-
getPreferredWorkGroupSizeMultiple
public long getPreferredWorkGroupSizeMultiple(CLDevice device)
Returns the preferred multiple of workgroup size to use for kernel launch. This is only a performance hint; enqueueing with other sizes will still work, unless the size is more than the maximum allowed.
-
getPrivateMemSize
public long getPrivateMemSize(CLDevice device)
Returns the number of bytes of private memory used by each work item in the kernel. This includes private memory declared with the__privatequalifier, as well as other private memory used by the implementation.
-
release
public void release()
Releases all resources of this kernel from its context.- Specified by:
releasein interfaceCLResource
-
clone
public CLKernel clone()
Returns a new instance of this kernel with uninitialized arguments.
-
close
@Deprecated public final void close()
Deprecated.This method is not intended to be called from client code.Implementation detail, satisfyingAutoCloseable. Might be remove as soon we have extension methods, but shall validate with Java 1.5 specs.- Specified by:
closein interfaceAutoCloseable- See Also:
AutoCloseable
-
isReleased
public boolean isReleased()
Description copied from interface:CLResourceReturns true ifCLResource.release()has been called.- Specified by:
isReleasedin interfaceCLResource
-
-