Class ImmutableDevice
- All Implemented Interfaces:
Device
Device
.
Use the builder to create immutable instances:
ImmutableDevice.builder()
.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.jocl.cl_device_id
private final Set
<DeviceType> private final String
private final String
private final boolean
private final int
private final int
private final long
private final int
private final long[]
private final String
private final int
private final String
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ImmutableDevice
(org.jocl.cl_device_id deviceId, String name, String vendor, String deviceVersion, String driverVersion, int maxClockFrequency, Set<DeviceType> deviceType, Set<String> builtInKernels, int maxComputeUnits, int maxWorkItemDimensions, long maxWorkGroupSize, long[] maxWorkItemSizes, boolean imageSupport, int preferredVectorWidthFloat) -
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableDevice.Builder
builder()
Creates a builder forImmutableDevice
.Returns the set of built-in kernel names available on this device.static ImmutableDevice
Creates an immutable copy of aDevice
value.private static <T> List
<T> createSafeList
(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls) createUnmodifiableEnumSet
(Iterable<T> iterable) private static <T> Set
<T> createUnmodifiableSet
(List<T> list) Unmodifiable set constructed from list to avoid rehashing.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
This instance is equal to all instances ofImmutableDevice
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableDevice another) int
hashCode()
Computes a hash code from attributes:deviceId
,name
,vendor
,deviceVersion
,driverVersion
,maxClockFrequency
,deviceType
,builtInKernels
,maxComputeUnits
,maxWorkItemDimensions
,maxWorkGroupSize
,maxWorkItemSizes
,imageSupport
,preferredVectorWidthFloat
.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.toString()
Prints the immutable valueDevice
with attribute values.vendor()
Returns the device vendor name.final ImmutableDevice
withBuiltInKernels
(Iterable<String> elements) Copy the current immutable object with elements that replace the content ofbuiltInKernels
.final ImmutableDevice
withBuiltInKernels
(String... elements) Copy the current immutable object with elements that replace the content ofbuiltInKernels
.final ImmutableDevice
withDeviceId
(org.jocl.cl_device_id value) Copy the current immutable object by setting a value for thedeviceId
attribute.final ImmutableDevice
withDeviceType
(Iterable<DeviceType> elements) Copy the current immutable object with elements that replace the content ofdeviceType
.final ImmutableDevice
withDeviceType
(DeviceType... elements) Copy the current immutable object with elements that replace the content ofdeviceType
.final ImmutableDevice
withDeviceVersion
(String value) Copy the current immutable object by setting a value for thedeviceVersion
attribute.final ImmutableDevice
withDriverVersion
(String value) Copy the current immutable object by setting a value for thedriverVersion
attribute.final ImmutableDevice
withImageSupport
(boolean value) Copy the current immutable object by setting a value for theimageSupport
attribute.final ImmutableDevice
withMaxClockFrequency
(int value) Copy the current immutable object by setting a value for themaxClockFrequency
attribute.final ImmutableDevice
withMaxComputeUnits
(int value) Copy the current immutable object by setting a value for themaxComputeUnits
attribute.final ImmutableDevice
withMaxWorkGroupSize
(long value) Copy the current immutable object by setting a value for themaxWorkGroupSize
attribute.final ImmutableDevice
withMaxWorkItemDimensions
(int value) Copy the current immutable object by setting a value for themaxWorkItemDimensions
attribute.final ImmutableDevice
withMaxWorkItemSizes
(long... elements) Copy the current immutable object with elements that replace the content ofmaxWorkItemSizes
.final ImmutableDevice
Copy the current immutable object by setting a value for thename
attribute.final ImmutableDevice
withPreferredVectorWidthFloat
(int value) Copy the current immutable object by setting a value for thepreferredVectorWidthFloat
attribute.final ImmutableDevice
withVendor
(String value) Copy the current immutable object by setting a value for thevendor
attribute.
-
Field Details
-
deviceId
private final org.jocl.cl_device_id deviceId -
name
-
vendor
-
deviceVersion
-
driverVersion
-
maxClockFrequency
private final int maxClockFrequency -
deviceType
-
builtInKernels
-
maxComputeUnits
private final int maxComputeUnits -
maxWorkItemDimensions
private final int maxWorkItemDimensions -
maxWorkGroupSize
private final long maxWorkGroupSize -
maxWorkItemSizes
private final long[] maxWorkItemSizes -
imageSupport
private final boolean imageSupport -
preferredVectorWidthFloat
private final int preferredVectorWidthFloat
-
-
Constructor Details
-
ImmutableDevice
private ImmutableDevice(org.jocl.cl_device_id deviceId, String name, String vendor, String deviceVersion, String driverVersion, int maxClockFrequency, Set<DeviceType> deviceType, Set<String> builtInKernels, int maxComputeUnits, int maxWorkItemDimensions, long maxWorkGroupSize, long[] maxWorkItemSizes, boolean imageSupport, int preferredVectorWidthFloat)
-
-
Method Details
-
deviceId
public org.jocl.cl_device_id deviceId()Returns the native OpenCL device identifier. -
name
Returns the device name provided by the vendor. -
vendor
Returns the device vendor name. -
deviceVersion
Returns the OpenCL version supported by this device.- Specified by:
deviceVersion
in interfaceDevice
- Returns:
- the device OpenCL version string (e.g., "OpenCL 2.1")
-
driverVersion
Returns the device driver version.- Specified by:
driverVersion
in interfaceDevice
- Returns:
- the driver version string provided by the vendor
-
maxClockFrequency
public int maxClockFrequency()Returns the maximum configured clock frequency of the device compute units in MHz.- Specified by:
maxClockFrequency
in interfaceDevice
- Returns:
- the maximum clock frequency in megahertz
-
deviceType
Returns the set of device types that classify this device.- Specified by:
deviceType
in interfaceDevice
- Returns:
- set of device types (e.g., GPU, CPU, ACCELERATOR)
-
builtInKernels
Returns the set of built-in kernel names available on this device.- Specified by:
builtInKernels
in interfaceDevice
- Returns:
- set of built-in kernel names provided by the device
-
maxComputeUnits
public 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.
- Specified by:
maxComputeUnits
in interfaceDevice
- Returns:
- the number of parallel compute units available
-
maxWorkItemDimensions
public int maxWorkItemDimensions()Returns the maximum number of work-item dimensions supported by the device.- Specified by:
maxWorkItemDimensions
in interfaceDevice
- Returns:
- the maximum number of dimensions for work-item indexing
-
maxWorkGroupSize
public 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.
- Specified by:
maxWorkGroupSize
in interfaceDevice
- Returns:
- the maximum work group size for kernel execution
-
maxWorkItemSizes
public 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.- Specified by:
maxWorkItemSizes
in interfaceDevice
- Returns:
- array of maximum work-item counts per dimension
-
imageSupport
public boolean imageSupport()Returns whether the device supports image objects in kernels.- Specified by:
imageSupport
in interfaceDevice
- Returns:
- true if the device supports image processing operations
-
preferredVectorWidthFloat
public 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.
- Specified by:
preferredVectorWidthFloat
in interfaceDevice
- Returns:
- the preferred vector width for float operations
-
withDeviceId
Copy the current immutable object by setting a value for thedeviceId
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for deviceId- Returns:
- A modified copy of the
this
object
-
withName
Copy the current immutable object by setting a value for thename
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for name- Returns:
- A modified copy of the
this
object
-
withVendor
Copy the current immutable object by setting a value for thevendor
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for vendor- Returns:
- A modified copy of the
this
object
-
withDeviceVersion
Copy the current immutable object by setting a value for thedeviceVersion
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for deviceVersion- Returns:
- A modified copy of the
this
object
-
withDriverVersion
Copy the current immutable object by setting a value for thedriverVersion
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for driverVersion- Returns:
- A modified copy of the
this
object
-
withMaxClockFrequency
Copy the current immutable object by setting a value for themaxClockFrequency
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for maxClockFrequency- Returns:
- A modified copy of the
this
object
-
withDeviceType
Copy the current immutable object with elements that replace the content ofdeviceType
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
withDeviceType
Copy the current immutable object with elements that replace the content ofdeviceType
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of deviceType elements to set- Returns:
- A modified copy of
this
object
-
withBuiltInKernels
Copy the current immutable object with elements that replace the content ofbuiltInKernels
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
withBuiltInKernels
Copy the current immutable object with elements that replace the content ofbuiltInKernels
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of builtInKernels elements to set- Returns:
- A modified copy of
this
object
-
withMaxComputeUnits
Copy the current immutable object by setting a value for themaxComputeUnits
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for maxComputeUnits- Returns:
- A modified copy of the
this
object
-
withMaxWorkItemDimensions
Copy the current immutable object by setting a value for themaxWorkItemDimensions
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for maxWorkItemDimensions- Returns:
- A modified copy of the
this
object
-
withMaxWorkGroupSize
Copy the current immutable object by setting a value for themaxWorkGroupSize
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for maxWorkGroupSize- Returns:
- A modified copy of the
this
object
-
withMaxWorkItemSizes
Copy the current immutable object with elements that replace the content ofmaxWorkItemSizes
. The array is cloned before being saved as attribute values.- Parameters:
elements
- The non-null elements for maxWorkItemSizes- Returns:
- A modified copy of
this
object
-
withImageSupport
Copy the current immutable object by setting a value for theimageSupport
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for imageSupport- Returns:
- A modified copy of the
this
object
-
withPreferredVectorWidthFloat
Copy the current immutable object by setting a value for thepreferredVectorWidthFloat
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for preferredVectorWidthFloat- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableDevice
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:deviceId
,name
,vendor
,deviceVersion
,driverVersion
,maxClockFrequency
,deviceType
,builtInKernels
,maxComputeUnits
,maxWorkItemDimensions
,maxWorkGroupSize
,maxWorkItemSizes
,imageSupport
,preferredVectorWidthFloat
. -
toString
Prints the immutable valueDevice
with attribute values. -
copyOf
Creates an immutable copy of aDevice
value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Parameters:
instance
- The instance to copy- Returns:
- A copied immutable Device instance
-
builder
Creates a builder forImmutableDevice
.ImmutableDevice.builder() .deviceId(org.jocl.cl_device_id) // required
deviceId
.name(String) // requiredname
.vendor(String) // requiredvendor
.deviceVersion(String) // requireddeviceVersion
.driverVersion(String) // requireddriverVersion
.maxClockFrequency(int) // requiredmaxClockFrequency
.addDeviceType|addAllDeviceType(net.bmahe.genetics4j.gpu.opencl.model.DeviceType) //deviceType
elements .addBuiltInKernels|addAllBuiltInKernels(String) //builtInKernels
elements .maxComputeUnits(int) // requiredmaxComputeUnits
.maxWorkItemDimensions(int) // requiredmaxWorkItemDimensions
.maxWorkGroupSize(long) // requiredmaxWorkGroupSize
.maxWorkItemSizes(long) // requiredmaxWorkItemSizes
.imageSupport(boolean) // requiredimageSupport
.preferredVectorWidthFloat(int) // requiredpreferredVectorWidthFloat
.build();- Returns:
- A new ImmutableDevice builder
-
createSafeList
-
createUnmodifiableSet
Unmodifiable set constructed from list to avoid rehashing. -
createUnmodifiableEnumSet
-