Package net.bmahe.genetics4j.gpu.opencl
Class ImmutableOpenCLExecutionContext.Builder
java.lang.Object
net.bmahe.genetics4j.gpu.opencl.ImmutableOpenCLExecutionContext.Builder
- Direct Known Subclasses:
OpenCLExecutionContext.Builder
- Enclosing class:
ImmutableOpenCLExecutionContext
Builds instances of type
ImmutableOpenCLExecutionContext
.
Initialize attributes and then invoke the build()
method to create an
immutable instance.
Builder
is not thread-safe and generally should not be stored in a field or collection,
but instead used immediately to create instances.
-
Field Summary
Modifier and TypeFieldDescriptionprivate org.jocl.cl_command_queue
private org.jocl.cl_context
private org.jocl.cl_program
private Device
private static final long
private static final long
private static final long
private static final long
private static final long
private long
private Map
<String, KernelInfo> private Platform
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newImmutableOpenCLExecutionContext
.clCommandQueue
(org.jocl.cl_command_queue clCommandQueue) Initializes the value for theclCommandQueue
attribute.clContext
(org.jocl.cl_context clContext) Initializes the value for theclContext
attribute.clProgram
(org.jocl.cl_program clProgram) Initializes the value for theclProgram
attribute.Initializes the value for thedevice
attribute.private String
from
(OpenCLExecutionContext instance) Fill a builder with attribute values from the providedOpenCLExecutionContext
instance.kernelInfos
(Map<String, ? extends KernelInfo> entries) Sets or replaces all mappings from the specified map as entries for thekernelInfos
map.Sets or replaces all mappings from the specified map as entries for thekernels
map.Initializes the value for theplatform
attribute.putAllKernelInfos
(Map<String, ? extends KernelInfo> entries) Put all mappings from the specified map as entries tokernelInfos
map.putAllKernels
(Map<String, ? extends org.jocl.cl_kernel> entries) Put all mappings from the specified map as entries tokernels
map.putKernelInfos
(String key, KernelInfo value) Put one entry to thekernelInfos
map.putKernelInfos
(Map.Entry<String, ? extends KernelInfo> entry) Put one entry to thekernelInfos
map.putKernels
(String key, org.jocl.cl_kernel value) Put one entry to thekernels
map.putKernels
(Map.Entry<String, ? extends org.jocl.cl_kernel> entry) Put one entry to thekernels
map.
-
Field Details
-
INIT_BIT_PLATFORM
private static final long INIT_BIT_PLATFORM- See Also:
-
INIT_BIT_DEVICE
private static final long INIT_BIT_DEVICE- See Also:
-
INIT_BIT_CL_CONTEXT
private static final long INIT_BIT_CL_CONTEXT- See Also:
-
INIT_BIT_CL_COMMAND_QUEUE
private static final long INIT_BIT_CL_COMMAND_QUEUE- See Also:
-
INIT_BIT_CL_PROGRAM
private static final long INIT_BIT_CL_PROGRAM- See Also:
-
initBits
private long initBits -
platform
-
device
-
clContext
private org.jocl.cl_context clContext -
clCommandQueue
private org.jocl.cl_command_queue clCommandQueue -
clProgram
private org.jocl.cl_program clProgram -
kernels
-
kernelInfos
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableOpenCLExecutionContext
instances.new OpenCLExecutionContext.Builder() .platform(net.bmahe.genetics4j.gpu.opencl.model.Platform) // required
platform
.device(net.bmahe.genetics4j.gpu.opencl.model.Device) // requireddevice
.clContext(org.jocl.cl_context) // requiredclContext
.clCommandQueue(org.jocl.cl_command_queue) // requiredclCommandQueue
.clProgram(org.jocl.cl_program) // requiredclProgram
.putKernels|putAllKernels(String => org.jocl.cl_kernel) //kernels
mappings .putKernelInfos|putAllKernelInfos(String => net.bmahe.genetics4j.gpu.opencl.model.KernelInfo) //kernelInfos
mappings .build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedOpenCLExecutionContext
instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.- Parameters:
instance
- The instance from which to copy values- Returns:
this
builder for use in a chained invocation
-
platform
Initializes the value for theplatform
attribute.- Parameters:
platform
- The value for platform- Returns:
this
builder for use in a chained invocation
-
device
Initializes the value for thedevice
attribute.- Parameters:
device
- The value for device- Returns:
this
builder for use in a chained invocation
-
clContext
Initializes the value for theclContext
attribute.- Parameters:
clContext
- The value for clContext- Returns:
this
builder for use in a chained invocation
-
clCommandQueue
public final OpenCLExecutionContext.Builder clCommandQueue(org.jocl.cl_command_queue clCommandQueue) Initializes the value for theclCommandQueue
attribute.- Parameters:
clCommandQueue
- The value for clCommandQueue- Returns:
this
builder for use in a chained invocation
-
clProgram
Initializes the value for theclProgram
attribute.- Parameters:
clProgram
- The value for clProgram- Returns:
this
builder for use in a chained invocation
-
putKernels
Put one entry to thekernels
map.- Parameters:
key
- The key in the kernels mapvalue
- The associated value in the kernels map- Returns:
this
builder for use in a chained invocation
-
putKernels
public final OpenCLExecutionContext.Builder putKernels(Map.Entry<String, ? extends org.jocl.cl_kernel> entry) Put one entry to thekernels
map. Nulls are not permitted- Parameters:
entry
- The key and value entry- Returns:
this
builder for use in a chained invocation
-
kernels
public final OpenCLExecutionContext.Builder kernels(Map<String, ? extends org.jocl.cl_kernel> entries) Sets or replaces all mappings from the specified map as entries for thekernels
map. Nulls are not permitted- Parameters:
entries
- The entries that will be added to the kernels map- Returns:
this
builder for use in a chained invocation
-
putAllKernels
public final OpenCLExecutionContext.Builder putAllKernels(Map<String, ? extends org.jocl.cl_kernel> entries) Put all mappings from the specified map as entries tokernels
map. Nulls are not permitted- Parameters:
entries
- The entries that will be added to the kernels map- Returns:
this
builder for use in a chained invocation
-
putKernelInfos
Put one entry to thekernelInfos
map.- Parameters:
key
- The key in the kernelInfos mapvalue
- The associated value in the kernelInfos map- Returns:
this
builder for use in a chained invocation
-
putKernelInfos
public final OpenCLExecutionContext.Builder putKernelInfos(Map.Entry<String, ? extends KernelInfo> entry) Put one entry to thekernelInfos
map. Nulls are not permitted- Parameters:
entry
- The key and value entry- Returns:
this
builder for use in a chained invocation
-
kernelInfos
Sets or replaces all mappings from the specified map as entries for thekernelInfos
map. Nulls are not permitted- Parameters:
entries
- The entries that will be added to the kernelInfos map- Returns:
this
builder for use in a chained invocation
-
putAllKernelInfos
public final OpenCLExecutionContext.Builder putAllKernelInfos(Map<String, ? extends KernelInfo> entries) Put all mappings from the specified map as entries tokernelInfos
map. Nulls are not permitted- Parameters:
entries
- The entries that will be added to the kernelInfos map- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableOpenCLExecutionContext
.- Returns:
- An immutable instance of OpenCLExecutionContext
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-