Top Description Inners Fields Constructors Methods
com.jogamp.opencl

public Class CLProgram

extends CLObjectResource
Class Inheritance
Imports
com.jogamp.common.nio.CachedBufferFactory, .PointerBuffer, com.jogamp.opencl.llb.CLProgramBinding, .CLKernelBinding, com.jogamp.opencl.util.CLProgramConfiguration, .CLUtil, .CLBuildListener, com.jogamp.common.os.Platform, com.jogamp.opencl.llb.impl.BuildProgramCallback, java.nio.ByteBuffer, .IntBuffer, java.util.Collections, .HashMap, .HashSet, .LinkedHashMap, .Map.Entry, .Set, .Map, java.util.concurrent.locks.ReentrantLock

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 and Inner Type Summary

Modifier and TypeClass and Description
public static interface
CLProgram.CompilerOptions

Common compiler options for the OpenCL compiler.

public static enum

Field Summary

Modifier and TypeField and Description
private final CLProgramBinding
private static final ReentrantLock
private Map<CLDevice, CLProgram.Status>
private boolean
private final Set<CLKernel>
private boolean
noSource

Set if program created from binary, or else getting source can crash the driver on Macs.

private boolean

Constructor Summary

AccessConstructor and Description
private
CLProgram(final CLContext context, final long id)

Method Summary

Modifier and TypeMethod and Description
public CLProgram

Returns:

this
build
()

Builds this program for all devices associated with the context.

public CLProgram

Returns:

this
build
(final CLBuildListener
A listener who is notified when the program was built.
listener
)

Builds this program for all devices associated with the context.

public CLProgram

Returns:

this
build
(final CLDevice...
A list of devices this program should be build on or null for all devices of its context.
devices
)

Builds this program for the given devices.

public CLProgram

Returns:

this
build
(final CLBuildListener
A listener who is notified when the program was built.
listener
,
final CLDevice...
A list of devices this program should be build on or null for all devices of its context.
devices
)

Builds this program for the given devices.

public CLProgram

Returns:

this
build
(final String options)

Builds this program for all devices associated with the context using the specified build options.

public CLProgram

Returns:

this
build
(final CLBuildListener
A listener who is notified when the program was built.
listener
,
final String options)

Builds this program for all devices associated with the context using the specified build options.

public CLProgram
build(final String... options)

Builds this program for all devices associated with the context using the specified build options.

public CLProgram
build(final CLBuildListener
A listener who is notified when the program was built.
listener
,
final String... options)

Builds this program for all devices associated with the context using the specified build options.

public CLProgram

Returns:

this
build
(final String options, final CLDevice...
A list of devices this program should be build on or null for all devices of its context.
devices
)

Builds this program for the given devices and with the specified build options.

public CLProgram

Returns:

this
build
(final CLBuildListener
A listener who is notified when the program was built.
listener
,
String options, final CLDevice...
A list of devices this program should be build on or null for all devices of its context.
devices
)

Builds this program for the given devices and with the specified build options.

pack-priv static CLProgram
create(final CLContext context, final String src)

pack-priv static CLProgram
create(final CLContext context, final Map<CLDevice, byte[]> binaries)

public CLKernel
createCLKernel(final String kernelName)

Creates a kernel with the specified kernel name.

public Map<String, CLKernel>
createCLKernels()

Creates all kernels of this program and stores them a Map with the kernel name as key.

public static String
define(final String name)

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

public static String
define(final String name, final Object value)

Utility method for defining macros as build options (Returns "-D name=value").

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

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
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.

private int
getBuildInfoInt(final CLDevice device, final int flag)

private String
getBuildInfoString(final CLDevice device, final int flag)

public String
getBuildLog()

Returns the build log of this program on all devices.

public String
getBuildLog(final CLDevice device)

Returns the build log for this program on the specified device.

public Map<CLDevice, CLProgram.Status>
getBuildStatus()

Returns the build status enum of this program for each device as Map.

public CLProgram.Status
getBuildStatus(final CLDevice device)

Returns the build status enum for this program on the specified device.

public CLDevice[]
getCLDevices()

Returns all devices associated with this program.

private CLKernelBinding
private String
getProgramInfoString(final int flag)

public String
getSource()

Returns the source code of this program.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
private void
public boolean
isExecutable()

