opencl_ruby_ffi 1.3.6 → 1.3.7
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 +4 -4
- data/lib/opencl_ruby_ffi/CommandQueue.rb +16 -9
- data/lib/opencl_ruby_ffi/Context.rb +13 -5
- data/lib/opencl_ruby_ffi/Device.rb +11 -9
- data/lib/opencl_ruby_ffi/Event.rb +13 -4
- data/lib/opencl_ruby_ffi/Kernel.rb +29 -10
- data/lib/opencl_ruby_ffi/Mem.rb +19 -9
- data/lib/opencl_ruby_ffi/Platform.rb +8 -6
- data/lib/opencl_ruby_ffi/Program.rb +57 -16
- data/lib/opencl_ruby_ffi/SVM.rb +23 -11
- data/lib/opencl_ruby_ffi/Sampler.rb +2 -1
- data/lib/opencl_ruby_ffi/intel/kernel_profiling.rb +38 -0
- data/lib/opencl_ruby_ffi/intel/unified_shared_memory_preview.rb +586 -0
- data/lib/opencl_ruby_ffi/intel/unofficial.rb +95 -0
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb +109 -24
- data/opencl_ruby_ffi.gemspec +1 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abb565a3d9a1e180eebf1e28ab06d330a4ae2477522ba2b22c0211bf7c720bc4
|
4
|
+
data.tar.gz: 2e47f057d7cf5a79a3972f8a3ab1ac7291827020c607c465d357b58824683ec5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d144d10d5744d13cf235a2f0ff4b9fa2bb1df7d47fc4c9b4799c233d1f9e2dc71f30f66c84cdf4a55db197cb6a4175b654845ac6be97c03ed57ea4b931508a10
|
7
|
+
data.tar.gz: 29561be75358ae7ae658a365f602930ff62a4bf5854ca1a0f0547ff5b7c4703ca01bd19fc036b15b3a503a0b3990eaa482d0c95c66b0be1b388316fa09e3348b
|
@@ -1070,6 +1070,12 @@ 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
|
+
return @_platform if @_platform
|
1076
|
+
@_platform = self.context.platform
|
1077
|
+
end
|
1078
|
+
|
1073
1079
|
# Returns the Context associated to the CommandQueue
|
1074
1080
|
def context
|
1075
1081
|
ptr = MemoryPointer::new( Context )
|
@@ -1654,11 +1660,11 @@ module OpenCL
|
|
1654
1660
|
#
|
1655
1661
|
# * +dst_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be written to
|
1656
1662
|
# * +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
1663
|
# * +options+ - a hash containing named options
|
1659
1664
|
#
|
1660
1665
|
# ==== Options
|
1661
1666
|
#
|
1667
|
+
# * +:size+ - the size of data to copy
|
1662
1668
|
# * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
|
1663
1669
|
# * +:blocking_copy+ - if provided indicates if the command blocks until the copy finishes
|
1664
1670
|
# * +:blocking+ - if provided indicates if the command blocks until the copy finishes
|
@@ -1666,8 +1672,8 @@ module OpenCL
|
|
1666
1672
|
# ==== Returns
|
1667
1673
|
#
|
1668
1674
|
# 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,
|
1675
|
+
def enqueue_svm_memcpy( dst_ptr, src_ptr, options = {})
|
1676
|
+
return OpenCL.enqueue_svm_memcpy(self, dst_ptr, src_ptr, options)
|
1671
1677
|
end
|
1672
1678
|
|
1673
1679
|
# Enqueues a command that frees SVMPointers (or Pointers using a callback) using the CommandQueue
|
@@ -1696,31 +1702,32 @@ module OpenCL
|
|
1696
1702
|
#
|
1697
1703
|
# * +svm_ptr+ - the SVMPointer to the area to fill
|
1698
1704
|
# * +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
1705
|
#
|
1701
1706
|
# ==== Options
|
1702
1707
|
#
|
1708
|
+
# * +:size+ - the size of the area to fill
|
1703
1709
|
# * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
|
1704
1710
|
# * +:pattern_size+ - if provided indicates the size of the pattern, else the maximum pattern data is used
|
1705
1711
|
#
|
1706
1712
|
# ==== Returns
|
1707
1713
|
#
|
1708
1714
|
# the Event associated with the command
|
1709
|
-
def enqueue_svm_memfill( svm_ptr, pattern,
|
1710
|
-
return OpenCL.enqueue_svm_memfill(self, svm_ptr, pattern,
|
1715
|
+
def enqueue_svm_memfill( svm_ptr, pattern, options = {})
|
1716
|
+
return OpenCL.enqueue_svm_memfill(self, svm_ptr, pattern, options)
|
1711
1717
|
end
|
1718
|
+
alias enqueue_svm_mem_fill enqueue_svm_memfill
|
1712
1719
|
|
1713
1720
|
# Enqueues a command to map an Image into host memory using the CommandQueue
|
1714
1721
|
#
|
1715
1722
|
# ==== Attributes
|
1716
1723
|
#
|
1717
1724
|
# * +svm_ptr+ - the SVMPointer to the area to map
|
1718
|
-
# * +size+ - the size of the region to map
|
1719
1725
|
# * +map_flags+ - a single or an Array of :cl_map_flags flags
|
1720
1726
|
# * +options+ - a hash containing named options
|
1721
1727
|
#
|
1722
1728
|
# ==== Options
|
1723
1729
|
#
|
1730
|
+
# * +:size+ - the size of the region to map
|
1724
1731
|
# * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
|
1725
1732
|
# * +:blocking_map+ - if provided indicates if the command blocks until the region is mapped
|
1726
1733
|
# * +:blocking+ - if provided indicates if the command blocks until the region is mapped
|
@@ -1728,8 +1735,8 @@ module OpenCL
|
|
1728
1735
|
# ==== Returns
|
1729
1736
|
#
|
1730
1737
|
# the Event associated with the command
|
1731
|
-
def enqueue_svm_map( svm_ptr,
|
1732
|
-
return OpenCL.enqueue_svm_map( self, svm_ptr,
|
1738
|
+
def enqueue_svm_map( svm_ptr, map_flags, options = {} )
|
1739
|
+
return OpenCL.enqueue_svm_map( self, svm_ptr, map_flags, options )
|
1733
1740
|
end
|
1734
1741
|
|
1735
1742
|
# Enqueues a command to unmap a previously mapped SVM memory area using the CommandQueue
|
@@ -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)
|
@@ -39,7 +41,9 @@ module OpenCL
|
|
39
41
|
# * +:properties+ - a list of :cl_context_properties
|
40
42
|
# * +:user_data+ - an Pointer or an object that can be converted into one using to_ptr. The pointer is passed to the callback.
|
41
43
|
def self.create_context_from_type(type, options = {}, &block)
|
42
|
-
|
44
|
+
if block
|
45
|
+
@@callbacks[block] = options[:user_data]
|
46
|
+
end
|
43
47
|
properties = get_context_properties( options )
|
44
48
|
user_data = options[:user_data]
|
45
49
|
error = MemoryPointer::new( :cl_int )
|
@@ -68,23 +72,26 @@ module OpenCL
|
|
68
72
|
|
69
73
|
# Returns the number of devices associated to the Context
|
70
74
|
def num_devices
|
75
|
+
return @_num_devices if @_num_devices
|
71
76
|
d_n = 0
|
72
77
|
ptr = MemoryPointer::new( :size_t )
|
73
78
|
error = OpenCL.clGetContextInfo(self, DEVICES, 0, nil, ptr)
|
74
79
|
error_check(error)
|
75
80
|
d_n = ptr.read_size_t / Platform.size
|
76
|
-
|
81
|
+
@_num_devices = d_n
|
77
82
|
end
|
78
83
|
|
79
84
|
# Returns an Array of Device associated to the Context
|
80
85
|
def devices
|
86
|
+
return @_devices if @_devices
|
81
87
|
n = self.num_devices
|
82
88
|
ptr2 = MemoryPointer::new( Device, n )
|
83
89
|
error = OpenCL.clGetContextInfo(self, DEVICES, Device.size*n, ptr2, nil)
|
84
90
|
error_check(error)
|
85
|
-
|
91
|
+
@_devices = ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
|
86
92
|
Device::new(device_ptr)
|
87
93
|
}
|
94
|
+
return @_devices
|
88
95
|
end
|
89
96
|
|
90
97
|
##
|
@@ -118,7 +125,8 @@ module OpenCL
|
|
118
125
|
|
119
126
|
# Returns the platform associated to the Context
|
120
127
|
def platform
|
121
|
-
|
128
|
+
return @_platform if @_platform
|
129
|
+
@_platform = self.devices.first.platform
|
122
130
|
end
|
123
131
|
|
124
132
|
# Returns an Array of ImageFormat that are supported for a given image type in the Context
|
@@ -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
|
-
|
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")
|
@@ -77,23 +77,31 @@ module OpenCL
|
|
77
77
|
|
78
78
|
# Returns the CommandQueue associated with the Event, if it exists
|
79
79
|
def command_queue
|
80
|
+
return @_command_queue if @_command_queue
|
80
81
|
ptr = MemoryPointer::new( CommandQueue )
|
81
82
|
error = OpenCL.clGetEventInfo(self, COMMAND_QUEUE, CommandQueue.size, ptr, nil)
|
82
83
|
error_check(error)
|
83
84
|
pt = ptr.read_pointer
|
84
85
|
if pt.null? then
|
85
|
-
|
86
|
+
@_command_queue = nil
|
86
87
|
else
|
87
|
-
|
88
|
+
@_command_queue = CommandQueue::new( pt )
|
88
89
|
end
|
90
|
+
@_command_queue
|
89
91
|
end
|
90
92
|
|
91
|
-
get_info("Event", :cl_command_type, "command_type")
|
93
|
+
get_info("Event", :cl_command_type, "command_type", true)
|
92
94
|
|
93
95
|
def context
|
94
96
|
return command_queue.context
|
95
97
|
end
|
96
98
|
|
99
|
+
# Returns the Platform associated with the Event
|
100
|
+
def platform
|
101
|
+
return @_platform if @_platform
|
102
|
+
@_platform = self.context.platform
|
103
|
+
end
|
104
|
+
|
97
105
|
# Returns a CommandExecutionStatus corresponding to the status of the command associtated with the Event
|
98
106
|
def command_execution_status
|
99
107
|
ptr = MemoryPointer::new( :cl_int )
|
@@ -140,10 +148,11 @@ module OpenCL
|
|
140
148
|
|
141
149
|
# Returns the Context associated with the Event
|
142
150
|
def context
|
151
|
+
return @_context if @_context
|
143
152
|
ptr = MemoryPointer::new( Context )
|
144
153
|
error = OpenCL.clGetEventInfo(self, CONTEXT, Context.size, ptr, nil)
|
145
154
|
error_check(error)
|
146
|
-
|
155
|
+
@_context = Context::new( ptr.read_pointer )
|
147
156
|
end
|
148
157
|
|
149
158
|
# Sets the satus of Event (a user event) to the given execution status
|
@@ -64,6 +64,11 @@ module OpenCL
|
|
64
64
|
# Returns the Kernel this Arg belongs to
|
65
65
|
attr_reader :kernel
|
66
66
|
|
67
|
+
# Returns the Platform associated with this Arg
|
68
|
+
def platform
|
69
|
+
kernel.platform
|
70
|
+
end
|
71
|
+
|
67
72
|
if ExtendedStruct::const_get(:FORCE_EXTENSIONS_LOADING) then
|
68
73
|
|
69
74
|
def self.register_extension(name, mod, cond)
|
@@ -108,24 +113,27 @@ module OpenCL
|
|
108
113
|
|
109
114
|
# Returns an AddressQualifier corresponding to the Arg
|
110
115
|
def address_qualifier
|
116
|
+
return @_address_qualifier if @_address_qualifier
|
111
117
|
error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
112
118
|
ptr = MemoryPointer::new( :cl_kernel_arg_address_qualifier )
|
113
119
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, ADDRESS_QUALIFIER, ptr.size, ptr, nil)
|
114
120
|
error_check(error)
|
115
|
-
|
121
|
+
@_address_qualifier = AddressQualifier::new( ptr.read_cl_kernel_arg_address_qualifier )
|
116
122
|
end
|
117
123
|
|
118
124
|
# Returns an AccessQualifier corresponding to the Arg
|
119
125
|
def access_qualifier
|
126
|
+
return @_access_qualifier if @_access_qualifier
|
120
127
|
error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
121
128
|
ptr = MemoryPointer::new( :cl_kernel_arg_access_qualifier )
|
122
129
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, ACCESS_QUALIFIER, ptr.size, ptr, nil)
|
123
130
|
error_check(error)
|
124
|
-
|
131
|
+
@_access_qualifier = AccessQualifier::new( ptr.read_cl_kernel_arg_access_qualifier )
|
125
132
|
end
|
126
133
|
|
127
134
|
# Returns a String corresponding to the Arg type name
|
128
135
|
def type_name
|
136
|
+
return @_type_name if @_type_name
|
129
137
|
error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
130
138
|
ptr1 = MemoryPointer::new( :size_t, 1)
|
131
139
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_NAME, 0, nil, ptr1)
|
@@ -133,20 +141,22 @@ module OpenCL
|
|
133
141
|
ptr2 = MemoryPointer::new( ptr1.read_size_t )
|
134
142
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_NAME, ptr1.read_size_t, ptr2, nil)
|
135
143
|
error_check(error)
|
136
|
-
|
144
|
+
@_type_name = ptr2.read_string
|
137
145
|
end
|
138
146
|
|
139
147
|
# Returns a TypeQualifier corresponding to the Arg
|
140
148
|
def type_qualifier
|
149
|
+
return @_type_qualifier if @_type_qualifier
|
141
150
|
error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
142
151
|
ptr = MemoryPointer::new( :cl_kernel_arg_type_qualifier )
|
143
152
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_QUALIFIER, ptr.size, ptr, nil)
|
144
153
|
error_check(error)
|
145
|
-
|
154
|
+
@_type_qualifier = TypeQualifier::new( ptr.read_cl_kernel_arg_type_qualifier )
|
146
155
|
end
|
147
156
|
|
148
157
|
# Returns a String corresponding to the Arg name
|
149
158
|
def name
|
159
|
+
return @_name if @_name
|
150
160
|
error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
151
161
|
ptr1 = MemoryPointer::new( :size_t, 1)
|
152
162
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, NAME, 0, nil, ptr1)
|
@@ -154,7 +164,7 @@ module OpenCL
|
|
154
164
|
ptr2 = MemoryPointer::new( ptr1.read_size_t )
|
155
165
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, NAME, ptr1.read_size_t, ptr2, nil)
|
156
166
|
error_check(error)
|
157
|
-
|
167
|
+
@_name = ptr2.read_string
|
158
168
|
end
|
159
169
|
|
160
170
|
alias to_s name
|
@@ -175,27 +185,35 @@ module OpenCL
|
|
175
185
|
return a
|
176
186
|
end
|
177
187
|
|
178
|
-
get_info("Kernel", :string, "function_name")
|
188
|
+
get_info("Kernel", :string, "function_name", true)
|
179
189
|
alias name function_name
|
180
190
|
alias to_s name
|
181
191
|
|
182
|
-
get_info("Kernel", :cl_uint, "num_args")
|
192
|
+
get_info("Kernel", :cl_uint, "num_args", true)
|
183
193
|
get_info("Kernel", :cl_uint, "reference_count")
|
184
194
|
|
195
|
+
# Returns the Platform associated with the Kernel
|
196
|
+
def platform
|
197
|
+
return @_platform if @_platform
|
198
|
+
@_platform = self.context.platform
|
199
|
+
end
|
200
|
+
|
185
201
|
# Returns the Context the Kernel is associated with
|
186
202
|
def context
|
203
|
+
return @_context if @_context
|
187
204
|
ptr = MemoryPointer::new( Context )
|
188
205
|
error = OpenCL.clGetKernelInfo(self, CONTEXT, Context.size, ptr, nil)
|
189
206
|
error_check(error)
|
190
|
-
|
207
|
+
@_context = Context::new( ptr.read_pointer )
|
191
208
|
end
|
192
209
|
|
193
210
|
# Returns the Program the Kernel was created from
|
194
211
|
def program
|
212
|
+
return @_program if @_program
|
195
213
|
ptr = MemoryPointer::new( Program )
|
196
214
|
error = OpenCL.clGetKernelInfo(self, PROGRAM, Program.size, ptr, nil)
|
197
215
|
error_check(error)
|
198
|
-
|
216
|
+
@_program = Program::new(ptr.read_pointer)
|
199
217
|
end
|
200
218
|
|
201
219
|
def work_group_size(device = program.devices.first)
|
@@ -268,6 +286,7 @@ module OpenCL
|
|
268
286
|
##
|
269
287
|
# returns a String containing the attributes qualifier used at kernel definition
|
270
288
|
def attributes
|
289
|
+
return @_attributes if @_attributes
|
271
290
|
attributes_size = MemoryPointer::new( :size_t )
|
272
291
|
error = OpenCL.clGetKernelInfo( self, ATTRIBUTES, 0, nil, attributes_size)
|
273
292
|
error_check(error)
|
@@ -275,7 +294,7 @@ module OpenCL
|
|
275
294
|
error = OpenCL.clGetKernelInfo( self, ATTRIBUTES, attributes_size.read_size_t, attr, nil)
|
276
295
|
error_check(error)
|
277
296
|
attr_string = attr.read_string
|
278
|
-
|
297
|
+
@_attributes = attr_string.split(" ")
|
279
298
|
end
|
280
299
|
|
281
300
|
def global_work_size(device = program.devices.first)
|
data/lib/opencl_ruby_ffi/Mem.rb
CHANGED
@@ -13,8 +13,16 @@ module OpenCL
|
|
13
13
|
#
|
14
14
|
# * +:user_data+ - a Pointer (or convertible to Pointer using to_ptr) to the memory area to pass to the callback
|
15
15
|
def self.set_mem_object_destructor_callback( memobj, options = {}, &block )
|
16
|
-
|
17
|
-
|
16
|
+
if block
|
17
|
+
wrapper_block = lambda { |p, u|
|
18
|
+
block.call(p, u)
|
19
|
+
@@callbacks.delete(wrapper_block)
|
20
|
+
}
|
21
|
+
@@callbacks[wrapper_block] = options[:user_data]
|
22
|
+
else
|
23
|
+
wrapper_block = nil
|
24
|
+
end
|
25
|
+
error = clSetMemObjectDestructorCallback( memobj, wrapper_block, options[:user_data] )
|
18
26
|
error_check(error)
|
19
27
|
return memobj
|
20
28
|
end
|
@@ -29,24 +37,26 @@ module OpenCL
|
|
29
37
|
return "#<#{self.class.name}: #{size}#{ 0 != f.to_i ? " (#{f})" : ""}>"
|
30
38
|
end
|
31
39
|
|
32
|
-
get_info("Mem", :cl_mem_object_type, "type")
|
33
|
-
get_info("Mem", :cl_mem_flags, "flags")
|
34
|
-
get_info("Mem", :size_t, "size")
|
40
|
+
get_info("Mem", :cl_mem_object_type, "type", true)
|
41
|
+
get_info("Mem", :cl_mem_flags, "flags", true)
|
42
|
+
get_info("Mem", :size_t, "size", true)
|
35
43
|
get_info("Mem", :pointer, "host_ptr")
|
36
44
|
get_info("Mem", :cl_uint, "map_count")
|
37
45
|
get_info("Mem", :cl_uint, "reference_count")
|
38
46
|
|
39
47
|
# Returns the Context associated to the Mem
|
40
48
|
def context
|
49
|
+
return @_context if @_context
|
41
50
|
ptr = MemoryPointer::new( Context )
|
42
51
|
error = OpenCL.clGetMemObjectInfo(self, CONTEXT, Context.size, ptr, nil)
|
43
52
|
error_check(error)
|
44
|
-
|
53
|
+
@_context = Context::new( ptr.read_pointer )
|
45
54
|
end
|
46
55
|
|
47
56
|
# Returns the Platform associated to the Mem
|
48
57
|
def platform
|
49
|
-
return
|
58
|
+
return @_platform if @_platform
|
59
|
+
@_platform = self.context.platform
|
50
60
|
end
|
51
61
|
|
52
62
|
# Returns the texture_target argument specified in create_from_GL_texture for Mem
|
@@ -88,7 +98,7 @@ module OpenCL
|
|
88
98
|
module OpenCL11
|
89
99
|
extend InnerGenerator
|
90
100
|
|
91
|
-
get_info("Mem", :size_t, "offset")
|
101
|
+
get_info("Mem", :size_t, "offset", true)
|
92
102
|
|
93
103
|
# Returns the Buffer this Buffer was created from using create_sub_buffer
|
94
104
|
def associated_memobject
|
@@ -119,7 +129,7 @@ module OpenCL
|
|
119
129
|
module OpenCL20
|
120
130
|
extend InnerGenerator
|
121
131
|
|
122
|
-
get_info("Mem", :cl_bool, "uses_svm_pointer")
|
132
|
+
get_info("Mem", :cl_bool, "uses_svm_pointer", true)
|
123
133
|
|
124
134
|
end
|
125
135
|
|