Class: OpenCL::CommandQueue

Inherits:
ExtendedStruct show all
Includes:
KHRPriorityHints, KHRThrottleHints, OpenCL11, OpenCL12, OpenCL20, OpenCL21, OpenCL30, UnifiedSharedMemoryPreviewINTEL
Defined in:
lib/opencl_ruby_ffi/CommandQueue.rb,
lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb,
lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb,
lib/opencl_ruby_ffi/khr/priority_hints.rb,
lib/opencl_ruby_ffi/khr/priority_hints.rb,
lib/opencl_ruby_ffi/khr/throttle_hints.rb,
lib/opencl_ruby_ffi/khr/throttle_hints.rb,
lib/opencl_ruby_ffi/intel/unified_shared_memory_preview.rb

Overview

Maps the cl_command_queue object of OpenCL

Defined Under Namespace

Modules: KHRPriorityHints, KHRThrottleHints, OpenCL11, OpenCL12, OpenCL20, OpenCL21, OpenCL30, UnifiedSharedMemoryPreviewINTEL Classes: PriorityKHR, Properties, ThrottleKHR

Instance Method Summary collapse

Methods included from UnifiedSharedMemoryPreviewINTEL

#clEnqueueMemAdviseINTEL, #clEnqueueMemFillINTEL, #clEnqueueMemcpyINTEL, #clEnqueueMigrateMemINTEL, #enqueue_mem_advise_intel, #enqueue_mem_fill_intel, #enqueue_memcpy_intel, #enqueue_migrate_mem_intel

Methods included from KHRThrottleHints

#throttle_khr

Methods included from KHRPriorityHints

#priority_khr

Methods included from OpenCL30

#properties_array

Methods included from OpenCL21

#device_default, #enqueue_svm_migrate_mem

Methods included from OpenCL20

#enqueue_svm_free, #enqueue_svm_map, #enqueue_svm_memcpy, #enqueue_svm_memfill, #enqueue_svm_unmap, #size

Methods included from OpenCL12

#enqueue_fill_buffer, #enqueue_fill_image, #enqueue_migrate_mem_objects

Methods included from OpenCL11

#enqueue_copy_buffer_rect, #enqueue_read_buffer_rect, #enqueue_write_buffer_rect

Methods inherited from ExtendedStruct

register_extension

Constructor Details

#initialize(ptr, retain = true) ⇒ CommandQueue

Creates a new CommandQueue and retains it if specified and aplicable



1191
1192
1193
1194
1195
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 1191

def initialize(ptr, retain = true)
  super(ptr)
  OpenCL.clRetainCommandQueue(ptr) if retain
  #STDERR.puts "Allocating CommandQueue: #{ptr}"
end

Instance Method Details

#contextObject

Returns the Context associated to the CommandQueue



1079
1080
1081
1082
1083
1084
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1079

def context
  ptr = MemoryPointer::new( Context )
  error = OpenCL.clGetCommandQueueInfo(self, CONTEXT, Context.size, ptr, nil)
  error_check(error)
  return Context::new( ptr.read_pointer )
end

#deviceObject

Returns the Device associated to the CommandQueue



1087
1088
1089
1090
1091
1092
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1087

def device
  ptr = MemoryPointer::new( Device )
  error = OpenCL.clGetCommandQueueInfo(self, DEVICE, Device.size, ptr, nil)
  error_check(error)
  return Device::new( ptr.read_pointer )
end

#enqueue_acquire_gl_objects(mem_objects, options = {}) ⇒ Object Also known as: enqueue_acquire_GL_objects

Acquire OpenCL Mem objects that have been created from OpenGL objects using the CommandQueue

Attributes

  • mem_objects - a single or an Array of Mem objects

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

Returns

the Event associated with the command



1374
1375
1376
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1374

def enqueue_acquire_gl_objects( mem_objects, options = {} )
  return OpenCL.enqueue_acquire_gl_objects( self, mem_objects, options )
end

#enqueue_barrier(events) ⇒ Object

Enqueues a barrier on a list of envents using the CommandQueue

Attributes

  • events - a single or an Array of Event to wait upon before the barrier is considered finished

Returns

an Event if implementation version is >= 1.2, nil otherwise



1214
1215
1216
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1214

def enqueue_barrier( events )
  return OpenCL.enqueue_barrier( self, events )
end

#enqueue_copy_buffer(src_buffer, dst_buffer, options = {}) ⇒ Object

Enqueues a command to copy data from a Buffer object into another Buffer object using the CommandQueue

