opencl_ruby_ffi 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/lib/opencl_ruby_ffi.rb +2 -0
  4. data/lib/opencl_ruby_ffi/Buffer.rb +18 -13
  5. data/lib/opencl_ruby_ffi/CommandQueue.rb +301 -302
  6. data/lib/opencl_ruby_ffi/Context.rb +158 -158
  7. data/lib/opencl_ruby_ffi/Device.rb +270 -224
  8. data/lib/opencl_ruby_ffi/Event.rb +40 -36
  9. data/lib/opencl_ruby_ffi/Image.rb +34 -57
  10. data/lib/opencl_ruby_ffi/Kernel.rb +251 -191
  11. data/lib/opencl_ruby_ffi/Mem.rb +49 -70
  12. data/lib/opencl_ruby_ffi/Pipe.rb +3 -14
  13. data/lib/opencl_ruby_ffi/Platform.rb +46 -48
  14. data/lib/opencl_ruby_ffi/Program.rb +131 -124
  15. data/lib/opencl_ruby_ffi/Sampler.rb +6 -24
  16. data/lib/opencl_ruby_ffi/amd/device_attribute_query.rb +100 -0
  17. data/lib/opencl_ruby_ffi/egl.rb +2 -0
  18. data/lib/opencl_ruby_ffi/ext.rb +11 -0
  19. data/lib/opencl_ruby_ffi/ext/device_fission.rb +264 -0
  20. data/lib/opencl_ruby_ffi/gl_ext.rb +2 -0
  21. data/lib/opencl_ruby_ffi/khr/d3d10_sharing.rb +120 -0
  22. data/lib/opencl_ruby_ffi/khr/d3d11_sharing.rb +120 -0
  23. data/lib/opencl_ruby_ffi/khr/dx9_media_sharing.rb +113 -0
  24. data/lib/opencl_ruby_ffi/khr/egl_event.rb +15 -0
  25. data/lib/opencl_ruby_ffi/khr/egl_image.rb +58 -0
  26. data/lib/opencl_ruby_ffi/khr/fp16.rb +23 -0
  27. data/lib/opencl_ruby_ffi/khr/fp64.rb +23 -0
  28. data/lib/opencl_ruby_ffi/khr/gl_event.rb +38 -0
  29. data/lib/opencl_ruby_ffi/khr/gl_sharing.rb +79 -0
  30. data/lib/opencl_ruby_ffi/khr/icd.rb +30 -0
  31. data/lib/opencl_ruby_ffi/khr/initalize_memory.rb +19 -0
  32. data/lib/opencl_ruby_ffi/khr/priority_hints.rb +48 -0
  33. data/lib/opencl_ruby_ffi/khr/spir.rb +45 -0
  34. data/lib/opencl_ruby_ffi/khr/sub_groups.rb +49 -0
  35. data/lib/opencl_ruby_ffi/khr/terminate_context.rb +46 -0
  36. data/lib/opencl_ruby_ffi/khr/throttle_hints.rb +47 -0
  37. data/lib/opencl_ruby_ffi/nv/device_attribute_query.rb +50 -0
  38. data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb +40 -13
  39. data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb +214 -2114
  40. data/lib/opencl_ruby_ffi/opencl_types.rb +15 -3
  41. data/opencl_ruby_ffi.gemspec +4 -4
  42. data/templates_custom/default/module/setup.rb +9 -0
  43. metadata +29 -6
  44. data/lib/opencl_ruby_ffi/GLExt.rb +0 -58
  45. data/lib/opencl_ruby_ffi/Stream.rb +0 -127
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe1596eeb249eb6744106b3bbad55656ab003ec9
4
- data.tar.gz: b91178b8e751c28a2412e7cdc8219a8d09e731d0
3
+ metadata.gz: 84004d4b456d5ea8aabfba8a811565b3b551086a
4
+ data.tar.gz: 89b78273145a8457c34e61ae6e0fb887f8b19b41
5
5
  SHA512:
