Interface Device
- All Known Implementing Classes:
ImmutableDevice
Device encapsulates the properties and capabilities of an OpenCL compute device (GPU, CPU, or accelerator) that can be used for fitness evaluation in evolutionary algorithms. This information is essential for device selection, kernel optimization, and workload configuration to achieve optimal performance.
Key device characteristics include:
- Device identification: Name, vendor, and version information
- Compute capabilities: Number of compute units and maximum work group sizes
- Memory hierarchy: Global, local, and constant memory sizes and characteristics
- Processing features: Vector width preferences, image support, and built-in kernels
- Performance metrics: Clock frequency and execution capabilities
Device selection considerations for evolutionary algorithms:
- Device type: GPU devices typically provide highest parallelism for large populations
- Compute units: More compute units allow better utilization of large populations
- Work group sizes: Must accommodate the parallelism patterns of fitness kernels
- Memory capacity: Must be sufficient for population data and intermediate results
- Vector operations: Vector width preferences can optimize numerical computations
Common device filtering patterns:
// Select GPU devices with sufficient parallel processing capability
Predicate<Device> gpuFilter = device ->
device.deviceType().contains(DeviceType.GPU) &&
device.maxComputeUnits() >= 8;
// Select devices with large work group support for population processing
Predicate<Device> workGroupFilter = device ->
device.maxWorkGroupSize() >= 256;
// Select devices with high clock frequency for compute-intensive fitness
Predicate<Device> performanceFilter = device ->
device.maxClockFrequency() >= 1000; // MHz
// Select devices that support floating-point vector operations
Predicate<Device> vectorFilter = device ->
device.preferredVectorWidthFloat() >= 4;
// Comprehensive filter for evolutionary algorithm suitability
Predicate<Device> eaOptimizedFilter = device ->
device.deviceType().contains(DeviceType.GPU) &&
device.maxComputeUnits() >= 4 &&
device.maxWorkGroupSize() >= 128 &&
device.preferredVectorWidthFloat() >= 2;
Performance optimization using device information:
- Work group sizing: Configure kernel work groups based on
maxWorkGroupSize()
- Parallel dispatch: Scale parallelism based on
maxComputeUnits()
- Vector operations: Optimize data layouts for
preferredVectorWidthFloat()
- Memory access patterns: Design kernels considering memory hierarchy characteristics
Device capability assessment workflow:
- Device discovery: Enumerate devices from selected platforms
- Capability query: Read device properties from OpenCL runtime
- Model creation: Create device objects with discovered capabilities
- Filtering: Apply user-defined predicates to select suitable devices
- Context creation: Create OpenCL contexts for selected devices
Common device types in evolutionary computation:
- GPU devices: Provide massive parallelism for large population fitness evaluation
- CPU devices: Offer good sequential performance and large memory capacity
- Accelerator devices: Specialized hardware for specific computational patterns
- Custom devices: FPGA or other specialized compute devices
Error handling and compatibility:
- Device availability: Devices may become unavailable during execution
- Capability validation: Ensure device supports required kernel features
- Memory constraints: Validate device memory is sufficient for population size
- Work group limits: Ensure kernels respect device work group size limits
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableDevice.Builder
builder()
Creates a new builder for constructing Device instances.Returns the set of built-in kernel names available on this device.org.jocl.cl_device_id
deviceId()
Returns the native OpenCL device identifier.Returns the set of device types that classify this device.Returns the OpenCL version supported by this device.Returns the device driver version.boolean
Returns whether the device supports image objects in kernels.int
Returns the maximum configured clock frequency of the device compute units in MHz.int
Returns the number of parallel compute units on the device.long
Returns the maximum number of work-items in a work group for kernel execution.int
Returns the maximum number of work-item dimensions supported by the device.long[]
Returns the maximum number of work-items in each dimension of a work group.name()
Returns the device name provided by the vendor.int
Returns the preferred vector width for float operations.vendor()
Returns the device vendor name.
-
Method Details
-
deviceId
org.jocl.cl_device_id deviceId()Returns the native OpenCL device identifier.- Returns:
- the OpenCL device ID for low-level operations
-
name
String name()Returns the device name provided by the vendor.- Returns:
- the human-readable device name (e.g., "GeForce RTX 3080", "Intel Core i7")
-
vendor
String vendor()Returns the device vendor name.- Returns:
- the vendor name (e.g., "NVIDIA Corporation", "Intel", "AMD")
-
deviceVersion
String deviceVersion()Returns the OpenCL version supported by this device.- Returns:
- the device OpenCL version string (e.g., "OpenCL 2.1")
-
driverVersion
String driverVersion()Returns the device driver version.- Returns:
- the driver version string provided by the vendor
-
maxClockFrequency
int maxClockFrequency()Returns the maximum configured clock frequency of the device compute units in MHz.- Returns:
- the maximum clock frequency in megahertz
-
deviceType
Set<DeviceType> deviceType()Returns the set of device types that classify this device.- Returns:
- set of device types (e.g., GPU, CPU, ACCELERATOR)
-
builtInKernels
Returns the set of built-in kernel names available on this device.- Returns:
- set of built-in kernel names provided by the device
-
maxComputeUnits
int maxComputeUnits()Returns the number of parallel compute units on the device.Compute units represent the primary parallel processing elements and directly impact the device's ability to execute work groups concurrently.
- Returns:
- the number of parallel compute units available
-
maxWorkItemDimensions
int maxWorkItemDimensions()Returns the maximum number of work-item dimensions supported by the device.- Returns:
- the maximum number of dimensions for work-item indexing
-
maxWorkGroupSize
long maxWorkGroupSize()Returns the maximum number of work-items in a work group for kernel execution.This limit constrains the local work group size that can be used when launching kernels on this device. Larger work groups can improve memory locality and reduce synchronization overhead.
- Returns:
- the maximum work group size for kernel execution
-
maxWorkItemSizes
long[] maxWorkItemSizes()Returns the maximum number of work-items in each dimension of a work group.The array contains the maximum work-item count for each dimension, providing more granular control over work group configuration than the overall
maxWorkGroupSize()
limit.- Returns:
- array of maximum work-item counts per dimension
-
imageSupport
boolean imageSupport()Returns whether the device supports image objects in kernels.- Returns:
- true if the device supports image processing operations
-
preferredVectorWidthFloat
int preferredVectorWidthFloat()Returns the preferred vector width for float operations.This indicates the optimal vector width for floating-point operations on this device, which can be used to optimize numerical computations in fitness evaluation kernels.
- Returns:
- the preferred vector width for float operations
-
builder
Creates a new builder for constructing Device instances.- Returns:
- a new builder for creating device objects
-