Package com.jogamp.opencl
Class CLProgram
- java.lang.Object
-
- com.jogamp.opencl.CLObject
-
- com.jogamp.opencl.CLProgram
-
- All Implemented Interfaces:
AutoCloseable,CLResource
public class CLProgram extends CLObject
Represents a OpenCL program executed on one or moreCLDevices. A CLProgram must be build using one of the build methods before creatingCLKernels.- 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 interfaceCLProgram.CompilerOptionsCommon compiler options for the OpenCL compiler.static classCLProgram.Status
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CLProgrambuild()Builds this program for all devices associated with the context.CLProgrambuild(CLDevice... devices)Builds this program for the given devices.CLProgrambuild(CLBuildListener listener)Builds this program for all devices associated with the context.CLProgrambuild(CLBuildListener listener, CLDevice... devices)Builds this program for the given devices.CLProgrambuild(CLBuildListener listener, String options)Builds this program for all devices associated with the context using the specified build options.CLProgrambuild(CLBuildListener listener, String... options)Builds this program for all devices associated with the context using the specified build options.CLProgrambuild(CLBuildListener listener, String options, CLDevice... devices)Builds this program for the given devices and with the specified build options.CLProgrambuild(String options)Builds this program for all devices associated with the context using the specified build options.CLProgrambuild(String... options)Builds this program for all devices associated with the context using the specified build options.CLProgrambuild(String options, CLDevice... devices)Builds this program for the given devices and with the specified build options.voidclose()Deprecated.This method is not intended to be called from client code.CLKernelcreateCLKernel(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 Stringdefine(String name)Utility method for defining macros as build options (Returns "-D name").static Stringdefine(String name, Object value)Utility method for defining macros as build options (Returns "-D name=value").booleanequals(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.StringgetBuildLog()Returns the build log of this program on all devices.StringgetBuildLog(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.StatusgetBuildStatus(CLDevice device)Returns the build status enum for this program on the specified device.CLDevice[]getCLDevices()Returns all devices associated with this program.StringgetSource()Returns the source code of this program.inthashCode()booleanisExecutable()Returns true if the build status 'BUILD_SUCCESS' for at least one device of this program exists.booleanisReleased()Returns true ifCLResource.release()has been called.static StringoptionsOf(String... options)Utility method which builds a properly seperated option string.CLProgramConfigurationprepare()Prepares the build for this program by returning a newCLProgramConfiguration.voidrelease()Releases this program with its kernels.voidsetNoSource()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.StringtoString()-
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:
releasein 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:
closein interfaceAutoCloseable- See Also:
AutoCloseable
-
isReleased
public boolean isReleased()
Description copied from interface:CLResourceReturns true ifCLResource.release()has been called.- Specified by:
isReleasedin interfaceCLResource
-
-