Class CL20

Direct Known Subclasses:
CL21

public class CL20 extends CL12
The core OpenCL 2.0 functionality.
  • Field Details

    • CL_VERSION_2_0

      public static final int CL_VERSION_2_0
      OpenCL Version.
      See Also:
    • CL_INVALID_PIPE_SIZE

      public static final int CL_INVALID_PIPE_SIZE
      Error Codes
      See Also:
    • CL_INVALID_DEVICE_QUEUE

      public static final int CL_INVALID_DEVICE_QUEUE
      Error Codes
      See Also:
    • CL_DEVICE_QUEUE_ON_HOST_PROPERTIES

      public static final int CL_DEVICE_QUEUE_ON_HOST_PROPERTIES
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_command_queue_properties value.

      Describes the on host command-queue properties supported by the device. This is a bitfield that describes one or more of the following values:

      The mandated minimum capability is: CL_QUEUE_PROFILING_ENABLE.

      See Also:
    • CL_DEVICE_IMAGE_PITCH_ALIGNMENT

      public static final int CL_DEVICE_IMAGE_PITCH_ALIGNMENT
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      The row pitch alignment size in pixels for images created from a buffer. The value returned must be a power of 2. If the device does not support images, this value should be 0.

      See Also:
    • CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT

      public static final int CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      This query should be used when an image is created from a buffer which was created using MEM_USE_HOST_PTR. The value returned must be a power of 2.

      This query specifies the minimum alignment in pixels of the host_ptr specified to CreateBuffer. If the device does not support images, this value should be 0.

      See Also:
    • CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS

      public static final int CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      Max number of image objects arguments of a kernel declared with the write_only or read_write qualifier.

      Support for read-write image arguments is required for an OpenCL 2.0, 2.1, or 2.2 device if DEVICE_IMAGE_SUPPORT is TRUE.

      The minimum value is 64 if the device supports read-write images arguments, and must be 0 for devices that do not support read-write images.

      See Also:
    • CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE

      public static final int CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE
      Accepted as the param_name parameter of GetDeviceInfo, returns a size_t value.

      The maximum number of bytes of storage that may be allocated for any single variable in program scope or inside a function in an OpenCL kernel language declared in the global address space.

      Support for program scope global variables is required for an OpenCL 2.0, 2.1, or 2.2 device. The minimum value is 64 KB if the device supports program scope global variables, and must be 0 for devices that do not support program scope global variables.

      See Also:
    • CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES

      public static final int CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_command_queue_properties value.

      Describes the on device command-queue properties supported by the device. This is a bitfield that describes one or more of the following values:

      Support for on-device queues is required for an OpenCL 2.0, 2.1, or 2.2 device. When on-device queues are supported, the mandated minimum capability is:

      
               CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE |
               CL_QUEUE_PROFILING_ENABLE.    

      Must be 0 for devices that do not support on-device queues.

      See Also:
    • CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE

      public static final int CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      The preferred size of the device queue, in bytes. Applications should use this size for the device queue to ensure good performance.

      The minimum value is 16 KB for devices supporting on-device queues, and must be 0 for devices that do not support on-device queues.

      See Also:
    • CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE

      public static final int CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      The maximum size of the device queue in bytes.

      The minimum value is 256 KB for the full profile and 64 KB for the embedded profile for devices supporting on-device queues, and must be 0 for devices that do not support on-device queues.

      See Also:
    • CL_DEVICE_MAX_ON_DEVICE_QUEUES

      public static final int CL_DEVICE_MAX_ON_DEVICE_QUEUES
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      The maximum number of device queues that can be created for this device in a single context.

      The minimum value is 1 for devices supporting on-device queues, and must be 0 for devices that do not support on-device queues.

      See Also:
    • CL_DEVICE_MAX_ON_DEVICE_EVENTS

      public static final int CL_DEVICE_MAX_ON_DEVICE_EVENTS
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      The maximum number of events in use by a device queue. These refer to events returned by the enqueue_ built-in functions to a device queue or user events returned by the create_user_event built-in function that have not been released.

      The minimum value is 1024 for devices supporting on-device queues, and must be 0 for devices that do not support on-device queues.

      See Also:
    • CL_DEVICE_SVM_CAPABILITIES

      public static final int CL_DEVICE_SVM_CAPABILITIES
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_device_svm_capabilities value.

      Describes the various shared virtual memory (SVM) memory allocation types the device supports. This is a bit-field that describes a combination of the following values:

      • DEVICE_SVM_COARSE_GRAIN_BUFFER - Support for coarse-grain buffer sharing using SVMAlloc. Memory consistency is guaranteed at synchronization points and the host must use calls to EnqueueMapBuffer and EnqueueUnmapMemObject.
      • DEVICE_SVM_FINE_GRAIN_BUFFER - Support for fine-grain buffer sharing using clSVMAlloc. Memory consistency is guaranteed at synchronization points without need for clEnqueueMapBuffer and clEnqueueUnmapMemObject.
      • DEVICE_SVM_FINE_GRAIN_SYSTEM - Support for sharing the host’s entire virtual memory including memory allocated using malloc. Memory consistency is guaranteed at synchronization points.
      • DEVICE_SVM_ATOMICS - Support for the OpenCL 2.0 atomic operations that provide memory consistency across the host and all OpenCL devices supporting fine-grain SVM allocations.

      The mandated minimum capability for an OpenCL 2.0, 2.1, or 2.2 device is CL_DEVICE_SVM_COARSE_GRAIN_BUFFER.

      For other device versions there is no mandated minimum capability.

      See Also:
    • CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE

      public static final int CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE
      Accepted as the param_name parameter of GetDeviceInfo, returns a size_t value.

      Maximum preferred total size, in bytes, of all program variables in the global address space. This is a performance hint. An implementation may place such variables in storage with optimized device access. This query returns the capacity of such storage. The minimum value is 0.

      See Also:
    • CL_DEVICE_MAX_PIPE_ARGS

      public static final int CL_DEVICE_MAX_PIPE_ARGS
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      The maximum number of pipe objects that can be passed as arguments to a kernel. The minimum value is 16 for devices supporting pipes, and must be 0 for devices that do not support pipes.

      See Also:
    • CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS

      public static final int CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      The maximum number of reservations that can be active for a pipe per work-item in a kernel. A work-group reservation is counted as one reservation per work-item. The minimum value is 1 for devices supporting pipes, and must be 0 for devices that do not support pipes.

      See Also:
    • CL_DEVICE_PIPE_MAX_PACKET_SIZE

      public static final int CL_DEVICE_PIPE_MAX_PACKET_SIZE
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      The maximum size of pipe packet in bytes.

      Support for pipes is required for an OpenCL 2.0, 2.1, or 2.2 device. The minimum value is 1024 bytes if the device supports pipes, and must be 0 for devices that do not support pipes.

      See Also:
    • CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT

      public static final int CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      Returns the value representing the preferred alignment in bytes for OpenCL 2.0 fine-grained SVM atomic types. This query can return 0 which indicates that the preferred alignment is aligned to the natural size of the type.

      See Also:
    • CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT

      public static final int CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      Returns the value representing the preferred alignment in bytes for OpenCL 2.0 atomic types to global memory. This query can return 0 which indicates that the preferred alignment is aligned to the natural size of the type.

      See Also:
    • CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT

      public static final int CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT
      Accepted as the param_name parameter of GetDeviceInfo, returns a cl_uint value.

      Returns the value representing the preferred alignment in bytes for OpenCL 2.0 atomic types to local memory. This query can return 0 which indicates that the preferred alignment is aligned to the natural size of the type.

      See Also:
    • CL_QUEUE_ON_DEVICE

      public static final int CL_QUEUE_ON_DEVICE
      cl_command_queue_properties
      See Also:
    • CL_QUEUE_ON_DEVICE_DEFAULT

      public static final int CL_QUEUE_ON_DEVICE_DEFAULT
      cl_command_queue_properties
      See Also:
    • CL_DEVICE_SVM_COARSE_GRAIN_BUFFER

      public static final int CL_DEVICE_SVM_COARSE_GRAIN_BUFFER
      cl_device_svm_capabilities
      See Also:
    • CL_DEVICE_SVM_FINE_GRAIN_BUFFER

      public static final int CL_DEVICE_SVM_FINE_GRAIN_BUFFER
      cl_device_svm_capabilities
      See Also:
    • CL_DEVICE_SVM_FINE_GRAIN_SYSTEM

      public static final int CL_DEVICE_SVM_FINE_GRAIN_SYSTEM
      cl_device_svm_capabilities
      See Also:
    • CL_DEVICE_SVM_ATOMICS

      public static final int CL_DEVICE_SVM_ATOMICS
      cl_device_svm_capabilities
      See Also:
    • CL_QUEUE_SIZE

      public static final int CL_QUEUE_SIZE
      Accepted cl_uint value for the properties parameter to CreateCommandQueueWithProperties.

      Specifies the size of the device queue in bytes.

      This can only be specified if QUEUE_ON_DEVICE is set in QUEUE_PROPERTIES. This must be a value ≤ DEVICE_QUEUE_ON_DEVICE_MAX_SIZE.

      For best performance, this should be ≤ DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE.

      If CL_QUEUE_SIZE is not specified, the device queue is created with CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE as the size of the queue.

      See Also:
    • CL_MEM_SVM_FINE_GRAIN_BUFFER

      public static final int CL_MEM_SVM_FINE_GRAIN_BUFFER
      SVM memory flag accepted by SVMAlloc.

      This specifies that the application wants the OpenCL implementation to do a fine-grained allocation.

      See Also:
    • CL_MEM_SVM_ATOMICS

      public static final int CL_MEM_SVM_ATOMICS
      SVM memory flag accepted by SVMAlloc.

      This flag is valid only if MEM_SVM_FINE_GRAIN_BUFFER is specified in flags. It is used to indicate that SVM atomic operations can control visibility of memory accesses in this SVM buffer.

      See Also:
    • CL_MEM_KERNEL_READ_AND_WRITE

      public static final int CL_MEM_KERNEL_READ_AND_WRITE
      This flag is only used by GetSupportedImageFormats to query image formats that may be both read from and written to by the same kernel instance. To create a memory object that may be read from and written to use MEM_READ_WRITE.
      See Also:
    • CL_MEM_OBJECT_PIPE

      public static final int CL_MEM_OBJECT_PIPE
      cl_mem_object_type
      See Also:
    • CL_MEM_USES_SVM_POINTER

      public static final int CL_MEM_USES_SVM_POINTER
      Accepted as the param_name parameter of GetMemObjectInfo, returns a cl_bool value.

      Return TRUE if memobj is a buffer object that was created with MEM_USE_HOST_PTR or is a sub-buffer object of a buffer object that was created with CL_MEM_USE_HOST_PTR and the host_ptr specified when the buffer object was created is a SVM pointer; otherwise returns FALSE.

      See Also:
    • CL_sRGB

      public static final int CL_sRGB
      cl_channel_order
      See Also:
    • CL_sRGBx

      public static final int CL_sRGBx
      cl_channel_order
      See Also:
    • CL_sRGBA

      public static final int CL_sRGBA
      cl_channel_order
      See Also:
    • CL_sBGRA

      public static final int CL_sBGRA
      cl_channel_order
      See Also:
    • CL_ABGR

      public static final int CL_ABGR
      cl_channel_order
      See Also:
    • CL_PIPE_PACKET_SIZE

      public static final int CL_PIPE_PACKET_SIZE
      Accepted as the param_name parameter of GetPipeInfo, returns a cl_uint value.

      Return pipe packet size specified when pipe is created with CreatePipe.

      See Also:
    • CL_PIPE_MAX_PACKETS

      public static final int CL_PIPE_MAX_PACKETS
      Accepted as the param_name parameter of GetPipeInfo, returns a cl_uint value.

      Return max. number of packets specified when pipe is created with CreatePipe.

      See Also:
    • CL_SAMPLER_MIP_FILTER_MODE

      public static final int CL_SAMPLER_MIP_FILTER_MODE
      cl_sampler_info
      See Also:
    • CL_SAMPLER_LOD_MIN

      public static final int CL_SAMPLER_LOD_MIN
      cl_sampler_info
      See Also:
    • CL_SAMPLER_LOD_MAX

      public static final int CL_SAMPLER_LOD_MAX
      cl_sampler_info
      See Also:
    • CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE

      public static final int CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE
      Accepted as the param_name parameter of GetProgramBuildInfo, returns a size_t value.

      The total amount of storage, in bytes, used by program variables in the global address space.

      See Also:
    • CL_KERNEL_ARG_TYPE_PIPE

      public static final int CL_KERNEL_ARG_TYPE_PIPE
      cl_kernel_arg_type_qualifier
      See Also:
    • CL_KERNEL_EXEC_INFO_SVM_PTRS

      public static final int CL_KERNEL_EXEC_INFO_SVM_PTRS
      Accepted as the param_name parameter of SetKernelExecInfo, returns a void*[] value.

      SVM pointers must reference locations contained entirely within buffers that are passed to kernel as arguments, or that are passed through the execution information.

      Non-argument SVM buffers must be specified by passing pointers to those buffers via clSetKernelExecInfo for coarse-grain and fine-grain buffer SVM allocations but not for finegrain system SVM allocations.

      See Also:
    • CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM

      public static final int CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM
      Accepted as the param_name parameter of SetKernelExecInfo, returns a cl_bool value.

      This flag indicates whether the kernel uses pointers that are fine grain system SVM allocations. These fine grain system SVM pointers may be passed as arguments or defined in SVM buffers that are passed as arguments to kernel.

      See Also:
    • CL_COMMAND_SVM_FREE

      public static final int CL_COMMAND_SVM_FREE
      cl_command_type
      See Also:
    • CL_COMMAND_SVM_MEMCPY

      public static final int CL_COMMAND_SVM_MEMCPY
      cl_command_type
      See Also:
    • CL_COMMAND_SVM_MEMFILL

      public static final int CL_COMMAND_SVM_MEMFILL
      cl_command_type
      See Also:
    • CL_COMMAND_SVM_MAP

      public static final int CL_COMMAND_SVM_MAP
      cl_command_type
      See Also:
    • CL_COMMAND_SVM_UNMAP

      public static final int CL_COMMAND_SVM_UNMAP
      cl_command_type
      See Also:
    • CL_PROFILING_COMMAND_COMPLETE

      public static final int CL_PROFILING_COMMAND_COMPLETE
      Accepted as the param_name parameter of GetEventProfilingInfo, returns a cl_ulong value.

      A 64-bit value that describes the current device time counter in nanoseconds when the command identified by event and any child commands enqueued by this command on the device have finished execution.

      See Also:
  • Method Details

    • nclCreateCommandQueueWithProperties

      public static long nclCreateCommandQueueWithProperties(long context, long device, long properties, long errcode_ret)
    • clCreateCommandQueueWithProperties

      public static long clCreateCommandQueueWithProperties(long context, long device, @Nullable LongBuffer properties, @Nullable IntBuffer errcode_ret)
      Creates a host or device command-queue on a specific device.

      OpenCL objects such as memory, program and kernel objects are created using a context. Operations on these objects are performed using a command-queue. The command-queue can be used to queue a set of operations (referred to as commands) in order. Having multiple command-queues allows applications to queue multiple independent commands without requiring synchronization. Note that this should work as long as these objects are not being shared. Sharing of objects across multiple command-queues will require the application to perform appropriate synchronization.

      Parameters:
      context - a valid OpenCL context
      device - a device associated with context. It can either be in the list of devices specified when context is created using CreateContext or have the same device type as device type specified when context is created using CreateContextFromType.
      properties - a list of properties for the command-queue and their corresponding values. Each property name is immediately followed by the corresponding desired value. The list is terminated with 0. If a supported property and its value is not specified in properties, its default value will be used. properties can be NULL in which case the default values for supported command-queue properties will be used. One of:
      QUEUE_PROPERTIESQUEUE_SIZE
      errcode_ret - will return an appropriate error code. If errcode_ret is NULL, no error code is returned.
      Returns:
      a valid non-zero command-queue and errcode_ret is set to SUCCESS if the command-queue is created successfully. Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:
      • INVALID_CONTEXT if context is not a valid context.
      • INVALID_DEVICE if device is not a valid device or is not associated with context.
      • INVALID_VALUE if values specified in properties are not valid.
      • INVALID_QUEUE_PROPERTIES if values specified in properties are valid but are not supported by the device.
      • OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
      • OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
      See Also:
    • nclCreatePipe

      public static long nclCreatePipe(long context, long flags, int pipe_packet_size, int pipe_max_packets, long properties, long errcode_ret)
      Unsafe version of: CreatePipe
    • clCreatePipe

      public static long clCreatePipe(long context, long flags, int pipe_packet_size, int pipe_max_packets, @Nullable PointerBuffer properties, @Nullable IntBuffer errcode_ret)
      Creates a pipe object.
      Parameters:
      context - a valid OpenCL context used to create the pipe object
      flags - a bit-field that is used to specify allocation and usage information such as the memory arena that should be used to allocate the pipe object and how it will be used. If value specified for flags is 0, the default is used which is MEM_READ_WRITE.
      pipe_packet_size - the size in bytes of a pipe packet
      pipe_max_packets - the pipe capacity by specifying the maximum number of packets the pipe can hold
      properties - a list of properties for the pipe and their corresponding values. Each property name is immediately followed by the corresponding desired value. The list is terminated with 0. In OpenCL 2.0, properties must be NULL.
      errcode_ret - will return an appropriate error code. If errcode_ret is NULL, no error code is returned.
      Returns:
      a valid non-zero pipe object and errcode_ret is set to SUCCESS if the pipe object is created successfully. Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:
      See Also:
    • nclGetPipeInfo

      public static int nclGetPipeInfo(long pipe, int param_name, long param_value_size, long param_value, long param_value_size_ret)
      Unsafe version of: GetPipeInfo
      Parameters:
      param_value_size - the size in bytes of memory pointed to by param_value. This size must be ≥ size of return type. If param_value is NULL, it is ignored.
    • clGetPipeInfo

      public static int clGetPipeInfo(long pipe, int param_name, @Nullable ByteBuffer param_value, @Nullable PointerBuffer param_value_size_ret)
      Queries information specific to a pipe object.
      Parameters:
      pipe - the pipe object being queried
      param_name - the information to query
      param_value - a pointer to memory where the appropriate result being queried is returned. If param_value is NULL, it is ignored.
      param_value_size_ret - the actual size in bytes of data being queried by param_value. If NULL, it is ignored.
      Returns:
      SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
      • INVALID_VALUE if param_name is not valid, or if size in bytes specified by param_value_size is < size of return type and param_value is not NULL.
      • INVALID_MEM_OBJECT if pipe is not a valid pipe object.
      • OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
      • OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
      See Also:
    • clGetPipeInfo

      public static int clGetPipeInfo(long pipe, int param_name, @Nullable IntBuffer param_value, @Nullable PointerBuffer param_value_size_ret)
      Queries information specific to a pipe object.
      Parameters:
      pipe - the pipe object being queried
      param_name - the information to query
      param_value - a pointer to memory where the appropriate result being queried is returned. If param_value is NULL, it is ignored.
      param_value_size_ret - the actual size in bytes of data being queried by param_value. If NULL, it is ignored.
      Returns:
      SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
      • INVALID_VALUE if param_name is not valid, or if size in bytes specified by param_value_size is < size of return type and param_value is not NULL.
      • INVALID_MEM_OBJECT if pipe is not a valid pipe object.
      • OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
      • OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
      See Also:
    • nclSVMAlloc

      public static long nclSVMAlloc(long context, long flags, long size, int alignment)
      Unsafe version of: SVMAlloc
    • clSVMAlloc

      @Nullable public static ByteBuffer clSVMAlloc(long context, long flags, long size, int alignment)
      Allocates a shared virtual memory buffer (referred to as a SVM buffer) that can be shared by the host and all devices in an OpenCL context that support shared virtual memory.

      If MEM_SVM_FINE_GRAIN_BUFFER is not specified, the buffer can be created as a coarse grained SVM allocation. Similarly, if MEM_SVM_ATOMICS is not specified, the buffer can be created without support for the OpenCL 2.0 SVM atomic operations.

      Calling SVMAlloc does not itself provide consistency for the shared memory region. When the host can't use the SVM atomic operations, it must rely on OpenCL's guaranteed memory consistency at synchronization points. To initialize a buffer to be shared with a kernel, the host can create the buffer and use the resulting virtual memory pointer to initialize the buffer's contents.

      For SVM to be used efficiently, the host and any devices sharing a buffer containing virtual memory pointers should have the same endianness. If the context passed to SVMAlloc has devices with mixed endianness and the OpenCL implementation is unable to implement SVM because of that mixed endianness, SVMAlloc will fail and return NULL.

      Although SVM is generally not supported for image objects, CreateImage may create an image from a buffer (a 1D image from a buffer or a 2D image from buffer) if the buffer specified in its image description parameter is a SVM buffer. Such images have a linear memory representation so their memory can be shared using SVM. However, fine grained sharing and atomics are not supported for image reads and writes in a kernel.

      If CreateBuffer is called with a pointer returned by SVMAlloc as its host_ptr argument, and MEM_USE_HOST_PTR is set in its flags argument, CreateBuffer will succeed and return a valid non-zero buffer object as long as the size argument to CreateBuffer is no larger than the size argument passed in the original SVMAlloc call. The new buffer object returned has the shared memory as the underlying storage. Locations in the buffer's underlying shared memory can be operated on using, e.g., atomic operations if the device supports them.

      Parameters:
      context - a valid OpenCL context used to create the SVM buffer
      flags - a bit-field that is used to specify allocation and usage information. One of:
      MEM_READ_WRITEMEM_WRITE_ONLYMEM_READ_ONLYMEM_SVM_FINE_GRAIN_BUFFERMEM_SVM_ATOMICS
      size - the size in bytes of the SVM buffer to be allocated
      alignment - the minimum alignment in bytes that is required for the newly created buffer's memory region. It must be a power of two up to the largest data type supported by the OpenCL device. For the full profile, the largest data type is long16. For the embedded profile, it is long16 if the device supports 64-bit integers; otherwise it is int16. If alignment is 0, a default alignment will be used that is equal to the size of largest data type supported by the OpenCL implementation.
      Returns:
      a valid non-NULL shared virtual memory address if the SVM buffer is successfully allocated. Otherwise, like malloc, it returns a NULL pointer value. SVMAlloc will fail if:
      • context is not a valid context.
      • flags does not contain MEM_SVM_FINE_GRAIN_BUFFER but does contain MEM_SVM_ATOMICS.
      • Values specified in flags do not follow rules for supported values.
      • MEM_SVM_FINE_GRAIN_BUFFER or MEM_SVM_ATOMICS is specified in flags and these are not supported by at least one device in context.
      • The values specified in flags are not valid.
      • size is 0 or > DEVICE_MAX_MEM_ALLOC_SIZE value for any device in context.
      • alignment is not a power of two or the OpenCL implementation cannot support the specified alignment for at least one device in context.
      • There was a failure to allocate resources.
      See Also:
    • nclSVMFree

      public static void nclSVMFree(long context, long svm_pointer)
      Unsafe version of: SVMFree
    • clSVMFree

      public static void clSVMFree(long context, ByteBuffer svm_pointer)
      Frees a shared virtual memory buffer allocated using SVMAlloc.

      Note that SVMFree does not wait for previously enqueued commands that may be using svm_pointer to finish before freeing svm_pointer. It is the responsibility of the application to make sure that enqueued commands that use svm_pointer have finished before freeing svm_pointer. This can be done by enqueuing a blocking operation such as Finish, WaitForEvents, EnqueueReadBuffer or by registering a callback with the events associated with enqueued commands and when the last enqueued command has finished freeing svm_pointer.

      The behavior of using svm_pointer after it has been freed is undefined. In addition, if a buffer object is created using CreateBuffer with svm_pointer, the buffer object must first be released before the svm_pointer is freed.

      Parameters:
      context - a valid OpenCL context used to create the SVM buffer
      svm_pointer - must be the value returned by a call to SVMAlloc. If a NULL pointer is passed in svm_pointer, no action occurs.
      See Also:
    • nclEnqueueSVMFree

      public static int nclEnqueueSVMFree(long command_queue, int num_svm_pointers, long svm_pointers, long pfn_free_func, long user_data, int num_events_in_wait_list, long event_wait_list, long event)
      Unsafe version of: EnqueueSVMFree
      Parameters:
      num_svm_pointers - the number of pointers in the svm_pointers array
      num_events_in_wait_list - the number of events in event_wait_list
    • clEnqueueSVMFree

      public static int clEnqueueSVMFree(long command_queue, PointerBuffer svm_pointers, @Nullable CLSVMFreeCallbackI pfn_free_func, long user_data, @Nullable PointerBuffer event_wait_list, @Nullable PointerBuffer event)
      Enqueues a command to free the shared virtual memory buffer allocated using SVMAlloc or a shared system memory pointer.
      Parameters:
      command_queue - a valid host command-queue
      svm_pointers - the shared virtual memory pointers to be freed. Each pointer in svm_pointers that was allocated using SVMAlloc must have been allocated from the same context from which command_queue was created. The memory associated with svm_pointers can be reused or freed after the function returns.
      pfn_free_func - the callback function to be called to free the SVM pointers. If pfn_free_func is NULL, all pointers specified in svm_pointers must be allocated using SVMAlloc and the OpenCL implementation will free these SVM pointers. pfn_free_func must be a valid callback function if any SVM pointer to be freed is a shared system memory pointer i.e. not allocated using SVMAlloc. If pfn_free_func is a valid callback function, the OpenCL implementation will call pfn_free_func to free all the SVM pointers specified in svm_pointers.
      user_data - will be passed as the user_data argument when pfn_free_func is called. user_data can be NULL.
      event_wait_list - a list of events that need to complete before this particular command can be executed. If event_wait_list is NULL, then this particular command does not wait on any event to complete. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same.
      event - Returns an event object that identifies this particular command and can be used to query or queue a wait for this particular command to complete. event can be NULL in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete. If the event_wait_list and the event arguments are not NULL, the event argument should not refer to an element of the event_wait_list array.
      Returns:
      SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
      • INVALID_COMMAND_QUEUE if command_queue is not a valid command-queue.
      • INVALID_VALUE if num_svm_pointers is 0 or if svm_pointers is NULL or if any of the pointers specified in svm_pointers array is NULL.
      • INVALID_EVENT_WAIT_LIST if event_wait_list is NULL and num_events_in_wait_list > 0, or event_wait_list is not NULL and num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.
      • OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
      • OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
      See Also:
    • nclEnqueueSVMMemcpy

      public static int nclEnqueueSVMMemcpy(long command_queue, int blocking_copy, long dst_ptr, long src_ptr, long size, int num_events_in_wait_list, long event_wait_list, long event)
      Unsafe version of: EnqueueSVMMemcpy
      Parameters:
      size - the size in bytes of data being copied
      num_events_in_wait_list - the number of events in event_wait_list
    • clEnqueueSVMMemcpy

      public static int clEnqueueSVMMemcpy(long command_queue, boolean blocking_copy, ByteBuffer dst_ptr, ByteBuffer src_ptr, @Nullable PointerBuffer event_wait_list, @Nullable PointerBuffer event)
      Enqueues a command to do a memcpy operation.

      If dst_ptr and/or src_ptr are allocated using SVMAlloc then they must be allocated from the same context from which command_queue was created. Otherwise the behavior is undefined.

      Parameters:
      command_queue - the host command-queue in which the read / write command will be queued
      blocking_copy - indicates if the copy operation is blocking or non-blocking.

      If blocking_copy is TRUE i.e. the copy command is blocking, EnqueueSVMMemcpy does not return until the buffer data has been copied into memory pointed to by dst_ptr.

      If blocking_copy is FALSE i.e. the copy command is non-blocking, EnqueueSVMMemcpy queues a non-blocking copy command and returns. The contents of the buffer that dst_ptr point to cannot be used until the copy command has completed. The event argument returns an event object which can be used to query the execution status of the read command. When the copy command has completed, the contents of the buffer that dst_ptr points to can be used by the application.

      dst_ptr - the pointer to a memory region where data is copied to
      src_ptr - the pointer to a memory region where data is copied from
      event_wait_list - a list of events that need to complete before this particular command can be executed. If event_wait_list is NULL, then this particular command does not wait on any event to complete. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same.
      event - Returns an event object that identifies this particular command and can be used to query or queue a wait for this particular command to complete. event can be NULL in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete. If the event_wait_list and the event arguments are not NULL, the event argument should not refer to an element of the event_wait_list array.
      Returns:
      SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
      • INVALID_COMMAND_QUEUE if command_queue is not a valid command-queue.
      • INVALID_CONTEXT if the context associated with command_queue and events in event_wait_list are not the same.
      • INVALID_EVENT_WAIT_LIST if event_wait_list is NULL and num_events_in_wait_list > 0, or event_wait_list is not NULL and num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.
      • EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST if the copy operation is blocking and the execution status of any of the events in event_wait_list is a negative integer value.
      • INVALID_VALUE if dst_ptr or src_ptr are NULL.
      • INVALID_VALUE if size is 0.
      • MEM_COPY_OVERLAP if the values specified for dst_ptr, src_ptr and size result in an overlapping copy.
      • OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
      • OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
      See Also:
    • nclEnqueueSVMMemFill

      public static int nclEnqueueSVMMemFill(long command_queue, long svm_ptr, long pattern, long pattern_size, long size, int num_events_in_wait_list, long event_wait_list, long event)
      Unsafe version of: EnqueueSVMMemFill
      Parameters:
      pattern_size - the size of the pattern array, in bytes
      size - the size in bytes of region being filled starting with svm_ptr and must be a multiple of pattern_size
      num_events_in_wait_list - the number of events in event_wait_list
    • clEnqueueSVMMemFill

      public static int clEnqueueSVMMemFill(long command_queue, ByteBuffer svm_ptr, ByteBuffer pattern, @Nullable PointerBuffer event_wait_list, @Nullable PointerBuffer event)
      Enqueues a command to fill a region in memory with a pattern of a given pattern size.
      Parameters:
      command_queue - the host command-queue in which the fill command will be queued
      svm_ptr - a pointer to a memory region that will be filled with pattern. It must be aligned to pattern_size bytes. If svm_ptr is allocated using SVMAlloc then it must be allocated from the same context from which command_queue was created. Otherwise the behavior is undefined.
      pattern - a pointer to the data pattern of size pattern_size in bytes. pattern will be used to fill a region in buffer starting at svm_ptr and is size bytes in size. The data pattern must be a scalar or vector integer or floating-point data type supported by OpenCL. For example, if region pointed to by svm_ptr is to be filled with a pattern of float4 values, then pattern will be a pointer to a cl_float4 value and pattern_size will be sizeof(cl_float4). The maximum value of pattern_size is the size of the largest integer or floating-point vector data type supported by the OpenCL device. The memory associated with pattern can be reused or freed after the function returns.
      event_wait_list - a list of events that need to complete before this particular command can be executed. If event_wait_list is NULL, then this particular command does not wait on any event to complete. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same.
      event - Returns an event object that identifies this particular command and can be used to query or queue a wait for this particular command to complete. event can be NULL in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete. If the event_wait_list and the event arguments are not NULL, the event argument should not refer to an element of the event_wait_list array.
      Returns:
      SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
      • INVALID_COMMAND_QUEUE if command_queue is not a valid command-queue.
      • INVALID_CONTEXT if the context associated with command_queue and events in event_wait_list are not the same.
      • INVALID_VALUE if svm_ptr is NULL.
      • INVALID_VALUE if svm_ptr is not aligned to pattern_size bytes.
      • INVALID_VALUE if pattern is NULL or if pattern_size is 0 or if pattern_size is not one of &#123;1, 2, 4, 8, 16, 32, 64, 128&#125;.
      • INVALID_VALUE if size is 0 or is not a multiple of pattern_size.
      • INVALID_EVENT_WAIT_LIST if event_wait_list is NULL and num_events_in_wait_list > 0, or event_wait_list is not NULL and num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.
      • OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
      • OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
      See Also:
    • nclEnqueueSVMMap

      public static int nclEnqueueSVMMap(long command_queue, int blocking_map, long map_flags, long svm_ptr, long size, int num_events_in_wait_list, long event_wait_list, long event)
      Unsafe version of: EnqueueSVMMap
      Parameters:
      size - the size of the memory region to map, in bytes
      num_events_in_wait_list - the number of events in event_wait_list
    • clEnqueueSVMMap

      public static int clEnqueueSVMMap(long command_queue, boolean blocking_map, long map_flags, ByteBuffer svm_ptr, @Nullable PointerBuffer event_wait_list, @Nullable PointerBuffer event)
      Enqueues a command that will allow the host to update a region of a SVM buffer. Note that since we are enqueuing a command with a SVM buffer, the region is already mapped in the host address space.
      Parameters:
      command_queue - a valid host command-queue
      blocking_map - indicates if the map operation is blocking or non-blocking.

      If blocking_map is TRUE, EnqueueSVMMap does not return until the application can access the contents of the SVM region specified by svm_ptr and size on the host.

      If blocking_map is FALSE i.e. map operation is non-blocking, the region specified by svm_ptr and size cannot be used until the map command has completed. The event argument returns an event object which can be used to query the execution status of the map command. When the map command is completed, the application can access the contents of the region specified by svm_ptr and size.

      map_flags - a bit-field
      svm_ptr - a pointer to a memory region and size in bytes that will be updated by the host. If svm_ptr is allocated using SVMAlloc then it must be allocated from the same context from which command_queue was created. Otherwise the behavior is undefined.
      event_wait_list - a list of events that need to complete before this particular command can be executed. If event_wait_list is NULL, then this particular command does not wait on any event to complete. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same.
      event - Returns an event object that identifies this particular command and can be used to query or queue a wait for this particular command to complete. event can be NULL in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete. If the event_wait_list and the event arguments are not NULL, the event argument should not refer to an element of the event_wait_list array.
      Returns:
      SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
      • INVALID_COMMAND_QUEUE if command_queue is not a valid command-queue.
      • INVALID_CONTEXT if context associated with command_queue and events in event_wait_list are not the same.
      • INVALID_VALUE if svm_ptr is NULL.
      • INVALID_VALUE if size is 0 or if values specified in map_flags are not valid.
      • INVALID_EVENT_WAIT_LIST if event_wait_list is NULL and num_events_in_wait_list > 0, or event_wait_list is not NULL and num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.
      • EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST if the map operation is blocking and the execution status of any of the events in event_wait_list is a negative integer value.
      • OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
      • OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
      See Also:
    • nclEnqueueSVMUnmap

      public static int nclEnqueueSVMUnmap(long command_queue, long svm_ptr, int num_events_in_wait_list, long event_wait_list, long event)
      Unsafe version of: EnqueueSVMUnmap
      Parameters:
      num_events_in_wait_list - the number of events in event_wait_list
    • clEnqueueSVMUnmap

      public static int clEnqueueSVMUnmap(long command_queue, ByteBuffer svm_ptr, @Nullable PointerBuffer event_wait_list, @Nullable PointerBuffer event)
      Enqueues a command to indicate that the host has completed updating the region given by svm_ptr and which was specified in a previous call to EnqueueSVMMap.
      Parameters:
      command_queue - a valid host command-queue
      svm_ptr - a pointer that was specified in a previous call to EnqueueSVMMap. If svm_ptr is allocated using SVMAlloc then it must be allocated from the same context from which command_queue was created. Otherwise the behavior is undefined.
      event_wait_list - a list of events that need to complete before this particular command can be executed. If event_wait_list is NULL, then this particular command does not wait on any event to complete. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same.
      event - Returns an event object that identifies this particular command and can be used to query or queue a wait for this particular command to complete. event can be NULL in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete. If the event_wait_list and the event arguments are not NULL, the event argument should not refer to an element of the event_wait_list array.
      Returns:
      SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
      • INVALID_COMMAND_QUEUE if command_queue is not a valid command-queue.
      • INVALID_CONTEXT if context associated with command_queue and events in event_wait_list are not the same.
      • INVALID_VALUE if svm_ptr is NULL.
      • INVALID_EVENT_WAIT_LIST if event_wait_list is NULL and num_events_in_wait_list > 0, or event_wait_list is not NULL and num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.
      • OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
      • OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
      See Also:
    • nclSetKernelArgSVMPointer

      public static int nclSetKernelArgSVMPointer(long kernel, int arg_index, long arg_value)
      Unsafe version of: SetKernelArgSVMPointer
    • clSetKernelArgSVMPointer

      public static int clSetKernelArgSVMPointer(long kernel, int arg_index, ByteBuffer arg_value)
      Set a SVM pointer as the argument value for a specific argument of a kernel.
      Parameters:
      kernel - a valid kernel object
      arg_index - the argument index. Arguments to the kernel are referred by indices that go from 0 for the leftmost argument to n - 1, where n is the total number of arguments declared by a kernel.
      arg_value - the SVM pointer that should be used as the argument value for argument specified by arg_index. The SVM pointer specified is the value used by all API calls that enqueue kernel (EnqueueNDRangeKernel) until the argument value is changed by a call to SetKernelArgSVMPointer for kernel. The SVM pointer can only be used for arguments that are declared to be a pointer to global or constant memory. The SVM pointer value must be aligned according to the argument's type. For example, if the argument is declared to be global float4 *p, the SVM pointer value passed for p must be at a minimum aligned to a float4. The SVM pointer value specified as the argument value can be the pointer returned by SVMAlloc or can be a pointer + offset into the SVM region.
      Returns:
      SUCCESS if the function was executed successfully. Otherwise, it returns one of the following errors:
      See Also:
    • nclSetKernelExecInfo

      public static int nclSetKernelExecInfo(long kernel, int param_name, long param_value_size, long param_value)
      Unsafe version of: SetKernelExecInfo
      Parameters:
      param_value_size - the size in bytes of the memory pointed to by param_value
    • clSetKernelExecInfo

      public static int clSetKernelExecInfo(long kernel, int param_name, ByteBuffer param_value)
      Can be used to pass additional information other than argument values to a kernel.

      NOTES

      1. Coarse-grain or fine-grain buffer SVM pointers used by a kernel which are not passed as a kernel arguments must be specified using SetKernelExecInfo with KERNEL_EXEC_INFO_SVM_PTRS. For example, if SVM buffer A contains a pointer to another SVM buffer B, and the kernel dereferences that pointer, then a pointer to B must either be passed as an argument in the call to that kernel or it must be made available to the kernel using SetKernelExecInfo. For example, we might pass extra SVM pointers as follows:

      clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_SVM_PTRS, num_ptrs * sizeof(void *), extra_svm_ptr_list);

      Here num_ptrs specifies the number of additional SVM pointers while extra_svm_ptr_list specifies a pointer to memory containing those SVM pointers. When calling SetKernelExecInfo with KERNEL_EXEC_INFO_SVM_PTRS to specify pointers to non-argument SVM buffers as extra arguments to a kernel, each of these pointers can be the SVM pointer returned by SVMAlloc or can be a pointer + offset into the SVM region. It is sufficient to provide one pointer for each SVM buffer used.

      2. KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM is used to indicate whether SVM pointers used by a kernel will refer to system allocations or not.

      KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = FALSE indicates that the OpenCL implementation may assume that system pointers are not passed as kernel arguments and are not stored inside SVM allocations passed as kernel arguments.

      KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = TRUE indicates that the OpenCL implementation must assume that system pointers might be passed as kernel arguments and/or stored inside SVM allocations passed as kernel arguments. In this case, if the device to which the kernel is enqueued does not support system SVM pointers, EnqueueNDRangeKernel will return a INVALID_OPERATION error. If none of the devices in the context associated with kernel support fine-grain system SVM allocations, SetKernelExecInfo will return a INVALID_OPERATION error.

      If SetKernelExecInfo has not been called with a value for KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, the default value is used for this kernel attribute. The default value depends on whether the device on which the kernel is enqueued supports fine-grain system SVM allocations. If so, the default value used is TRUE (system pointers might be passed); otherwise, the default is FALSE.

      Parameters:
      kernel - the kernel object being queried
      param_name - the information to be passed to kernel. One of:
      KERNEL_EXEC_INFO_SVM_PTRSKERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM
      param_value - a pointer to memory where the appropriate values determined by param_name are specified
      Returns:
      SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
      See Also:
    • clSetKernelExecInfo

      public static int clSetKernelExecInfo(long kernel, int param_name, PointerBuffer param_value)
      Can be used to pass additional information other than argument values to a kernel.

      NOTES

      1. Coarse-grain or fine-grain buffer SVM pointers used by a kernel which are not passed as a kernel arguments must be specified using SetKernelExecInfo with KERNEL_EXEC_INFO_SVM_PTRS. For example, if SVM buffer A contains a pointer to another SVM buffer B, and the kernel dereferences that pointer, then a pointer to B must either be passed as an argument in the call to that kernel or it must be made available to the kernel using SetKernelExecInfo. For example, we might pass extra SVM pointers as follows:

      clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_SVM_PTRS, num_ptrs * sizeof(void *), extra_svm_ptr_list);

      Here num_ptrs specifies the number of additional SVM pointers while extra_svm_ptr_list specifies a pointer to memory containing those SVM pointers. When calling SetKernelExecInfo with KERNEL_EXEC_INFO_SVM_PTRS to specify pointers to non-argument SVM buffers as extra arguments to a kernel, each of these pointers can be the SVM pointer returned by SVMAlloc or can be a pointer + offset into the SVM region. It is sufficient to provide one pointer for each SVM buffer used.

      2. KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM is used to indicate whether SVM pointers used by a kernel will refer to system allocations or not.

      KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = FALSE indicates that the OpenCL implementation may assume that system pointers are not passed as kernel arguments and are not stored inside SVM allocations passed as kernel arguments.

      KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = TRUE indicates that the OpenCL implementation must assume that system pointers might be passed as kernel arguments and/or stored inside SVM allocations passed as kernel arguments. In this case, if the device to which the kernel is enqueued does not support system SVM pointers, EnqueueNDRangeKernel will return a INVALID_OPERATION error. If none of the devices in the context associated with kernel support fine-grain system SVM allocations, SetKernelExecInfo will return a INVALID_OPERATION error.

      If SetKernelExecInfo has not been called with a value for KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, the default value is used for this kernel attribute. The default value depends on whether the device on which the kernel is enqueued supports fine-grain system SVM allocations. If so, the default value used is TRUE (system pointers might be passed); otherwise, the default is FALSE.

      Parameters:
      kernel - the kernel object being queried
      param_name - the information to be passed to kernel. One of:
      KERNEL_EXEC_INFO_SVM_PTRSKERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM
      param_value - a pointer to memory where the appropriate values determined by param_name are specified
      Returns:
      SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
      See Also:
    • clSetKernelExecInfo

      public static int clSetKernelExecInfo(long kernel, int param_name, IntBuffer param_value)
      Can be used to pass additional information other than argument values to a kernel.

      NOTES

      1. Coarse-grain or fine-grain buffer SVM pointers used by a kernel which are not passed as a kernel arguments must be specified using SetKernelExecInfo with KERNEL_EXEC_INFO_SVM_PTRS. For example, if SVM buffer A contains a pointer to another SVM buffer B, and the kernel dereferences that pointer, then a pointer to B must either be passed as an argument in the call to that kernel or it must be made available to the kernel using SetKernelExecInfo. For example, we might pass extra SVM pointers as follows:

      clSetKernelExecInfo(kernel, CL_KERNEL_EXEC_INFO_SVM_PTRS, num_ptrs * sizeof(void *), extra_svm_ptr_list);

      Here num_ptrs specifies the number of additional SVM pointers while extra_svm_ptr_list specifies a pointer to memory containing those SVM pointers. When calling SetKernelExecInfo with KERNEL_EXEC_INFO_SVM_PTRS to specify pointers to non-argument SVM buffers as extra arguments to a kernel, each of these pointers can be the SVM pointer returned by SVMAlloc or can be a pointer + offset into the SVM region. It is sufficient to provide one pointer for each SVM buffer used.

      2. KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM is used to indicate whether SVM pointers used by a kernel will refer to system allocations or not.

      KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = FALSE indicates that the OpenCL implementation may assume that system pointers are not passed as kernel arguments and are not stored inside SVM allocations passed as kernel arguments.

      KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = TRUE indicates that the OpenCL implementation must assume that system pointers might be passed as kernel arguments and/or stored inside SVM allocations passed as kernel arguments. In this case, if the device to which the kernel is enqueued does not support system SVM pointers, EnqueueNDRangeKernel will return a INVALID_OPERATION error. If none of the devices in the context associated with kernel support fine-grain system SVM allocations, SetKernelExecInfo will return a INVALID_OPERATION error.

      If SetKernelExecInfo has not been called with a value for KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM, the default value is used for this kernel attribute. The default value depends on whether the device on which the kernel is enqueued supports fine-grain system SVM allocations. If so, the default value used is TRUE (system pointers might be passed); otherwise, the default is FALSE.

      Parameters:
      kernel - the kernel object being queried
      param_name - the information to be passed to kernel. One of:
      KERNEL_EXEC_INFO_SVM_PTRSKERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM
      param_value - a pointer to memory where the appropriate values determined by param_name are specified
      Returns:
      SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
      See Also:
    • nclCreateSamplerWithProperties

      public static long nclCreateSamplerWithProperties(long context, long sampler_properties, long errcode_ret)
      Unsafe version of: CreateSamplerWithProperties
    • clCreateSamplerWithProperties

      public static long clCreateSamplerWithProperties(long context, @Nullable LongBuffer sampler_properties, @Nullable IntBuffer errcode_ret)
      Creates a sampler object.
      Parameters:
      context - a valid OpenCL context
      sampler_properties - a list of sampler property names and their corresponding values. Each sampler property name is immediately followed by the corresponding desired value. The list is terminated with 0. If a supported property and its value is not specified in sampler_properties, its default value will be used. sampler_properties can be NULL in which case the default values for supported sampler properties will be used.
      errcode_ret - will return an appropriate error code. If errcode_ret is NULL, no error code is returned.
      Returns:
      a valid non-zero sampler object and errcode_ret is set to SUCCESS if the sampler object is created successfully. Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:
      • INVALID_CONTEXT if context is not a valid context.
      • INVALID_VALUE if the property name in sampler_properties is not a supported property name, if the value specified for a supported property name is not valid, or if the same property name is specified more than once.
      • INVALID_OPERATION if images are not supported by any device associated with context.
      • OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
      • OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
      See Also:
    • clCreateCommandQueueWithProperties

      public static long clCreateCommandQueueWithProperties(long context, long device, @Nullable long[] properties, @Nullable int[] errcode_ret)
      See Also:
    • clCreatePipe

      public static long clCreatePipe(long context, long flags, int pipe_packet_size, int pipe_max_packets, @Nullable PointerBuffer properties, @Nullable int[] errcode_ret)
      Array version of: CreatePipe
      See Also:
    • clGetPipeInfo

      public static int clGetPipeInfo(long pipe, int param_name, @Nullable int[] param_value, @Nullable PointerBuffer param_value_size_ret)
      Array version of: GetPipeInfo
      See Also:
    • clSetKernelExecInfo

      public static int clSetKernelExecInfo(long kernel, int param_name, int[] param_value)
      Array version of: SetKernelExecInfo
      See Also:
    • clCreateSamplerWithProperties

      public static long clCreateSamplerWithProperties(long context, @Nullable long[] sampler_properties, @Nullable int[] errcode_ret)
      Array version of: CreateSamplerWithProperties
      See Also: