Top Description Fields Constructors Methods
com.jogamp.opencl

public Class CLPlatform

extends Object
Class Inheritance
Imports
com.jogamp.opencl.llb.CLPlatformBinding, .CLProgramBinding, .CLSamplerBinding, .CLKernelBinding, .CLImageBinding, .CL, .CLBufferBinding, .CLCommandQueueBinding, .CLContextBinding, .CLDeviceBinding, .CLEventBinding, .CLMemObjBinding, com.jogamp.opencl.impl.CLTLAccessorFactory, com.jogamp.common.nio.Buffers, .PointerBuffer, com.jogamp.common.JogampRuntimeException, com.jogamp.opencl.spi.CLPlatformInfoAccessor, .CLAccessorFactory, com.jogamp.opencl.util.CLUtil, .Filter, com.jogamp.opencl.llb.impl.CLAbstractImpl, .CLImpl, java.nio.IntBuffer, java.util.ArrayList, .Collections, .HashSet, .List, .Map, .Scanner, .Set

CLPlatfrorm representing a OpenCL implementation (e.g. graphics driver). optional eager initialization:

    if( !CLPlatform.isAvailable() ) {
       return; // abort
    }
    try{
         CLPlatform.initialize();
    }catch(JogampRuntimeException ex) {
         throw new RuntimeException("could not load Java OpenCL Binding");
    }

Example initialization:

    if( !CLPlatform.isAvailable() ) {
       return; // abort
    }
    CLPlatform platform = CLPlatform.getDefault(type(GPU));

    if(platform == null) {
         throw new RuntimeException("please update your graphics drivers");
    }

    CLContext context = CLContext.create(platform.getMaxFlopsDevice());
    try {
         // use it
    }finally{
         context.release();
    }

concurrency:
CLPlatform is threadsafe.
Author
Michael Bien, et al.
See Also
isAvailable(), initialize(), getDefault(), listCLPlatforms()

Field Summary

Modifier and TypeField and Description
protected static CL
private static CLAccessorFactory
private Set<String>
private final CLAccessorFactory
public final long
ID

OpenCL platform id for this platform.

protected final CLPlatformInfoAccessor
public final CLVersion
version

Version of this OpenCL platform.

Constructor Summary

AccessConstructor and Description
private
CLPlatform(final long id)

protected
CLPlatform(final long id, final CLAccessorFactory factory)

Method Summary

Modifier and TypeMethod and Description
private static <I> void
addIfAccepted(final I item, final List<I> list, final Filter<I>[] filters)

protected CLDevice
createDevice(final long id)

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.
pack-priv static CLDevice
findMaxFlopsDevice(final CLDevice[] devices)

pack-priv static CLDevice
findMaxFlopsDevice(final CLDevice[] devices, final CLDevice.Type type)

pack-priv final CLAccessorFactory
protected CLBufferBinding
public final CLPlatformInfoAccessor
protected CL
protected CLCommandQueueBinding
protected CLContextBinding
public static CLPlatform
getDefault()

Returns the default OpenCL platform or null when no platform found.

public static CLPlatform
getDefault(final Filter<CLPlatform>... filter)

Returns the default OpenCL platform or null when no platform found.

protected CLDeviceBinding
protected CLEventBinding
public synchronized Set<String>
getExtensions()

Returns all platform extension names as unmodifiable Set.

public String
getICDSuffix()

Returns the ICD suffix.

protected CLImageBinding
public final String
getInfoString(final int key)

Returns a info string in exchange for a key (CL_PLATFORM_*).

protected CLKernelBinding
public static CL
getLowLevelCLInterface()

Returns the low level binding interface to the OpenCL APIs.

public CLDevice
getMaxFlopsDevice()

Returns the device with maximal FLOPS from this platform.

public CLDevice
getMaxFlopsDevice(final CLDevice.Type... types)

Returns the device with maximal FLOPS and the specified type from this platform.

public CLDevice
getMaxFlopsDevice(final Filter<CLDevice>... filter)

Returns the device with maximal FLOPS and the specified type from this platform.

protected CLMemObjBinding
public String
getName()

Returns the platform name.

protected CLPlatformBinding
public String
getProfile()

Returns the platform profile.

protected CLProgramBinding
public Map<String, String>
getProperties()

Returns a Map of platform properties with the enum names as keys.

protected CLSamplerBinding
public String
getSpecVersion()

Returns the OpenCL Specification version supported by this platform.

public String
getVendor()

Returns the platform vendor.

public CLVersion
getVersion()

Returns the OpenCL version supported by this platform.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public static void
initialize()

Eagerly initializes JOCL.

