Class: OpenCL::CommandQueue

Inherits:
ExtendedStruct show all
Includes:
KHRPriorityHints, KHRThrottleHints, OpenCL11, OpenCL12, OpenCL20, OpenCL21
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

Overview

Maps the cl_command_queue object of OpenCL

Defined Under Namespace

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

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
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)

Instance Method Summary collapse

Methods included from KHRThrottleHints

#throttle_khr

Methods included from KHRPriorityHints

#priority_khr

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



1124
1125
1126
1127
1128
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 1124

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



1062
1063
1064
1065
1066
1067
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1062

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



1070
1071
1072
1073
1074
1075
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1070

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



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

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



1197
1198
1199
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1197

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



1184
1185
1186
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1184

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



1317
1318
1319
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1317

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



1295
1296
1297
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1295

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



1339
1340
1341
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1339

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



1402
1403
1404
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1402

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



1429
1430
1431
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1429

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



1210
1211
1212
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1210

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



1468
1469
1470
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1468

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



1115
1116
1117
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1115

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



1162
1163
1164
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1162

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



1273
1274
1275
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1273

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



1376
1377
1378
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1376

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



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

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



1448
1449
1450
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1448

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



1223
1224
1225
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1223

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



1139
1140
1141
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1139

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



1248
1249
1250
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1248

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



1473
1474
1475
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1473

def finish
  return OpenCL.finish(self)
end

#flushObject

Issues all the commands in a CommandQueue to the Device



1478
1479
1480
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1478

def flush
  return OpenCL.flush( self )
end

#inspectObject



1056
1057
1058
1059
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1056

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

#propertiesObject

Returns the OpenCL::CommandQueue::properties info

Returns:

  • cl_command_queue_properties



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

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

#reference_countObject

Returns the OpenCL::CommandQueue::reference_count info

Returns:

  • cl_uint



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

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