Top Description Fields Constructors Methods
com.jogamp.opencl

public final Class CLProgramBuilder

extends Object
implements CLProgramConfiguration, Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable, com.jogamp.opencl.util.CLProgramConfiguration, com.jogamp.opencl.util.CLBuildConfiguration
Imports
com.jogamp.opencl.util.CLBuildConfiguration, .CLBuildListener, .CLProgramConfiguration, java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serializable, java.util.ArrayList, .Arrays, .Collections, .Iterator, .LinkedHashMap, .LinkedHashSet, .List, .Map, .Set

CLProgramBuilder is a helper for building programs with more complex configurations or building multiple programs with similar configurations. CLProgramBuilder is used to create CLProgramConfigurations and CLBuildConfigurations.
Author
Michael Bien
See Also
CLProgram#prepare(), createConfiguration(), createConfiguration(com.jogamp.opencl.CLProgram), loadConfiguration(java.io.ObjectInputStream), loadConfiguration(java.io.ObjectInputStream, com.jogamp.opencl.CLContext)

Field Summary

Modifier and TypeField and Description
private transient Map<CLDevice, byte[]>
private final Set<String>
private static final byte[]
private final Set<String>
private transient CLProgram
pack-priv static final long
private String

Constructor Summary

AccessConstructor and Description
private
private
CLProgramBuilder(final CLProgram program)

private
CLProgramBuilder(final CLProgram program, final String source, final Map<CLDevice, byte[]> map)

Method Summary

Modifier and TypeMethod and Description
private static boolean
public CLProgramBuilder
asBuildConfiguration()

Implements com.jogamp.opencl.util.CLProgramConfiguration.asBuildConfiguration.

Returns a new instance of of this configuration without a CLProgram, program binaries or sources associated with it.
public CLProgram
build()

Implements com.jogamp.opencl.util.CLProgramConfiguration.build.

Builds or rebuilds a program.
public CLProgram
build(final CLBuildListener
The callback who will be notified when the program has built.
listener
)

Implements com.jogamp.opencl.util.CLProgramConfiguration.build.

Builds or rebuilds a program.
public CLProgram
build(final CLProgram
The program which should be build.
program
)

Implements com.jogamp.opencl.util.CLBuildConfiguration.build.

Builds or rebuilds the program.
public CLProgram
build(final CLProgram
The program which should be build.
program
,
final CLBuildListener
The callback who is notified when the program has built.
listener
)

Implements com.jogamp.opencl.util.CLBuildConfiguration.build.

Builds or rebuilds the program.
public CLProgramBuilder
clone()

Overrides java.lang.Object.clone.

Implements com.jogamp.opencl.util.CLProgramConfiguration.clone.

Clones this configuration.
public static CLBuildConfiguration
createConfiguration()

Creates a new CLBuildConfiguration.

public static CLProgramConfiguration
createConfiguration(final CLProgram program)

Creates a new CLProgramConfiguration for this program.

