com.jogamp.opencl
Class CLProgram

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

public class CLProgram
extends CLObject

Represents a OpenCL program executed on one or more CLDevices. A CLProgram must be build using one of the build methods before creating CLKernels.

Author:
Michael Bien, et al.
See Also:
CLContext.createProgram(java.io.InputStream), CLContext.createProgram(java.lang.String), CLContext.createProgram(java.util.Map)

Nested Class Summary
static interface CLProgram.CompilerOptions
          Common compiler options for the OpenCL compiler.
static class CLProgram.Status
           
 
Field Summary
 
Fields inherited from class com.jogamp.opencl.CLObject
context, ID
 
Method Summary
 CLProgram build()
          Builds this program for all devices associated with the context.
 CLProgram build(CLBuildListener listener)
          Builds this program for all devices associated with the context.
 CLProgram build(CLBuildListener listener, CLDevice... devices)
          Builds this program for the given devices.
 CLProgram build(CLBuildListener listener, String... options)
          Builds this program for all devices associated with the context using the specified build options.
 CLProgram build(CLBuildListener listener, String options)
          Builds this program for all devices associated with the context using the specified build options.
 CLProgram build(CLBuildListener listener, String options, CLDevice... devices)
          Builds this program for the given devices and with the specified build options.
 CLProgram build(CLDevice... devices)
          Builds this program for the given devices.
 CLProgram build(String... options)
          Builds this program for all devices associated with the context using the specified build options.
 CLProgram build(String options)
          Builds this program for all devices associated with the context using the specified build options.
 CLProgram build(String options, CLDevice... devices)
          Builds this program for the given devices and with the specified build options.
 void close()
          Deprecated. This method is not intended to be called from client code.
 CLKernel createCLKernel(String kernelName)
          Creates a kernel with the specified kernel name.
 Map<String,CLKernel> createCLKernels()
          Creates all kernels of this program and stores them a Map with the kernel name as key.
static String define(String name)
          Utility method for defining macros as build options (Returns "-D name").
static String define(String name, Object value)
          Utility method for defining macros as build options (Returns "-D name=value").
 boolean equals(Object obj)
           
 Map<CLDevice,byte[]> getBinaries()
          Returns the binaries for this program in an ordered Map containing the device as key and the program binaries as value.
 String getBuildLog()
          Returns the build log of this program on all devices.
 String getBuildLog(CLDevice device)
          Returns the build log for this program on the specified device.
 Map<CLDevice,CLProgram.Status> getBuildStatus()
          Returns the build status enum of this program for each device as Map.
 CLProgram.Status getBuildStatus(CLDevice device)
          Returns the build status enum for this program on the specified device.
 CLDevice[] getCLDevices()
          Returns all devices associated with this program.
 String getSource()
          Returns the source code of this program.
 int hashCode()
           
 boolean isExecutable()
          Returns true if the build status 'BUILD_SUCCESS' for at least one device of this program exists.
 boolean isReleased()
          Returns true if CLResource.release() has been called.
static String optionsOf(String... options)
          Utility method which builds a properly seperated option string.
 CLProgramConfiguration prepare()
          Prepares the build for this program by returning a new CLProgramConfiguration.
 void release()
          Releases this program with its kernels.
 String toString()
           
 
Methods inherited from class com.jogamp.opencl.CLObject
getContext, getID, getPlatform
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

build

public CLProgram build()
Builds this program for all devices associated with the context.

Returns:
this

build

public CLProgram build(CLBuildListener listener)
Builds this program for all devices associated with the context.

Parameters:
listener - A listener who is notified when the program was built.
Returns:
this
See Also:
CLBuildListener

build

public CLProgram build(CLDevice... devices)
Builds this program for the given devices.

Parameters:
devices - A list of devices this program should be build on or null for all devices of its context.
Returns:
this

build

public CLProgram build(CLBuildListener listener,
                       CLDevice... devices)
Builds this program for the given devices.

