opencl_ruby_ffi 1.3.9 → 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/CommandQueue.rb +1 -2
- data/lib/opencl_ruby_ffi/Context.rb +16 -18
- data/lib/opencl_ruby_ffi/Device.rb +6 -7
- data/lib/opencl_ruby_ffi/Event.rb +17 -17
- data/lib/opencl_ruby_ffi/Kernel.rb +64 -57
- data/lib/opencl_ruby_ffi/Mem.rb +7 -7
- data/lib/opencl_ruby_ffi/Platform.rb +11 -11
- data/lib/opencl_ruby_ffi/Program.rb +21 -17
- data/lib/opencl_ruby_ffi/Sampler.rb +6 -5
- data/lib/opencl_ruby_ffi/intel/unified_shared_memory_preview.rb +67 -40
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb +56 -56
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_library.rb +10 -10
- data/opencl_ruby_ffi.gemspec +1 -1
- metadata +3 -3
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
|
@@ -1072,8 +1072,7 @@ module OpenCL
|
|
1072
1072
|
|
1073
1073
|
# Returns the Platform associated with the CommandQueue
|
1074
1074
|
def platform
|
1075
|
-
|
1076
|
-
@_platform = self.context.platform
|
1075
|
+
@_platform ||= self.context.platform
|
1077
1076
|
end
|
1078
1077
|
|
1079
1078
|
# Returns the Context associated to the CommandQueue
|
@@ -116,26 +116,25 @@ module OpenCL
|
|
116
116
|
|
117
117
|
# Returns the number of devices associated to the Context
|
118
118
|
def num_devices
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
@_num_devices = d_n
|
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
|
126
125
|
end
|
127
126
|
|
128
127
|
# Returns an Array of Device associated to the Context
|
129
128
|
def devices
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
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
|
139
138
|
end
|
140
139
|
|
141
140
|
##
|
@@ -169,8 +168,7 @@ module OpenCL
|
|
169
168
|
|
170
169
|
# Returns the platform associated to the Context
|
171
170
|
def platform
|
172
|
-
|
173
|
-
@_platform = self.devices.first.platform
|
171
|
+
@_platform ||= self.devices.first.platform
|
174
172
|
end
|
175
173
|
|
176
174
|
# Returns an Array of ImageFormat that are supported for a given image type in the Context
|
@@ -107,11 +107,12 @@ module OpenCL
|
|
107
107
|
|
108
108
|
# Returns the Platform the Device belongs to
|
109
109
|
def platform
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
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
|
115
116
|
end
|
116
117
|
|
117
118
|
get_info("Device", :cl_uint, "preferred_vector_width_char")
|
@@ -158,8 +159,6 @@ module OpenCL
|
|
158
159
|
n = ver.scan(/OpenCL C (\d+\.\d+)/)
|
159
160
|
return n.first.first.to_f
|
160
161
|
end
|
161
|
-
|
162
|
-
get_info("Device", :cl_uint, "preferred_vector_width_half")
|
163
162
|
|
164
163
|
end
|
165
164
|
|
@@ -77,17 +77,17 @@ module OpenCL
|
|
77
77
|
|
78
78
|
# Returns the CommandQueue associated with the Event, if it exists
|
79
79
|
def command_queue
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
80
|
+
@_command_queue ||= begin
|
81
|
+
ptr = MemoryPointer::new( CommandQueue )
|
82
|
+
error = OpenCL.clGetEventInfo(self, COMMAND_QUEUE, CommandQueue.size, ptr, nil)
|
83
|
+
error_check(error)
|
84
|
+
pt = ptr.read_pointer
|
85
|
+
if pt.null? then
|
86
|
+
nil
|
87
|
+
else
|
88
|
+
CommandQueue::new( pt )
|
89
|
+
end
|
89
90
|
end
|
90
|
-
@_command_queue
|
91
91
|
end
|
92
92
|
|
93
93
|
get_info("Event", :cl_command_type, "command_type", true)
|
@@ -98,8 +98,7 @@ module OpenCL
|
|
98
98
|
|
99
99
|
# Returns the Platform associated with the Event
|
100
100
|
def platform
|
101
|
-
|
102
|
-
@_platform = self.context.platform
|
101
|
+
@_platform ||= self.context.platform
|
103
102
|
end
|
104
103
|
|
105
104
|
# Returns a CommandExecutionStatus corresponding to the status of the command associtated with the Event
|
@@ -148,11 +147,12 @@ module OpenCL
|
|
148
147
|
|
149
148
|
# Returns the Context associated with the Event
|
150
149
|
def context
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
150
|
+
@_context ||= begin
|
151
|
+
ptr = MemoryPointer::new( Context )
|
152
|
+
error = OpenCL.clGetEventInfo(self, CONTEXT, Context.size, ptr, nil)
|
153
|
+
error_check(error)
|
154
|
+
Context::new( ptr.read_pointer )
|
155
|
+
end
|
156
156
|
end
|
157
157
|
|
158
158
|
# Sets the satus of Event (a user event) to the given execution status
|
@@ -113,58 +113,63 @@ module OpenCL
|
|
113
113
|
|
114
114
|
# Returns an AddressQualifier corresponding to the Arg
|
115
115
|
def address_qualifier
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
116
|
+
@_address_qualifier ||= begin
|
117
|
+
error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
118
|
+
ptr = MemoryPointer::new( :cl_kernel_arg_address_qualifier )
|
119
|
+
error = OpenCL.clGetKernelArgInfo(@kernel, @index, ADDRESS_QUALIFIER, ptr.size, ptr, nil)
|
120
|
+
error_check(error)
|
121
|
+
AddressQualifier::new( ptr.read_cl_kernel_arg_address_qualifier )
|
122
|
+
end
|
122
123
|
end
|
123
124
|
|
124
125
|
# Returns an AccessQualifier corresponding to the Arg
|
125
126
|
def access_qualifier
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
127
|
+
@_access_qualifier ||= begin
|
128
|
+
error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
129
|
+
ptr = MemoryPointer::new( :cl_kernel_arg_access_qualifier )
|
130
|
+
error = OpenCL.clGetKernelArgInfo(@kernel, @index, ACCESS_QUALIFIER, ptr.size, ptr, nil)
|
131
|
+
error_check(error)
|
132
|
+
AccessQualifier::new( ptr.read_cl_kernel_arg_access_qualifier )
|
133
|
+
end
|
132
134
|
end
|
133
135
|
|
134
136
|
# Returns a String corresponding to the Arg type name
|
135
137
|
def type_name
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
138
|
+
@_type_name ||= begin
|
139
|
+
error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
140
|
+
ptr1 = MemoryPointer::new( :size_t, 1)
|
141
|
+
error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_NAME, 0, nil, ptr1)
|
142
|
+
error_check(error)
|
143
|
+
ptr2 = MemoryPointer::new( ptr1.read_size_t )
|
144
|
+
error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_NAME, ptr1.read_size_t, ptr2, nil)
|
145
|
+
error_check(error)
|
146
|
+
ptr2.read_string
|
147
|
+
end
|
145
148
|
end
|
146
149
|
|
147
150
|
# Returns a TypeQualifier corresponding to the Arg
|
148
151
|
def type_qualifier
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
152
|
+
@_type_qualifier ||= begin
|
153
|
+
error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
154
|
+
ptr = MemoryPointer::new( :cl_kernel_arg_type_qualifier )
|
155
|
+
error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_QUALIFIER, ptr.size, ptr, nil)
|
156
|
+
error_check(error)
|
157
|
+
TypeQualifier::new( ptr.read_cl_kernel_arg_type_qualifier )
|
158
|
+
end
|
155
159
|
end
|
156
160
|
|
157
161
|
# Returns a String corresponding to the Arg name
|
158
162
|
def name
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
163
|
+
@_name ||= begin
|
164
|
+
error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
165
|
+
ptr1 = MemoryPointer::new( :size_t, 1)
|
166
|
+
error = OpenCL.clGetKernelArgInfo(@kernel, @index, NAME, 0, nil, ptr1)
|
167
|
+
error_check(error)
|
168
|
+
ptr2 = MemoryPointer::new( ptr1.read_size_t )
|
169
|
+
error = OpenCL.clGetKernelArgInfo(@kernel, @index, NAME, ptr1.read_size_t, ptr2, nil)
|
170
|
+
error_check(error)
|
171
|
+
ptr2.read_string
|
172
|
+
end
|
168
173
|
end
|
169
174
|
|
170
175
|
alias to_s name
|
@@ -194,26 +199,27 @@ module OpenCL
|
|
194
199
|
|
195
200
|
# Returns the Platform associated with the Kernel
|
196
201
|
def platform
|
197
|
-
|
198
|
-
@_platform = self.context.platform
|
202
|
+
@_platform ||= self.context.platform
|
199
203
|
end
|
200
204
|
|
201
205
|
# Returns the Context the Kernel is associated with
|
202
206
|
def context
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
207
|
+
@_context ||= begin
|
208
|
+
ptr = MemoryPointer::new( Context )
|
209
|
+
error = OpenCL.clGetKernelInfo(self, CONTEXT, Context.size, ptr, nil)
|
210
|
+
error_check(error)
|
211
|
+
Context::new( ptr.read_pointer )
|
212
|
+
end
|
208
213
|
end
|
209
214
|
|
210
215
|
# Returns the Program the Kernel was created from
|
211
216
|
def program
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
+
@_program ||= begin
|
218
|
+
ptr = MemoryPointer::new( Program )
|
219
|
+
error = OpenCL.clGetKernelInfo(self, PROGRAM, Program.size, ptr, nil)
|
220
|
+
error_check(error)
|
221
|
+
Program::new(ptr.read_pointer)
|
222
|
+
end
|
217
223
|
end
|
218
224
|
|
219
225
|
def work_group_size(device = program.devices.first)
|
@@ -286,15 +292,16 @@ module OpenCL
|
|
286
292
|
##
|
287
293
|
# returns a String containing the attributes qualifier used at kernel definition
|
288
294
|
def attributes
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
295
|
+
@_attributes ||= begin
|
296
|
+
attributes_size = MemoryPointer::new( :size_t )
|
297
|
+
error = OpenCL.clGetKernelInfo( self, ATTRIBUTES, 0, nil, attributes_size)
|
298
|
+
error_check(error)
|
299
|
+
attr = MemoryPointer::new( attributes_size.read_size_t )
|
300
|
+
error = OpenCL.clGetKernelInfo( self, ATTRIBUTES, attributes_size.read_size_t, attr, nil)
|
301
|
+
error_check(error)
|
302
|
+
attr_string = attr.read_string
|
303
|
+
attr_string.split(" ")
|
304
|
+
end
|
298
305
|
end
|
299
306
|
|
300
307
|
def global_work_size(device = program.devices.first)
|
data/lib/opencl_ruby_ffi/Mem.rb
CHANGED
@@ -46,17 +46,17 @@ module OpenCL
|
|
46
46
|
|
47
47
|
# Returns the Context associated to the Mem
|
48
48
|
def context
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
@_context ||= begin
|
50
|
+
ptr = MemoryPointer::new( Context )
|
51
|
+
error = OpenCL.clGetMemObjectInfo(self, CONTEXT, Context.size, ptr, nil)
|
52
|
+
error_check(error)
|
53
|
+
Context::new( ptr.read_pointer )
|
54
|
+
end
|
54
55
|
end
|
55
56
|
|
56
57
|
# Returns the Platform associated to the Mem
|
57
58
|
def platform
|
58
|
-
|
59
|
-
@_platform = self.context.platform
|
59
|
+
@_platform ||= self.context.platform
|
60
60
|
end
|
61
61
|
|
62
62
|
# Returns the texture_target argument specified in create_from_GL_texture for Mem
|
@@ -63,18 +63,18 @@ module OpenCL
|
|
63
63
|
|
64
64
|
# Returns an Array of Platform containing the available OpenCL platforms
|
65
65
|
def self.get_platforms
|
66
|
-
|
67
|
-
|
66
|
+
@_platforms ||= begin
|
67
|
+
ptr1 = MemoryPointer::new(:cl_uint , 1)
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
69
|
+
error = clGetPlatformIDs(0, nil, ptr1)
|
70
|
+
error_check(error)
|
71
|
+
ptr2 = MemoryPointer::new(:pointer, ptr1.read_uint)
|
72
|
+
error = clGetPlatformIDs(ptr1.read_uint(), ptr2, nil)
|
73
|
+
error_check(error)
|
74
|
+
ptr2.get_array_of_pointer(0,ptr1.read_uint()).collect { |platform_ptr|
|
75
|
+
Platform::new(platform_ptr, false)
|
76
|
+
}
|
77
|
+
end
|
78
78
|
end
|
79
79
|
|
80
80
|
class << self
|
@@ -280,7 +280,11 @@ module OpenCL
|
|
280
280
|
build_status.each { |d,s|
|
281
281
|
success |= true if s.to_i == BuildStatus::SUCCESS
|
282
282
|
}
|
283
|
-
|
283
|
+
begin
|
284
|
+
return "#<#{self.class.name}: #{success ? kernel_names : ""}>"
|
285
|
+
rescue
|
286
|
+
return "#<#{self.class.name}: >"
|
287
|
+
end
|
284
288
|
end
|
285
289
|
|
286
290
|
alias_method :orig_method_missing, :method_missing
|
@@ -304,17 +308,17 @@ module OpenCL
|
|
304
308
|
|
305
309
|
# Returns the Platform associated with the Program
|
306
310
|
def platform
|
307
|
-
|
308
|
-
@_platform = self.context.platform
|
311
|
+
@_platform ||= self.context.platform
|
309
312
|
end
|
310
313
|
|
311
314
|
# Returns the Context the Program is associated to
|
312
315
|
def context
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
316
|
+
@_context ||= begin
|
317
|
+
ptr = MemoryPointer::new( Context )
|
318
|
+
error = OpenCL.clGetProgramInfo(self, CONTEXT, Context.size, ptr, nil)
|
319
|
+
error_check(error)
|
320
|
+
Context::new( ptr.read_pointer )
|
321
|
+
end
|
318
322
|
end
|
319
323
|
|
320
324
|
get_info("Program", :cl_uint, "num_devices", true)
|
@@ -322,15 +326,15 @@ module OpenCL
|
|
322
326
|
|
323
327
|
# Returns the Array of Device the Program is associated with
|
324
328
|
def devices
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
329
|
+
@_devices ||= begin
|
330
|
+
n = self.num_devices
|
331
|
+
ptr2 = MemoryPointer::new( Device, n )
|
332
|
+
error = OpenCL.clGetProgramInfo(self, DEVICES, Device.size*n, ptr2, nil)
|
333
|
+
error_check(error)
|
334
|
+
ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
|
335
|
+
Device::new(device_ptr)
|
336
|
+
}
|
337
|
+
end
|
334
338
|
end
|
335
339
|
|
336
340
|
get_info("Program", :string, "source")
|
@@ -71,11 +71,12 @@ module OpenCL
|
|
71
71
|
|
72
72
|
# Returns the context associated with the Sampler
|
73
73
|
def context
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
@_context ||= begin
|
75
|
+
ptr = MemoryPointer::new( Context )
|
76
|
+
error = OpenCL.clGetSamplerInfo(self, CONTEXT, Context.size, ptr, nil)
|
77
|
+
error_check(error)
|
78
|
+
Context::new( ptr.read_pointer )
|
79
|
+
end
|
79
80
|
end
|
80
81
|
|
81
82
|
get_info("Sampler", :cl_uint, "reference_count")
|
@@ -228,6 +228,23 @@ module OpenCL
|
|
228
228
|
get_info("Device", :cl_unified_shared_memory_capabilities_intel, "device_shared_mem_capabilities_intel")
|
229
229
|
get_info("Device", :cl_unified_shared_memory_capabilities_intel, "cross_device_mem_capabilities_intel")
|
230
230
|
get_info("Device", :cl_unified_shared_memory_capabilities_intel, "shared_system_mem_capabilities_intel")
|
231
|
+
|
232
|
+
def clGetDeviceGlobalVariablePointerINTEL
|
233
|
+
@_clGetDeviceGlobalVariablePointerINTEL ||= begin
|
234
|
+
p = platform.get_extension_function("clGetDeviceGlobalVariablePointerINTEL", :cl_int, [Device, Program, :string, :pointer, :pointer])
|
235
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
236
|
+
p
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
def get_global_variable_pointer_intel(program, name)
|
241
|
+
pSize = MemoryPointer::new(:size_t)
|
242
|
+
pAddr = MemoryPointer::new(:pointer)
|
243
|
+
error = clGetDeviceGlobalVariablePointerINTEL.call(self, program, name, pAddr, pSize)
|
244
|
+
error_check(error)
|
245
|
+
return USMPointer::new(pAddr.read_pointer.slice(0, pSize.read_size_t), self)
|
246
|
+
end
|
247
|
+
|
231
248
|
end
|
232
249
|
register_extension( :cl_intel_unified_shared_memory_preview, UnifiedSharedMemoryPreviewINTEL, "extensions.include?(\"cl_intel_unified_shared_memory_preview\")" )
|
233
250
|
end
|
@@ -282,38 +299,43 @@ module OpenCL
|
|
282
299
|
extend InnerGenerator
|
283
300
|
|
284
301
|
def clGetMemAllocInfoINTEL
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
302
|
+
@_clGetMemAllocInfoINTEL ||= begin
|
303
|
+
p = platform.get_extension_function("clGetMemAllocInfoINTEL", :cl_int, [Context, :pointer, :cl_mem_info_intel, :size_t, :pointer, :pointer])
|
304
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
305
|
+
p
|
306
|
+
end
|
289
307
|
end
|
290
308
|
|
291
309
|
def clHostMemAllocINTEL
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
310
|
+
@_clHostMemAllocINTEL ||= begin
|
311
|
+
p = platform.get_extension_function("clHostMemAllocINTEL", :pointer, [Context, :pointer, :size_t, :cl_uint, :pointer])
|
312
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
313
|
+
p
|
314
|
+
end
|
296
315
|
end
|
297
316
|
|
298
317
|
def clDeviceMemAllocINTEL
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
318
|
+
@_clDeviceMemAllocINTEL ||= begin
|
319
|
+
p = platform.get_extension_function("clDeviceMemAllocINTEL", :pointer, [Context, Device, :pointer, :size_t, :cl_uint, :pointer])
|
320
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
321
|
+
p
|
322
|
+
end
|
303
323
|
end
|
304
324
|
|
305
325
|
def clSharedMemAllocINTEL
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
326
|
+
@_clSharedMemAllocINTEL ||= begin
|
327
|
+
p = platform.get_extension_function("clSharedMemAllocINTEL", :pointer, [Context, Device, :pointer, :size_t, :cl_uint, :pointer])
|
328
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
329
|
+
p
|
330
|
+
end
|
310
331
|
end
|
311
332
|
|
312
333
|
def clMemFreeINTEL
|
313
|
-
return @_clMemFreeINTEL
|
314
|
-
|
315
|
-
|
316
|
-
|
334
|
+
return @_clMemFreeINTEL ||= begin
|
335
|
+
p = platform.get_extension_function("clMemFreeINTEL", :cl_int, [Context, :pointer])
|
336
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
337
|
+
p
|
338
|
+
end
|
317
339
|
end
|
318
340
|
|
319
341
|
def get_mem_properties_intel(properties)
|
@@ -414,10 +436,11 @@ module OpenCL
|
|
414
436
|
extend InnerGenerator
|
415
437
|
|
416
438
|
def clSetKernelArgMemPointerINTEL
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
439
|
+
@_clSetKernelArgMemPointerINTEL ||= begin
|
440
|
+
p = context.platform.get_extension_function("clSetKernelArgMemPointerINTEL", :cl_int, Kernel, :cl_uint, :pointer)
|
441
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
442
|
+
p
|
443
|
+
end
|
421
444
|
end
|
422
445
|
|
423
446
|
def set_arg_mem_pointer_intel(index, usm_pointer)
|
@@ -508,31 +531,35 @@ module OpenCL
|
|
508
531
|
extend InnerGenerator
|
509
532
|
|
510
533
|
def clEnqueueMemFillINTEL
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
534
|
+
@_clEnqueueMemFillINTEL ||= begin
|
535
|
+
p = platform.get_extension_function("clEnqueueMemFillINTEL", :cl_int, [CommandQueue, :pointer, :pointer, :size_t, :size_t, :cl_uint, :pointer, :pointer])
|
536
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
537
|
+
p
|
538
|
+
end
|
515
539
|
end
|
516
540
|
|
517
541
|
def clEnqueueMemcpyINTEL
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
542
|
+
@_clEnqueueMemcpyINTEL ||= begin
|
543
|
+
p = platform.get_extension_function("clEnqueueMemcpyINTEL", :cl_int, [CommandQueue, :cl_bool, :pointer, :pointer, :size_t, :cl_uint, :pointer, :pointer])
|
544
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
545
|
+
p
|
546
|
+
end
|
522
547
|
end
|
523
548
|
|
524
549
|
def clEnqueueMigrateMemINTEL
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
550
|
+
@_clEnqueueMigrateMemINTEL ||= begin
|
551
|
+
p = platform.get_extension_function("clEnqueueMigrateMemINTEL", :cl_int, [CommandQueue, :pointer, :size_t, :cl_mem_migration_flags_intel, :cl_uint, :pointer, :pointer])
|
552
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
553
|
+
p
|
554
|
+
end
|
529
555
|
end
|
530
556
|
|
531
557
|
def clEnqueueMemAdviseINTEL
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
558
|
+
@_clEnqueueMemAdviseINTEL ||= begin
|
559
|
+
p = platform.get_extension_function("clEnqueueMemAdviseINTEL", :cl_int, [CommandQueue, :pointer, :size_t, :cl_mem_advice_intel, :cl_uint, :pointer, :pointer])
|
560
|
+
error_check(OpenCL::INVALID_OPERATION) unless p
|
561
|
+
p
|
562
|
+
end
|
536
563
|
end
|
537
564
|
|
538
565
|
def enqueue_mem_fill_intel(usm_ptr, pattern, options = {})
|
@@ -388,22 +388,22 @@ module OpenCL
|
|
388
388
|
if memoizable
|
389
389
|
s = <<EOF
|
390
390
|
def #{name.downcase}
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
391
|
+
@_#{name.downcase} ||= begin
|
392
|
+
f = platform.get_extension_function("#{function}", :cl_int, [#{klass}, :cl_uint, :size_t, :pointer, :pointer])
|
393
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
394
|
+
|
395
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
396
|
+
error = f.call(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
397
|
+
error_check(error)
|
398
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
399
|
+
error = f.call(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
400
|
+
error_check(error)
|
401
|
+
if(convert_type(:#{type})) then
|
402
|
+
convert_type(:#{type})::new(ptr2.read_#{type})
|
403
|
+
else
|
404
|
+
ptr2.read_#{type}
|
405
|
+
end
|
405
406
|
end
|
406
|
-
return @_#{name.downcase}
|
407
407
|
end
|
408
408
|
EOF
|
409
409
|
else
|
@@ -444,23 +444,23 @@ EOF
|
|
444
444
|
if memoizable
|
445
445
|
s = <<EOF
|
446
446
|
def #{name.downcase}
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
447
|
+
@_#{name.downcase} ||= begin
|
448
|
+
f = platform.get_extension_function("#{function}", :cl_int, [#{klass}, :cl_uint, :size_t, :pointer, :pointer])
|
449
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
450
|
+
|
451
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
452
|
+
error = f.call(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
453
|
+
error_check(error)
|
454
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
455
|
+
error = f.call(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
456
|
+
error_check(error)
|
457
|
+
arr = ptr2.get_array_of_#{type}(0, ptr1.read_size_t / OpenCL.find_type(:#{type}).size)
|
458
|
+
if(convert_type(:#{type})) then
|
459
|
+
arr.collect { |e| convert_type(:#{type})::new(e) }
|
460
|
+
else
|
461
|
+
arr
|
462
|
+
end
|
462
463
|
end
|
463
|
-
return @_#{name.downcase}
|
464
464
|
end
|
465
465
|
EOF
|
466
466
|
else
|
@@ -504,19 +504,19 @@ EOF
|
|
504
504
|
if memoizable
|
505
505
|
s = <<EOF
|
506
506
|
def #{name.downcase}
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
507
|
+
@_#{name.downcase} ||= begin
|
508
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
509
|
+
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
510
|
+
error_check(error)
|
511
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
512
|
+
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
513
|
+
error_check(error)
|
514
|
+
if(convert_type(:#{type})) then
|
515
|
+
convert_type(:#{type})::new(ptr2.read_#{type})
|
516
|
+
else
|
517
|
+
ptr2.read_#{type}
|
518
|
+
end
|
518
519
|
end
|
519
|
-
return @_#{name.downcase}
|
520
520
|
end
|
521
521
|
EOF
|
522
522
|
else
|
@@ -556,20 +556,20 @@ EOF
|
|
556
556
|
if memoizable
|
557
557
|
s = <<EOF
|
558
558
|
def #{name.downcase}
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
559
|
+
@_#{name.downcase} ||= begin
|
560
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
561
|
+
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
562
|
+
error_check(error)
|
563
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
564
|
+
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
565
|
+
error_check(error)
|
566
|
+
arr = ptr2.get_array_of_#{type}(0, ptr1.read_size_t / OpenCL.find_type(:#{type}).size)
|
567
|
+
if(convert_type(:#{type})) then
|
568
|
+
arr.collect { |e| convert_type(:#{type})::new(e) }
|
569
|
+
else
|
570
|
+
arr
|
571
|
+
end
|
571
572
|
end
|
572
|
-
return @_#{name.downcase}
|
573
573
|
end
|
574
574
|
EOF
|
575
575
|
else
|
@@ -6,16 +6,16 @@ module OpenCL
|
|
6
6
|
else
|
7
7
|
raise LoadError
|
8
8
|
end
|
9
|
-
rescue LoadError
|
9
|
+
rescue LoadError
|
10
10
|
begin
|
11
11
|
ffi_lib "OpenCL"
|
12
|
-
rescue LoadError
|
12
|
+
rescue LoadError
|
13
13
|
begin
|
14
14
|
ffi_lib "libOpenCL.so.1"
|
15
|
-
rescue LoadError
|
15
|
+
rescue LoadError
|
16
16
|
begin
|
17
17
|
ffi_lib '/System/Library/Frameworks/OpenCL.framework/OpenCL'
|
18
|
-
rescue LoadError
|
18
|
+
rescue LoadError
|
19
19
|
raise "OpenCL implementation not found!"
|
20
20
|
end
|
21
21
|
end
|
@@ -160,22 +160,22 @@ module OpenCL
|
|
160
160
|
attach_function :clCreateImageWithProperties, [Context,:pointer,:cl_mem_flags,:pointer,:pointer,:pointer,:pointer], Mem
|
161
161
|
callback :clSetContextDestructorCallback_notify, [Context.by_ref,:pointer], :void
|
162
162
|
attach_function :clSetContextDestructorCallback, [Context,:clSetContextDestructorCallback_notify,:pointer], :cl_int
|
163
|
-
rescue NotFoundError
|
163
|
+
rescue NotFoundError
|
164
164
|
warn "Warning OpenCL 2.2 loader detected!"
|
165
165
|
end
|
166
|
-
rescue NotFoundError
|
166
|
+
rescue NotFoundError
|
167
167
|
warn "Warning OpenCL 2.1 loader detected!"
|
168
168
|
end
|
169
|
-
rescue NotFoundError
|
169
|
+
rescue NotFoundError
|
170
170
|
warn "Warning OpenCL 2.0 loader detected!"
|
171
171
|
end
|
172
|
-
rescue NotFoundError
|
172
|
+
rescue NotFoundError
|
173
173
|
warn "Warning OpenCL 1.2 loader detected!"
|
174
174
|
end
|
175
|
-
rescue NotFoundError
|
175
|
+
rescue NotFoundError
|
176
176
|
warn "Warning OpenCL 1.1 loader detected!"
|
177
177
|
end
|
178
|
-
rescue NotFoundError
|
178
|
+
rescue NotFoundError
|
179
179
|
warn "Warning OpenCL 1.0 loader detected!"
|
180
180
|
end
|
181
181
|
end
|
data/opencl_ruby_ffi.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opencl_ruby_ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice Videau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: narray
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
- !ruby/object:Gem::Version
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
151
|
+
rubygems_version: 3.2.5
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: Ruby OpenCL FFI bindings
|