com.jogamp.opencl
Class CLPlatform

java.lang.Object
  extended by com.jogamp.opencl.CLPlatform

public class CLPlatform
extends Object

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

     try{
          CLPlatform.initialize();
     }catch(JogampRuntimeException ex) {
          throw new RuntimeException("could not load Java OpenCL Binding");
     }
 

Example initialization:

     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:
initialize(), getDefault(), listCLPlatforms()

Field Summary
protected static CL cl
           
 long ID
          OpenCL platform id for this platform.
protected  CLPlatformInfoAccessor info
           
 CLVersion version
          Version of this OpenCL platform.
 
Constructor Summary
protected CLPlatform(long id, CLAccessorFactory factory)
           
 
Method Summary
protected  CLDevice createDevice(long id)
           
 boolean equals(Object obj)
           
protected  CLBufferBinding getBufferBinding()
           
 CLPlatformInfoAccessor getCLAccessor()
           
protected  CL getCLBinding()
           
protected  CLCommandQueueBinding getCommandQueueBinding()
           
protected  CLContextBinding getContextBinding()
           
static CLPlatform getDefault()
          Returns the default OpenCL platform or null when no platform found.
static CLPlatform getDefault(Filter<CLPlatform>... filter)
          Returns the default OpenCL platform or null when no platform found.
protected  CLDeviceBinding getDeviceBinding()
           
protected  CLEventBinding getEventBinding()
           
 Set<String> getExtensions()
          Returns all platform extension names as unmodifiable Set.
 String getICDSuffix()
          Returns the ICD suffix.
protected  CLImageBinding getImageBinding()
           
 String getInfoString(int key)
          Returns a info string in exchange for a key (CL_PLATFORM_*).
protected  CLKernelBinding getKernelBinding()
           
static CL getLowLevelCLInterface()
          Returns the low level binding interface to the OpenCL APIs.
 CLDevice getMaxFlopsDevice()
          Returns the device with maximal FLOPS from this platform.
 CLDevice getMaxFlopsDevice(CLDevice.Type... types)
          Returns the device with maximal FLOPS and the specified type from this platform.
 CLDevice getMaxFlopsDevice(Filter<CLDevice>... filter)
          Returns the device with maximal FLOPS and the specified type from this platform.
protected  CLMemObjBinding getMemObjectBinding()
           
 String getName()
          Returns the platform name.
protected  CLPlatformBinding getPlatformBinding()
           
 String getProfile()
          Returns the platform profile.
protected  CLProgramBinding getProgramBinding()
           
 Map<String,String> getProperties()
          Returns a Map of platform properties with the enum names as keys.
protected  CLSamplerBinding getSamplerBinding()
           
 String getSpecVersion()
          Returns the OpenCL Specification version supported by this platform.
 String getVendor()
          Returns the platform vendor.
 CLVersion getVersion()
          Returns the OpenCL version supported by this platform.
 int hashCode()
           
static void initialize()
          Eagerly initializes JOCL.
 boolean isAtLeast(CLVersion other)
           
 boolean isAtLeast(int major, int minor)
           
 boolean isExtensionAvailable(String extension)
          Returns true if the extension is supported on this platform.
 CLDevice[] listCLDevices()
          Lists all physical devices available on this platform.
 CLDevice[] listCLDevices(CLDevice.Type... types)
          Lists all physical devices available on this platform matching the given CLDevice.Type.
 CLDevice[] listCLDevices(Filter<CLDevice>... filters)
          Lists all physical devices available on this platform matching the given Filter.
static CLPlatform[] listCLPlatforms()
          Lists all available OpenCL implementations.
static CLPlatform[] listCLPlatforms(Filter<CLPlatform>... filter)
          Lists all available OpenCL implementations.
 String toString()
           
static void unloadCompiler()
          Hint to allow the implementation to release the resources allocated by the OpenCL compiler.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public final long ID
OpenCL platform id for this platform.


version

public final CLVersion version
Version of this OpenCL platform.


cl

protected static CL cl

info

