opencl_ruby_ffi 1.3.5 → 1.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opencl_ruby_ffi.rb +1 -0
- data/lib/opencl_ruby_ffi/Buffer.rb +7 -1
- data/lib/opencl_ruby_ffi/CommandQueue.rb +24 -11
- data/lib/opencl_ruby_ffi/Context.rb +88 -18
- data/lib/opencl_ruby_ffi/Device.rb +99 -18
- data/lib/opencl_ruby_ffi/Event.rb +22 -13
- data/lib/opencl_ruby_ffi/Image.rb +7 -1
- data/lib/opencl_ruby_ffi/Kernel.rb +76 -49
- data/lib/opencl_ruby_ffi/Mem.rb +28 -12
- data/lib/opencl_ruby_ffi/Pipe.rb +8 -0
- data/lib/opencl_ruby_ffi/Platform.rb +41 -14
- data/lib/opencl_ruby_ffi/Program.rb +71 -26
- data/lib/opencl_ruby_ffi/SVM.rb +23 -11
- data/lib/opencl_ruby_ffi/Sampler.rb +6 -4
- data/lib/opencl_ruby_ffi/ext.rb +1 -0
- data/lib/opencl_ruby_ffi/intel/kernel_profiling.rb +38 -0
- data/lib/opencl_ruby_ffi/intel/unified_shared_memory_preview.rb +613 -0
- data/lib/opencl_ruby_ffi/intel/unofficial.rb +95 -0
- data/lib/opencl_ruby_ffi/khr/device_uuid.rb +119 -0
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb +222 -61
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb +84 -174
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_library.rb +181 -0
- data/lib/opencl_ruby_ffi/opencl_types.rb +4 -0
- data/opencl_ruby_ffi.gemspec +3 -4
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed02c06ec493e3a80c58182e631294ddeaa05d2f5a2236607a8431dc2684d4ab
|
4
|
+
data.tar.gz: 6f0404c434de4e4d392b1f3e641acc2e08010aa06c5f3d9cc035c52dead6070f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84cb00cb6e7a753eb365e64aac09dcf7fcd488aa5f9de3abf5685ddce81bdee6b44a7ea5548257e441c986ecb0f50ed9023c264cb51eede26100d03f36fbe2b7
|
7
|
+
data.tar.gz: 89e804309e0e092daacb1e614c9cb79467198c2259051a3ceaab101552bcd49969767920e6db34894bf53b73ec53ad2cd2eb935cb7946c47f2a0c274918c420f
|
data/lib/opencl_ruby_ffi.rb
CHANGED
@@ -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
|
-
|
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 { |
|
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 { |
|
603
|
+
[mem_objects].flatten.each_with_index { |e, i|
|
604
604
|
objs[i].write_pointer(e)
|
605
605
|
}
|
606
606
|
end
|
@@ -1070,6 +1070,11 @@ module OpenCL
|
|
1070
1070
|
return "#<#{self.class.name}: -> #{device.inspect}#{ 0 != p.to_i ? " (#{p})" : ""}>"
|
1071
1071
|
end
|
1072
1072
|
|
1073
|
+
# Returns the Platform associated with the CommandQueue
|
1074
|
+
def platform
|
1075
|
+
@_platform ||= self.context.platform
|
1076
|
+
end
|
1077
|
+
|
1073
1078
|
# Returns the Context associated to the CommandQueue
|
1074
1079
|
def context
|
1075
1080
|
ptr = MemoryPointer::new( Context )
|
@@ -1654,11 +1659,11 @@ module OpenCL
|
|
1654
1659
|
#
|
1655
1660
|
# * +dst_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be written to
|
1656
1661
|
# * +src_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be read from
|
1657
|
-
# * +size+ - the size of data to copy
|
1658
1662
|
# * +options+ - a hash containing named options
|
1659
1663
|
#
|
1660
1664
|
# ==== Options
|
1661
1665
|
#
|
1666
|
+
# * +:size+ - the size of data to copy
|
1662
1667
|
# * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
|
1663
1668
|
# * +:blocking_copy+ - if provided indicates if the command blocks until the copy finishes
|
1664
1669
|
# * +:blocking+ - if provided indicates if the command blocks until the copy finishes
|
@@ -1666,8 +1671,8 @@ module OpenCL
|
|
1666
1671
|
# ==== Returns
|
1667
1672
|
#
|
1668
1673
|
# the Event associated with the command
|
1669
|
-
def enqueue_svm_memcpy( dst_ptr, src_ptr,
|
1670
|
-
return OpenCL.enqueue_svm_memcpy(self, dst_ptr, src_ptr,
|
1674
|
+
def enqueue_svm_memcpy( dst_ptr, src_ptr, options = {})
|
1675
|
+
return OpenCL.enqueue_svm_memcpy(self, dst_ptr, src_ptr, options)
|
1671
1676
|
end
|
1672
1677
|
|
1673
1678
|
# Enqueues a command that frees SVMPointers (or Pointers using a callback) using the CommandQueue
|
@@ -1696,31 +1701,32 @@ module OpenCL
|
|
1696
1701
|
#
|
1697
1702
|
# * +svm_ptr+ - the SVMPointer to the area to fill
|
1698
1703
|
# * +pattern+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area where the pattern is stored
|
1699
|
-
# * +size+ - the size of the area to fill
|
1700
1704
|
#
|
1701
1705
|
# ==== Options
|
1702
1706
|
#
|
1707
|
+
# * +:size+ - the size of the area to fill
|
1703
1708
|
# * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
|
1704
1709
|
# * +:pattern_size+ - if provided indicates the size of the pattern, else the maximum pattern data is used
|
1705
1710
|
#
|
1706
1711
|
# ==== Returns
|
1707
1712
|
#
|
1708
1713
|
# the Event associated with the command
|
1709
|
-
def enqueue_svm_memfill( svm_ptr, pattern,
|
1710
|
-
return OpenCL.enqueue_svm_memfill(self, svm_ptr, pattern,
|
1714
|
+
def enqueue_svm_memfill( svm_ptr, pattern, options = {})
|
1715
|
+
return OpenCL.enqueue_svm_memfill(self, svm_ptr, pattern, options)
|
1711
1716
|
end
|
1717
|
+
alias enqueue_svm_mem_fill enqueue_svm_memfill
|
1712
1718
|
|
1713
1719
|
# Enqueues a command to map an Image into host memory using the CommandQueue
|
1714
1720
|
#
|
1715
1721
|
# ==== Attributes
|
1716
1722
|
#
|
1717
1723
|
# * +svm_ptr+ - the SVMPointer to the area to map
|
1718
|
-
# * +size+ - the size of the region to map
|
1719
1724
|
# * +map_flags+ - a single or an Array of :cl_map_flags flags
|
1720
1725
|
# * +options+ - a hash containing named options
|
1721
1726
|
#
|
1722
1727
|
# ==== Options
|
1723
1728
|
#
|
1729
|
+
# * +:size+ - the size of the region to map
|
1724
1730
|
# * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
|
1725
1731
|
# * +:blocking_map+ - if provided indicates if the command blocks until the region is mapped
|
1726
1732
|
# * +:blocking+ - if provided indicates if the command blocks until the region is mapped
|
@@ -1728,8 +1734,8 @@ module OpenCL
|
|
1728
1734
|
# ==== Returns
|
1729
1735
|
#
|
1730
1736
|
# the Event associated with the command
|
1731
|
-
def enqueue_svm_map( svm_ptr,
|
1732
|
-
return OpenCL.enqueue_svm_map( self, svm_ptr,
|
1737
|
+
def enqueue_svm_map( svm_ptr, map_flags, options = {} )
|
1738
|
+
return OpenCL.enqueue_svm_map( self, svm_ptr, map_flags, options )
|
1733
1739
|
end
|
1734
1740
|
|
1735
1741
|
# Enqueues a command to unmap a previously mapped SVM memory area using the CommandQueue
|
@@ -1783,10 +1789,17 @@ module OpenCL
|
|
1783
1789
|
|
1784
1790
|
end
|
1785
1791
|
|
1792
|
+
module OpenCL30
|
1793
|
+
extend InnerGenerator
|
1794
|
+
|
1795
|
+
get_info_array("CommandQueue", :cl_queue_properties, "properties_array")
|
1796
|
+
end
|
1797
|
+
|
1786
1798
|
register_extension( :v11, OpenCL11, "device.platform.version_number >= 1.1" )
|
1787
1799
|
register_extension( :v12, OpenCL12, "device.platform.version_number >= 1.2" )
|
1788
1800
|
register_extension( :v20, OpenCL20, "device.platform.version_number >= 2.0" )
|
1789
1801
|
register_extension( :v21, OpenCL21, "device.platform.version_number >= 2.1" )
|
1802
|
+
register_extension( :v30, OpenCL30, "device.platform.version_number >= 3.0" )
|
1790
1803
|
|
1791
1804
|
end
|
1792
1805
|
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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,25 @@ module OpenCL
|
|
68
116
|
|
69
117
|
# Returns the number of devices associated to the Context
|
70
118
|
def num_devices
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
119
|
+
@_num_devices ||= begin
|
120
|
+
ptr = MemoryPointer::new( :size_t )
|
121
|
+
error = OpenCL.clGetContextInfo(self, DEVICES, 0, nil, ptr)
|
122
|
+
error_check(error)
|
123
|
+
ptr.read_size_t / Platform.size
|
124
|
+
end
|
77
125
|
end
|
78
126
|
|
79
127
|
# Returns an Array of Device associated to the Context
|
80
128
|
def devices
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
129
|
+
@_devices ||= begin
|
130
|
+
n = self.num_devices
|
131
|
+
ptr2 = MemoryPointer::new( Device, n )
|
132
|
+
error = OpenCL.clGetContextInfo(self, DEVICES, Device.size*n, ptr2, nil)
|
133
|
+
error_check(error)
|
134
|
+
ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
|
135
|
+
Device::new(device_ptr)
|
136
|
+
}
|
137
|
+
end
|
88
138
|
end
|
89
139
|
|
90
140
|
##
|
@@ -118,7 +168,7 @@ module OpenCL
|
|
118
168
|
|
119
169
|
# Returns the platform associated to the Context
|
120
170
|
def platform
|
121
|
-
self.devices.first.platform
|
171
|
+
@_platform ||= self.devices.first.platform
|
122
172
|
end
|
123
173
|
|
124
174
|
# Returns an Array of ImageFormat that are supported for a given image type in the Context
|
@@ -451,16 +501,36 @@ module OpenCL
|
|
451
501
|
return OpenCL.create_program_with_il(self, il)
|
452
502
|
end
|
453
503
|
|
504
|
+
#
|
454
505
|
def set_default_device_command_queue( device, command_queue )
|
455
506
|
return OpenCL.set_default_device_command_queue( self, device, command_queue )
|
456
507
|
end
|
457
508
|
|
458
509
|
end
|
459
510
|
|
511
|
+
module OpenCL30
|
512
|
+
|
513
|
+
# Attaches a callback to context that will be called on context destruction
|
514
|
+
#
|
515
|
+
# ==== Attributes
|
516
|
+
#
|
517
|
+
# * +options+ - a hash containing named options
|
518
|
+
# * +block+ - if provided, a callback invoked when program is released. Signature of the callback is { |Pointer to the context, Pointer to user_data| ... }
|
519
|
+
#
|
520
|
+
# ==== Options
|
521
|
+
#
|
522
|
+
# * +:user_data+ - a Pointer (or convertible to Pointer using to_ptr) to the memory area to pass to the callback
|
523
|
+
def set_destructor_callback( options = {}, &block )
|
524
|
+
OpenCL.set_context_destructor_callback( self, option, &block )
|
525
|
+
return self
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
460
529
|
register_extension( :v11, OpenCL11, "platform.version_number >= 1.1" )
|
461
530
|
register_extension( :v12, OpenCL12, "platform.version_number >= 1.2" )
|
462
531
|
register_extension( :v20, OpenCL20, "platform.version_number >= 2.0" )
|
463
532
|
register_extension( :v21, OpenCL21, "platform.version_number >= 2.1" )
|
533
|
+
register_extension( :v30, OpenCL30, "platform.version_number >= 3.0" )
|
464
534
|
|
465
535
|
end
|
466
536
|
|
@@ -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,18 @@ 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
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
@_platform ||= begin
|
111
|
+
ptr = MemoryPointer::new( OpenCL::Platform )
|
112
|
+
error = OpenCL.clGetDeviceInfo(self, PLATFORM, OpenCL::Platform.size, ptr, nil)
|
113
|
+
error_check(error)
|
114
|
+
OpenCL::Platform::new(ptr.read_pointer)
|
115
|
+
end
|
114
116
|
end
|
115
117
|
|
116
118
|
get_info("Device", :cl_uint, "preferred_vector_width_char")
|
@@ -119,14 +121,14 @@ module OpenCL
|
|
119
121
|
get_info("Device", :cl_uint, "preferred_vector_width_long")
|
120
122
|
get_info("Device", :cl_uint, "preferred_vector_width_float")
|
121
123
|
get_info("Device", :cl_uint, "preferred_vector_width_double")
|
122
|
-
get_info("Device", :string, "profile")
|
124
|
+
get_info("Device", :string, "profile", true)
|
123
125
|
get_info("Device", :size_t, "profiling_timer_resolution")
|
124
126
|
get_info("Device", :cl_command_queue_properties, "queue_properties")
|
125
127
|
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")
|
128
|
+
get_info("Device", :cl_device_type, "type", true)
|
129
|
+
get_info("Device", :string, "vendor", true)
|
130
|
+
get_info("Device", :cl_uint, "vendor_id", true)
|
131
|
+
get_info("Device", :string, "version", true)
|
130
132
|
|
131
133
|
# returs a floating point number corresponding to the OpenCL version of the Device
|
132
134
|
def version_number
|
@@ -140,6 +142,7 @@ module OpenCL
|
|
140
142
|
module OpenCL11
|
141
143
|
extend InnerGenerator
|
142
144
|
|
145
|
+
get_info("Device", :cl_uint, "preferred_vector_width_half")
|
143
146
|
get_info("Device", :cl_bool, "host_unified_memory")
|
144
147
|
get_info("Device", :cl_uint, "native_vector_width_char")
|
145
148
|
get_info("Device", :cl_uint, "native_vector_width_short")
|
@@ -156,8 +159,6 @@ module OpenCL
|
|
156
159
|
n = ver.scan(/OpenCL C (\d+\.\d+)/)
|
157
160
|
return n.first.first.to_f
|
158
161
|
end
|
159
|
-
|
160
|
-
get_info("Device", :cl_uint, "preferred_vector_width_half")
|
161
162
|
|
162
163
|
end
|
163
164
|
|
@@ -364,10 +365,90 @@ module OpenCL
|
|
364
365
|
|
365
366
|
end
|
366
367
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
368
|
+
module OpenCL30
|
369
|
+
extend InnerGenerator
|
370
|
+
get_info("Device", :cl_device_atomic_capabilities, "atomic_memory_capabilities")
|
371
|
+
get_info("Device", :cl_device_atomic_capabilities, "atomic_fence_capabilities")
|
372
|
+
get_info("Device", :cl_bool, "non_uniform_work_group_support")
|
373
|
+
get_info("Device", :size_t, "preferred_work_group_size_multiple")
|
374
|
+
get_info("Device", :cl_bool, "work_group_collective_functions_support")
|
375
|
+
get_info("Device", :cl_bool, "generic_address_space_support")
|
376
|
+
get_info("Device", :cl_bool, "device_enqueue_support")
|
377
|
+
get_info("Device", :cl_bool, "pipe_support")
|
378
|
+
|
379
|
+
def numeric_version
|
380
|
+
ptr = MemoryPointer::new( :cl_version )
|
381
|
+
error = OpenCL.clGetDeviceInfo( self, NUMERIC_VERSION, 4, ptr, nil)
|
382
|
+
error_check(error)
|
383
|
+
return Version::from_int(ptr.read_cl_version)
|
384
|
+
end
|
385
|
+
|
386
|
+
def extensions_with_version
|
387
|
+
sz = MemoryPointer::new( :size_t )
|
388
|
+
error = OpenCL.clGetDeviceInfo( self, EXTENSIONS_WITH_VERSION, 0, nil, sz)
|
389
|
+
error_check(error)
|
390
|
+
sz = sz.read_size_t
|
391
|
+
ptr = MemoryPointer::new( sz )
|
392
|
+
error = OpenCL.clGetDeviceInfo( self, EXTENSIONS_WITH_VERSION, sz, ptr, nil)
|
393
|
+
error_check(error)
|
394
|
+
nvsz = NameVersion.size
|
395
|
+
return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
|
396
|
+
end
|
397
|
+
|
398
|
+
def ils_with_version
|
399
|
+
sz = MemoryPointer::new( :size_t )
|
400
|
+
error = OpenCL.clGetDeviceInfo( self, ILS_WITH_VERSION, 0, nil, sz)
|
401
|
+
error_check(error)
|
402
|
+
sz = sz.read_size_t
|
403
|
+
ptr = MemoryPointer::new( sz )
|
404
|
+
error = OpenCL.clGetDeviceInfo( self, ILS_WITH_VERSION, sz, ptr, nil)
|
405
|
+
error_check(error)
|
406
|
+
nvsz = NameVersion.size
|
407
|
+
return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
|
408
|
+
end
|
409
|
+
|
410
|
+
def built_in_kernels_with_version
|
411
|
+
sz = MemoryPointer::new( :size_t )
|
412
|
+
error = OpenCL.clGetDeviceInfo( self, BUILT_IN_KERNELS_WITH_VERSION, 0, nil, sz)
|
413
|
+
error_check(error)
|
414
|
+
sz = sz.read_size_t
|
415
|
+
ptr = MemoryPointer::new( sz )
|
416
|
+
error = OpenCL.clGetDeviceInfo( self, BUILT_IN_KERNELS_WITH_VERSION, sz, ptr, nil)
|
417
|
+
error_check(error)
|
418
|
+
nvsz = NameVersion.size
|
419
|
+
return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
|
420
|
+
end
|
421
|
+
|
422
|
+
def opencl_c_all_versions
|
423
|
+
sz = MemoryPointer::new( :size_t )
|
424
|
+
error = OpenCL.clGetDeviceInfo( self, OPENCL_C_ALL_VERSIONS, 0, nil, sz)
|
425
|
+
error_check(error)
|
426
|
+
sz = sz.read_size_t
|
427
|
+
ptr = MemoryPointer::new( sz )
|
428
|
+
error = OpenCL.clGetDeviceInfo( self, OPENCL_C_ALL_VERSIONS, sz, ptr, nil)
|
429
|
+
error_check(error)
|
430
|
+
nvsz = NameVersion.size
|
431
|
+
return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
|
432
|
+
end
|
433
|
+
|
434
|
+
def opencl_c_features
|
435
|
+
sz = MemoryPointer::new( :size_t )
|
436
|
+
error = OpenCL.clGetDeviceInfo( self, OPENCL_C_FEATURES, 0, nil, sz)
|
437
|
+
error_check(error)
|
438
|
+
sz = sz.read_size_t
|
439
|
+
ptr = MemoryPointer::new( sz )
|
440
|
+
error = OpenCL.clGetDeviceInfo( self, OPENCL_C_FEATURES, sz, ptr, nil)
|
441
|
+
error_check(error)
|
442
|
+
nvsz = NameVersion.size
|
443
|
+
return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
register_extension( :v11, OpenCL11, "platform.version_number >= 1.1" )
|
448
|
+
register_extension( :v12, OpenCL12, "platform.version_number >= 1.2" )
|
449
|
+
register_extension( :v20, OpenCL20, "platform.version_number >= 2.0" )
|
450
|
+
register_extension( :v21, OpenCL21, "platform.version_number >= 2.1" )
|
451
|
+
register_extension( :v30, OpenCL30, "platform.version_number >= 3.0" )
|
371
452
|
|
372
453
|
end
|
373
454
|
|