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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b82499588d782647276b70a17225849c4468bb0c3619191fcba4bb15729318a
4
- data.tar.gz: 3b015990606ee221a9e7288b2f1b99bfdae814ae3016f8142fb1044df3b3ec3b
3
+ metadata.gz: ed02c06ec493e3a80c58182e631294ddeaa05d2f5a2236607a8431dc2684d4ab
4
+ data.tar.gz: 6f0404c434de4e4d392b1f3e641acc2e08010aa06c5f3d9cc035c52dead6070f
5
5
  SHA512:
6
- metadata.gz: 28148b57ac0b7cf8e8b619ed50e94c0bf5af77cfebad6fdae788efc23e90850bfe439a64f50270573367729a7fd47751a1fe3d75e8dd5b0405c9ffeb2b4012f6
7
- data.tar.gz: 6b11039332b1c93141c350ab5b0a642521d0019e5bc1670af22daad333d85a4f32db8fa18d7bba5d2032944300ecdba6167903f623661f448b74fe45bd4a6948
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
- return @_platform if @_platform
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
- return @_num_devices if @_num_devices
120
- d_n = 0
121
- ptr = MemoryPointer::new( :size_t )
122
- error = OpenCL.clGetContextInfo(self, DEVICES, 0, nil, ptr)
123
- error_check(error)
124
- d_n = ptr.read_size_t / Platform.size
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
- return @_devices if @_devices
131
- n = self.num_devices
132
- ptr2 = MemoryPointer::new( Device, n )
133
- error = OpenCL.clGetContextInfo(self, DEVICES, Device.size*n, ptr2, nil)
134
- error_check(error)
135
- @_devices = ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
136
- Device::new(device_ptr)
137
- }
138
- return @_devices
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
- return @_platform if @_platform
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
- return @_platform if @_platform
111
- ptr = MemoryPointer::new( OpenCL::Platform )
112
- error = OpenCL.clGetDeviceInfo(self, PLATFORM, OpenCL::Platform.size, ptr, nil)
113
- error_check(error)
114
- @_platform = OpenCL::Platform::new(ptr.read_pointer)
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
- return @_command_queue if @_command_queue
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
- @_command_queue = nil
87
- else
88
- @_command_queue = CommandQueue::new( pt )
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
- return @_platform if @_platform
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
- return @_context if @_context
152
- ptr = MemoryPointer::new( Context )
153
- error = OpenCL.clGetEventInfo(self, CONTEXT, Context.size, ptr, nil)
154
- error_check(error)
155
- @_context = Context::new( ptr.read_pointer )
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
- return @_address_qualifier if @_address_qualifier
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
- @_address_qualifier = AddressQualifier::new( ptr.read_cl_kernel_arg_address_qualifier )
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
- return @_access_qualifier if @_access_qualifier
127
- error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
128
- ptr = MemoryPointer::new( :cl_kernel_arg_access_qualifier )
129
- error = OpenCL.clGetKernelArgInfo(@kernel, @index, ACCESS_QUALIFIER, ptr.size, ptr, nil)
130
- error_check(error)
131
- @_access_qualifier = AccessQualifier::new( ptr.read_cl_kernel_arg_access_qualifier )
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
- return @_type_name if @_type_name
137
- error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
138
- ptr1 = MemoryPointer::new( :size_t, 1)
139
- error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_NAME, 0, nil, ptr1)
140
- error_check(error)
141
- ptr2 = MemoryPointer::new( ptr1.read_size_t )
142
- error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_NAME, ptr1.read_size_t, ptr2, nil)
143
- error_check(error)
144
- @_type_name = ptr2.read_string
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
- return @_type_qualifier if @_type_qualifier
150
- error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
151
- ptr = MemoryPointer::new( :cl_kernel_arg_type_qualifier )
152
- error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_QUALIFIER, ptr.size, ptr, nil)
153
- error_check(error)
154
- @_type_qualifier = TypeQualifier::new( ptr.read_cl_kernel_arg_type_qualifier )
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
- return @_name if @_name
160
- error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
161
- ptr1 = MemoryPointer::new( :size_t, 1)
162
- error = OpenCL.clGetKernelArgInfo(@kernel, @index, NAME, 0, nil, ptr1)
163
- error_check(error)
164
- ptr2 = MemoryPointer::new( ptr1.read_size_t )
165
- error = OpenCL.clGetKernelArgInfo(@kernel, @index, NAME, ptr1.read_size_t, ptr2, nil)
166
- error_check(error)
167
- @_name = ptr2.read_string
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
- return @_platform if @_platform
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
- return @_context if @_context
204
- ptr = MemoryPointer::new( Context )
205
- error = OpenCL.clGetKernelInfo(self, CONTEXT, Context.size, ptr, nil)
206
- error_check(error)
207
- @_context = Context::new( ptr.read_pointer )
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
- return @_program if @_program
213
- ptr = MemoryPointer::new( Program )
214
- error = OpenCL.clGetKernelInfo(self, PROGRAM, Program.size, ptr, nil)
215
- error_check(error)
216
- @_program = Program::new(ptr.read_pointer)
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
- return @_attributes if @_attributes
290
- attributes_size = MemoryPointer::new( :size_t )
291
- error = OpenCL.clGetKernelInfo( self, ATTRIBUTES, 0, nil, attributes_size)
292
- error_check(error)
293
- attr = MemoryPointer::new( attributes_size.read_size_t )
294
- error = OpenCL.clGetKernelInfo( self, ATTRIBUTES, attributes_size.read_size_t, attr, nil)
295
- error_check(error)
296
- attr_string = attr.read_string
297
- @_attributes = attr_string.split(" ")
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)
@@ -46,17 +46,17 @@ module OpenCL
46
46
 