6
- metadata.gz: 93c59bc28c66d2266b8a5bce0d6407597c0f05a355feb93b0dadc44c57b1cb28e401318e637e2e92ab6a124564f8934a26a4652d57e1b85ebbb775e07a4799d1
7
- data.tar.gz: 5bb49883a1a101adce60f50c6cf6164da77319068af72b1ed91e6ce9033e714d59626247756bec6b14cc40748e1fd76f83da0b3bd6581bb210274dc84f253713
6
+ metadata.gz: d799134cb834e51f1782c07c328bebf91dde9cec0134fbe60400ff4a2f79b46a2db38a0e6fbed5db7b5bf1f067a8843453050a22403ba1f5c1ea4130a7296476
7
+ data.tar.gz: 8b9c3fa63dca70bf13b7deaca5ac4d1291f24b39c6de642edb1e78c483cb86ad8faa6e22daa7b661987724335400a13ab673be908b614a8c0913ab83c5e00093
@@ -0,0 +1 @@
1
+ -p templates_custom/ --no-private lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb lib/**/*.rb lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb lib/**/**/*.rb
@@ -15,6 +15,8 @@ require "opencl_ruby_ffi/Image.rb"
15
15
  require "opencl_ruby_ffi/Sampler.rb"
16
16
  require "opencl_ruby_ffi/Pipe.rb"
17
17
  require "opencl_ruby_ffi/SVM.rb"
18
+ require "opencl_ruby_ffi/ext.rb"
19
+ require "opencl_ruby_ffi/gl_ext.rb"
18
20
 
19
21
  require "narray_ffi"
20
22
 
@@ -69,20 +69,25 @@ module OpenCL
69
69
  class Buffer < Mem
70
70
  layout :dummy, :pointer
71
71
 
72
- # Creates a Buffer from a sub part of the Buffer
73
- #
74
- # ==== Attributes
75
- #
76
- # * +info+ - inf reguarding the type of sub-buffer created. if type == OpenCL::BUFFER_CREATE_TYPE_REGION, info is a BufferRegion
77
- # * +tyep+ - type of sub-buffer to create. Only OpenCL::BUFFER_CREATE_TYPE_REGION is supported for now
78
- # * +options+ - a hash containing named options
79
- #
80
- # ==== Options
81
- #
82
- # * :flags - a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Buffer
83
- def create_sub_buffer( type, region, options = {} )
84
- OpenCL.create_sub_buffer( self, type, region, options )
72
+ module OpenCL11
73
+ # Creates a Buffer from a sub part of the Buffer
74
+ #
75
+ # ==== Attributes
76
+ #
77
+ # * +type+ - type of sub-buffer to create. Only OpenCL::BUFFER_CREATE_TYPE_REGION is supported for now
78
+ # * +info+ - inf reguarding the type of sub-buffer created. if type == OpenCL::BUFFER_CREATE_TYPE_REGION, info is a BufferRegion
79
+ # * +options+ - a hash containing named options
80
+ #
81
+ # ==== Options
82
+ #
83
+ # * +:flags+ - a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Buffer
84
+ def create_sub_buffer( type, region, options = {} )
85
+ OpenCL.create_sub_buffer( self, type, region, options )
86
+ end
85
87
  end
88
+
89
+ register_extension( :v11, Buffer::OpenCL11, "platform.version_number >= 1.1" )
90
+
86
91
  end
87
92
 
88
93
  end
@@ -39,7 +39,7 @@ module OpenCL
39
39
  properties = get_command_queue_properties( options )
40
40
  size = options[:size]
41
41
  error = MemoryPointer::new( :cl_int )
42
- if context.platform.version_number < 2.0 then
42
+ if device.platform.version_number < 2.0 then
43
43
  cmd = clCreateCommandQueue( context, device, properties, error )
44
44
  else
45
45
  props = nil
@@ -85,7 +85,7 @@ module OpenCL
85
85
  #
86
86
  # the Event associated with the command
87
87
  def self.enqueue_migrate_mem_objects( command_queue, mem_objects, options = {} )
88
- error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.2
88
+ error_check(INVALID_OPERATION) if command_queue.device.platform.version_number < 1.2
89
89
  num_mem_objects = [mem_objects].flatten.length
90
90
  mem_list = nil
91
91
  if num_mem_objects > 0 then
@@ -234,7 +234,7 @@ module OpenCL
234
234
  #
235
235
  # the Event associated with the command
236
236
  def self.enqueue_read_buffer_rect( command_queue, buffer, ptr, region, options = {} )
237
- error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
237
+ error_check(INVALID_OPERATION) if command_queue.device.platform.version_number < 1.1
238
238
  blocking = FALSE
239
239
  blocking = TRUE if options[:blocking] or options[:blocking_read]
240
240
 
@@ -311,7 +311,7 @@ module OpenCL
311
311
  #
312
312
  # the Event associated with the command
313
313
  def self.enqueue_write_buffer_rect(command_queue, buffer, ptr, region, options = {})
314
- error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
314
+ error_check(INVALID_OPERATION) if command_queue.device.platform.version_number < 1.1
315
315
  blocking = FALSE
316
316
  blocking = TRUE if options[:blocking] or options[:blocking_write]
317
317
 
@@ -386,7 +386,7 @@ module OpenCL
386
386
  #
387
387
  # the Event associated with the command
388
388
  def self.enqueue_copy_buffer_rect(command_queue, src_buffer, dst_buffer, region, options = {})
389
- error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
389
+ error_check(INVALID_OPERATION) if command_queue.device.platform.version_number < 1.1
390
390
 
391
391
  src_origin = MemoryPointer::new( :size_t, 3 )
392
392
  (0..2).each { |i| src_origin[i].write_size_t(0) }
@@ -623,7 +623,7 @@ module OpenCL
623
623
  #
624
624
  # the Event associated with the command
625
625
  def self.enqueue_fill_buffer( command_queue, buffer, pattern, options = {} )
626
- error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
626
+ error_check(INVALID_OPERATION) if command_queue.device.platform.version_number < 1.1
627
627
  offset = 0
628
628
  offset = options[:offset] if options[:offset]
629
629
  pattern_size = pattern.size
@@ -656,7 +656,7 @@ module OpenCL
656
656
  #
657
657
  # the Event associated with the command
658
658
  def self.enqueue_fill_image( command_queue, image, fill_color, options = {} )
659
- error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
659
+ error_check(INVALID_OPERATION) if command_queue.device.platform.version_number < 1.1
660
660
  origin, region = get_origin_region( image, options, :origin, :region )
661
661
  num_events, events = get_event_wait_list( options )
662
662
  event = MemoryPointer::new( Event )
@@ -905,7 +905,7 @@ module OpenCL
905
905
  #
906
906
  # the Event associated with the command
907
907
  def self.enqueue_task( command_queue, kernel, options = {} )
908
- if queue.context.platform.version_number < 2.0 then
908
+ if command_queue.device.platform.version_number < 2.0 then
909
909
  num_events, events = get_event_wait_list( options )
910
910
  event = MemoryPointer::new( Event )
911
911
  error = clEnqueueTask( command_queue, kernel, num_events, events, event )
@@ -990,7 +990,7 @@ module OpenCL
990
990
  #
991
991
  # an Event if implementation version is >= 1.2, nil otherwise
992
992
  def self.enqueue_barrier( command_queue, events = [] )
993
- if command_queue.context.platform.version_number < 1.2 then
993
+ if command_queue.device.platform.version_number < 1.2 then
994
994
  num_events = [events].flatten.length
995
995
  if num_events > 0 then
996
996
  evts = MemoryPointer::new( Event, num_events )
@@ -1031,7 +1031,7 @@ module OpenCL
1031
1031
  # an Event
1032
1032
  def self.enqueue_marker( command_queue, events = [] )
1033
1033
  event = MemoryPointer::new( Event )
1034
- if command_queue.context.platform.version_number < 1.2 then
1034
+ if command_queue.device.platform.version_number < 1.2 then
1035
1035
  error = clEnqueueMarker( command_queue, event )
1036
1036
  else
1037
1037
  num_events = [events].flatten.length
@@ -1051,10 +1051,7 @@ module OpenCL
1051
1051
  # Maps the cl_command_queue object of OpenCL
1052
1052
  class CommandQueue
1053
1053
  include InnerInterface
1054
-
1055
- class << self
1056
- include InnerGenerator
1057
- end
1054
+ extend InnerGenerator
1058
1055
 
1059
1056
  def inspect
1060
1057
  p = properties
@@ -1077,38 +1074,8 @@ module OpenCL
1077
1074
  return Device::new( ptr.read_pointer )
1078
1075
  end
1079
1076
 
1080
- # Return the default CommandQueue for the underlying Device
1081
- def device_default
1082
- ptr = MemoryPointer::new( CommandQueue )
1083
- error = OpenCL.clGetCommandQueueInfo(self, DEVICE_DEFAULT, CommandQueue.size, ptr, nil)
1084
- error_check(error)
1085
- return CommandQueue::new( ptr.read_pointer )
1086
- end
1087
-
1088
- ##
1089
- # :method: reference_count
1090
- # Returns the reference count of the CommandQueue
1091
- eval get_info("CommandQueue", :cl_uint, "REFERENCE_COUNT")
1092
-
1093
- ##
1094
- # :method: size
1095
- # Returns the currently specified size for the command queue (2.0 and for device queue only)
1096
- eval get_info("CommandQueue", :cl_uint, "SIZE")
1097
-
1098
- ##
1099
- # :method: properties
1100
- # Returns the :cl_command_queue_properties used to create the CommandQueue
1101
- eval get_info("CommandQueue", :cl_command_queue_properties, "PROPERTIES")
1102
-
1103
- ##
1104
- # :method: priority_khr
1105
- # Returns the :cl_queue_priority_khr used to create the CommandQueue (2.1 and cl_khr_priority_hints required)
1106
- eval get_info("CommandQueue", :cl_queue_priority_khr, "PRIORITY_KHR")
1107
-
1108
- ##
1109
- # :method: throttle_khr
1110
- # Returns the :cl_queue_throttle_khr used to create the CommandQueue (2.1 and cl_khr_throttle_hints required)
1111
- eval get_info("CommandQueue", :cl_queue_throttle_khr, "THROTTLE_KHR")
1077
+ get_info("CommandQueue", :cl_uint, "reference_count")
1078
+ get_info("CommandQueue", :cl_command_queue_properties, "properties")
1112
1079
 
1113
1080
  # Enqueues a kernel as a task using the CommandQueue
1114
1081
  #
@@ -1173,34 +1140,6 @@ module OpenCL
1173
1140
  return OpenCL.enqueue_write_buffer( self, buffer, ptr, options )
1174
1141
  end
1175
1142
 
1176
- # Enqueues a command to write to a rectangular region in a Buffer object from host memory using the CommandQueue
1177
- #
1178
- # ==== Attributes
1179
- #
1180
- # * +buffer+ - the Buffer to be written to
1181
- # * +ptr+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area to use
1182
- # * +region+ - the region to write in the Buffer
1183
- # * +options+ - a hash containing named options
1184
- #
1185
- # ==== Options
1186
- #
1187
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1188
- # * +:blocking_write+ - if provided indicates if the command blocks until the region is written
1189
- # * +:blocking+ - if provided indicates if the command blocks until the region is written
1190
- # * +:buffer_origin+ - if provided indicates the origin inside the buffer of the area to copy, else [0, 0, 0]
1191
- # * +:host_origin+ - if provided indicates the origin inside the target host area, else [0, 0, 0]
1192
- # * +:buffer_row_pitch+ - if provided indicates the row pitch inside the buffer, else 0
1193
- # * +:buffer_slice_pitch+ - if provided indicates the slice pitch inside the buffer, else 0
1194
- # * +:host_row_pitch+ - if provided indicates the row pitch inside the host area, else 0
1195
- # * +:host_slice_pitch+ - if provided indicates the slice pitch inside the host area, else 0
1196
- #
1197
- # ==== Returns
1198
- #
1199
- # the Event associated with the command
1200
- def enqueue_write_buffer_rect( buffer, ptr, region, options = {} )
1201
- return OpenCL.enqueue_write_buffer_rect( self, buffer, ptr, region, options )
1202
- end
1203
-
1204
1143
  # Enqueues a command to read from a Buffer object to host memory using the CommandQueue
1205
1144
  #
1206
1145
  # ==== Attributes
@@ -1224,34 +1163,6 @@ module OpenCL
1224
1163
  return OpenCL.enqueue_read_buffer( self, buffer, ptr, options)
1225
1164
  end
1226
1165
 
1227
- # Enqueues a command to read from a rectangular region from a Buffer object to host memory using the CommandQueue
1228
- #
1229
- # ==== Attributes
1230
- #
1231
- # * +buffer+ - the Buffer to be read from
1232
- # * +ptr+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area to use
1233
- # * +region+ - the region in the Buffer to copy
1234
- # * +options+ - a hash containing named options
1235
- #
1236
- # ==== Options
1237
- #
1238
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1239
- # * +:blocking_read+ - if provided indicates if the command blocks until the region is read
1240
- # * +:blocking+ - if provided indicates if the command blocks until the region is read
1241
- # * +:buffer_origin+ - if provided indicates the origin inside the buffer of the area to copy, else [0, 0, 0]
1242
- # * +:host_origin+ - if provided indicates the origin inside the target host area, else [0, 0, 0]
1243
- # * +:buffer_row_pitch+ - if provided indicates the row pitch inside the buffer, else 0
1244
- # * +:buffer_slice_pitch+ - if provided indicates the slice pitch inside the buffer, else 0
1245
- # * +:host_row_pitch+ - if provided indicates the row pitch inside the host area, else 0
1246
- # * +:host_slice_pitch+ - if provided indicates the slice pitch inside the host area, else 0
1247
- #
1248
- # ==== Returns
1249
- #
1250
- # the Event associated with the command
1251
- def enqueue_read_buffer_rect( buffer, ptr, region, options = {} )
1252
- return OpenCL.enqueue_read_buffer_rect( self, buffer, ptr, region, options )
1253
- end
1254
-
1255
1166
  # Enqueues a command to copy data from a Buffer object into another Buffer object using the CommandQueue
1256
1167
  #
1257
1168
  # ==== Attributes
@@ -1274,32 +1185,6 @@ module OpenCL
1274
1185
  return OpenCL.enqueue_copy_buffer( self, src_buffer, dst_buffer, options )
1275
1186
  end
1276
1187
 
1277
- # Enqueues a command to copy a rectangular region into a Buffer object from another Buffer object using the CommandQueue
1278
- #
1279
- # ==== Attributes
1280
- #
1281
- # * +src_buffer+ - the Buffer to be read from
1282
- # * +dst_buffer+ - the Buffer to be written to
1283
- # * +region+ - the region to write in the Buffer
1284
- # * +options+ - a hash containing named options
1285
- #
1286
- # ==== Options
1287
- #
1288
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1289
- # * +:src_origin+ - if provided indicates the origin inside the src Buffer of the area to copy, else [0, 0, 0]
1290
- # * +:dst_origin+ - if provided indicates the origin inside the dst Buffer of the area to write to, else [0, 0, 0]
1291
- # * +:src_row_pitch+ - if provided indicates the row pitch inside the src Buffer, else 0
1292
- # * +:src_slice_pitch+ - if provided indicates the slice pitch inside the src Buffer, else 0
1293
- # * +:dst_row_pitch+ - if provided indicates the row pitch inside the dst Buffer, else 0
1294
- # * +:dst_slice_pitch+ - if provided indicates the slice pitch inside the dst Buffer area, else 0
1295
- #
1296
- # ==== Returns
1297
- #
1298
- # the Event associated with the command
1299
- def enqueue_copy_buffer_rect( src_buffer, dst_buffer, region, options = {} )
1300
- return OpenCL.enqueue_copy_buffer_rect( self, src_buffer, dst_buffer, region, options )
1301
- end
1302
-
1303
1188
  # Enqueues a barrier on a list of envents using the CommandQueue
1304
1189
  #
1305
1190
  # ==== Attributes
@@ -1455,49 +1340,6 @@ module OpenCL
1455
1340
  return OpenCL.enqueue_copy_image_to_buffer( self, src_image, dst_buffer, options )
1456
1341
  end
1457
1342
 
1458
- # Enqueues a command to fill an Image with the given color using the CommandQueue
1459
- #
1460
- # ==== Attributes
1461
- #
1462
- # * +image+ - an Image object to be filled
1463
- # * +fill_color+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area where the color is stored
1464
- # * +options+ - a hash containing named options
1465
- #
1466
- # ==== Options
1467
- #
1468
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1469
- # * +:origin+ - if provided indicates the origin of the region to fill inside the Image, else [0, 0, 0]
1470
- # * +:region+ - if provided indicates the dimension of the region to fill, else the maximum region is filled
1471
- #
1472
- # ==== Returns
1473
- #
1474
- # the Event associated with the command
1475
- def enqueue_fill_image( image, fill_color, options = {} )
1476
- return OpenCL.enqueue_fill_image( self, image, fill_color, options )
1477
- end
1478
-
1479
- # Enqueues a command to fill a Buffer with the given pattern using the CommandQueue
1480
- #
1481
- # ==== Attributes
1482
- #
1483
- # * +buffer+ - a Buffer object to be filled
1484
- # * +pattern+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area where the pattern is stored
1485
- # * +options+ - a hash containing named options
1486
- #
1487
- # ==== Options
1488
- #
1489
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1490
- # * +:offset+ - if provided indicates the offset inside the Buffer of the area to be filled, else 0
1491
- # * +:size+ - if provided indicates the size of data to fill, else the maximum size is filled
1492
- # * +:pattern_size+ - if provided indicates the size of the pattern, else the maximum pattern data is used
1493
- #
1494
- # ==== Returns
1495
- #
1496
- # the Event associated with the command
1497
- def enqueue_fill_buffer( buffer, pattern, options = {} )
1498
- return OpenCL.enqueue_fill_buffer( self, buffer, pattern, options )
1499
- end
1500
-
1501
1343
  # Acquire OpenCL Mem objects that have been created from OpenGL objects using the CommandQueue
1502
1344
  #
1503
1345
  # ==== Attributes
@@ -1607,25 +1449,6 @@ module OpenCL
1607
1449
  return OpenCL.enqueue_unmap_mem_object( self, mem_obj, mapped_ptr, options )
1608
1450
  end
1609
1451
 
1610
- # Enqueues a command to indicate which device a set of memory objects should be migrated to using the CommandQueue
1611
- #
1612
- # ==== Attributes
1613
- #
1614
- # * +mem_objects+ - the Mem objects to migrate
1615
- # * +options+ - a hash containing named options
1616
- #
1617
- # ==== Options
1618
- #
1619
- # * +:flags+ - a single or an Array of :cl_mem_migration flags
1620
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1621
- #
1622
- # ==== Returns
1623
- #
1624
- # the Event associated with the command
1625
- def enqueue_migrate_mem_objects( mem_objects, options = {} )
1626
- return OpenCL.enqueue_migrate_mem_objects( self, mem_objects, options )
1627
- end
1628
-
1629
1452
  # Enqueues a native kernel in the CommandQueue
1630
1453
  #
1631
1454
  # ==== Attributes
@@ -1656,127 +1479,303 @@ module OpenCL
1656
1479
  return OpenCL.flush( self )
1657
1480
  end
1658
1481
 
1659
- # Enqueues a command to copy from or to an SVMPointer using the CommandQueue
1660
- #
1661
- # ==== Attributes
1662
- #
1663
- # * +dst_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be written to
1664
- # * +src_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be read from
1665
- # * +size+ - the size of data to copy
1666
- # * +options+ - a hash containing named options
1667
- #
1668
- # ==== Options
1669
- #
1670
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1671
- # * +:blocking_copy+ - if provided indicates if the command blocks until the copy finishes
1672
- # * +:blocking+ - if provided indicates if the command blocks until the copy finishes
1673
- #
1674
- # ==== Returns
1675
- #
1676
- # the Event associated with the command
1677
- def enqueue_svm_memcpy( dst_ptr, src_ptr, size, options = {})
1678
- return OpenCL.enqueue_svm_memcpy(self, dst_ptr, src_ptr, size, options)
1679
- end
1482
+ module OpenCL11
1483
+
1484
+ # Enqueues a command to read from a rectangular region from a Buffer object to host memory using the CommandQueue
1485
+ #
1486
+ # ==== Attributes
1487
+ #
1488
+ # * +buffer+ - the Buffer to be read from
1489
+ # * +ptr+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area to use
1490
+ # * +region+ - the region in the Buffer to copy
1491
+ # * +options+ - a hash containing named options
1492
+ #
1493
+ # ==== Options
1494
+ #
1495
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1496
+ # * +:blocking_read+ - if provided indicates if the command blocks until the region is read
1497
+ # * +:blocking+ - if provided indicates if the command blocks until the region is read
1498
+ # * +:buffer_origin+ - if provided indicates the origin inside the buffer of the area to copy, else [0, 0, 0]
1499
+ # * +:host_origin+ - if provided indicates the origin inside the target host area, else [0, 0, 0]
1500
+ # * +:buffer_row_pitch+ - if provided indicates the row pitch inside the buffer, else 0
1501
+ # * +:buffer_slice_pitch+ - if provided indicates the slice pitch inside the buffer, else 0
1502
+ # * +:host_row_pitch+ - if provided indicates the row pitch inside the host area, else 0
1503
+ # * +:host_slice_pitch+ - if provided indicates the slice pitch inside the host area, else 0
1504
+ #
1505
+ # ==== Returns
1506
+ #
1507
+ # the Event associated with the command
1508
+ def enqueue_read_buffer_rect( buffer, ptr, region, options = {} )
1509
+ return OpenCL.enqueue_read_buffer_rect( self, buffer, ptr, region, options )
1510
+ end
1680
1511
 
1681
- # Enqueues a command that frees SVMPointers (or Pointers using a callback) using the CommandQueue
1682
- #
1683
- # ==== Attributes
1684
- #
1685
- # * +svm_pointer+ - a single or an Array of SVMPointer (or Pointer)
1686
- # * +options+ - a hash containing named options
1687
- # * +block+ - if provided, a callback invoked to free the pointers. Signature of the callback is { |CommandQueue, num_pointers, Pointer to an array of num_pointers Pointers, Pointer to user_data| ... }
1688
- #
1689
- # ==== Options
1690
- #
1691
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1692
- # * +:user_data+ - if provided, a Pointer (or convertible to using to_ptr) that will be passed to the callback
1693
- #
1694
- # ==== Returns
1695
- #
1696
- # the Event associated with the command
1697
- def enqueue_svm_free(svm_pointers, options = {}, &block)
1698
- return OpenCL.enqueue_svm_free(self, svm_pointers, options, &block)
1699
- end
1512
+ # Enqueues a command to write to a rectangular region in a Buffer object from host memory using the CommandQueue
1513
+ #
1514
+ # ==== Attributes
1515
+ #
1516
+ # * +buffer+ - the Buffer to be written to
1517
+ # * +ptr+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area to use
1518
+ # * +region+ - the region to write in the Buffer
1519
+ # * +options+ - a hash containing named options
1520
+ #
1521
+ # ==== Options
1522
+ #
1523
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1524
+ # * +:blocking_write+ - if provided indicates if the command blocks until the region is written
1525
+ # * +:blocking+ - if provided indicates if the command blocks until the region is written
1526
+ # * +:buffer_origin+ - if provided indicates the origin inside the buffer of the area to copy, else [0, 0, 0]
1527
+ # * +:host_origin+ - if provided indicates the origin inside the target host area, else [0, 0, 0]
1528
+ # * +:buffer_row_pitch+ - if provided indicates the row pitch inside the buffer, else 0
1529
+ # * +:buffer_slice_pitch+ - if provided indicates the slice pitch inside the buffer, else 0
1530
+ # * +:host_row_pitch+ - if provided indicates the row pitch inside the host area, else 0
1531
+ # * +:host_slice_pitch+ - if provided indicates the slice pitch inside the host area, else 0
1532
+ #
1533
+ # ==== Returns
1534
+ #
1535
+ # the Event associated with the command
1536
+ def enqueue_write_buffer_rect( buffer, ptr, region, options = {} )
1537
+ return OpenCL.enqueue_write_buffer_rect( self, buffer, ptr, region, options )
1538
+ end
1539
+
1540
+ # Enqueues a command to copy a rectangular region into a Buffer object from another Buffer object using the CommandQueue
1541
+ #
1542
+ # ==== Attributes
1543
+ #
1544
+ # * +src_buffer+ - the Buffer to be read from
1545
+ # * +dst_buffer+ - the Buffer to be written to
1546
+ # * +region+ - the region to write in the Buffer
1547
+ # * +options+ - a hash containing named options
1548
+ #
1549
+ # ==== Options
1550
+ #
1551
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1552
+ # * +:src_origin+ - if provided indicates the origin inside the src Buffer of the area to copy, else [0, 0, 0]
1553
+ # * +:dst_origin+ - if provided indicates the origin inside the dst Buffer of the area to write to, else [0, 0, 0]
1554
+ # * +:src_row_pitch+ - if provided indicates the row pitch inside the src Buffer, else 0
1555
+ # * +:src_slice_pitch+ - if provided indicates the slice pitch inside the src Buffer, else 0
1556
+ # * +:dst_row_pitch+ - if provided indicates the row pitch inside the dst Buffer, else 0
1557
+ # * +:dst_slice_pitch+ - if provided indicates the slice pitch inside the dst Buffer area, else 0
1558
+ #
1559
+ # ==== Returns
1560
+ #
1561
+ # the Event associated with the command
1562
+ def enqueue_copy_buffer_rect( src_buffer, dst_buffer, region, options = {} )
1563
+ return OpenCL.enqueue_copy_buffer_rect( self, src_buffer, dst_buffer, region, options )
1564
+ end
1700
1565
 
1701
- # Enqueues a command to fill a an SVM memory area using the CommandQueue
1702
- #
1703
- # ==== Attributes
1704
- #
1705
- # * +svm_ptr+ - the SVMPointer to the area to fill
1706
- # * +pattern+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area where the pattern is stored
1707
- # * +size+ - the size of the area to fill
1708
- #
1709
- # ==== Options
1710
- #
1711
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1712
- # * +:pattern_size+ - if provided indicates the size of the pattern, else the maximum pattern data is used
1713
- #
1714
- # ==== Returns
1715
- #
1716
- # the Event associated with the command
1717
- def enqueue_svm_memfill(command_queue, svm_ptr, pattern, size, options = {})
1718
- return OpenCL.enqueue_svm_memfill(self, svm_ptr, pattern, size, options)
1719
1566
  end
1720
1567
 
1721
- # Enqueues a command to map an Image into host memory using the CommandQueue
1722
- #
1723
- # ==== Attributes
1724
- #
1725
- # * +svm_ptr+ - the SVMPointer to the area to map
1726
- # * +size+ - the size of the region to map
1727
- # * +map_flags+ - a single or an Array of :cl_map_flags flags
1728
- # * +options+ - a hash containing named options
1729
- #
1730
- # ==== Options
1731
- #
1732
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1733
- # * +:blocking_map+ - if provided indicates if the command blocks until the region is mapped
1734
- # * +:blocking+ - if provided indicates if the command blocks until the region is mapped
1735
- #
1736
- # ==== Returns
1737
- #
1738
- # the Event associated with the command
1739
- def enqueue_svm_map( svm_ptr, size, map_flags, options = {} )
1740
- return OpenCL.enqueue_svm_map( self, svm_ptr, size, map_flags, options )
1568
+ module OpenCL12
1569
+
1570
+ # Enqueues a command to fill a Buffer with the given pattern using the CommandQueue
1571
+ #
1572
+ # ==== Attributes
1573
+ #
1574
+ # * +buffer+ - a Buffer object to be filled
1575
+ # * +pattern+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area where the pattern is stored
1576
+ # * +options+ - a hash containing named options
1577
+ #
1578
+ # ==== Options
1579
+ #
1580
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1581
+ # * +:offset+ - if provided indicates the offset inside the Buffer of the area to be filled, else 0
1582
+ # * +:size+ - if provided indicates the size of data to fill, else the maximum size is filled
1583
+ # * +:pattern_size+ - if provided indicates the size of the pattern, else the maximum pattern data is used
1584
+ #
1585
+ # ==== Returns
1586
+ #
1587
+ # the Event associated with the command
1588
+ def enqueue_fill_buffer( buffer, pattern, options = {} )
1589
+ return OpenCL.enqueue_fill_buffer( self, buffer, pattern, options )
1590
+ end
1591
+
1592
+ # Enqueues a command to fill an Image with the given color using the CommandQueue
1593
+ #
1594
+ # ==== Attributes
1595
+ #
1596
+ # * +image+ - an Image object to be filled
1597
+ # * +fill_color+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area where the color is stored
1598
+ # * +options+ - a hash containing named options
1599
+ #
1600
+ # ==== Options
1601
+ #
1602
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1603
+ # * +:origin+ - if provided indicates the origin of the region to fill inside the Image, else [0, 0, 0]
1604
+ # * +:region+ - if provided indicates the dimension of the region to fill, else the maximum region is filled
1605
+ #
1606
+ # ==== Returns
1607
+ #
1608
+ # the Event associated with the command
1609
+ def enqueue_fill_image( image, fill_color, options = {} )
1610
+ return OpenCL.enqueue_fill_image( self, image, fill_color, options )
1611
+ end
1612
+
1613
+ # Enqueues a command to indicate which device a set of memory objects should be migrated to using the CommandQueue
1614
+ #
1615
+ # ==== Attributes
1616
+ #
1617
+ # * +mem_objects+ - the Mem objects to migrate
1618
+ # * +options+ - a hash containing named options
1619
+ #
1620
+ # ==== Options
1621
+ #
1622
+ # * +:flags+ - a single or an Array of :cl_mem_migration flags
1623
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1624
+ #
1625
+ # ==== Returns
1626
+ #
1627
+ # the Event associated with the command
1628
+ def enqueue_migrate_mem_objects( mem_objects, options = {} )
1629
+ return OpenCL.enqueue_migrate_mem_objects( self, mem_objects, options )
1630
+ end
1631
+
1741
1632
  end
1742
-
1743
- # Enqueues a command to unmap a previously mapped SVM memory area using the CommandQueue
1744
- #
1745
- # ==== Attributes
1746
- #
1747
- # * +svm_ptr+ - the SVMPointer of the area to be unmapped
1748
- # * +options+ - a hash containing named options
1749
- #
1750
- # ==== Options
1751
- #
1752
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1753
- #
1754
- # ==== Returns
1755
- #
1756
- # the Event associated with the command
1757
- def enqueue_svm_unmap( svm_ptr, options = {} )
1758
- return OpenCL.enqueue_svm_unmap( self, svm_ptr, options )
1633
+
1634
+ module OpenCL20
1635
+ extend InnerGenerator
1636
+
1637
+ get_info("CommandQueue", :cl_uint, "size")
1638
+
1639
+ # Enqueues a command to copy from or to an SVMPointer using the CommandQueue
1640
+ #
1641
+ # ==== Attributes
1642
+ #
1643
+ # * +dst_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be written to
1644
+ # * +src_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be read from
1645
+ # * +size+ - the size of data to copy
1646
+ # * +options+ - a hash containing named options
1647
+ #
1648
+ # ==== Options
1649
+ #
1650
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1651
+ # * +:blocking_copy+ - if provided indicates if the command blocks until the copy finishes
1652
+ # * +:blocking+ - if provided indicates if the command blocks until the copy finishes
1653
+ #
1654
+ # ==== Returns
1655
+ #
1656
+ # the Event associated with the command
1657
+ def enqueue_svm_memcpy( dst_ptr, src_ptr, size, options = {})
1658
+ return OpenCL.enqueue_svm_memcpy(self, dst_ptr, src_ptr, size, options)
1659
+ end
1660
+
1661
+ # Enqueues a command that frees SVMPointers (or Pointers using a callback) using the CommandQueue
1662
+ #
1663
+ # ==== Attributes
1664
+ #
1665
+ # * +svm_pointer+ - a single or an Array of SVMPointer (or Pointer)
1666
+ # * +options+ - a hash containing named options
1667
+ # * +block+ - if provided, a callback invoked to free the pointers. Signature of the callback is { |CommandQueue, num_pointers, Pointer to an array of num_pointers Pointers, Pointer to user_data| ... }
1668
+ #
1669
+ # ==== Options
1670
+ #
1671
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1672
+ # * +:user_data+ - if provided, a Pointer (or convertible to using to_ptr) that will be passed to the callback
1673
+ #
1674
+ # ==== Returns
1675
+ #
1676
+ # the Event associated with the command
1677
+ def enqueue_svm_free(svm_pointers, options = {}, &block)
1678
+ return OpenCL.enqueue_svm_free(self, svm_pointers, options, &block)
1679
+ end
1680
+
1681
+ # Enqueues a command to fill a an SVM memory area using the CommandQueue
1682
+ #
1683
+ # ==== Attributes
1684
+ #
1685
+ # * +svm_ptr+ - the SVMPointer to the area to fill
1686
+ # * +pattern+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area where the pattern is stored
1687
+ # * +size+ - the size of the area to fill
1688
+ #
1689
+ # ==== Options
1690
+ #
1691
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1692
+ # * +:pattern_size+ - if provided indicates the size of the pattern, else the maximum pattern data is used
1693
+ #
1694
+ # ==== Returns
1695
+ #
1696
+ # the Event associated with the command
1697
+ def enqueue_svm_memfill(command_queue, svm_ptr, pattern, size, options = {})
1698
+ return OpenCL.enqueue_svm_memfill(self, svm_ptr, pattern, size, options)
1699
+ end
1700
+
1701
+ # Enqueues a command to map an Image into host memory using the CommandQueue
1702
+ #
1703
+ # ==== Attributes
1704
+ #
1705
+ # * +svm_ptr+ - the SVMPointer to the area to map
1706
+ # * +size+ - the size of the region to map
1707
+ # * +map_flags+ - a single or an Array of :cl_map_flags flags
1708
+ # * +options+ - a hash containing named options
1709
+ #
1710
+ # ==== Options
1711
+ #
1712
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1713
+ # * +:blocking_map+ - if provided indicates if the command blocks until the region is mapped
1714
+ # * +:blocking+ - if provided indicates if the command blocks until the region is mapped
1715
+ #
1716
+ # ==== Returns
1717
+ #
1718
+ # the Event associated with the command
1719
+ def enqueue_svm_map( svm_ptr, size, map_flags, options = {} )
1720
+ return OpenCL.enqueue_svm_map( self, svm_ptr, size, map_flags, options )
1721
+ end
1722
+
1723
+ # Enqueues a command to unmap a previously mapped SVM memory area using the CommandQueue
1724
+ #
1725
+ # ==== Attributes
1726
+ #
1727
+ # * +svm_ptr+ - the SVMPointer of the area to be unmapped
1728
+ # * +options+ - a hash containing named options
1729
+ #
1730
+ # ==== Options
1731
+ #
1732
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1733
+ #
1734
+ # ==== Returns
1735
+ #
1736
+ # the Event associated with the command
1737
+ def enqueue_svm_unmap( svm_ptr, options = {} )
1738
+ return OpenCL.enqueue_svm_unmap( self, svm_ptr, options )
1739
+ end
1740
+
1759
1741
  end
1760
1742
 
1761
- # Enqueues a command to migrate SVM memory area
1762
- # ==== Attributes
1763
- #
1764
- # * +svm_ptrs+ - a single or an Array of SVM memory area to migrate
1765
- # * +options+ - a hash containing named options
1766
- #
1767
- # ==== Options
1768
- #
1769
- # * +:sizes+ - a single or an Array of sizes to transfer
1770
- # * +:flags+ - a single or an Array of :cl_mem_migration flags
1771
- # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1772
- #
1773
- # ==== Returns
1774
- #
1775
- # the Event associated with the command
1776
- def enqueue_svm_migrate_mem( svn_ptrs, options = {} )
1777
- return OpenCL.enqueue_svm_migrate_mem( self, svn_ptrs, options = {} )
1743
+ module OpenCL21
1744
+
1745
+ # Return the default CommandQueue for the underlying Device
1746
+ def device_default
1747
+ ptr = MemoryPointer::new( CommandQueue )
1748
+ error = OpenCL.clGetCommandQueueInfo(self, DEVICE_DEFAULT, CommandQueue.size, ptr, nil)
1749
+ error_check(error)
1750
+ return CommandQueue::new( ptr.read_pointer )
1751
+ end
1752
+
1753
+ # Enqueues a command to migrate SVM memory area
1754
+ # ==== Attributes
1755
+ #
1756
+ # * +svm_ptrs+ - a single or an Array of SVM memory area to migrate
1757
+ # * +options+ - a hash containing named options
1758
+ #
1759
+ # ==== Options
1760
+ #
1761
+ # * +:sizes+ - a single or an Array of sizes to transfer
1762
+ # * +:flags+ - a single or an Array of :cl_mem_migration flags
1763
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1764
+ #
1765
+ # ==== Returns
1766
+ #
1767
+ # the Event associated with the command
1768
+ def enqueue_svm_migrate_mem( svn_ptrs, options = {} )
1769
+ return OpenCL.enqueue_svm_migrate_mem( self, svn_ptrs, options = {} )
1770
+ end
1771
+
1778
1772
  end
1779
1773
 
1774
+ register_extension( :v11, OpenCL11, "device.platform.version_number >= 1.1" )
1775
+ register_extension( :v12, OpenCL12, "device.platform.version_number >= 1.2" )
1776
+ register_extension( :v20, OpenCL20, "device.platform.version_number >= 2.0" )
1777
+ register_extension( :v21, OpenCL21, "device.platform.version_number >= 2.1" )
1778
+
1780
1779
  end
1781
1780
 
1782
1781
  end