com.jogamp.opencl
Class CLKernel

java.lang.Object
  extended by com.jogamp.opencl.CLKernel
All Implemented Interfaces:
AutoCloseable, CLResource, Cloneable

public class CLKernel
extends Object
implements CLResource, Cloneable

High level abstraction for an OpenCL Kernel. A kernel is a function declared in a program. A kernel is identified by the kernel qualifier applied to any function in a program. A kernel object encapsulates the specific kernel function declared in a program and the argument values to be used when executing this kernel function. CLKernel is not threadsafe.

Author:
Michael Bien
See Also:
CLProgram.createCLKernel(java.lang.String), CLProgram.createCLKernels()

Field Summary
protected  CL cl
           
protected  CLContext context
           
 long ID
          The OpenCL object handle.
 String name
           
 int numArgs
           
 
Method Summary
 CLKernel clone()
          Returns a new instance of this kernel with uninitialized arguments.
 void close()
          Deprecated. This method is not intended to be called from client code.
 boolean equals(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.
 CLContext getContext()
          Returns the context for this OpenCL object.
 long getID()
          Returns the OpenCL object handle
 long getLocalMemorySize(CLDevice device)
          Returns the amount of local memory in bytes being used by a kernel.
 CLPlatform getPlatform()
          Returns the platform for this OpenCL object.
 CLProgram getProgram()
           
 long getWorkGroupSize(CLDevice device)
          Returns the work group size for this kernel on the given device.
 int hashCode()
           
 boolean isForce32BitArgsEnabled()
           
 CLKernel putArg(CLMemory<?> value)
           
 CLKernel putArg(double value)
           
 CLKernel putArg(float value)
           
 CLKernel putArg(int value)
           
 CLKernel putArg(long value)
           
 CLKernel putArgs(CLMemory<?>... values)
           
 CLKernel putNullArg(int size)
           
 void release()
          Releases all resources of this kernel from its context.
 CLKernel rewind()
           
 CLKernel setArg(int argumentIndex, CLMemory<?> value)
           
 CLKernel setArg(int argumentIndex, double value)
           
 CLKernel setArg(int argumentIndex, float value)
           
 CLKernel setArg(int argumentIndex, int value)
           
 CLKernel setArg(int argumentIndex, long value)
           
 CLKernel setArgs(CLMemory<?>... values)
           
 CLKernel setForce32BitArgs(boolean force)
          Forces double and long arguments to be passed as float and int to the OpenCL kernel.
 CLKernel setNullArg(int argumentIndex, int size)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public final String name

numArgs

public final int numArgs

ID

public final long ID
The OpenCL object handle.


context

protected CLContext context

cl

protected final CL cl
Method Detail

putArg

public CLKernel putArg(CLMemory<?> 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)

putArgs

public CLKernel putArgs(CLMemory<?>... values)

rewind

public CLKernel rewind()

setArg

public CLKernel setArg(int argumentIndex,
                       CLMemory<?> 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)

setArgs

public CLKernel setArgs(CLMemory<?>... values)

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 __local address qualifier and local memory to be allocated for arguments to the kernel declared as pointers with the __local address qualifier and whose size is specified with clSetKernelArg. If the local memory size, for any pointer argument to the kernel declared with the __local address 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 qualifier new long[]{(0, 0, 0)} is returned. The returned array has always three elements.


release

public void release()
Releases all resources of this kernel from its context.

Specified by:
release in interface CLResource

toString

public String toString()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

clone

public CLKernel clone()
Returns a new instance of this kernel with uninitialized arguments.

Overrides:
clone in class Object

close

@Deprecated
public final void close()
Deprecated. This method is not intended to be called from client code.

Implementation detail. TODO remove as soon we have extension methods.

Specified by:
close in interface AutoCloseable
See Also:
AutoCloseable

getContext

public CLContext getContext()
Returns the context for this OpenCL object.


getPlatform

public CLPlatform getPlatform()
Returns the platform for this OpenCL object.


getID

public long getID()
Returns the OpenCL object handle