Class ImmutableOpenCLExecutionContext.Builder

java.lang.Object
net.bmahe.genetics4j.gpu.opencl.ImmutableOpenCLExecutionContext.Builder
Direct Known Subclasses:
OpenCLExecutionContext.Builder
Enclosing class:
ImmutableOpenCLExecutionContext

public static class ImmutableOpenCLExecutionContext.Builder extends Object
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 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

      private Platform platform
    • device

      private Device device
    • clContext

      private org.jocl.cl_context clContext
    • clCommandQueue

      private org.jocl.cl_command_queue clCommandQueue
    • clProgram

      private org.jocl.cl_program clProgram
    • kernels

      private Map<String,org.jocl.cl_kernel> kernels
    • kernelInfos

      private Map<String,KernelInfo> kernelInfos
  • Constructor Details

    • Builder

      public Builder()
      Creates a builder for ImmutableOpenCLExecutionContext instances.
       new OpenCLExecutionContext.Builder()
          .platform(net.bmahe.genetics4j.gpu.opencl.model.Platform) // required platform
          .device(net.bmahe.genetics4j.gpu.opencl.model.Device) // required device
          .clContext(org.jocl.cl_context) // required clContext
          .clCommandQueue(org.jocl.cl_command_queue) // required clCommandQueue
          .clProgram(org.jocl.cl_program) // required clProgram
          .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 provided OpenCLExecutionContext 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

      public final OpenCLExecutionContext.Builder platform(Platform platform)
      Initializes the value for the platform attribute.
      Parameters:
      platform - The value for platform
      Returns:
      this builder for use in a chained invocation
    • device

      public final OpenCLExecutionContext.Builder device(Device device)
      Initializes the value for the device attribute.
      Parameters:
      device - The value for device
      Returns:
      this builder for use in a chained invocation
    • clContext

      public final OpenCLExecutionContext.Builder clContext(org.jocl.cl_context clContext)
      Initializes the value for the clContext 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 the clCommandQueue attribute.
      Parameters:
      clCommandQueue - The value for clCommandQueue
      Returns:
      this builder for use in a chained invocation
    • clProgram

      public final OpenCLExecutionContext.Builder clProgram(org.jocl.cl_program clProgram)
      Initializes the value for the clProgram attribute.
      Parameters:
      clProgram - The value for clProgram
      Returns:
      this builder for use in a chained invocation
    • putKernels

      public final OpenCLExecutionContext.Builder putKernels(String key, org.jocl.cl_kernel value)
      Put one entry to the kernels map.
      Parameters:
      key - The key in the kernels map
      value - 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 the kernels 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 the kernels 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 to kernels 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

      public final OpenCLExecutionContext.Builder putKernelInfos(String key, KernelInfo value)
      Put one entry to the kernelInfos map.
      Parameters:
      key - The key in the kernelInfos map
      value - 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 the kernelInfos map. Nulls are not permitted
      Parameters:
      entry - The key and value entry
      Returns:
      this builder for use in a chained invocation
    • kernelInfos

      public final OpenCLExecutionContext.Builder kernelInfos(Map<String,? extends KernelInfo> entries)
      Sets or replaces all mappings from the specified map as entries for the kernelInfos 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 to kernelInfos 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

      Returns:
      An immutable instance of OpenCLExecutionContext
      Throws:
      IllegalStateException - if any required attributes are missing
    • formatRequiredAttributesMessage

      private String formatRequiredAttributesMessage()