Parameters:
listener - A listener who is notified when the program was built.
devices - A list of devices this program should be build on or null for all devices of its context.
Returns:
this
See Also:
CLBuildListener

build

public CLProgram build(String options)
Builds this program for all devices associated with the context using the specified build options.

Returns:
this
See Also:
CLProgram.CompilerOptions

build

public CLProgram build(CLBuildListener listener,
                       String options)
Builds this program for all devices associated with the context using the specified build options.

Parameters:
listener - A listener who is notified when the program was built.
Returns:
this
See Also:
CLProgram.CompilerOptions, CLBuildListener

build

public CLProgram build(String... options)
Builds this program for all devices associated with the context using the specified build options.

See Also:
CLProgram.CompilerOptions

build

public CLProgram build(CLBuildListener listener,
                       String... options)
Builds this program for all devices associated with the context using the specified build options.

Parameters:
listener - A listener who is notified when the program was built.
See Also:
CLProgram.CompilerOptions, CLBuildListener

build

public CLProgram build(String options,
                       CLDevice... devices)
Builds this program for the given devices and with the specified build options. In case this program was already built and there are kernels associated with this program they will be released first before rebuild.

Parameters:
devices - A list of devices this program should be build on or null for all devices of its context.
Returns:
this
See Also:
CLProgram.CompilerOptions

build

public CLProgram build(CLBuildListener listener,
                       String options,
                       CLDevice... devices)
Builds this program for the given devices and with the specified build options. In case this program was already built and there are kernels associated with this program they will be released first before rebuild.

Parameters:
devices - A list of devices this program should be build on or null for all devices of its context.
listener - A listener who is notified when the program was built.
Returns:
this
See Also:
CLProgram.CompilerOptions, CLBuildListener

prepare

public CLProgramConfiguration prepare()
Prepares the build for this program by returning a new CLProgramConfiguration.


createCLKernel

public CLKernel createCLKernel(String kernelName)
Creates a kernel with the specified kernel name.


createCLKernels

public Map<String,CLKernel> createCLKernels()
Creates all kernels of this program and stores them a Map with the kernel name as key.


release

public void release()
Releases this program with its kernels.

Specified by:
release in interface CLResource

getCLDevices

public CLDevice[] getCLDevices()
Returns all devices associated with this program.


getBuildLog

public String getBuildLog()
Returns the build log of this program on all devices. The contents of the log are implementation dependent.


getBuildStatus

public Map<CLDevice,CLProgram.Status> getBuildStatus()
Returns the build status enum of this program for each device as Map.


isExecutable

public boolean isExecutable()
Returns true if the build status 'BUILD_SUCCESS' for at least one device of this program exists.


getBuildLog

public String getBuildLog(CLDevice device)
Returns the build log for this program on the specified device. The contents of the log are implementation dependent log can be an empty String.


getBuildStatus

public CLProgram.Status getBuildStatus(CLDevice device)
Returns the build status enum for this program on the specified device.


getSource

public String getSource()
Returns the source code of this program. Note: sources are not cached, each call of this method calls into Open


getBinaries

public Map<CLDevice,byte[]> getBinaries()
Returns the binaries for this program in an ordered Map containing the device as key and the program binaries as value.


optionsOf

public static String optionsOf(String... options)
Utility method which builds a properly seperated option string.


define

public static String define(String name)
Utility method for defining macros as build options (Returns "-D name").


define

public static String define(String name,
                            Object value)
Utility method for defining macros as build options (Returns "-D name=value").


toString

public String toString()
Overrides:
toString in class CLObject

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

close

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

Implementation detail, satisfying AutoCloseable. Might be remove as soon we have extension methods, but shall validate with Java 1.5 specs.

Specified by:
close in interface AutoCloseable
See Also:
AutoCloseable

isReleased

public boolean isReleased()
Description copied from interface: CLResource
Returns true if CLResource.release() has been called.

Specified by:
isReleased in interface CLResource