Package com.jogamp.opencl
Class CLProgramBuilder
- java.lang.Object
-
- com.jogamp.opencl.CLProgramBuilder
-
- All Implemented Interfaces:
CLBuildConfiguration
,CLProgramConfiguration
,Serializable
,Cloneable
public final class CLProgramBuilder extends Object implements CLProgramConfiguration, Serializable, Cloneable
CLProgramBuilder is a helper for building programs with more complex configurations or building multiple programs with similar configurations. CLProgramBuilder is used to createCLProgramConfiguration
s andCLBuildConfiguration
s.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CLProgramBuilder
asBuildConfiguration()
Returns a new instance of of this configuration without aCLProgram
, program binaries or sources associated with it.CLProgram
build()
Builds or rebuilds a program.CLProgram
build(CLProgram program)
Builds or rebuilds the program.CLProgram
build(CLProgram program, CLBuildListener listener)
Builds or rebuilds the program.CLProgram
build(CLBuildListener listener)
Builds or rebuilds a program.CLProgramBuilder
clone()
Clones this configuration.static CLBuildConfiguration
createConfiguration()
Creates a new CLBuildConfiguration.static CLProgramConfiguration
createConfiguration(CLProgram program)
Creates a new CLProgramConfiguration for this program.boolean
equals(Object o)
CLProgramBuilder
forDevice(CLDevice device)
Adds the device as build target.CLProgramBuilder
forDevices(CLDevice... devices)
Adds the devices as build target.CLProgram
getProgram()
Returns the program.int
hashCode()
static CLBuildConfiguration
loadConfiguration(ObjectInputStream ois)
Loads a CLBuildConfiguration.static CLProgramConfiguration
loadConfiguration(ObjectInputStream ois, CLContext context)
Loads a CLProgramConfiguration containing a CLProgram.CLProgramBuilder
reset()
Resets this builder's configuration like options, devices and definitions.CLProgramConfiguration
resetDefines()
Resets this builder's macro definitions.CLProgramConfiguration
resetDevices()
Resets this builder's device list.CLProgramConfiguration
resetOptions()
Resets this builder's configuration options.void
save(ObjectOutputStream oos)
Saves this configuration to the ObjectOutputStream.CLProgramBuilder
setProgram(CLProgram program)
Sets the program which should be build.String
toString()
CLProgramBuilder
withDefine(String name)
Adds the definition to the build configuration.CLProgramBuilder
withDefine(String name, Object value)
Adds the definition to the build configuration.CLProgramBuilder
withDefines(String... names)
Adds the definitions to the build configuration.CLProgramBuilder
withDefines(Map<String,? extends Object> defines)
Adds the definitions to the build configuration.CLProgramBuilder
withOption(String option)
Adds the compiler option to the build configuration.CLProgramBuilder
withOptions(String... options)
Adds the compiler options to the build configuration.
-
-
-
Method Detail
-
createConfiguration
public static CLBuildConfiguration createConfiguration()
Creates a new CLBuildConfiguration.
-
createConfiguration
public static CLProgramConfiguration createConfiguration(CLProgram program)
Creates a new CLProgramConfiguration for this program.
-
loadConfiguration
public static CLBuildConfiguration loadConfiguration(ObjectInputStream ois) throws IOException, ClassNotFoundException
Loads a CLBuildConfiguration.- Parameters:
ois
- The ObjectInputStream for reading the object.- Throws:
IOException
ClassNotFoundException
-
loadConfiguration
public static CLProgramConfiguration loadConfiguration(ObjectInputStream ois, 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
- The ObjectInputStream for reading the object.context
- The context used for program initialization.- Throws:
IOException
ClassNotFoundException
-
save
public void save(ObjectOutputStream oos) throws IOException
Description copied from interface:CLBuildConfiguration
Saves this configuration to the ObjectOutputStream. The caller is responsible for closing the stream.- Specified by:
save
in interfaceCLBuildConfiguration
- Throws:
IOException
-
withOption
public CLProgramBuilder withOption(String option)
Description copied from interface:CLBuildConfiguration
Adds the compiler option to the build configuration.- Specified by:
withOption
in interfaceCLBuildConfiguration
- Specified by:
withOption
in interfaceCLProgramConfiguration
- See Also:
CLProgram.CompilerOptions
-
withOptions
public CLProgramBuilder withOptions(String... options)
Description copied from interface:CLBuildConfiguration
Adds the compiler options to the build configuration.- Specified by:
withOptions
in interfaceCLBuildConfiguration
- Specified by:
withOptions
in interfaceCLProgramConfiguration
- See Also:
CLProgram.CompilerOptions
-
withDefine
public CLProgramBuilder withDefine(String name)
Description copied from interface:CLBuildConfiguration
Adds the definition to the build configuration.- Specified by:
withDefine
in interfaceCLBuildConfiguration
- Specified by:
withDefine
in interfaceCLProgramConfiguration
- See Also:
CLProgram.define(java.lang.String)
-
withDefines
public CLProgramBuilder withDefines(String... names)
Description copied from interface:CLBuildConfiguration
Adds the definitions to the build configuration.- Specified by:
withDefines
in interfaceCLBuildConfiguration
- Specified by:
withDefines
in interfaceCLProgramConfiguration
- See Also:
CLProgram.define(java.lang.String)
-
withDefine
public CLProgramBuilder withDefine(String name, Object value)
Description copied from interface:CLBuildConfiguration
Adds the definition to the build configuration.- Specified by:
withDefine
in interfaceCLBuildConfiguration
- Specified by:
withDefine
in interfaceCLProgramConfiguration
- See Also:
CLProgram.define(java.lang.String, java.lang.Object)
-
withDefines
public CLProgramBuilder withDefines(Map<String,? extends Object> defines)
Description copied from interface:CLBuildConfiguration
Adds the definitions to the build configuration.- Specified by:
withDefines
in interfaceCLBuildConfiguration
- Specified by:
withDefines
in interfaceCLProgramConfiguration
- See Also:
CLProgram.define(java.lang.String, java.lang.Object)
-
forDevice
public CLProgramBuilder forDevice(CLDevice device)
Description copied from interface:CLBuildConfiguration
Adds the device as build target.- Specified by:
forDevice
in interfaceCLBuildConfiguration
- Specified by:
forDevice
in interfaceCLProgramConfiguration
-
forDevices
public CLProgramBuilder forDevices(CLDevice... devices)
Description copied from interface:CLBuildConfiguration
Adds the devices as build target.- Specified by:
forDevices
in interfaceCLBuildConfiguration
- Specified by:
forDevices
in interfaceCLProgramConfiguration
-
build
public CLProgram build()
Description copied from interface:CLProgramConfiguration
Builds or rebuilds a program.- Specified by:
build
in interfaceCLProgramConfiguration
-
build
public CLProgram build(CLBuildListener listener)
Description copied from interface:CLProgramConfiguration
Builds or rebuilds a program.- Specified by:
build
in interfaceCLProgramConfiguration
- Parameters:
listener
- The callback who will be notified when the program has built.
-
build
public CLProgram build(CLProgram program)
Description copied from interface:CLBuildConfiguration
Builds or rebuilds the program.- Specified by:
build
in interfaceCLBuildConfiguration
- Parameters:
program
- The program which should be build.
-
build
public CLProgram build(CLProgram program, CLBuildListener listener)
Description copied from interface:CLBuildConfiguration
Builds or rebuilds the program.- Specified by:
build
in interfaceCLBuildConfiguration
- Parameters:
program
- The program which should be build.listener
- The callback who is notified when the program has built.
-
reset
public CLProgramBuilder reset()
Description copied from interface:CLBuildConfiguration
Resets this builder's configuration like options, devices and definitions.- Specified by:
reset
in interfaceCLBuildConfiguration
- Specified by:
reset
in interfaceCLProgramConfiguration
-
resetDefines
public CLProgramConfiguration resetDefines()
Description copied from interface:CLBuildConfiguration
Resets this builder's macro definitions.- Specified by:
resetDefines
in interfaceCLBuildConfiguration
- Specified by:
resetDefines
in interfaceCLProgramConfiguration
-
resetDevices
public CLProgramConfiguration resetDevices()
Description copied from interface:CLBuildConfiguration
Resets this builder's device list.- Specified by:
resetDevices
in interfaceCLBuildConfiguration
- Specified by:
resetDevices
in interfaceCLProgramConfiguration
-
resetOptions
public CLProgramConfiguration resetOptions()
Description copied from interface:CLBuildConfiguration
Resets this builder's configuration options.- Specified by:
resetOptions
in interfaceCLBuildConfiguration
- Specified by:
resetOptions
in interfaceCLProgramConfiguration
-
asBuildConfiguration
public CLProgramBuilder asBuildConfiguration()
Description copied from interface:CLProgramConfiguration
Returns a new instance of of this configuration without aCLProgram
, program binaries or sources associated with it.- Specified by:
asBuildConfiguration
in interfaceCLProgramConfiguration
-
clone
public CLProgramBuilder clone()
Description copied from interface:CLBuildConfiguration
Clones this configuration.- Specified by:
clone
in interfaceCLBuildConfiguration
- Specified by:
clone
in interfaceCLProgramConfiguration
- Overrides:
clone
in classObject
-
getProgram
public CLProgram getProgram()
Description copied from interface:CLProgramConfiguration
Returns the program.- Specified by:
getProgram
in interfaceCLProgramConfiguration
-
setProgram
public CLProgramBuilder setProgram(CLProgram program)
Description copied from interface:CLBuildConfiguration
Sets the program which should be build.- Specified by:
setProgram
in interfaceCLBuildConfiguration
-
-