Class CLPlatform


  • public class CLPlatform
    extends Object
    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 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
    • Method Detail

      • isAvailable

        public static boolean isAvailable()
      • 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. This interface is always for OpenCL 1.1.
      • getLowLevelCLInterfaceForDevice

        public static CL getLowLevelCLInterfaceForDevice​(long device)
        Returns the low level binding interface to the OpenCL APIs for the specified device. This interface is the newest one the device supports.
      • 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​(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​(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.
      • getProfile

        public String getProfile()
        Returns the platform profile.
      • getVendor

        public String getVendor()
        Returns the platform vendor.
      • isVendorAMD

        public boolean isVendorAMD()
        Returns:
        true if the vendor is AMD.
      • isVendorIntel

        public boolean isVendorIntel()
        Returns:
        true if the vendor is Intel.
      • 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.
      • getInfoString

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

        protected CL getCLBinding()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object