org.encog.engine.opencl.kernels
Class EncogKernel

java.lang.Object
  extended by org.encog.engine.opencl.kernels.EncogKernel
Direct Known Subclasses:
KernelNetworkCalc, KernelNetworkTrain, KernelVectorAdd

public class EncogKernel
extends Object

Defines a basic OpenCL kernal, as used by Encog. Contains the kernal source code and a compiled program/kernal.


Constructor Summary
EncogKernel(EncogCLDevice device, String sourceName, String kernelName)
          Create an Encog OpenCL kernel.
 
Method Summary
 void compile()
          Compile the kernel with no preprocessor defines.
 void compile(Map<String,String> options)
          Compile the kernel with a map of preprocessor defines, a collection of name-value pairs.
 org.jocl.cl_mem createArrayReadOnly(float[] array)
          Create an array buffer that is read only for floats.
 org.jocl.cl_mem createArrayReadOnly(int[] array)
          Create an array buffer that is read only for ints.
 org.jocl.cl_mem createFloatArrayWriteOnly(int length)
          Create an array buffer that is write only.
 String getCLSource()
           
 org.jocl.cl_context getContext()
           
 EncogCLDevice getDevice()
           
 int getGlobalWork()
           
 org.jocl.cl_kernel getKernel()
           
 int getLocalWork()
           
 int getMaxWorkGroupSize()
           
 org.jocl.cl_program getProgram()
           
 String getSourceName()
           
 long getWorkGroupLong(int param)
          Get a long param from the device.
 void prepareKernel()
          Called internally to prepare to execute a kernel.
 void release()
          Release this kernel.
 void releaseBuffer(org.jocl.cl_mem mem)
          Release a buffer.
 void setArg(int num, org.jocl.cl_mem mem)
          Set an argument.
 void setCLSource(String cl)
           
 void setGlobalWork(int globalWork)
          Set the size of the global work group.
 void setLocalWork(int localWork)
          Set the size of the local work group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncogKernel

public EncogKernel(EncogCLDevice device,
                   String sourceName,
                   String kernelName)
Create an Encog OpenCL kernel. The Kernel will be loaded from an embedded resource.

Parameters:
device - The OpenCL device to use.
sourceName - The name of the kernel, from an embedded resource.
kernelName - The name of the function, in the kernel, called to start the kernel.
Method Detail

compile

public void compile()
Compile the kernel with no preprocessor defines.


compile

public void compile(Map<String,String> options)
Compile the kernel with a map of preprocessor defines, a collection of name-value pairs.

Parameters:
options - A map of preprocessor defines.

createArrayReadOnly

public org.jocl.cl_mem createArrayReadOnly(float[] array)
Create an array buffer that is read only for floats.

Parameters:
array - The array to base on.
Returns:
The memory buffer.

createArrayReadOnly

public org.jocl.cl_mem createArrayReadOnly(int[] array)
Create an array buffer that is read only for ints.

Parameters:
array - The array to base on.
Returns:
The memory buffer.

createFloatArrayWriteOnly

public org.jocl.cl_mem createFloatArrayWriteOnly(int length)
Create an array buffer that is write only.

Parameters:
length - The length of the buffer.
Returns:
The memory buffer.

getCLSource

public String getCLSource()
Returns:
the cl

getContext

public org.jocl.cl_context getContext()
Returns:
The OpenCL context that this kernel belongs to.

getDevice

public EncogCLDevice getDevice()
Returns:
the device

getGlobalWork

public int getGlobalWork()
Returns:
The size of the global work buffer.

getKernel

public org.jocl.cl_kernel getKernel()
Returns:
The OpenCL kernel.

getLocalWork

public int getLocalWork()
Returns:
The size of the local work group.

getMaxWorkGroupSize

public int getMaxWorkGroupSize()
Returns:
Suggested max workgroup size. You will very likely crash the GPU if you go above this.

getProgram

public org.jocl.cl_program getProgram()
Returns:
The OpenCL program that the kernel belongs to.

getSourceName

public String getSourceName()
Returns:
the sourceName

getWorkGroupLong

public long getWorkGroupLong(int param)
Get a long param from the device.

Parameters:
param - The param desired.
Returns:
The param value.

prepareKernel

public void prepareKernel()
Called internally to prepare to execute a kernel.


release

public void release()
Release this kernel.


releaseBuffer

public void releaseBuffer(org.jocl.cl_mem mem)
Release a buffer.

Parameters:
mem - The buffer to release.

setArg

public void setArg(int num,
                   org.jocl.cl_mem mem)
Set an argument.

Parameters:
num - The argument number.
mem - The memory buffer.

setCLSource

public void setCLSource(String cl)
Parameters:
cl - the cl to set

setGlobalWork

public void setGlobalWork(int globalWork)
Set the size of the global work group.

Parameters:
globalWork - The size of the global work group.

setLocalWork

public void setLocalWork(int localWork)
Set the size of the local work group.

Parameters:
localWork - The size of the local work group.


Copyright © 2011. All Rights Reserved.