opencl_ruby_ffi 1.3.4 → 1.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b21d6823d5293898d032505607499b748d65fc45c30b0ba11d618210630a6c0
4
- data.tar.gz: a6439a7eb8f5fbb3f4555ac735b271053ceedc3e5b0367bab14952fb857cdd4d
3
+ metadata.gz: 5b82499588d782647276b70a17225849c4468bb0c3619191fcba4bb15729318a
4
+ data.tar.gz: 3b015990606ee221a9e7288b2f1b99bfdae814ae3016f8142fb1044df3b3ec3b
5
5
  SHA512:
6
- metadata.gz: 32995522c19c6180d34879752bab8613f3f0caf9049fa4a10ecb2ab692a46ac6df3a68b122d39e7bb6df44fe4327410cc229127d515be561dea722f4b85cd3b0
7
- data.tar.gz: b2e8933cc719de81412adc6ee3864547f0308b9ae959bf93f8d0806019ffe7c835cea8530dbbc43e84b6a84d4d66b87de6619b3d32089595312870c473efc615
6
+ metadata.gz: 28148b57ac0b7cf8e8b619ed50e94c0bf5af77cfebad6fdae788efc23e90850bfe439a64f50270573367729a7fd47751a1fe3d75e8dd5b0405c9ffeb2b4012f6
7
+ data.tar.gz: 6b11039332b1c93141c350ab5b0a642521d0019e5bc1670af22daad333d85a4f32db8fa18d7bba5d2032944300ecdba6167903f623661f448b74fe45bd4a6948
@@ -2,6 +2,7 @@ require "opencl_ruby_ffi/opencl_types.rb"
2
2
  require "opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb"
3
3
  require "opencl_ruby_ffi/opencl_arithmetic_gen.rb"
4
4
  require "opencl_ruby_ffi/opencl_ruby_ffi_base.rb"
5
+ require "opencl_ruby_ffi/opencl_ruby_ffi_library.rb"
5
6
  require "opencl_ruby_ffi/Context.rb"
6
7
  require "opencl_ruby_ffi/Platform.rb"
7
8
  require "opencl_ruby_ffi/Device.rb"
@@ -13,11 +13,17 @@ module OpenCL
13
13
  #
14
14
  # * +:flags+ - a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Buffer
15
15
  # * +:host_ptr+ - if provided, the Pointer (or convertible to Pointer using to_ptr) to the memory area to use
16
+ # * +:properties+ - if provided, an array of :cl_mem_properties (OpenCL 3.0)
16
17
  def self.create_buffer( context, size, options = {} )
17
18
  flags = get_flags( options )
18
19
  host_ptr = options[:host_ptr]
19
20
  error = MemoryPointer::new( :cl_int )
20
- buff = clCreateBuffer(context, flags, size, host_ptr, error)
21
+ if context.platform.version_number < 3.0 then
22
+ buff = clCreateBuffer(context, flags, size, host_ptr, error)
23
+ else
24
+ properties = get_mem_properties( options )
25
+ buff = clCreateBufferWithProperties(context, properties, flags, size, host_ptr, error)
26
+ end
21
27
  error_check(error.read_cl_int)
22
28
  return Buffer::new( buff, false )
23
29
  end
@@ -566,7 +566,7 @@ module OpenCL
566
566
  objs = nil
567
567
  if num_objs > 0 then
568
568
  objs = MemoryPointer::new( Mem, num_objs )