47
47
  # Returns the Context associated to the Mem
48
48
  def context
49
- return @_context if @_context
50
- ptr = MemoryPointer::new( Context )
51
- error = OpenCL.clGetMemObjectInfo(self, CONTEXT, Context.size, ptr, nil)
52
- error_check(error)
53
- @_context = Context::new( ptr.read_pointer )
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
- return @_platform if @_platform
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
- return @_platforms if @_platforms
67
- ptr1 = MemoryPointer::new(:cl_uint , 1)
66
+ @_platforms ||= begin
67
+ ptr1 = MemoryPointer::new(:cl_uint , 1)
68
68
 
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
- @_platforms = ptr2.get_array_of_pointer(0,ptr1.read_uint()).collect { |platform_ptr|
75
- Platform::new(platform_ptr, false)
76
- }
77
- return @_platforms
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
- return "#<#{self.class.name}: #{success ? kernel_names : ""}>"
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
- return @_platform if @_platform
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
- return @_context if @_context
314
- ptr = MemoryPointer::new( Context )
315
- error = OpenCL.clGetProgramInfo(self, CONTEXT, Context.size, ptr, nil)
316
- error_check(error)
317
- @_context = Context::new( ptr.read_pointer )
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
- return @_devices if @_devices
326
- n = self.num_devices
327
- ptr2 = MemoryPointer::new( Device, n )
328
- error = OpenCL.clGetProgramInfo(self, DEVICES, Device.size*n, ptr2, nil)
329
- error_check(error)
330
- @_devices = ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
331
- Device::new(device_ptr)
332
- }
333
- return @_devices
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
- return @_context if @_context
75
- ptr = MemoryPointer::new( Context )
76
- error = OpenCL.clGetSamplerInfo(self, CONTEXT, Context.size, ptr, nil)
77
- error_check(error)
78
- @_context = Context::new( ptr.read_pointer )
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
- return @_clGetMemAllocInfoINTEL if @_clGetMemAllocInfoINTEL
286
- @_clGetMemAllocInfoINTEL = platform.get_extension_function("clGetMemAllocInfoINTEL", :cl_int, [Context, :pointer, :cl_mem_info_intel, :size_t, :pointer, :pointer])
287
- error_check(OpenCL::INVALID_OPERATION) unless @_clGetMemAllocInfoINTEL
288
- return @_clGetMemAllocInfoINTEL
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
- return @_clHostMemAllocINTEL if @_clHostMemAllocINTEL
293
- @_clHostMemAllocINTEL = platform.get_extension_function("clHostMemAllocINTEL", :pointer, [Context, :pointer, :size_t, :cl_uint, :pointer])
294
- error_check(OpenCL::INVALID_OPERATION) unless @_clHostMemAllocINTEL
295
- return @_clHostMemAllocINTEL
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
- return @_clDeviceMemAllocINTEL if @_clDeviceMemAllocINTEL
300
- @_clDeviceMemAllocINTEL = platform.get_extension_function("clDeviceMemAllocINTEL", :pointer, [Context, Device, :pointer, :size_t, :cl_uint, :pointer])
301
- error_check(OpenCL::INVALID_OPERATION) unless @_clDeviceMemAllocINTEL
302
- return @_clDeviceMemAllocINTEL
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
- return @_clSharedMemAllocINTEL if @_clSharedMemAllocINTEL
307
- @_clSharedMemAllocINTEL = platform.get_extension_function("clSharedMemAllocINTEL", :pointer, [Context, Device, :pointer, :size_t, :cl_uint, :pointer])
308
- error_check(OpenCL::INVALID_OPERATION) unless @_clSharedMemAllocINTEL
309
- return @_clSharedMemAllocINTEL
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 if @_clMemFreeINTEL
314
- @_clMemFreeINTEL = platform.get_extension_function("clMemFreeINTEL", :cl_int, [Context, :pointer])
315
- error_check(OpenCL::INVALID_OPERATION) unless @_clMemFreeINTEL
316
- return @_clMemFreeINTEL
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
- return @_clSetKernelArgMemPointerINTEL if @_clSetKernelArgMemPointerINTEL
418
- @_clSetKernelArgMemPointerINTEL = context.platform.get_extension_function("clSetKernelArgMemPointerINTEL", :cl_int, Kernel, :cl_uint, :pointer)
419
- error_check(OpenCL::INVALID_OPERATION) unless @_clSetKernelArgMemPointerINTEL
420
- return @_clSetKernelArgMemPointerINTEL
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
- return @_clEnqueueMemFillINTEL if @_clEnqueueMemFillINTEL
512
- @_clEnqueueMemFillINTEL = platform.get_extension_function("clEnqueueMemFillINTEL", :cl_int, [CommandQueue, :pointer, :pointer, :size_t, :size_t, :cl_uint, :pointer, :pointer])
513
- error_check(OpenCL::INVALID_OPERATION) unless @_clEnqueueMemFillINTEL
514
- return @_clEnqueueMemFillINTEL
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
- return @_clEnqueueMemcpyINTEL if @_clEnqueueMemcpyINTEL
519
- @_clEnqueueMemcpyINTEL = platform.get_extension_function("clEnqueueMemcpyINTEL", :cl_int, [CommandQueue, :cl_bool, :pointer, :pointer, :size_t, :cl_uint, :pointer, :pointer])
520
- error_check(OpenCL::INVALID_OPERATION) unless @_clEnqueueMemcpyINTEL
521
- return @_clEnqueueMemcpyINTEL
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
- return @_clEnqueueMigrateMemINTEL if @_clEnqueueMigrateMemINTEL
526
- @_clEnqueueMigrateMemINTEL = platform.get_extension_function("clEnqueueMigrateMemINTEL", :cl_int, [CommandQueue, :pointer, :size_t, :cl_mem_migration_flags_intel, :cl_uint, :pointer, :pointer])
527
- error_check(OpenCL::INVALID_OPERATION) unless @_clEnqueueMemcpyINTEL
528
- return @_clEnqueueMemcpyINTEL
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
- return @_clEnqueueMemAdviseINTEL if @_clEnqueueMemAdviseINTEL
533
- @_clEnqueueMemAdviseINTEL = platform.get_extension_function("clEnqueueMemAdviseINTEL", :cl_int, [CommandQueue, :pointer, :size_t, :cl_mem_advice_intel, :cl_uint, :pointer, :pointer])
534
- error_check(OpenCL::INVALID_OPERATION) unless @_clEnqueueMemAdviseINTEL
535
- return @_clEnqueueMemAdviseINTEL
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
- return @_#{name.downcase} if @_#{name.downcase}
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
- @_#{name.downcase} = convert_type(:#{type})::new(ptr2.read_#{type})
403
- else
404
- @_#{name.downcase} = ptr2.read_#{type}
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
- return @_#{name.downcase} if @_#{name.downcase}
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
- @_#{name.downcase} = arr.collect { |e| convert_type(:#{type})::new(e) }
460
- else
461
- @_#{name.downcase} = arr
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
- return @_#{name.downcase} if @_#{name.downcase}
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
- @_#{name.downcase} = convert_type(:#{type})::new(ptr2.read_#{type})
516
- else
517
- @_#{name.downcase} = ptr2.read_#{type}
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
- return @_#{name.downcase} if @_#{name.downcase}
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
- @_#{name.downcase} = arr.collect { |e| convert_type(:#{type})::new(e) }
569
- else
570
- @_#{name.downcase} = arr
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 => e
9
+ rescue LoadError
10
10
  begin