Attributes

  • src_buffer - the Buffer to be read from

  • dst_buffer - the Buffer to be written to

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :src_offset - if provided indicates the offset inside the src Buffer of the area to copy, else 0

  • :dst_offset - if provided indicates the offset inside the dst Buffer of the area to write to, else 0

  • :size - if provided indicates the size of data to copy, else the maximum possible is copied

Returns

the Event associated with the command



1201
1202
1203
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1201

def enqueue_copy_buffer( src_buffer, dst_buffer, options = {} )
  return OpenCL.enqueue_copy_buffer( self, src_buffer, dst_buffer, options )
end

#enqueue_copy_buffer_to_image(src_buffer, dst_image, options = {}) ⇒ Object

Enqueues a command to copy a Buffer into an Image using the CommandQueue

Attributes

  • src_buffer - the Buffer to be read from

  • dst_image - the Image to be written to

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :dst_origin - if provided indicates the origin of the region to write into the Image, else [0, 0, 0]

  • :region - if provided indicates the dimension of the region to copy, else the maximum region is copied

  • :src_offset - if provided indicates the offset inside the Buffer, else 0

Returns

the Event associated with the command



1334
1335
1336
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1334

def enqueue_copy_buffer_to_image( src_buffer, dst_image, options = {} )
  return OpenCL.enqueue_copy_buffer_to_image( self, src_buffer, dst_image, options )
end

#enqueue_copy_image(src_image, dst_image, options = {}) ⇒ Object

Enqueues a command to copy from an Image into an Image using the CommandQueue

Attributes

  • src_image - the Image to be written to

  • dst_image - the Image to be written to

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :src_origin - if provided indicates the origin of the region to read into the src Image, else [0, 0, 0]

  • :dst_origin - if provided indicates the origin of the region to write into the dst Image, else [0, 0, 0]

  • :region - if provided indicates the dimension of the region to copy, else the maximum region is copied

Returns

the Event associated with the command



1312
1313
1314
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1312

def enqueue_copy_image( src_image, dst_image, options = {} )
  return OpenCL.enqueue_copy_image( self, src_image, dst_image, options )
end

#enqueue_copy_image_to_buffer(src_image, dst_buffer, options = {}) ⇒ Object

Enqueues a command to copy an Image into a Buffer using the CommandQueue

Attributes

  • src_image - the Image to be read from

  • dst_buffer - the Buffer to be written to

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :src_origin - if provided indicates the origin of the region to copy from the Image, else [0, 0, 0]

  • :region - if provided indicates the dimension of the region to copy, else the maximum region is copied

  • :dst_offset - if provided indicates the offset inside the Buffer, else 0

Returns

the Event associated with the command



1356
1357
1358
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1356

def enqueue_copy_image_to_buffer( src_image, dst_buffer, options = {} )
  return OpenCL.enqueue_copy_image_to_buffer( self, src_image, dst_buffer, options )
end

#enqueue_map_buffer(buffer, map_flags, options = {}) ⇒ Object

Enqueues a command to map a Buffer into host memory using the CommandQueue

Attributes

  • buffer - the Buffer object to map

  • map_flags - a single or an Array of :cl_map_flags flags

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :blocking_map - if provided indicates if the command blocks until the region is mapped

  • :blocking - if provided indicates if the command blocks until the region is mapped

  • :offset - if provided the offset inside the Buffer region to map, else 0

  • :size - if provided the size of the region in the Buffer to map, else the largest possible size is used

Returns

an Array composed of [event, pointer] where:

  • event - the Event associated with the command

  • pointer - a Pointer to the mapped memory region



1419
1420
1421
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1419

def enqueue_map_buffer( buffer, map_flags, options = {} )
  return OpenCL.enqueue_map_buffer( self, buffer, map_flags, options )
end

#enqueue_map_image(image, map_flags, options = {}) ⇒ Object

Enqueues a command to map an Image into host memory using the CommandQueue

Attributes

  • image - the Image object to map

  • map_flags - a single or an Array of :cl_map_flags flags

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :blocking_map - if provided indicates if the command blocks until the region is mapped

  • :blocking - if provided indicates if the command blocks until the region is mapped

  • :origin - if provided the origin in the Image of the region to map, else [0, 0, 0]

  • :region - if provided the region in the image to map, else the largest possible area is used

Returns

an Array composed of [event, pointer, image_row_pitch, image_slice_pitch] where:

  • event - the Event associated with the command

  • pointer - a Pointer to the mapped memory region

  • image_row_pitch - the row pitch of the mapped region

  • image_slice_pitch - the slice pitch of the mapped region



1446
1447
1448
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1446

def enqueue_map_image( image, map_flags, options = {} )
  return OpenCL.enqueue_map_image( self, image, map_flags, options )