pack-priv static synchronized void
initialize(final CLAccessorFactory
CLAccessorFactory used for creating the bindings.
factory
)

Eagerly initializes JOCL.

public boolean
isAtLeast(final CLVersion other)

public boolean
isAtLeast(final int major, final int minor)

public static boolean

Returns:

true if OpenCL is available on this machine, i.e. all native libraries could be loaded (CL and CL/JNI).
isAvailable
()

public boolean
isExtensionAvailable(final String extension)

Returns true if the extension is supported on this platform.

public boolean

Returns:

true if the vendor is AMD.
isVendorAMD
()

private static CLPlatform
latest(final CLPlatform[] platforms)

public CLDevice[]
listCLDevices()

Lists all physical devices available on this platform.

public CLDevice[]
listCLDevices(final CLDevice.Type... types)

Lists all physical devices available on this platform matching the given CLDevice.Type.

public CLDevice[]
listCLDevices(final Filter<CLDevice>... filters)

Lists all physical devices available on this platform matching the given Filter.

public static CLPlatform[]
listCLPlatforms()

Lists all available OpenCL implementations.

public static CLPlatform[]
listCLPlatforms(final Filter<CLPlatform>...
Acceptance filter for the returned platforms.
filter
)

Lists all available OpenCL implementations.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public static void
unloadCompiler()

Hint to allow the implementation to release the resources allocated by the OpenCL compiler.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

clback to summary
protected static CL cl
defaultFactoryback to summary
private static CLAccessorFactory defaultFactory
extensionsback to summary
private Set<String> extensions
factoryback to summary
private final CLAccessorFactory factory
IDback to summary
public final long ID

OpenCL platform id for this platform.

infoback to summary
protected final CLPlatformInfoAccessor info
versionback to summary
public final CLVersion version

Version of this OpenCL platform.

Constructor Detail

CLPlatformback to summary
private CLPlatform(final long id)
CLPlatformback to summary
protected CLPlatform(final long id, final CLAccessorFactory factory)

Method Detail

addIfAcceptedback to summary
private static <I> void addIfAccepted(final I item, final List<I> list, final Filter<I>[] filters)
createDeviceback to summary
protected CLDevice createDevice(final long id)
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
findMaxFlopsDeviceback to summary
pack-priv static CLDevice findMaxFlopsDevice(final CLDevice[] devices)
findMaxFlopsDeviceback to summary
pack-priv static CLDevice findMaxFlopsDevice(final CLDevice[] devices, final CLDevice.Type type)
getAccessorFactoryback to summary
pack-priv final CLAccessorFactory getAccessorFactory()
getBufferBindingback to summary
protected CLBufferBinding getBufferBinding()
getCLAccessorback to summary
public final CLPlatformInfoAccessor getCLAccessor()
getCLBindingback to summary
protected CL getCLBinding()
getCommandQueueBindingback to summary
protected CLCommandQueueBinding getCommandQueueBinding()
getContextBindingback to summary
protected CLContextBinding getContextBinding()
getDefaultback to summary
public static CLPlatform getDefault()

Returns the default OpenCL platform or null when no platform found.

getDefaultback to summary
public static CLPlatform getDefault(final Filter<CLPlatform>... filter)

Returns the default OpenCL platform or null when no platform found.

getDeviceBindingback to summary
protected CLDeviceBinding getDeviceBinding()
getEventBindingback to summary
protected CLEventBinding getEventBinding()
getExtensionsback to summary
public synchronized Set<String> getExtensions()

Returns all platform extension names as unmodifiable Set.

Annotations
@CLProperty:CL_PLATFORM_EXTENSIONS
getICDSuffixback to summary
public String getICDSuffix()

Returns the ICD suffix.

Annotations
@CLProperty:CL_PLATFORM_ICD_SUFFIX_KHR
getImageBindingback to summary
protected CLImageBinding getImageBinding()
getInfoStringback to summary
public final String getInfoString(final int key)

Returns a info string in exchange for a key (CL_PLATFORM_*).

getKernelBindingback to summary
protected CLKernelBinding getKernelBinding()
getLowLevelCLInterfaceback to summary
public static CL getLowLevelCLInterface()

Returns the low level binding interface to the OpenCL APIs.

getMaxFlopsDeviceback to summary
public CLDevice getMaxFlopsDevice()

Returns the device with maximal FLOPS from this platform. The device speed is estimated by calculating the product of MAX_COMPUTE_UNITS and MAX_CLOCK_FREQUENCY.

See Also
getMaxFlopsDevice(com.jogamp.opencl.CLDevice.Type...)
getMaxFlopsDeviceback to summary
public CLDevice getMaxFlopsDevice(final CLDevice.Type... types)

