org.jocl.utils
Class Kernels

java.lang.Object
  extended by org.jocl.utils.Kernels

public class Kernels
extends java.lang.Object

Utility methods related to kernels and programs.


Method Summary
static org.jocl.cl_kernel create(org.jocl.cl_program program, java.lang.String kernelName)
          Creates an OpenCL kernel for the function with the given name in the given program.
static org.jocl.cl_kernel createFromFile(org.jocl.cl_context context, java.lang.String fileName, java.lang.String kernelName, java.lang.String... compileOptions)
          Creates an OpenCL kernel for the function with the given name from the specified file.
static org.jocl.cl_kernel createFromSource(org.jocl.cl_context context, java.lang.String sourceCode, java.lang.String kernelName, java.lang.String... compileOptions)
          Creates an OpenCL kernel for the function with the given name from the given source code.
static org.jocl.cl_kernel createFromStream(org.jocl.cl_context context, java.io.InputStream stream, java.lang.String kernelName, java.lang.String... compileOptions)
          Creates an OpenCL program for the function with the given name from the given input stream.
static void release(org.jocl.cl_kernel... kernels)
          Release each of the given kernels if it is not null.
static void release(java.lang.Iterable<org.jocl.cl_kernel> kernels)
          Release each of the given kernels if it is not null.
static void setArgs(org.jocl.cl_kernel kernel, java.lang.Object... args)
          Utility method to set the specified kernel arguments
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static org.jocl.cl_kernel create(org.jocl.cl_program program,
                                        java.lang.String kernelName)
Creates an OpenCL kernel for the function with the given name in the given program.

Parameters:
program - The program
kernelName - The kernel name
Returns:
The program

createFromFile

public static org.jocl.cl_kernel createFromFile(org.jocl.cl_context context,
                                                java.lang.String fileName,
                                                java.lang.String kernelName,
                                                java.lang.String... compileOptions)
                                         throws java.io.IOException
Creates an OpenCL kernel for the function with the given name from the specified file. The program will be created using the given context, and released after the kernel has been created.

Parameters:
context - The context
fileName - The file name
kernelName - The name of the kernel
compileOptions - The compile options
Returns:
The kernel
Throws:
java.io.IOException - If the file can not be read

createFromStream

public static org.jocl.cl_kernel createFromStream(org.jocl.cl_context context,
                                                  java.io.InputStream stream,
                                                  java.lang.String kernelName,
                                                  java.lang.String... compileOptions)
                                           throws java.io.IOException
Creates an OpenCL program for the function with the given name from the given input stream. The program will be created using the given context, and released after the kernel has been created. The caller is responsible for closing the given stream after this method returns.

Parameters:
context - The context
stream - The stream
kernelName - The kernel name
compileOptions - The compile options
Returns:
The kernel
Throws:
java.io.IOException - If the stream can not be read

createFromSource

public static org.jocl.cl_kernel createFromSource(org.jocl.cl_context context,
                                                  java.lang.String sourceCode,
                                                  java.lang.String kernelName,
                                                  java.lang.String... compileOptions)
Creates an OpenCL kernel for the function with the given name from the given source code. The program will be created using the given context, and released after the kernel has been created.

Parameters:
context - The context
sourceCode - The source code
kernelName - The kernel name
compileOptions - The compile options
Returns:
The kernel

setArgs

public static void setArgs(org.jocl.cl_kernel kernel,
                           java.lang.Object... args)
Utility method to set the specified kernel arguments

Parameters:
kernel - The kernel
args - The arguments
Throws:
java.lang.IllegalArgumentException - If the argument types are not primitive types and cl_mem

release

public static void release(org.jocl.cl_kernel... kernels)
Release each of the given kernels if it is not null.

Parameters:
kernels - The kernels to release

release

public static void release(java.lang.Iterable<org.jocl.cl_kernel> kernels)
Release each of the given kernels if it is not null.

Parameters:
kernels - The kernels to release