569
- [mem_objects].flatten.each_with_index { |o, i|
569
+ [mem_objects].flatten.each_with_index { |e, i|
570
570
  objs[i].write_pointer(e)
571
571
  }
572
572
  end
@@ -600,7 +600,7 @@ module OpenCL
600
600
  objs = nil
601
601
  if num_objs > 0 then
602
602
  objs = MemoryPointer::new( Mem, num_objs )
603
- [mem_objects].flatten.each_with_index { |o, i|
603
+ [mem_objects].flatten.each_with_index { |e, i|
604
604
  objs[i].write_pointer(e)
605
605
  }
606
606
  end
@@ -639,7 +639,8 @@ module OpenCL
639
639
  offset = options[:offset] if options[:offset]
640
640
  pattern_size = pattern.size
641
641
  pattern_size = options[:pattern_size] if options[:pattern_size]
642
- size = (buffer.size - offset) % pattern_size
642
+ size = (buffer.size - offset)
643
+ size -= size % pattern_size
643
644
  size = options[:size] if options[:size]
644
645
  num_events, events = get_event_wait_list( options )
645
646
  event = MemoryPointer::new( Event )
@@ -1069,6 +1070,12 @@ module OpenCL
1069
1070
  return "#<#{self.class.name}: -> #{device.inspect}#{ 0 != p.to_i ? " (#{p})" : ""}>"
1070
1071
  end
1071
1072
 
1073
+ # Returns the Platform associated with the CommandQueue
1074
+ def platform
1075
+ return @_platform if @_platform
1076
+ @_platform = self.context.platform
1077
+ end
1078
+
1072
1079
  # Returns the Context associated to the CommandQueue
1073
1080
  def context
1074
1081
  ptr = MemoryPointer::new( Context )
@@ -1653,11 +1660,11 @@ module OpenCL
1653
1660
  #
1654
1661
  # * +dst_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be written to
1655
1662
  # * +src_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be read from
1656
- # * +size+ - the size of data to copy
1657
1663
  # * +options+ - a hash containing named options
1658
1664
  #
1659
1665
  # ==== Options
1660
1666
  #
1667
+ # * +:size+ - the size of data to copy
1661
1668
  # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1662
1669
  # * +:blocking_copy+ - if provided indicates if the command blocks until the copy finishes
1663
1670
  # * +:blocking+ - if provided indicates if the command blocks until the copy finishes
@@ -1665,8 +1672,8 @@ module OpenCL
1665
1672
  # ==== Returns
1666
1673
  #
1667
1674
  # the Event associated with the command
1668
- def enqueue_svm_memcpy( dst_ptr, src_ptr, size, options = {})
1669
- return OpenCL.enqueue_svm_memcpy(self, dst_ptr, src_ptr, size, options)
1675
+ def enqueue_svm_memcpy( dst_ptr, src_ptr, options = {})
1676
+ return OpenCL.enqueue_svm_memcpy(self, dst_ptr, src_ptr, options)
1670
1677
  end
1671
1678
 
1672
1679
  # Enqueues a command that frees SVMPointers (or Pointers using a callback) using the CommandQueue
@@ -1695,31 +1702,32 @@ module OpenCL
1695
1702
  #
1696
1703
  # * +svm_ptr+ - the SVMPointer to the area to fill
1697
1704
  # * +pattern+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area where the pattern is stored
1698
- # * +size+ - the size of the area to fill
1699
1705
  #
1700
1706
  # ==== Options
1701
1707
  #
1708
+ # * +:size+ - the size of the area to fill
1702
1709
  # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1703
1710
  # * +:pattern_size+ - if provided indicates the size of the pattern, else the maximum pattern data is used
1704
1711
  #
1705
1712
  # ==== Returns
1706
1713
  #
1707
1714
  # the Event associated with the command
1708
- def enqueue_svm_memfill( svm_ptr, pattern, size, options = {})
1709
- return OpenCL.enqueue_svm_memfill(self, svm_ptr, pattern, size, options)
1715
+ def enqueue_svm_memfill( svm_ptr, pattern, options = {})
1716
+ return OpenCL.enqueue_svm_memfill(self, svm_ptr, pattern, options)
1710
1717
  end
1718
+ alias enqueue_svm_mem_fill enqueue_svm_memfill
1711
1719
 
1712
1720
  # Enqueues a command to map an Image into host memory using the CommandQueue
1713
1721
  #
1714
1722
  # ==== Attributes
1715
1723
  #
1716
1724
  # * +svm_ptr+ - the SVMPointer to the area to map
1717
- # * +size+ - the size of the region to map
1718
1725
  # * +map_flags+ - a single or an Array of :cl_map_flags flags
1719
1726
  # * +options+ - a hash containing named options
1720
1727
  #
1721
1728
  # ==== Options
1722
1729
  #
1730
+ # * +:size+ - the size of the region to map
1723
1731
  # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1724
1732
  # * +:blocking_map+ - if provided indicates if the command blocks until the region is mapped
1725
1733
  # * +:blocking+ - if provided indicates if the command blocks until the region is mapped
@@ -1727,8 +1735,8 @@ module OpenCL
1727
1735
  # ==== Returns
1728
1736
  #
1729
1737
  # the Event associated with the command
1730
- def enqueue_svm_map( svm_ptr, size, map_flags, options = {} )
1731
- return OpenCL.enqueue_svm_map( self, svm_ptr, size, map_flags, options )
1738
+ def enqueue_svm_map( svm_ptr, map_flags, options = {} )
1739
+ return OpenCL.enqueue_svm_map( self, svm_ptr, map_flags, options )
1732
1740
  end
1733
1741
 
1734
1742
  # Enqueues a command to unmap a previously mapped SVM memory area using the CommandQueue
@@ -1782,10 +1790,17 @@ module OpenCL
1782
1790
 
1783
1791
  end
1784
1792
 
1793
+ module OpenCL30
1794
+ extend InnerGenerator
1795
+
1796
+ get_info_array("CommandQueue", :cl_queue_properties, "properties_array")
1797
+ end
1798
+
1785
1799
  register_extension( :v11, OpenCL11, "device.platform.version_number >= 1.1" )
1786
1800
  register_extension( :v12, OpenCL12, "device.platform.version_number >= 1.2" )
1787
1801
  register_extension( :v20, OpenCL20, "device.platform.version_number >= 2.0" )
1788
1802
  register_extension( :v21, OpenCL21, "device.platform.version_number >= 2.1" )
1803
+ register_extension( :v30, OpenCL30, "device.platform.version_number >= 3.0" )
1789
1804
 
1790
1805
  end
1791
1806
 
@@ -14,7 +14,9 @@ module OpenCL
14
14
  # * +:properties+ - a list of :cl_context_properties
15
15
  # * +:user_data+ - an Pointer or an object that can be converted into one using to_ptr. The pointer is passed to the callback.
16
16
  def self.create_context(devices, options = {}, &block)
17
- @@callbacks.push( block ) if block
17
+ if block
18
+ @@callbacks[block] = options[:user_data]
19
+ end
18
20
  devs = [devices].flatten
19
21
  pointer = MemoryPointer::new( Device, devs.size)
20
22
  pointer.write_array_of_pointer(devs)
@@ -23,7 +25,16 @@ module OpenCL
23
25
  error = MemoryPointer::new( :cl_int )
24
26
  ptr = clCreateContext(properties, devs.size, pointer, block, user_data, error)
25
27
  error_check(error.read_cl_int)
26
- return Context::new(ptr, false)
28
+ context = Context::new(ptr, false)
29
+ if block && context.platform.version_number >= 3.0
30
+ callback_destructor_callback = lambda { |c, u|
31
+ @@callbacks.delete(block)
32
+ @@callbacks.delete(callback_destructor_callback)
33
+ }
34
+ @@callbacks[callback_destructor_callback] = nil
35
+ context.set_destructor_callback(&callback_destructor_callback)
36
+ end
37
+ return context
27
38
  end
28
39
 
29
40
  # Creates an Context using devices of the selected type
@@ -39,13 +50,24 @@ module OpenCL
39
50
  # * +:properties+ - a list of :cl_context_properties
40
51
  # * +:user_data+ - an Pointer or an object that can be converted into one using to_ptr. The pointer is passed to the callback.
41
52
  def self.create_context_from_type(type, options = {}, &block)
42
- @@callbacks.push( block ) if block
53
+ if block
54
+ @@callbacks[block] = options[:user_data]
55
+ end
43
56
  properties = get_context_properties( options )
44
57
  user_data = options[:user_data]
45
58
  error = MemoryPointer::new( :cl_int )
46
59
  ptr = clCreateContextFromType(properties, type, block, user_data, error)
47
60
  error_check(error.read_cl_int)
48
- return Context::new(ptr, false)
61
+ context = Context::new(ptr, false)
62
+ if block && context.platform.version_number >= 3.0
63
+ callback_destructor_callback = lambda { |c, u|
64
+ @@callbacks.delete(block)
65
+ @@callbacks.delete(callback_destructor_callback)
66
+ }
67
+ @@callbacks[callback_destructor_callback] = nil
68
+ context.set_destructor_callback(&callback_destructor_callback)
69
+ end
70
+ return context
49
71
  end
50
72
 
51
73
  def self.set_default_device_command_queue( context, device, command_queue )
@@ -55,6 +77,32 @@ module OpenCL
55
77
  return context
56
78
  end
57
79
 
80
+ # Attaches a callback to context that will be called on context destruction
81
+ #
82
+ # ==== Attributes
83
+ #
84
+ # * +context+ - the Program to attach the callback to
85
+ # * +options+ - a hash containing named options
86
+ # * +block+ - if provided, a callback invoked when program is released. Signature of the callback is { |Pointer to the context, Pointer to user_data| ... }
87
+ #
88
+ # ==== Options
89
+ #
90
+ # * +:user_data+ - a Pointer (or convertible to Pointer using to_ptr) to the memory area to pass to the callback
91
+ def self.set_context_destructor_callback( context, options = {}, &block )
92
+ if block
93
+ wrapper_block = lambda { |p, u|
94
+ block.call(p, u)
95
+ @@callbacks.delete(wrapper_block)
96
+ }
97
+ @@callbacks[wrapper_block] = options[:user_data]
98
+ else
99
+ wrapper_block = nil
100
+ end
101
+ error = clSetContextDestructorCallback( context, wrapper_block, options[:user_data] )
102
+ error_check(error)
103
+ return context
104
+ end
105
+
58
106
  #Maps the cl_context object of OpenCL
59
107
  class Context
60
108
  include InnerInterface
@@ -68,23 +116,26 @@ module OpenCL
68
116
 
69
117
  # Returns the number of devices associated to the Context
70
118
  def num_devices
119
+ return @_num_devices if @_num_devices
71
120
  d_n = 0
72
121
  ptr = MemoryPointer::new( :size_t )
73
122
  error = OpenCL.clGetContextInfo(self, DEVICES, 0, nil, ptr)
74
123
  error_check(error)
75
124
  d_n = ptr.read_size_t / Platform.size
76
- return d_n
125
+ @_num_devices = d_n
77
126
  end
78
127
 
79
128
  # Returns an Array of Device associated to the Context
80
129
  def devices
130
+ return @_devices if @_devices
81
131
  n = self.num_devices
82
132
  ptr2 = MemoryPointer::new( Device, n )
83
133
  error = OpenCL.clGetContextInfo(self, DEVICES, Device.size*n, ptr2, nil)
84
134
  error_check(error)
85
- return ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
135
+ @_devices = ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
86
136
  Device::new(device_ptr)
87
137
  }
138
+ return @_devices
88
139
  end
89
140
 
90
141
  ##
@@ -118,7 +169,8 @@ module OpenCL
118
169
 
119
170
  # Returns the platform associated to the Context
120
171
  def platform
121
- self.devices.first.platform
172
+ return @_platform if @_platform
173
+ @_platform = self.devices.first.platform
122
174
  end
123
175
 
124
176
  # Returns an Array of ImageFormat that are supported for a given image type in the Context
@@ -451,16 +503,36 @@ module OpenCL
451
503
  return OpenCL.create_program_with_il(self, il)
452
504
  end
453
505
 
506
+ #
454
507
  def set_default_device_command_queue( device, command_queue )
455
508
  return OpenCL.set_default_device_command_queue( self, device, command_queue )
456
509
  end
457
510
 
458
511
  end
459
512
 
513
+ module OpenCL30
514
+
515
+ # Attaches a callback to context that will be called on context destruction
516
+ #
517
+ # ==== Attributes
518
+ #
519
+ # * +options+ - a hash containing named options
520
+ # * +block+ - if provided, a callback invoked when program is released. Signature of the callback is { |Pointer to the context, Pointer to user_data| ... }
521
+ #
522
+ # ==== Options
523
+ #
524
+ # * +:user_data+ - a Pointer (or convertible to Pointer using to_ptr) to the memory area to pass to the callback
525
+ def set_destructor_callback( options = {}, &block )
526
+ OpenCL.set_context_destructor_callback( self, option, &block )
527
+ return self
528
+ end
529
+ end
530
+
460
531
  register_extension( :v11, OpenCL11, "platform.version_number >= 1.1" )
461
532
  register_extension( :v12, OpenCL12, "platform.version_number >= 1.2" )
462
533
  register_extension( :v20, OpenCL20, "platform.version_number >= 2.0" )
463
534
  register_extension( :v21, OpenCL21, "platform.version_number >= 2.1" )
535
+ register_extension( :v30, OpenCL30, "platform.version_number >= 3.0" )
464
536
 
465
537
  end
466
538
 
@@ -14,7 +14,7 @@ module OpenCL
14
14
  def self.create_sub_devices( in_device, properties )
15
15
  error_check(INVALID_OPERATION) if in_device.platform.version_number < 1.2
16
16
  props = MemoryPointer::new( :cl_device_partition_property, properties.length + 1 )
17
- properties.each_with_index { |e,i|
17
+ properties.each_with_index { |e, i|
18
18
  props[i].write_cl_device_partition_property(e)
19
19
  }
20
20
  props[properties.length].write_cl_device_partition_property(0)
@@ -56,7 +56,7 @@ module OpenCL
56
56
  return "#<#{self.class.name}: #{name} (#{pointer.to_i})>"
57
57
  end
58
58
 
59
- get_info("Device", :cl_uint, "address_bits")
59
+ get_info("Device", :cl_uint, "address_bits", true)
60
60
  get_info("Device", :cl_bool, "available")
61
61
  get_info("Device", :cl_bool, "compiler_available")
62
62
  get_info("Device", :cl_bool, "endian_little")
@@ -101,16 +101,17 @@ module OpenCL
101
101
  get_info("Device", :cl_uint, "max_write_image_args")
102
102
  get_info("Device", :cl_uint, "mem_base_addr_align")
103
103
  get_info("Device", :cl_uint, "min_data_type_align_size")
104
- get_info("Device", :string, "name")
104
+ get_info("Device", :string, "name", true)
105
105
 
106
106
  alias to_s name
107
107
 
108
108
  # Returns the Platform the Device belongs to
109
109
  def platform
110
+ return @_platform if @_platform
110
111
  ptr = MemoryPointer::new( OpenCL::Platform )
111
112
  error = OpenCL.clGetDeviceInfo(self, PLATFORM, OpenCL::Platform.size, ptr, nil)
112
113
  error_check(error)
113
- return OpenCL::Platform::new(ptr.read_pointer)
114
+ @_platform = OpenCL::Platform::new(ptr.read_pointer)
114
115
  end
115
116
 
116
117
  get_info("Device", :cl_uint, "preferred_vector_width_char")
@@ -119,14 +120,14 @@ module OpenCL
119
120
  get_info("Device", :cl_uint, "preferred_vector_width_long")
120
121
  get_info("Device", :cl_uint, "preferred_vector_width_float")
121
122
  get_info("Device", :cl_uint, "preferred_vector_width_double")
122
- get_info("Device", :string, "profile")
123
+ get_info("Device", :string, "profile", true)
123
124
  get_info("Device", :size_t, "profiling_timer_resolution")
124
125
  get_info("Device", :cl_command_queue_properties, "queue_properties")
125
126
  get_info("Device", :cl_device_fp_config, "single_fp_config")
126
- get_info("Device", :cl_device_type, "type")
127
- get_info("Device", :string, "vendor")
128
- get_info("Device", :cl_uint, "vendor_id")
129
- get_info("Device", :string, "version")
127
+ get_info("Device", :cl_device_type, "type", true)
128
+ get_info("Device", :string, "vendor", true)
129
+ get_info("Device", :cl_uint, "vendor_id", true)
130
+ get_info("Device", :string, "version", true)
130
131
 
131
132
  # returs a floating point number corresponding to the OpenCL version of the Device
132
133
  def version_number
@@ -140,6 +141,7 @@ module OpenCL
140
141
  module OpenCL11
141
142
  extend InnerGenerator
142
143
 
144
+ get_info("Device", :cl_uint, "preferred_vector_width_half")
143
145
  get_info("Device", :cl_bool, "host_unified_memory")
144
146
  get_info("Device", :cl_uint, "native_vector_width_char")
145
147
  get_info("Device", :cl_uint, "native_vector_width_short")
@@ -364,10 +366,90 @@ module OpenCL
364
366
 
365
367
  end
366
368
 
367
- register_extension( :v11, OpenCL11, "platform.version_number >= 1.1" )
368
- register_extension( :v12, OpenCL12, "platform.version_number >= 1.2" )
369
- register_extension( :v20, OpenCL20, "platform.version_number >= 2.0" )
370
- register_extension( :v21, OpenCL21, "platform.version_number >= 2.1" )
369
+ module OpenCL30
370
+ extend InnerGenerator
371
+ get_info("Device", :cl_device_atomic_capabilities, "atomic_memory_capabilities")
372
+ get_info("Device", :cl_device_atomic_capabilities, "atomic_fence_capabilities")
373
+ get_info("Device", :cl_bool, "non_uniform_work_group_support")
374
+ get_info("Device", :size_t, "preferred_work_group_size_multiple")
375
+ get_info("Device", :cl_bool, "work_group_collective_functions_support")
376
+ get_info("Device", :cl_bool, "generic_address_space_support")
377
+ get_info("Device", :cl_bool, "device_enqueue_support")
378
+ get_info("Device", :cl_bool, "pipe_support")
379
+
380
+ def numeric_version
381
+ ptr = MemoryPointer::new( :cl_version )
382
+ error = OpenCL.clGetDeviceInfo( self, NUMERIC_VERSION, 4, ptr, nil)
383
+ error_check(error)
384
+ return Version::from_int(ptr.read_cl_version)
385
+ end
386
+
387
+ def extensions_with_version
388
+ sz = MemoryPointer::new( :size_t )
389
+ error = OpenCL.clGetDeviceInfo( self, EXTENSIONS_WITH_VERSION, 0, nil, sz)
390
+ error_check(error)
391
+ sz = sz.read_size_t
392
+ ptr = MemoryPointer::new( sz )
393
+ error = OpenCL.clGetDeviceInfo( self, EXTENSIONS_WITH_VERSION, sz, ptr, nil)
394
+ error_check(error)
395
+ nvsz = NameVersion.size
396
+ return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
397
+ end
398
+
399
+ def ils_with_version
400
+ sz = MemoryPointer::new( :size_t )
401
+ error = OpenCL.clGetDeviceInfo( self, ILS_WITH_VERSION, 0, nil, sz)
402
+ error_check(error)
403
+ sz = sz.read_size_t
404
+ ptr = MemoryPointer::new( sz )
405
+ error = OpenCL.clGetDeviceInfo( self, ILS_WITH_VERSION, sz, ptr, nil)
406
+ error_check(error)
407
+ nvsz = NameVersion.size
408
+ return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
409
+ end
410
+
411
+ def built_in_kernels_with_version
412
+ sz = MemoryPointer::new( :size_t )
413
+ error = OpenCL.clGetDeviceInfo( self, BUILT_IN_KERNELS_WITH_VERSION, 0, nil, sz)
414
+ error_check(error)
415
+ sz = sz.read_size_t
416
+ ptr = MemoryPointer::new( sz )
417
+ error = OpenCL.clGetDeviceInfo( self, BUILT_IN_KERNELS_WITH_VERSION, sz, ptr, nil)
418
+ error_check(error)
419
+ nvsz = NameVersion.size
420
+ return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
421
+ end
422
+
423
+ def opencl_c_all_versions
424
+ sz = MemoryPointer::new( :size_t )
425
+ error = OpenCL.clGetDeviceInfo( self, OPENCL_C_ALL_VERSIONS, 0, nil, sz)
426
+ error_check(error)
427
+ sz = sz.read_size_t
428
+ ptr = MemoryPointer::new( sz )
429
+ error = OpenCL.clGetDeviceInfo( self, OPENCL_C_ALL_VERSIONS, sz, ptr, nil)
430
+ error_check(error)
431
+ nvsz = NameVersion.size
432
+ return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
433
+ end
434
+
435
+ def opencl_c_features
436
+ sz = MemoryPointer::new( :size_t )
437
+ error = OpenCL.clGetDeviceInfo( self, OPENCL_C_FEATURES, 0, nil, sz)
438
+ error_check(error)
439
+ sz = sz.read_size_t
440
+ ptr = MemoryPointer::new( sz )
441
+ error = OpenCL.clGetDeviceInfo( self, OPENCL_C_FEATURES, sz, ptr, nil)
442
+ error_check(error)
443
+ nvsz = NameVersion.size
444
+ return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
445
+ end
446
+ end
447
+
448
+ register_extension( :v11, OpenCL11, "platform.version_number >= 1.1" )
449
+ register_extension( :v12, OpenCL12, "platform.version_number >= 1.2" )
450
+ register_extension( :v20, OpenCL20, "platform.version_number >= 2.0" )
451
+ register_extension( :v21, OpenCL21, "platform.version_number >= 2.1" )
452
+ register_extension( :v30, OpenCL30, "platform.version_number >= 3.0" )
371
453
 
372
454
  end
373
455