Returns the device with maximal FLOPS and the specified type from this platform. The device speed is estimated by calculating the product of MAX_COMPUTE_UNITS and MAX_CLOCK_FREQUENCY.

getMaxFlopsDeviceback to summary
public CLDevice getMaxFlopsDevice(final Filter<CLDevice>... filter)

Returns the device with maximal FLOPS and the specified type from this platform. The device speed is estimated by calculating the product of MAX_COMPUTE_UNITS and MAX_CLOCK_FREQUENCY.

getMemObjectBindingback to summary
protected CLMemObjBinding getMemObjectBinding()
getNameback to summary
public String getName()

Returns the platform name.

Annotations
@CLProperty:CL_PLATFORM_NAME
getPlatformBindingback to summary
protected CLPlatformBinding getPlatformBinding()
getProfileback to summary
public String getProfile()

Returns the platform profile.

Annotations
@CLProperty:CL_PLATFORM_PROFILE
getProgramBindingback to summary
protected CLProgramBinding getProgramBinding()
getPropertiesback to summary
public Map<String, String> getProperties()

Returns a Map of platform properties with the enum names as keys.

See Also
CLUtil#obtainPlatformProperties(com.jogamp.opencl.CLPlatform)
getSamplerBindingback to summary
protected CLSamplerBinding getSamplerBinding()
getSpecVersionback to summary
public String getSpecVersion()

Returns the OpenCL Specification version supported by this platform.

getVendorback to summary
public String getVendor()

Returns the platform vendor.

Annotations
@CLProperty:CL_PLATFORM_VENDOR
getVersionback to summary
public CLVersion getVersion()

Returns the OpenCL version supported by this platform.

Annotations
@CLProperty:CL_PLATFORM_VERSION
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
initializeback to summary
public static void initialize() throws JogampRuntimeException

Eagerly initializes JOCL. Subsequent calls do nothing.

Exceptions
JogampRuntimeException:
if something went wrong in the initialization (e.g. OpenCL lib not found).
See Also
isAvailable()
initializeback to summary
pack-priv static synchronized void initialize(final CLAccessorFactory factory) throws JogampRuntimeException

Eagerly initializes JOCL. Subsequent calls do nothing.

Parameters
factory:CLAccessorFactory

CLAccessorFactory used for creating the bindings.

Exceptions
JogampRuntimeException:
if something went wrong in the initialization (e.g. OpenCL lib not found).
See Also
isAvailable()
isAtLeastback to summary
public boolean isAtLeast(final CLVersion other)
See Also
CLVersion#isAtLeast(com.jogamp.opencl.CLVersion)
isAtLeastback to summary
public boolean isAtLeast(final int major, final int minor)
See Also
CLVersion#isAtLeast(int, int)
isAvailableback to summary
public static boolean isAvailable()
Returns:boolean

true if OpenCL is available on this machine, i.e. all native libraries could be loaded (CL and CL/JNI).

isExtensionAvailableback to summary
public boolean isExtensionAvailable(final String extension)

Returns true if the extension is supported on this platform.

isVendorAMDback to summary
public boolean isVendorAMD()
Returns:boolean

true if the vendor is AMD.

latestback to summary
private static CLPlatform latest(final CLPlatform[] platforms)
listCLDevicesback to summary
public CLDevice[] listCLDevices()

Lists all physical devices available on this platform.

See Also
listCLDevices(com.jogamp.opencl.CLDevice.Type...)
listCLDevicesback to summary
public CLDevice[] listCLDevices(final CLDevice.Type... types)

Lists all physical devices available on this platform matching the given CLDevice.Type.

listCLDevicesback to summary
public CLDevice[] listCLDevices(final Filter<CLDevice>... filters)

Lists all physical devices available on this platform matching the given Filter.

listCLPlatformsback to summary
public static CLPlatform[] listCLPlatforms()

Lists all available OpenCL implementations.

Exceptions
CLException:
if something went wrong initializing OpenCL
listCLPlatformsback to summary
public static CLPlatform[] listCLPlatforms(final Filter<CLPlatform>... filter)

Lists all available OpenCL implementations. The platforms returned must pass all filters.

Parameters
filter:Filter<CLPlatform>[]

Acceptance filter for the returned platforms.

Exceptions
CLException:
if something went wrong initializing OpenCL
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
unloadCompilerback to summary
public static void unloadCompiler()

Hint to allow the implementation to release the resources allocated by the OpenCL compiler. Calls to CLProgram#build() after unloadCompiler will reload the compiler if necessary.