Package com.jogamp.opencl
Class CLProgram
- java.lang.Object
-
- com.jogamp.opencl.CLObject
-
- com.jogamp.opencl.CLProgram
-
- All Implemented Interfaces:
AutoCloseable
,CLResource
,AutoCloseable
public class CLProgram extends CLObject
Represents a OpenCL program executed on one or moreCLDevice
s. A CLProgram must be build using one of the build methods before creatingCLKernel
s.- 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
Nested Classes Modifier and Type Class Description static interface
CLProgram.CompilerOptions
Common compiler options for the OpenCL compiler.static class
CLProgram.Status
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CLProgram
build()
Builds this program for all devices associated with the context.CLProgram
build(CLDevice... devices)
Builds this program for the given devices.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(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 ifCLResource.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 newCLProgramConfiguration
.void
release()
Releases this program with its kernels.void
setNoSource()
Must set this if the program is created from binary so we know not to call getSource(), which can SIGSEGV on Macs if there is no source.String
toString()
-
Methods inherited from class com.jogamp.opencl.CLObject
getContext, getID, getPlatform
-
-
-
-
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 newCLProgramConfiguration
.
-
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 interfaceCLResource
-
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.
-
setNoSource
public void setNoSource()
Must set this if the program is created from binary so we know not to call getSource(), which can SIGSEGV on Macs if there is no source.
-
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").
-
close
@Deprecated public final void close()
Deprecated.This method is not intended to be called from client code.Implementation detail, satisfyingAutoCloseable
. Might be remove as soon we have extension methods, but shall validate with Java 1.5 specs.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceAutoCloseable
- See Also:
AutoCloseable
-
isReleased
public boolean isReleased()
Description copied from interface:CLResource
Returns true ifCLResource.release()
has been called.- Specified by:
isReleased
in interfaceCLResource
-
-