Interface Platform

All Known Implementing Classes:
ImmutablePlatform

@Immutable public interface Platform
Represents an OpenCL platform providing access to compute devices and their capabilities.

Platform encapsulates the information about an OpenCL platform, which is a vendor-specific implementation of the OpenCL specification. Each platform represents a collection of OpenCL devices (CPUs, GPUs, accelerators) provided by a single vendor with consistent runtime behavior.

Key platform characteristics include:

  • Vendor identification: Platform vendor (AMD, NVIDIA, Intel, etc.)
  • Capability profile: FULL_PROFILE or EMBEDDED_PROFILE feature support
  • Version support: OpenCL specification version implemented
  • Extension support: Additional features beyond the core specification
  • Device count: Number of compute devices available on this platform

Platform selection considerations:

  • Vendor optimization: Different vendors may optimize for different workloads
  • Feature requirements: Embedded profiles may lack required features
  • Version compatibility: Newer OpenCL versions provide additional features
  • Extension dependencies: Some algorithms may require specific extensions
  • Device availability: Platforms must have compatible devices

Common filtering patterns:


 // Select platforms with full OpenCL profile support
 Predicate<Platform> fullProfileFilter = platform -> 
     platform.profile() == PlatformProfile.FULL_PROFILE;
 
 // Select platforms from specific vendors
 Predicate<Platform> vendorFilter = platform -> 
     platform.vendor().toLowerCase().contains("nvidia") ||
     platform.vendor().toLowerCase().contains("amd");
 
 // Select platforms with minimum OpenCL version
 Predicate<Platform> versionFilter = platform -> {
     String version = platform.version();
     return version.contains("2.") || version.contains("3.");
 };
 
 // Select platforms with required extensions
 Predicate<Platform> extensionFilter = platform ->
     platform.extensions().contains("cl_khr_fp64");
 
 // Combine filters for comprehensive platform selection
 Predicate<Platform> combinedFilter = fullProfileFilter
     .and(versionFilter)
     .and(platform -> platform.numDevices() > 0);
 

Platform discovery workflow:

  1. Enumeration: System discovers all available OpenCL platforms
  2. Information query: Platform properties are read from OpenCL runtime
  3. Model creation: Platform objects are created with discovered information
  4. Filtering: User-defined predicates select appropriate platforms
  5. Device discovery: Selected platforms are queried for available devices

Performance implications:

  • Driver optimization: Platform vendors optimize for their hardware
  • Memory models: Different platforms may have different memory hierarchies
  • Kernel compilation: Platform-specific optimizations during compilation
  • Runtime behavior: Platform-specific scheduling and resource management

Error handling considerations:

  • Platform availability: Platforms may become unavailable at runtime
  • Version compatibility: Kernels may require specific OpenCL versions
  • Extension support: Missing extensions may cause compilation failures
  • Device enumeration: Platform may have no compatible devices
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new builder for constructing Platform instances.
    Returns the set of OpenCL extensions supported by this platform.
    Returns the platform name provided by the vendor.
    int
    Returns the number of OpenCL devices available on this platform.
    org.jocl.cl_platform_id
    Returns the native OpenCL platform identifier.
    Returns the OpenCL profile supported by this platform.
    Returns the platform vendor name.
    Returns the OpenCL version string supported by this platform.
  • Method Details

    • platformId

      org.jocl.cl_platform_id platformId()
      Returns the native OpenCL platform identifier.
      Returns:
      the OpenCL platform ID for low-level operations
    • profile

      PlatformProfile profile()
      Returns the OpenCL profile supported by this platform.
      Returns:
      the platform profile (FULL_PROFILE or EMBEDDED_PROFILE)
    • version

      String version()
      Returns the OpenCL version string supported by this platform.
      Returns:
      the OpenCL version (e.g., "OpenCL 2.1")
    • name

      String name()
      Returns the platform name provided by the vendor.
      Returns:
      the human-readable platform name
    • vendor

      String vendor()
      Returns the platform vendor name.
      Returns:
      the vendor name (e.g., "NVIDIA Corporation", "AMD")
    • extensions

      Set<String> extensions()
      Returns the set of OpenCL extensions supported by this platform.
      Returns:
      set of extension names (e.g., "cl_khr_fp64", "cl_khr_global_int32_base_atomics")
    • numDevices

      int numDevices()
      Returns the number of OpenCL devices available on this platform.
      Returns:
      the count of devices that can be used for computation
    • builder

      static ImmutablePlatform.Builder builder()
      Creates a new builder for constructing Platform instances.
      Returns:
      a new builder for creating platform objects