Package net.haesleinhuepf.clij.clearcl
Class ClearCLKernel
- java.lang.Object
-
- net.haesleinhuepf.clij.clearcl.abs.ClearCLBase
-
- net.haesleinhuepf.clij.clearcl.ClearCLKernel
-
- All Implemented Interfaces:
AutoCloseable,Runnable
public class ClearCLKernel extends ClearCLBase implements Runnable
ClearCLKernel is the ClearCL abstraction for OpenCL kernels.- Author:
- royer
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearArguments()Clears arguments.voidclose()ObjectgetArgument(int pIndex)Return argument value for a given argument index.ObjectgetArgument(String pArgumentName)Return argument value for a given argument name.long[]getGlobalOffsets()Return global offsets.long[]getGlobalSizes()returns the global sizeslong[]getLocalSizes()Returns the local sizes.StringgetName()Returns kernel nameStringgetSourceCode()Returns source codebooleanhasArgument(String pArgumentName)booleanisArgumentCaching()Returns true if arguments are cached.booleanisLogExecutionTime()Returns true if execution times for this kernel should be logged.voidrun()Executes kernel for current set of arguments on default queue (blocking call until kernel finishes).voidrun(boolean pWaitToFinish)Executes kernel for current set of arguments on default queue.voidrun(ClearCLQueue pClearCLQueue, boolean pWaitToFinish)Executes kernel for current set of arguments on provided queue.voidsetArgument(int pIndex, Object pObject)Sets argument for a given argument index.voidsetArgument(String pArgumentName, Object pObject)Sets argument for a given argument name.voidsetArgumentCaching(boolean pArgumentCaching)Sets argument caching.voidsetArguments(Object... pArguments)Sets the kernel arguments for the next kernel run.voidsetGlobalOffsets(long... pGlobalOffsets)Sets the global offsets.voidsetGlobalSizes(long... pGlobalSizes)Sets the global sizesvoidsetGlobalSizes(ClearCLImageInterface pImage)Sets the global sizes to the dimensions of a image (1D, 2D, or 3D)voidsetLocalMemoryArgument(String pArgumentName, net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeTypeEnum, long pNumberOfElements)Sets a local memory argument for the kernel.voidsetLocalSizes(long... pLocalSizes)Sets the local sizes.voidsetLogExecutionTime(boolean pLogExecutionTime)Sets whether this kernel should log its execution time.booleansetOptionalArgument(String pArgumentName, Object pObject)Sets optional argument for a given argument name.StringtoString()-
Methods inherited from class net.haesleinhuepf.clij.clearcl.abs.ClearCLBase
getBackend, getPeerPointer, setPeerPointer
-
-
-
-
Method Detail
-
getName
public String getName()
Returns kernel name- Returns:
- kernel name
-
getSourceCode
public String getSourceCode()
Returns source code- Returns:
- source code
-
getGlobalOffsets
public long[] getGlobalOffsets()
Return global offsets.- Returns:
- global offsets
-
setGlobalOffsets
public void setGlobalOffsets(long... pGlobalOffsets)
Sets the global offsets.- Parameters:
pGlobalOffsets- new global offsets
-
getGlobalSizes
public long[] getGlobalSizes()
returns the global sizes- Returns:
- global sizes
-
setGlobalSizes
public void setGlobalSizes(long... pGlobalSizes)
Sets the global sizes- Parameters:
pGlobalSizes- global sizes
-
setGlobalSizes
public void setGlobalSizes(ClearCLImageInterface pImage)
Sets the global sizes to the dimensions of a image (1D, 2D, or 3D)- Parameters:
pImage- image
-
getLocalSizes
public long[] getLocalSizes()
Returns the local sizes.- Returns:
- local sizes
-
setLocalSizes
public void setLocalSizes(long... pLocalSizes)
Sets the local sizes.- Parameters:
pLocalSizes- local sizes
-
isArgumentCaching
public boolean isArgumentCaching()
Returns true if arguments are cached.- Returns:
- true if caching active, false otherwise
-
setArgumentCaching
public void setArgumentCaching(boolean pArgumentCaching)
Sets argument caching. This prevents resubmitting an argument which value is unchanged. Caching is on by default.- Parameters:
pArgumentCaching- true for cacging, false otherwise
-
clearArguments
public void clearArguments()
Clears arguments.
-
setArgument
public void setArgument(int pIndex, Object pObject)Sets argument for a given argument index.- Parameters:
pIndex- argument indexpObject- argument
-
getArgument
public Object getArgument(int pIndex)
Return argument value for a given argument index.- Parameters:
pIndex- argument index- Returns:
- value
-
setArguments
public void setArguments(Object... pArguments)
Sets the kernel arguments for the next kernel run.- Parameters:
pArguments- list of arguments
-
setArgument
public void setArgument(String pArgumentName, Object pObject)
Sets argument for a given argument name. If argument is unknown for kernel, an exception is thrown.- Parameters:
pArgumentName- argument namepObject- argument
-
hasArgument
public boolean hasArgument(String pArgumentName)
-
getArgument
public Object getArgument(String pArgumentName)
Return argument value for a given argument name.- Parameters:
pArgumentName- argument name- Returns:
- value
-
setLocalMemoryArgument
public void setLocalMemoryArgument(String pArgumentName, net.haesleinhuepf.clij.coremem.enums.NativeTypeEnum pNativeTypeEnum, long pNumberOfElements)
Sets a local memory argument for the kernel.- Parameters:
pArgumentName- argument namepNativeTypeEnum- native type for elementspNumberOfElements- number of elements
-
setOptionalArgument
public boolean setOptionalArgument(String pArgumentName, Object pObject)
Sets optional argument for a given argument name.- Parameters:
pArgumentName- argument namepObject- argument- Returns:
- true is argument set, false if argument unknown
-
run
public void run()
Executes kernel for current set of arguments on default queue (blocking call until kernel finishes).
-
run
public void run(boolean pWaitToFinish)
Executes kernel for current set of arguments on default queue.- Parameters:
pWaitToFinish- if true the call is blocking, false otherwise
-
run
public void run(ClearCLQueue pClearCLQueue, boolean pWaitToFinish)
Executes kernel for current set of arguments on provided queue. IMPORTANT: about blocking calls: there is a cost associated to waiting for a kernel to finish... If you execute several kernels in the same queue, you do no need to wait.- Parameters:
pClearCLQueue- queuepWaitToFinish- if true the call is blocking, false otherwise
-
toString
public String toString()
- Overrides:
toStringin classClearCLBase
-
isLogExecutionTime
public boolean isLogExecutionTime()
Returns true if execution times for this kernel should be logged.- Returns:
- true if logging on.
-
setLogExecutionTime
public void setLogExecutionTime(boolean pLogExecutionTime)
Sets whether this kernel should log its execution time.- Parameters:
pLogExecutionTime- true for logging
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classClearCLBase
-
-