Returns true if the build status 'BUILD_SUCCESS' for at least one device of this program exists.

pack-priv void
onKernelReleased(final CLKernel kernel)

public static String
optionsOf(final String... options)

Utility method which builds a properly seperated option string.

public CLProgramConfiguration
prepare()

Prepares the build for this program by returning a new CLProgramConfiguration.

public void
release()

Overrides com.jogamp.opencl.CLObjectResource.release.

Implements com.jogamp.opencl.CLResource.release.

Releases this program with its kernels.
private void
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.

public String
toString()

Overrides com.jogamp.opencl.CLObject.toString.

Returns a string representation of the object.
Inherited from com.jogamp.opencl.CLObjectResource:
closeisReleased

Field Detail

bindingback to summary
private final CLProgramBinding binding
buildLockback to summary
private static final ReentrantLock buildLock
buildStatusMapback to summary
private Map<CLDevice, CLProgram.Status> buildStatusMap
executableback to summary
private boolean executable
kernelsback to summary
private final Set<CLKernel> kernels
noSourceback to summary
private boolean noSource

Set if program created from binary, or else getting source can crash the driver on Macs.

releasedback to summary
private boolean released

Hides com.jogamp.opencl.CLObjectResource.released.

Constructor Detail

CLProgramback to summary
private CLProgram(final CLContext context, final long id)

Method Detail

buildback to summary
public CLProgram build()

Builds this program for all devices associated with the context.

Returns:CLProgram

this

buildback to summary
public CLProgram build(final CLBuildListener listener)

Builds this program for all devices associated with the context.

Parameters
listener:CLBuildListener

A listener who is notified when the program was built.

Returns:CLProgram

this

See Also
CLBuildListener
buildback to summary
public CLProgram build(final CLDevice... devices)

Builds this program for the given devices.

Parameters
devices:CLDevice[]

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

Returns:CLProgram

this

buildback to summary
public CLProgram build(final CLBuildListener listener, final CLDevice... devices)

Builds this program for the given devices.

Parameters
listener:CLBuildListener

A listener who is notified when the program was built.

devices:CLDevice[]

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

Returns:CLProgram

this

See Also
CLBuildListener
buildback to summary
public CLProgram build(final String options)

Builds this program for all devices associated with the context using the specified build options.

Returns:CLProgram

this

See Also
CompilerOptions
buildback to summary
public CLProgram build(final CLBuildListener listener, final String options)

Builds this program for all devices associated with the context using the specified build options.

Parameters
listener:CLBuildListener

A listener who is notified when the program was built.

Returns:CLProgram

this

See Also
CompilerOptions, CLBuildListener
buildback to summary
public CLProgram build(final String... options)

Builds this program for all devices associated with the context using the specified build options.

See Also
CompilerOptions
buildback to summary
public CLProgram build(final CLBuildListener listener, final String... options)

Builds this program for all devices associated with the context using the specified build options.

Parameters
listener:CLBuildListener

A listener who is notified when the program was built.