protected final CLPlatformInfoAccessor info
Constructor Detail

CLPlatform

protected CLPlatform(long id,
                     CLAccessorFactory factory)
Method Detail

initialize

public static void initialize()
                       throws JogampRuntimeException
Eagerly initializes JOCL. Subsequent calls do nothing.

Throws:
JogampRuntimeException - if something went wrong in the initialization (e.g. OpenCL lib not found).

getDefault

public static CLPlatform getDefault()
Returns the default OpenCL platform or null when no platform found.


getDefault

public static CLPlatform getDefault(Filter<CLPlatform>... filter)
Returns the default OpenCL platform or null when no platform found.


listCLPlatforms

public static CLPlatform[] listCLPlatforms()
Lists all available OpenCL implementations.

Throws:
CLException - if something went wrong initializing OpenCL

listCLPlatforms

public static CLPlatform[] listCLPlatforms(Filter<CLPlatform>... filter)
Lists all available OpenCL implementations. The platforms returned must pass all filters.

Parameters:
filter - Acceptance filter for the returned platforms.
Throws:
CLException - if something went wrong initializing OpenCL

getLowLevelCLInterface

public static CL getLowLevelCLInterface()
Returns the low level binding interface to the OpenCL APIs.


unloadCompiler

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.


listCLDevices

public CLDevice[] listCLDevices()
Lists all physical devices available on this platform.

See Also:
listCLDevices(com.jogamp.opencl.CLDevice.Type...)

listCLDevices

public CLDevice[] listCLDevices(CLDevice.Type... types)
Lists all physical devices available on this platform matching the given CLDevice.Type.


listCLDevices

public CLDevice[] listCLDevices(Filter<CLDevice>... filters)
Lists all physical devices available on this platform matching the given Filter.


createDevice

protected CLDevice createDevice(long id)

getMaxFlopsDevice

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...)

getMaxFlopsDevice

public CLDevice getMaxFlopsDevice(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.


getMaxFlopsDevice

public CLDevice getMaxFlopsDevice(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.


getName

public String getName()
Returns the platform name.


getVersion

public CLVersion getVersion()
Returns the OpenCL version supported by this platform.


getSpecVersion

public String getSpecVersion()
Returns the OpenCL Specification version supported by this platform.


isAtLeast

public boolean isAtLeast(CLVersion other)
See Also:
CLVersion.isAtLeast(com.jogamp.opencl.CLVersion)

isAtLeast

public boolean isAtLeast(int major,
                         int minor)
See Also:
CLVersion.isAtLeast(int, int)

getProfile

public String getProfile()
Returns the platform profile.


getVendor

public String getVendor()
Returns the platform vendor.


getICDSuffix

public String getICDSuffix()
Returns the ICD suffix.


isExtensionAvailable

public boolean isExtensionAvailable(String extension)
Returns true if the extension is supported on this platform.


getExtensions

public Set<String> getExtensions()
Returns all platform extension names as unmodifiable Set.


getProperties

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)

getInfoString

public final String getInfoString(int key)
Returns a info string in exchange for a key (CL_PLATFORM_*).


getCLAccessor

public final CLPlatformInfoAccessor getCLAccessor()

getBufferBinding

protected CLBufferBinding getBufferBinding()

getCommandQueueBinding

protected CLCommandQueueBinding getCommandQueueBinding()

getContextBinding

protected CLContextBinding getContextBinding()

getDeviceBinding

protected CLDeviceBinding getDeviceBinding()

getEventBinding

protected CLEventBinding getEventBinding()

getImageBinding

protected CLImageBinding getImageBinding()

getKernelBinding

protected CLKernelBinding getKernelBinding()

getMemObjectBinding

protected CLMemObjBinding getMemObjectBinding()

getPlatformBinding

protected CLPlatformBinding getPlatformBinding()

getProgramBinding

protected CLProgramBinding getProgramBinding()

getSamplerBinding

protected CLSamplerBinding getSamplerBinding()

getCLBinding

protected CL getCLBinding()

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object