11
11
  ffi_lib "OpenCL"
12
- rescue LoadError => e
12
+ rescue LoadError
13
13
  begin
14
14
  ffi_lib "libOpenCL.so.1"
15
- rescue LoadError => e
15
+ rescue LoadError
16
16
  begin
17
17
  ffi_lib '/System/Library/Frameworks/OpenCL.framework/OpenCL'
18
- rescue LoadError => e
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 => e
163
+ rescue NotFoundError
164
164
  warn "Warning OpenCL 2.2 loader detected!"
165
165
  end
166
- rescue NotFoundError => e
166
+ rescue NotFoundError
167
167
  warn "Warning OpenCL 2.1 loader detected!"
168
168
  end
169
- rescue NotFoundError => e
169
+ rescue NotFoundError
170
170
  warn "Warning OpenCL 2.0 loader detected!"
171
171
  end
172
- rescue NotFoundError => e
172
+ rescue NotFoundError
173
173
  warn "Warning OpenCL 1.2 loader detected!"
174
174
  end
175
- rescue NotFoundError => e
175
+ rescue NotFoundError
176
176
  warn "Warning OpenCL 1.1 loader detected!"
177
177
  end
178
- rescue NotFoundError => e
178
+ rescue NotFoundError
179
179
  warn "Warning OpenCL 1.0 loader detected!"
180
180
  end
181
181
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'opencl_ruby_ffi'
3
- s.version = "1.3.9"
3
+ s.version = "1.3.10"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "bvideau@anl.gov"
6
6
  s.homepage = "https://github.com/Nanosim-LIG/opencl-ruby"
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.9
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-04-08 00:00:00.000000000 Z
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.1.2
151
+ rubygems_version: 3.2.5
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Ruby OpenCL FFI bindings