See Also
CompilerOptions, CLBuildListener
buildback to summary
public CLProgram build(final String options, final 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:CLDevice[]

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

Returns:CLProgram

this

See Also
CompilerOptions
buildback to summary
public CLProgram build(final CLBuildListener listener, String options, final 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
listener:CLBuildListener

A listener who is notified when the program was built.

devices:CLDevice[]

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

Returns:CLProgram

this

See Also
CompilerOptions, CLBuildListener
createback to summary
pack-priv static CLProgram create(final CLContext context, final String src)
createback to summary
pack-priv static CLProgram create(final CLContext context, final Map<CLDevice, byte[]> binaries)
createCLKernelback to summary
public CLKernel createCLKernel(final String kernelName)

Creates a kernel with the specified kernel name.

createCLKernelsback to summary
public Map<String, CLKernel> createCLKernels()

Creates all kernels of this program and stores them a Map with the kernel name as key.

defineback to summary
public static String define(final String name)

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

defineback to summary
public static String define(final String name, final Object value)

Utility method for defining macros as build options (Returns "-D name=value").

equalsback to summary
public boolean equals(final Object obj)

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
obj: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
getBinariesback to summary
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.

getBuildInfoIntback to summary
private int getBuildInfoInt(final CLDevice device, final int flag)
getBuildInfoStringback to summary
private String getBuildInfoString(final CLDevice device, final int flag)
getBuildLogback to summary
public String getBuildLog()

Returns the build log of this program on all devices. The contents of the log are implementation dependent.

getBuildLogback to summary
public String getBuildLog(final 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.

getBuildStatusback to summary
public Map<CLDevice, CLProgram.Status> getBuildStatus()

Returns the build status enum of this program for each device as Map.

getBuildStatusback to summary
public CLProgram.Status getBuildStatus(final CLDevice device)

Returns the build status enum for this program on the specified device.

getCLDevicesback to summary
public CLDevice[] getCLDevices()

Returns all devices associated with this program.

getKernelBindingback to summary
private CLKernelBinding getKernelBinding()
getProgramInfoStringback to summary
private String getProgramInfoString(final int flag)
getSourceback to summary
public String getSource()

Returns the source code of this program.

Note

sources are not cached, each call of this method calls into Open

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
initBuildStatusback to summary
private void initBuildStatus()
isExecutableback to summary
public boolean isExecutable()

Returns true if the build status 'BUILD_SUCCESS' for at least one device of this program exists.

onKernelReleasedback to summary
pack-priv void onKernelReleased(final CLKernel kernel)
optionsOfback to summary
public static String optionsOf(final String... options)

Utility method which builds a properly seperated option string.

prepareback to summary
public CLProgramConfiguration prepare()

Prepares the build for this program by returning a new CLProgramConfiguration.

releaseback to summary
public void release()

Overrides com.jogamp.opencl.CLObjectResource.release.

Implements com.jogamp.opencl.CLResource.release.

Releases this program with its kernels.

Annotations
@Override
releaseKernelsback to summary
private void releaseKernels()
setNoSourceback to summary
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.

toStringback to summary
public String toString()

Overrides com.jogamp.opencl.CLObject.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.jogamp.opencl back to summary

public Interface CLProgram.CompilerOptions


Common compiler options for the OpenCL compiler.

Field Summary

Modifier and TypeField and Description
public static final String
DENORMS_ARE_ZERO

This option controls how single precision and double precision denormalized numbers are handled.

public static final String
DISABLE_OPT

This option disables all optimizations.

public static final String
DISABLE_WARNINGS

Inhibit all warning messages.

public static final String
ENABLE_MAD

Allow a * b + c to be replaced by a mad.

public static final String
FAST_RELAXED_MATH

Sets the optimization options -cl-finite-math-only (FINITE_MATH_ONLY) and -cl-unsafe-math-optimizations (UNSAFE_MATH).

public static final String
FINITE_MATH_ONLY

Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or plus/minus infinity.

public static final String
NO_SIGNED_ZEROS

Allow optimizations for floating-point arithmetic that ignore the signedness of zero.

public static final String
SINGLE_PRECISION_CONSTANTS

Treat double precision floating-point constant as single precision constant.

public static final String
STRICT_ALIASING

This option allows the compiler to assume the strictest aliasing rules.

public static final String
UNSAFE_MATH

Allow optimizations for floating-point arithmetic that (a) assume that arguments and results are valid, (b) may violate IEEE 754 standard and (c) may violate the OpenCL numerical compliance requirements as defined in section 7.4 for single-precision floating-point, section 9.3.9 for double-precision floating-point, and edge case behavior in section 7.5.

public static final String
WARNINGS_ARE_ERRORS

Make all warnings into errors.

Field Detail

DENORMS_ARE_ZEROback to summary
public static final String DENORMS_ARE_ZERO

This option controls how single precision and double precision denormalized numbers are handled. If specified as a build option, the single precision denormalized numbers may be flushed to zero and if the optional extension for double precision is supported, double precision denormalized numbers may also be flushed to zero. This is intended to be a performance hint and the OpenCL compiler can choose not to flush denorms to zero if the device supports single precision (or double precision) denormalized numbers.
This option is ignored for single precision numbers if the device does not support single precision denormalized numbers i.e. CLDevice.FPConfig#DENORM is not present in the set returned by CLDevice#getSingleFPConfig()
This option is ignored for double precision numbers if the device does not support double precision or if it does support double precision but CLDevice.FPConfig#DENORM is not present in the set returned by CLDevice#getDoubleFPConfig().
This flag only applies for scalar and vector single precision floating-point variables and computations on these floating-point variables inside a program. It does not apply to reading from or writing to image objects.

DISABLE_OPTback to summary
public static final String DISABLE_OPT

This option disables all optimizations. The default is optimizations are enabled.

DISABLE_WARNINGSback to summary
public static final String DISABLE_WARNINGS

Inhibit all warning messages.

ENABLE_MADback to summary
public static final String ENABLE_MAD

Allow a * b + c to be replaced by a mad. The mad computes a * b + c with reduced accuracy. For example, some OpenCL devices implement mad as truncate the result of a * b before adding it to c.

FAST_RELAXED_MATHback to summary
public static final String FAST_RELAXED_MATH

Sets the optimization options -cl-finite-math-only (FINITE_MATH_ONLY) and -cl-unsafe-math-optimizations (UNSAFE_MATH). This allows optimizations for floating-point arithmetic that may violate the IEEE 754 standard and the OpenCL numerical compliance requirements defined in the specification in section 7.4 for single-precision floating-point, section 9.3.9 for double-precision floating-point, and edge case behavior in section 7.5. This option causes the preprocessor macro __FAST_RELAXED_MATH__ to be defined in the OpenCL program.

FINITE_MATH_ONLYback to summary
public static final String FINITE_MATH_ONLY

Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or plus/minus infinity. This option may violate the OpenCL numerical compliance requirements defined in in section 7.4 for single-precision floating-point, section 9.3.9 for double-precision floating-point, and edge case behavior in section 7.5.

NO_SIGNED_ZEROSback to summary
public static final String NO_SIGNED_ZEROS

Allow optimizations for floating-point arithmetic that ignore the signedness of zero. IEEE 754 arithmetic specifies the behavior of distinct +0.0 and -0.0 values, which then prohibits simplification of expressions such as x+0.0 or 0.0*x (even with -cl-finite-math-only (FINITE_MATH_ONLY)). This option implies that the sign of a zero result isn't significant.

SINGLE_PRECISION_CONSTANTSback to summary
public static final String SINGLE_PRECISION_CONSTANTS

Treat double precision floating-point constant as single precision constant.

STRICT_ALIASINGback to summary
public static final String STRICT_ALIASING

This option allows the compiler to assume the strictest aliasing rules.

UNSAFE_MATHback to summary
public static final String UNSAFE_MATH

Allow optimizations for floating-point arithmetic that
(a) assume that arguments and results are valid,
(b) may violate IEEE 754 standard and
(c) may violate the OpenCL numerical compliance requirements as defined in section 7.4 for single-precision floating-point, section 9.3.9 for double-precision floating-point, and edge case behavior in section 7.5. This option includes the -cl-no-signed-zeros (NO_SIGNED_ZEROS) and -cl-mad-enable (ENABLE_MAD) options.

WARNINGS_ARE_ERRORSback to summary
public static final String WARNINGS_ARE_ERRORS

Make all warnings into errors.

com.jogamp.opencl back to summary

public final Enum CLProgram.Status

extends Enum<CLProgram.Status>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final CLProgram.Status
public static final CLProgram.Status
public static final CLProgram.Status
public static final CLProgram.Status
public final int
STATUS

Value of wrapped OpenCL device type.

Constructor Summary

AccessConstructor and Description
private
Status(final int status)

Method Summary

Modifier and TypeMethod and Description
public static CLProgram.Status
public static CLProgram.Status
valueOf(final int clBuildStatus)

public static CLProgram.Status[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BUILD_ERRORback to summary
public static final CLProgram.Status BUILD_ERROR
BUILD_IN_PROGRESSback to summary
public static final CLProgram.Status BUILD_IN_PROGRESS
BUILD_NONEback to summary
public static final CLProgram.Status BUILD_NONE
BUILD_SUCCESSback to summary
public static final CLProgram.Status BUILD_SUCCESS
STATUSback to summary
public final int STATUS

Value of wrapped OpenCL device type.

Constructor Detail

Statusback to summary
private Status(final int status)

Method Detail

valueOfback to summary
public static CLProgram.Status valueOf(String name)
valueOfback to summary
public static CLProgram.Status valueOf(final int clBuildStatus)
valuesback to summary
public static CLProgram.Status[] values()