public boolean
equals(final Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public CLProgramBuilder
forDevice(final CLDevice device)

Implements com.jogamp.opencl.util.CLProgramConfiguration.forDevice.

Adds the device as build target.
public CLProgramBuilder
forDevices(final CLDevice... devices)

Implements com.jogamp.opencl.util.CLProgramConfiguration.forDevices.

Adds the devices as build target.
public CLProgram
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public static CLBuildConfiguration
loadConfiguration(final ObjectInputStream
The ObjectInputStream for reading the object.
ois
)

Loads a CLBuildConfiguration.

public static CLProgramConfiguration
loadConfiguration(final ObjectInputStream
The ObjectInputStream for reading the object.
ois
,
final CLContext
The context used for program initialization.
context
)

Loads a CLProgramConfiguration containing a CLProgram.

private void
public CLProgramBuilder
reset()

Implements com.jogamp.opencl.util.CLProgramConfiguration.reset.

Resets this builder's configuration like options, devices and definitions.
public CLProgramConfiguration
resetDefines()

Implements com.jogamp.opencl.util.CLProgramConfiguration.resetDefines.

Resets this builder's macro definitions.
public CLProgramConfiguration
resetDevices()

Implements com.jogamp.opencl.util.CLProgramConfiguration.resetDevices.

Resets this builder's device list.
public CLProgramConfiguration
resetOptions()

Implements com.jogamp.opencl.util.CLProgramConfiguration.resetOptions.

Resets this builder's configuration options.
public void
save(final ObjectOutputStream oos)

Implements com.jogamp.opencl.util.CLBuildConfiguration.save.

Saves this configuration to the ObjectOutputStream.
public CLProgramBuilder
setProgram(final CLProgram program)

Implements com.jogamp.opencl.util.CLBuildConfiguration.setProgram.

Sets the program which should be build.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public CLProgramBuilder
withDefine(final String name)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withDefine.

Adds the definition to the build configuration.
public CLProgramBuilder
withDefine(final String name, final Object value)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withDefine.

Adds the definition to the build configuration.
public CLProgramBuilder
withDefines(final String... names)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withDefines.

Adds the definitions to the build configuration.
public CLProgramBuilder
withDefines(final Map<String, ? extends Object> defines)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withDefines.

Adds the definitions to the build configuration.
public CLProgramBuilder
withOption(final String option)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withOption.

Adds the compiler option to the build configuration.
public CLProgramBuilder
withOptions(final String... options)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withOptions.

Adds the compiler options to the build configuration.
private void
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

binariesMapback to summary
private transient Map<CLDevice, byte[]> binariesMap
defineSetback to summary
private final Set<String> defineSet
NO_BINARIESback to summary
private static final byte[] NO_BINARIES
optionSetback to summary
private final Set<String> optionSet
programback to summary
private transient CLProgram program
serialVersionUIDback to summary
pack-priv static final long serialVersionUID
sourceback to summary
private String source

Constructor Detail

CLProgramBuilderback to summary
private CLProgramBuilder()
CLProgramBuilderback to summary
private CLProgramBuilder(final CLProgram program)
CLProgramBuilderback to summary
private CLProgramBuilder(final CLProgram program, final String source, final Map<CLDevice, byte[]> map)

Method Detail

allBinariesAvailableback to summary
private static boolean allBinariesAvailable(final CLProgramBuilder config)
asBuildConfigurationback to summary
public CLProgramBuilder asBuildConfiguration()

Implements com.jogamp.opencl.util.CLProgramConfiguration.asBuildConfiguration.

Doc from com.jogamp.opencl.util.CLProgramConfiguration.asBuildConfiguration.

Returns a new instance of of this configuration without a CLProgram, program binaries or sources associated with it.

Annotations
@Override
buildback to summary
public CLProgram build()

Implements com.jogamp.opencl.util.CLProgramConfiguration.build.

Doc from com.jogamp.opencl.util.CLProgramConfiguration.build.

Builds or rebuilds a program.

Annotations
@Override
buildback to summary
public CLProgram build(final CLBuildListener listener)

Implements com.jogamp.opencl.util.CLProgramConfiguration.build.

Doc from com.jogamp.opencl.util.CLProgramConfiguration.build.

Builds or rebuilds a program.

Parameters
listener:CLBuildListener

The callback who will be notified when the program has built.

Annotations
@Override
buildback to summary
public CLProgram build(final CLProgram program)

Implements com.jogamp.opencl.util.CLBuildConfiguration.build.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.build.

Builds or rebuilds the program.

Parameters
program:CLProgram

The program which should be build.

Annotations
@Override
buildback to summary
public CLProgram build(final CLProgram program, final CLBuildListener listener)

Implements com.jogamp.opencl.util.CLBuildConfiguration.build.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.build.

Builds or rebuilds the program.

Parameters
program:CLProgram

The program which should be build.

listener:CLBuildListener

The callback who is notified when the program has built.

Annotations
@Override
cloneback to summary
public CLProgramBuilder clone()

Overrides java.lang.Object.clone.

Implements com.jogamp.opencl.util.CLProgramConfiguration.clone.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.clone.

Clones this configuration.

Returns:CLProgramBuilder

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
createConfigurationback to summary
public static CLBuildConfiguration createConfiguration()

Creates a new CLBuildConfiguration.

createConfigurationback to summary
public static CLProgramConfiguration createConfiguration(final CLProgram program)

Creates a new CLProgramConfiguration for this program.

equalsback to summary
public boolean equals(final Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
forDeviceback to summary
public CLProgramBuilder forDevice(final CLDevice device)

Implements com.jogamp.opencl.util.CLProgramConfiguration.forDevice.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.forDevice.

Adds the device as build target.

Annotations
@Override
forDevicesback to summary
public CLProgramBuilder forDevices(final CLDevice... devices)

Implements com.jogamp.opencl.util.CLProgramConfiguration.forDevices.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.forDevices.

Adds the devices as build target.

Annotations
@Override
getProgramback to summary
public CLProgram getProgram()

Implements com.jogamp.opencl.util.CLProgramConfiguration.getProgram.

Doc from com.jogamp.opencl.util.CLProgramConfiguration.getProgram.

Returns the program.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
loadConfigurationback to summary
public static CLBuildConfiguration loadConfiguration(final ObjectInputStream ois) throws IOException, ClassNotFoundException

Loads a CLBuildConfiguration.

Parameters
ois:ObjectInputStream

The ObjectInputStream for reading the object.

loadConfigurationback to summary
public static CLProgramConfiguration loadConfiguration(final ObjectInputStream ois, final CLContext context) throws IOException, ClassNotFoundException

Loads a CLProgramConfiguration containing a CLProgram. The CLProgram is initialized and ready to be build after this method call. This method prefers program initialization from binaries if this fails or if no binaries have been found, it will try to load the program from sources. If this also fails an appropriate exception will be thrown.

Parameters
ois:ObjectInputStream

The ObjectInputStream for reading the object.

context:CLContext

The context used for program initialization.

readObjectback to summary
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException
resetback to summary
public CLProgramBuilder reset()

Implements com.jogamp.opencl.util.CLProgramConfiguration.reset.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.reset.

Resets this builder's configuration like options, devices and definitions.

Annotations
@Override
resetDefinesback to summary
public CLProgramConfiguration resetDefines()

Implements com.jogamp.opencl.util.CLProgramConfiguration.resetDefines.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.resetDefines.

Resets this builder's macro definitions.

Annotations
@Override
resetDevicesback to summary
public CLProgramConfiguration resetDevices()

Implements com.jogamp.opencl.util.CLProgramConfiguration.resetDevices.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.resetDevices.

Resets this builder's device list.

Annotations
@Override
resetOptionsback to summary
public CLProgramConfiguration resetOptions()

Implements com.jogamp.opencl.util.CLProgramConfiguration.resetOptions.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.resetOptions.

Resets this builder's configuration options.

Annotations
@Override
saveback to summary
public void save(final ObjectOutputStream oos) throws IOException

Implements com.jogamp.opencl.util.CLBuildConfiguration.save.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.save.

Saves this configuration to the ObjectOutputStream. The caller is responsible for closing the stream.

Annotations
@Override
setProgramback to summary
public CLProgramBuilder setProgram(final CLProgram program)

Implements com.jogamp.opencl.util.CLBuildConfiguration.setProgram.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.setProgram.

Sets the program which should be build.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
withDefineback to summary
public CLProgramBuilder withDefine(final String name)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withDefine.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.withDefine.

Adds the definition to the build configuration.

Annotations
@Override
withDefineback to summary
public CLProgramBuilder withDefine(final String name, final Object value)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withDefine.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.withDefine.

Adds the definition to the build configuration.

Annotations
@Override
withDefinesback to summary
public CLProgramBuilder withDefines(final String... names)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withDefines.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.withDefines.

Adds the definitions to the build configuration.

Annotations
@Override
withDefinesback to summary
public CLProgramBuilder withDefines(final Map<String, ? extends Object> defines)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withDefines.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.withDefines.

Adds the definitions to the build configuration.

Annotations
@Override
withOptionback to summary
public CLProgramBuilder withOption(final String option)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withOption.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.withOption.

Adds the compiler option to the build configuration.

Annotations
@Override
withOptionsback to summary
public CLProgramBuilder withOptions(final String... options)

Implements com.jogamp.opencl.util.CLProgramConfiguration.withOptions.

Doc from com.jogamp.opencl.util.CLBuildConfiguration.withOptions.

Adds the compiler options to the build configuration.

Annotations
@Override
writeObjectback to summary
private void writeObject(final ObjectOutputStream out) throws IOException