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:
- Enumeration: System discovers all available OpenCL platforms
- Information query: Platform properties are read from OpenCL runtime
- Model creation: Platform objects are created with discovered information
- Filtering: User-defined predicates select appropriate platforms
- 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 TypeMethodDescriptionstatic ImmutablePlatform.Builder
builder()
Creates a new builder for constructing Platform instances.Returns the set of OpenCL extensions supported by this platform.name()
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.profile()
Returns the OpenCL profile supported by this platform.vendor()
Returns the platform vendor name.version()
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
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
Creates a new builder for constructing Platform instances.- Returns:
- a new builder for creating platform objects
-