end

#enqueue_marker(events = []) ⇒ Object

Enqueues a marker using the CommandQueue

Attributes

  • events - an optional single or Array of Event to wait upon before the marker is considered finished, if not provided all previous command are waited for before the marker is considered finished (unavailable if implementation version < 1.2 )

Returns

an Event



1227
1228
1229
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1227

def enqueue_marker( events = [] )
  return OpenCL.enqueue_marker( self, events )
end

#enqueue_native_kernel(options = {}, &func) ⇒ Object

Enqueues a native kernel in the CommandQueue

Attributes

  • options - a hash containing named options

  • func - a Proc object to execute

Options

  • :args - if provided, a list of arguments to pass to the kernel. Arguments should have a size method and be convertible to Pointer with to_ptr

  • :mem_list - if provided, a hash containing Buffer objects and their index inside the argument list.

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

Returns

the Event associated with the command



1485
1486
1487
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1485

def enqueue_native_kernel( options = {}, &func )
  return OpenCL.enqueue_native_kernel( self, options, &func )
end

#enqueue_ndrange_kernel(kernel, global_work_size, options = {}) ⇒ Object Also known as: enqueue_NDrange_kernel

Enqueues a kernel as a ndrange using the CommandQueue

Attributes

  • kernel - a Kernel object to execute

  • global_work_size - dimensions of the work

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :local_work_size - if provided, dimensions of the local work group size

  • :global_work_offset - if provided, offset inside the global work size

Returns

the Event associated with the command



1132
1133
1134
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1132

def enqueue_ndrange_kernel( kernel, global_work_size, options = {} )
  return OpenCL.enqueue_ndrange_kernel( self, kernel, global_work_size, options )
end

#enqueue_read_buffer(buffer, ptr, options = {}) ⇒ Object

Enqueues a command to read from a Buffer object to host memory using the CommandQueue

Attributes

  • buffer - the Buffer to be read from

  • ptr - the Pointer (or convertible to Pointer using to_ptr) to the memory area to use

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :blocking_read - if provided indicates if the command blocks until the region is read

  • :blocking - if provided indicates if the command blocks until the region is read

  • :offset - if provided indicates the offset inside the Buffer of the area to read from, else 0

  • :size - if provided indicates the size of data to copy, else the maximum data is copied

Returns

the Event associated with the command



1179
1180
1181
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1179

def enqueue_read_buffer( buffer, ptr, options = {} )
  return OpenCL.enqueue_read_buffer( self, buffer, ptr, options)
end

#enqueue_read_image(image, ptr, options = {}) ⇒ Object

Enqueues a command to copy from an Image into host memory using the CommandQueue

Attributes

  • image - the Image to be written to

  • ptr - the Pointer (or convertible to Pointer using to_ptr) to the memory area to use

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :blocking_read - if provided indicates if the command blocks until the region is read.

  • :blocking - if provided indicates if the command blocks until the region is read

  • :origin - if provided indicates the origin of the region to read from the Image, else [0, 0, 0]

  • :region - if provided indicates the dimension of the region to copy, else the maximum region is copied

  • :row_pitch - if provided indicates the row pitch inside the host area, else 0

  • :slice_pitch - if provided indicates the slice pitch inside the host area, else 0

Returns

the Event associated with the command



1290
1291
1292
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1290

def enqueue_read_image( image, ptr, options = {} )
  return OpenCL.enqueue_read_image( self, image, ptr, options )
end

#enqueue_release_gl_objects(mem_objects, options = {}) ⇒ Object Also known as: enqueue_release_GL_objects

Release OpenCL Mem objects that have been created from OpenGL objects and previously acquired using the CommandQueue

Attributes

  • mem_objects - a single or an Array of Mem objects

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

Returns

the Event associated with the command



1393
1394
1395
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1393

def enqueue_release_gl_objects( mem_objects, options = {} )
  return OpenCL.enqueue_release_gl_objects( self, mem_objects, options )
end

#enqueue_task(kernel, options = {}) ⇒ Object

Enqueues a kernel as a task using the CommandQueue

Attributes

  • kernel - a Kernel object to execute

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

Returns

the Event associated with the command



1111
1112
1113
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1111

def enqueue_task( kernel, options = {} )
  return OpenCL.enqueue_task( self, kernel, options )
end

#enqueue_unmap_mem_object(mem_obj, mapped_ptr, options = {}) ⇒ Object

Enqueues a command to unmap a previously mapped region of a memory object using the CommandQueue

Attributes

  • mem_obj - the Mem object that was previously mapped

  • mapped_ptr - the Pointer previously returned by a map command

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

Returns

the Event associated with the command



1465
1466
1467
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1465

def enqueue_unmap_mem_object( mem_obj, mapped_ptr, options = {} )
  return OpenCL.enqueue_unmap_mem_object( self, mem_obj, mapped_ptr, options )
end

#enqueue_wait_for_events(events = []) ⇒ Object

Enqueues a barrier on a list of envents using the CommandQueue

Attributes

  • events - a single or an Array of Event to wait upon before the barrier is considered finished

Returns

an Event if implementation version is >= 1.2, nil otherwise



1240
1241
1242
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1240

def enqueue_wait_for_events( events = [] )
  return OpenCL.enqueue_wait_for_events( self, events )
end

#enqueue_write_buffer(buffer, ptr, options = {}) ⇒ Object

Enqueues a command to write to a Buffer object from host memory using the CommandQueue

Attributes

  • buffer - the Buffer to be written to

  • ptr - the Pointer (or convertible to Pointer using to_ptr) to the memory area to use

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :blocking_write - if provided indicates if the command blocks until the region is written.

  • :blocking - if provided indicates if the command blocks until the region is written

  • :offset - if provided indicates the offset inside the Buffer of the area to read from, else 0

  • :size - if provided indicates the size of data to copy, else the maximum data is copied

Returns

the Event associated with the command



1156
1157
1158
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1156

def enqueue_write_buffer( buffer, ptr, options = {} )
  return OpenCL.enqueue_write_buffer( self, buffer, ptr, options )
end

#enqueue_write_image(image, ptr, options = {}) ⇒ Object

Enqueues a command to copy from host memory into an Image using the CommandQueue

Attributes

  • image - the Image to be written to

  • ptr - the Pointer (or convertible to Pointer using to_ptr) to the memory area to use

  • options - a hash containing named options

Options

  • :event_wait_list - if provided, a list of Event to wait upon before executing the command

  • :blocking_write - if provided indicates if the command blocks until the region is written.

  • :blocking - if provided indicates if the command blocks until the region is written

  • :origin - if provided indicates the origin of the region to write into the Image, else [0, 0, 0]

  • :region - if provided indicates the dimension of the region to copy, else the maximum region is copied

  • :input_row_pitch - if provided indicates the row pitch inside the host area, else 0

  • :input_slice_pitch - if provided indicates the slice pitch inside the host area, else 0

Returns

the Event associated with the command



1265
1266
1267
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1265

def enqueue_write_image( image, ptr, options = {} )
  return OpenCL.enqueue_write_image( self, image, ptr, options )
end

#finishObject

Blocks until all the commands in the CommandQueue have completed



1490
1491
1492
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1490

def finish
  return OpenCL.finish(self)
end

#flushObject

Issues all the commands in a CommandQueue to the Device



1495
1496
1497
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1495

def flush
  return OpenCL.flush( self )
end

#inspectObject



1068
1069
1070
1071
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1068

def inspect
  p = properties
  return "#<#{self.class.name}: -> #{device.inspect}#{ 0 != p.to_i ? " (#{p})" : ""}>"
end

#platformObject

Returns the Platform associated with the CommandQueue



1074
1075
1076
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1074

def platform
  @_platform ||= self.context.platform
end

#propertiesObject

Returns the OpenCL::CommandQueue::properties info

Returns:

  • cl_command_queue_properties



1095
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1095

get_info("CommandQueue", :cl_command_queue_properties, "properties")

#reference_countObject

Returns the OpenCL::CommandQueue::reference_count info

Returns:

  • cl_uint



1094
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1094

get_info("CommandQueue", :cl_uint, "reference_count")

Constant Summary collapse

OUT_OF_ORDER_EXEC_MODE_ENABLE =
(1 << 0)
PROFILING_ENABLE =
(1 << 1)
ON_DEVICE =
(1 << 2)
ON_DEVICE_DEFAULT =
(1 << 3)
CONTEXT =
0x1090
DEVICE =
0x1091
REFERENCE_COUNT =
0x1092
PROPERTIES =
0x1093
SIZE =
0x1094
DEVICE_DEFAULT =
0x1095
PROPERTIES_ARRAY =
0x1098
PRIORITY_KHR =
0x1096
PRIORITY_HIGH_KHR =
(1 << 0)
PRIORITY_MED_KHR =
(1 << 1)
PRIORITY_LOW_KHR =
(1 << 2)
THROTTLE_KHR =
0x1097
THROTTLE_HIGH_KHR =
(1 << 0)
THROTTLE_MED_KHR =
(1 << 1)
THROTTLE_LOW_KHR =
(1 << 2)