opencl_ruby_ffi 1.0.4 → 1.0.5

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
  SHA1:
3
- metadata.gz: a6f786a54595a4363b22411ac225a5d44c984332
4
- data.tar.gz: f50ddf84afe6ff0022c3ef7d4001864e497384c6
3
+ metadata.gz: dd555efd1a1de7fe705c6569cc5d16fce21eb6c4
4
+ data.tar.gz: d505cc68ce876b9edcd04cd1734b834e6e8f4083
5
5
  SHA512:
6
- metadata.gz: 0b6a8a0ed56620924b0411e7eecad1a27c1546daebd9b0e94e6f8d8792c758907c3ee674cce4c6dffa4a3b2b216ab41e149691766ec5ae5e0d08d2b1a52a2cdc
7
- data.tar.gz: 179386d9185ccb45c9f32fb431c6c66eb9c8d72eccadf8ec3b084319c356677c7fc2c5b691e3dc8f314b4cb4dac7c61695121caa93edaa60f05c06899044386b
6
+ metadata.gz: 79de2103fa41ccd3bb3fa067a5aebbd3dd2e6b58c9abacfa457a9134bd0e0f8e9bd0f61d89bd36101b24f30206b3166192371236d11be9915e48417921f20991
7
+ data.tar.gz: 9f057c582f34c69e177f14f9d42ecfb03c3e883e0f00a5b58982f04f13ff31d163ccd63d20a8e5433db4dee98c34fba3bdcbe1907a15a49ed11746f1d1b44b74
@@ -257,7 +257,7 @@ module OpenCL
257
257
 
258
258
  r = FFI::MemoryPointer::new( :size_t, 3 )
259
259
  (0..2).each { |i| r[i].write_size_t(0) }
260
- region[0..3].each_with_index { |e, i|
260
+ region[0..2].each_with_index { |e, i|
261
261
  r[i].write_size_t(e)
262
262
  }
263
263
 
@@ -334,7 +334,7 @@ module OpenCL
334
334
 
335
335
  r = FFI::MemoryPointer::new( :size_t, 3 )
336
336
  (0..2).each { |i| r[i].write_size_t(0) }
337
- region[0..3].each_with_index { |e, i|
337
+ region[0..2].each_with_index { |e, i|
338
338
  r[i].write_size_t(e)
339
339
  }
340
340
 
@@ -405,7 +405,7 @@ module OpenCL
405
405
 
406
406
  r = FFI::MemoryPointer::new( :size_t, 3 )
407
407
  (0..2).each { |i| r[i].write_size_t(0) }
408
- region[0..3].each_with_index { |e, i|
408
+ region[0..2].each_with_index { |e, i|
409
409
  r[i].write_size_t(e)
410
410
  }
411
411
 
@@ -1071,6 +1071,14 @@ module OpenCL
1071
1071
  return Device::new( ptr.read_pointer )
1072
1072
  end
1073
1073
 
1074
+ # Return the default CommandQueue for the underlying Device
1075
+ def device_default
1076
+ ptr = FFI::MemoryPointer::new( CommandQueue )
1077
+ error = OpenCL.clGetCommandQueueInfo(self, DEVICE_DEFAULT, CommandQueue.size, ptr, nil)
1078
+ error_check(error)
1079
+ return CommandQueue::new( ptr.read_pointer )
1080
+ end
1081
+
1074
1082
  ##
1075
1083
  # :method: reference_count
1076
1084
  # Returns the reference count of the CommandQueue
@@ -1734,6 +1742,25 @@ module OpenCL
1734
1742
  return OpenCL.enqueue_svm_unmap( self, svm_ptr, options )
1735
1743
  end
1736
1744
 
1745
+ # Enqueues a command to migrate SVM memory area
1746
+ # ==== Attributes
1747
+ #
1748
+ # * +svm_ptrs+ - a single or an Array of SVM memory area to migrate
1749
+ # * +options+ - a hash containing named options
1750
+ #
1751
+ # ==== Options
1752
+ #
1753
+ # * +:sizes+ - a single or an Array of sizes to transfer
1754
+ # * +:flags+ - a single or an Array of :cl_mem_migration flags
1755
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
1756
+ #
1757
+ # ==== Returns
1758
+ #
1759
+ # the Event associated with the command
1760
+ def enqueue_svm_migrate_mem( svn_ptrs, options = {} )
1761
+ return OpenCL.enqueue_svm_migrate_mem( self, svn_ptrs, options = {} )
1762
+ end
1763
+
1737
1764
  end
1738
1765
 
1739
1766
  end
@@ -47,6 +47,13 @@ module OpenCL
47
47
  return Context::new(ptr, false)
48
48
  end
49
49
 
50
+ def self.set_default_device_command_queue( context, device, command_queue )
51
+ error_check(INVALID_OPERATION) if context.platform.version_number < 2.1
52
+ error = clSetDefaultDeviceCommandQueue( context, device, command_queue )
53
+ error_check(error)
54
+ return context
55
+ end
56
+
50
57
  #Maps the cl_context object of OpenCL
51
58
  class Context
52
59
  include InnerInterface
@@ -361,6 +368,15 @@ module OpenCL
361
368
  return OpenCL.create_program_with_source(self, strings)
362
369
  end
363
370
 
371
+ # Create a Program from an intermediate level representation in the Context
372
+ #
373
+ # ==== Attributes
374
+ #
375
+ # * +il+ - a binary string containing the intermediate level representation of the program
376
+ def create_program_with_il(il)
377
+ return OpenCL.create_program_with_il(self, il)
378
+ end
379
+
364
380
  # Creates a Sampler in the Context
365
381
  #
366
382
  # ==== Options
@@ -412,6 +428,10 @@ module OpenCL
412
428
  return OpenCL.svm_free(self, svm_pointer)
413
429
  end
414
430
 
431
+ def set_default_device_command_queue( device, command_queue )
432
+ return OpenCL.set_default_device_command_queue( self, device, command_queue )
433
+ end
434
+
415
435
  end
416
436
 
417
437
  end
@@ -29,6 +29,23 @@ module OpenCL
29
29
  }
30
30
  end
31
31
 
32
+ def self.get_device_and_host_timer( device )
33
+ error_check(INVALID_OPERATION) if device.platform.version_number < 2.1
34
+ device_timestamp_p = FFI::MemoryPointer::new( :cl_ulong )
35
+ host_timestamp_p = FFI::MemoryPointer::new( :cl_ulong )
36
+ error = clGetDeviceAndHostTimer( device, device_timestamp_p, host_timestamp_p)
37
+ error_check(error)
38
+ return [ device_timestamp_p.read_cl_ulong, host_timestamp_p.read_cl_ulong ]
39
+ end
40
+
41
+ def self.get_device_and_host_timer( device )
42
+ error_check(INVALID_OPERATION) if device.platform.version_number < 2.1
43
+ host_timestamp_p = FFI::MemoryPointer::new( :cl_ulong )
44
+ error = clGetHostTimer( device, host_timestamp_p)
45
+ error_check(error)
46
+ return host_timestamp_p.read_cl_ulong
47
+ end
48
+
32
49
  # Maps the cl_device_id object of OpenCL
33
50
  class Device
34
51
  include InnerInterface
@@ -82,7 +99,11 @@ module OpenCL
82
99
  return vers_strings.collect { |s| s.scan(/(\d+\.\d+)/).first.first.to_f }
83
100
  end
84
101
 
85
- %w( BUILT_IN_KERNELS DRIVER_VERSION VERSION VENDOR PROFILE OPENCL_C_VERSION NAME ).each { |prop|
102
+ def il_version_number
103
+ return il_version.scan(/(\d+\.\d+)/).first.first.to_f
104
+ end
105
+
106
+ %w( BUILT_IN_KERNELS DRIVER_VERSION VERSION VENDOR PROFILE OPENCL_C_VERSION NAME IL_VERSION ).each { |prop|
86
107
  eval get_info("Device", :string, prop)
87
108
  }
88
109
 
@@ -104,15 +125,15 @@ module OpenCL
104
125
  eval get_info("Device", :cl_ulong, prop)
105
126
  }
106
127
 
107
- %w( IMAGE_PITCH_ALIGNMENT IMAGE_BASE_ADDRESS_ALIGNMENT REFERENCE_COUNT PARTITION_MAX_SUB_DEVICES VENDOR_ID PREFERRED_VECTOR_WIDTH_HALF PREFERRED_VECTOR_WIDTH_CHAR PREFERRED_VECTOR_WIDTH_SHORT PREFERRED_VECTOR_WIDTH_INT PREFERRED_VECTOR_WIDTH_LONG PREFERRED_VECTOR_WIDTH_FLOAT PREFERRED_VECTOR_WIDTH_DOUBLE NATIVE_VECTOR_WIDTH_CHAR NATIVE_VECTOR_WIDTH_SHORT NATIVE_VECTOR_WIDTH_INT NATIVE_VECTOR_WIDTH_LONG NATIVE_VECTOR_WIDTH_FLOAT NATIVE_VECTOR_WIDTH_DOUBLE NATIVE_VECTOR_WIDTH_HALF MIN_DATA_TYPE_ALIGN_SIZE MEM_BASE_ADDR_ALIGN MAX_WRITE_IMAGE_ARGS MAX_READ_WRITE_IMAGE_ARGS MAX_WORK_ITEM_DIMENSIONS MAX_SAMPLERS MAX_READ_IMAGE_ARGS MAX_CONSTANT_ARGS MAX_COMPUTE_UNITS MAX_CLOCK_FREQUENCY ADDRESS_BITS GLOBAL_MEM_CACHELINE_SIZE QUEUE_ON_DEVICE_PREFERRED_SIZE QUEUE_ON_DEVICE_MAX_SIZE MAX_ON_DEVICE_QUEUES MAX_ON_DEVICE_EVENTS MAX_PIPE_ARGS PIPE_MAX_ACTIVE_RESERVATIONS PIPE_MAX_PACKET_SIZE PREFERRED_PLATFORM_ATOMIC_ALIGNMENT PREFERRED_GLOBAL_ATOMIC_ALIGNMENT PREFERRED_LOCAL_ATOMIC_ALIGNMENT).each { |prop|
128
+ %w( IMAGE_PITCH_ALIGNMENT IMAGE_BASE_ADDRESS_ALIGNMENT REFERENCE_COUNT PARTITION_MAX_SUB_DEVICES VENDOR_ID PREFERRED_VECTOR_WIDTH_HALF PREFERRED_VECTOR_WIDTH_CHAR PREFERRED_VECTOR_WIDTH_SHORT PREFERRED_VECTOR_WIDTH_INT PREFERRED_VECTOR_WIDTH_LONG PREFERRED_VECTOR_WIDTH_FLOAT PREFERRED_VECTOR_WIDTH_DOUBLE NATIVE_VECTOR_WIDTH_CHAR NATIVE_VECTOR_WIDTH_SHORT NATIVE_VECTOR_WIDTH_INT NATIVE_VECTOR_WIDTH_LONG NATIVE_VECTOR_WIDTH_FLOAT NATIVE_VECTOR_WIDTH_DOUBLE NATIVE_VECTOR_WIDTH_HALF MIN_DATA_TYPE_ALIGN_SIZE MEM_BASE_ADDR_ALIGN MAX_WRITE_IMAGE_ARGS MAX_READ_WRITE_IMAGE_ARGS MAX_WORK_ITEM_DIMENSIONS MAX_SAMPLERS MAX_READ_IMAGE_ARGS MAX_CONSTANT_ARGS MAX_COMPUTE_UNITS MAX_CLOCK_FREQUENCY ADDRESS_BITS GLOBAL_MEM_CACHELINE_SIZE QUEUE_ON_DEVICE_PREFERRED_SIZE QUEUE_ON_DEVICE_MAX_SIZE MAX_ON_DEVICE_QUEUES MAX_ON_DEVICE_EVENTS MAX_PIPE_ARGS PIPE_MAX_ACTIVE_RESERVATIONS PIPE_MAX_PACKET_SIZE PREFERRED_PLATFORM_ATOMIC_ALIGNMENT PREFERRED_GLOBAL_ATOMIC_ALIGNMENT PREFERRED_LOCAL_ATOMIC_ALIGNMENT MAX_NUM_SUB_GROUPS ).each { |prop|
108
129
  eval get_info("Device", :cl_uint, prop)
109
130
  }
110
131
 
111
- %w( PRINTF_BUFFER_SIZE IMAGE_MAX_BUFFER_SIZE IMAGE_MAX_ARRAY_SIZE PROFILING_TIMER_RESOLUTION MAX_WORK_GROUP_SIZE MAX_PARAMETER_SIZE IMAGE2D_MAX_WIDTH IMAGE2D_MAX_HEIGHT IMAGE3D_MAX_WIDTH IMAGE3D_MAX_HEIGHT IMAGE3D_MAX_DEPTH MAX_GLOBAL_VARIABLE_SIZE GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE).each { |prop|
132
+ %w( PRINTF_BUFFER_SIZE IMAGE_MAX_BUFFER_SIZE IMAGE_MAX_ARRAY_SIZE PROFILING_TIMER_RESOLUTION MAX_WORK_GROUP_SIZE MAX_PARAMETER_SIZE IMAGE2D_MAX_WIDTH IMAGE2D_MAX_HEIGHT IMAGE3D_MAX_WIDTH IMAGE3D_MAX_HEIGHT IMAGE3D_MAX_DEPTH MAX_GLOBAL_VARIABLE_SIZE GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE ).each { |prop|
112
133
  eval get_info("Device", :size_t, prop)
113
134
  }
114
135
 
115
- %w( PREFERRED_INTEROP_USER_SYNC LINKER_AVAILABLE IMAGE_SUPPORT HOST_UNIFIED_MEMORY COMPILER_AVAILABLE AVAILABLE ENDIAN_LITTLE ERROR_CORRECTION_SUPPORT ).each { |prop|
136
+ %w( PREFERRED_INTEROP_USER_SYNC LINKER_AVAILABLE IMAGE_SUPPORT HOST_UNIFIED_MEMORY COMPILER_AVAILABLE AVAILABLE ENDIAN_LITTLE ERROR_CORRECTION_SUPPORT SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS ).each { |prop|
116
137
  eval get_info("Device", :cl_bool, prop)
117
138
  }
118
139
 
@@ -189,7 +210,7 @@ module OpenCL
189
210
  # Returns a list of :cl_device_partition_property used to create the Device
190
211
  eval get_info_array("Device", :cl_device_partition_property, "PARTITION_TYPE")
191
212
 
192
- # Returns the platform the Device belongs to
213
+ # Returns the Platform the Device belongs to
193
214
  def platform
194
215
  ptr = FFI::MemoryPointer::new( OpenCL::Platform )
195
216
  error = OpenCL.clGetDeviceInfo(self, PLATFORM, OpenCL::Platform.size, ptr, nil)
@@ -258,6 +279,14 @@ module OpenCL
258
279
  return OpenCL.create_sub_devices( self, [ PARTITION_BY_COUNTS] + compute_unit_number_list + [ PARTITION_BY_COUNTS_LIST_END ] )
259
280
  end
260
281
 
282
+ def get_device_and_host_timer
283
+ return OpenCL.get_device_and_host_timer( self )
284
+ end
285
+
286
+ def get_host_timer
287
+ return OpenCL.get_host_timer( self )
288
+ end
289
+
261
290
  end
262
291
 
263
292
  end
@@ -35,6 +35,14 @@ module OpenCL
35
35
  error_check(error)
36
36
  end
37
37
 
38
+ def self.clone_kernel( kernel )
39
+ error_check(INVALID_OPERATION) if kernel.context.platform.version_number < 2.1
40
+ error = FFI::MemoryPointer::new( :cl_int )
41
+ kernel_ptr = clCloneKernel( kernel, error )
42
+ error_check(error.read_cl_int)
43
+ return Kernel::new( kernel_ptr, false )
44
+ end
45
+
38
46
  # Maps the cl_kernel object
39
47
  class Kernel
40
48
  include InnerInterface
@@ -196,6 +204,103 @@ module OpenCL
196
204
  return Program::new(ptr.read_pointer)
197
205
  end
198
206
 
207
+ def work_group_size(device = program.devices.first)
208
+ ptr = FFI::MemoryPointer::new( :size_t )
209
+ error = OpenCL.clGetKernelWorkGroupInfo(self, device, WORK_GROUP_SIZE, ptr.size, ptr, nil)
210
+ error_check(error)
211
+ return ptr.read_size_t
212
+ end
213
+
214
+ def compile_work_group_size(device = program.devices.first)
215
+ ptr = FFI::MemoryPointer::new( :size_t, 3 )
216
+ error = OpenCL.clGetKernelWorkGroupInfo(self, device, COMPILE_WORK_GROUP_SIZE, ptr.size, ptr, nil)
217
+ error_check(error)
218
+ return ptr.get_array_of_size_t(0,3)
219
+ end
220
+
221
+ def local_mem_size(device = program.devices.first)
222
+ ptr = FFI::MemoryPointer::new( :cl_ulong )
223
+ error = OpenCL.clGetKernelWorkGroupInfo(self, device, LOCAL_MEM_SIZE, ptr.size, ptr, nil)
224
+ error_check(error)
225
+ return ptr.read_cl_ulong
226
+ end
227
+
228
+ def preferred_work_group_size_multiple(device = program.devices.first)
229
+ ptr = FFI::MemoryPointer::new( :size_t )
230
+ error = OpenCL.clGetKernelWorkGroupInfo(self, device, PREFERRED_WORK_GROUP_SIZE_MULTIPLE, ptr.size, ptr, nil)
231
+ error_check(error)
232
+ return ptr.read_size_t
233
+ end
234
+
235
+ def private_mem_size(device = program.devices.first)
236
+ ptr = FFI::MemoryPointer::new( :cl_ulong )
237
+ error = OpenCL.clGetKernelWorkGroupInfo(self, device, PRIVATE_MEM_SIZE, ptr.size, ptr, nil)
238
+ error_check(error)
239
+ return ptr.read_cl_ulong
240
+ end
241
+
242
+ def global_work_size(device = program.devices.first)
243
+ ptr = FFI::MemoryPointer::new( :size_t, 3 )
244
+ error = OpenCL.clGetKernelWorkGroupInfo(self, device, GLOBAL_WORK_SIZE, ptr.size, ptr, nil)
245
+ error_check(error)
246
+ return ptr.get_array_of_size_t(0,3)
247
+ end
248
+
249
+ def max_num_sub_groups(device = program.devices.first)
250
+ error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.1
251
+ ptr = FFI::MemoryPointer::new( :size_t )
252
+ error = OpenCL.clGetKernelSubGroupInfo(self, device, MAX_NUM_SUB_GROUPS, 0, nil, ptr.size, ptr, nil)
253
+ error_check(error)
254
+ return ptr.read_size_t
255
+ end
256
+
257
+ def compile_num_sub_groups(device = program.devices.first)
258
+ error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.1
259
+ ptr = FFI::MemoryPointer::new( :size_t )
260
+ error = OpenCL.clGetKernelSubGroupInfo(self, device, COMPILE_NUM_SUB_GROUPS, 0, nil, ptr.size, ptr, nil)
261
+ error_check(error)
262
+ return ptr.read_size_t
263
+ end
264
+
265
+ def max_sub_group_size_for_ndrange(local_work_size, device = program.devices.first)
266
+ error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.1
267
+ local_work_size = [local_work_size].flatten
268
+ lws_p = FFI::MemoryPointer::new( :size_t, local_work_size.length )
269
+ local_work_size.each_with_index { |e,i|
270
+ lws_p[i].write_size_t( e )
271
+ }
272
+ ptr = FFI::MemoryPointer::new( :size_t )
273
+ error = OpenCL.clGetKernelSubGroupInfo(self, device, MAX_SUB_GROUP_SIZE_FOR_NDRANGE, lws_p.size, lws_p, ptr.size, ptr, nil)
274
+ error_check(error)
275
+ return ptr.read_size_t
276
+ end
277
+
278
+ def sub_groups_count_for_ndrange(local_work_size, device = program.devices.first)
279
+ error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.1
280
+ local_work_size = [local_work_size].flatten
281
+ lws_p = FFI::MemoryPointer::new( :size_t, local_work_size.length )
282
+ local_work_size.each_with_index { |e,i|
283
+ lws_p[i].write_size_t( e )
284
+ }
285
+ ptr = FFI::MemoryPointer::new( :size_t )
286
+ error = OpenCL.clGetKernelSubGroupInfo(self, device, SUB_GROUP_COUNT_FOR_NDRANGE, lws_p.size, lws_p, ptr.size, ptr, nil)
287
+ error_check(error)
288
+ return ptr.read_size_t
289
+ end
290
+
291
+ def local_size_for_sub_group_count(sub_group_number, device = program.devices.first)
292
+ error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.1
293
+ sgp_p = FFI::MemoryPointer::new( :size_t )
294
+ sgp_p.write_size_t(sub_group_number)
295
+ size_ptr = FFI::MemoryPointer::new( :size_t )
296
+ error = OpenCL.clGetKernelSubGroupInfo(self, device, LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sgp_p.size, sgp_p, 0, nil, size_ptr)
297
+ error_check(error)
298
+ lws_p = FFI::MemoryPointer::new( size_ptr.read_size_t )
299
+ error = OpenCL.clGetKernelSubGroupInfo(self, device, LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sgp_p.size, sgp_p, lws_p.size, lws_p, nil)
300
+ error_check(error)
301
+ return lws_p.get_array_of_size_t(0, lws_p.size/size_ptr.size)
302
+ end
303
+
199
304
  # Set the index th argument of the Kernel to value. The size of value can be specified.
200
305
  def set_arg(index, value, size = nil)
201
306
  OpenCL.set_kernel_arg(self, index, value, size)
@@ -226,6 +331,10 @@ module OpenCL
226
331
  command_queue.enqueue_ndrange_kernel(self, global_work_size, options)
227
332
  end
228
333
 
334
+ def clone
335
+ return OpenCL.clone_kernel( self )
336
+ end
337
+
229
338
  end
230
339
 
231
340
  end
@@ -94,12 +94,17 @@ module OpenCL
94
94
  # Returns a String containing the Platform name
95
95
 
96
96
  ##
97
- # :mathod: vendor()
97
+ # :method: vendor()
98
98
  # Returns a String identifying the Platform vendor
99
99
  %w(PROFILE VERSION NAME VENDOR ICD_SUFFIX_KHR).each { |prop|
100
100
  eval get_info("Platform", :string, prop)
101
101
  }
102
102
 
103
+ ##
104
+ # :method: host_timer_resolution()
105
+ # returns the host timer resulution in nanoseconds
106
+ eval get_info("Platform", :cl_ulong, "HOST_TIMER_RESOLUTION")
107
+
103
108
  # Returns an Array of string corresponding to the Platform extensions
104
109
  def extensions
105
110
  extensions_size = FFI::MemoryPointer::new( :size_t )
@@ -186,6 +186,22 @@ module OpenCL
186
186
  return Program::new( program_ptr, false )
187
187
  end
188
188
 
189
+ # Create a Program from an intermediate level representation
190
+ #
191
+ # ==== Attributes
192
+ #
193
+ # * +context+ - Context the created Program will be associated to
194
+ # * +il+ - a binary string containing the intermediate level representation of the program
195
+ def self.create_program_with_il(context, il)
196
+ length = il.bytesize
197
+ il_p = FFI::MemoryPointer::new( length )
198
+ error = FFI::MemoryPointer::new( :cl_int )
199
+ il_p.write_bytes(il)
200
+ program_ptr = clCreateProgramWithIL(context, il_p, length, error)
201
+ error_check(error.read_cl_int)
202
+ return Program::new( program_ptr, false )
203
+ end
204
+
189
205
  # Maps the cl_program object of OpenCL
190
206
  class Program
191
207
  include InnerInterface
@@ -319,6 +335,19 @@ module OpenCL
319
335
  return bins
320
336
  end
321
337
 
338
+ # Return the intermediate level representation of the program if any, nil otherwise
339
+ def il
340
+ il_size = FFI::MemoryPointer::new( :size_t )
341
+ error = OpenCL.clGetProgramInfo(self, IL, 0, nil, il_size)
342
+ error_check(error)
343
+ return nil if il_size == 0
344
+ length = il_size.read_size_t
345
+ il_p = FFI::MemoryPointer::new( length )
346
+ error = OpenCL.clGetProgramInfo(self, IL, length, il_p, nil)
347
+ error_check(error)
348
+ return il_p.read_bytes(length)
349
+ end
350
+
322
351
  # Builds (compile and link) the Program created from sources or binary
323
352
  #
324
353
  # ==== Attributes
@@ -209,4 +209,41 @@ module OpenCL
209
209
  return Event::new( event.read_ptr, false )
210
210
  end
211
211
 
212
+ # Enqueues a command to migrate SVM memory area
213
+ # ==== Attributes
214
+ #
215
+ # * +command_queue+ - CommandQueue used to execute the unmap command
216
+ # * +svm_ptrs+ - a single or an Array of SVM memory area to migrate
217
+ # * +options+ - a hash containing named options
218
+ #
219
+ # ==== Options
220
+ #
221
+ # * +:sizes+ - a single or an Array of sizes to transfer
222
+ # * +:flags+ - a single or an Array of :cl_mem_migration flags
223
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
224
+ #
225
+ # ==== Returns
226
+ #
227
+ # the Event associated with the command
228
+ def self.enqueue_svm_migrate_mem( command_queue, svn_ptrs, options = {} )
229
+ svn_ptrs = [svn_ptrs].flatten
230
+ num_svm_pointers = svn_ptrs.length
231
+ num_events, events = get_event_wait_list( options )
232
+ flags = get_flags( options )
233
+ sizes = [0]*num_svm_pointers
234
+ sizes = options[:sizes] if options[:sizes]
235
+ svn_ptrs_p = FFI::MemoryPointer::new( :pointer, num_svm_pointers)
236
+ svn_ptrs.each_with_index { |e, i|
237
+ svn_ptrs_p[i].write_pointer(e)
238
+ }
239
+ sizes_p = FFI::MemoryPointer::new( :size_t, num_svm_pointers)
240
+ num_svm_pointers.times { |i|
241
+ sizes_p[i].write_size_t(sizes[i])
242
+ }
243
+ event = FFI::MemoryPointer::new( Event )
244
+ error = clEnqueueSVMMigrateMem( command_queue, num_svm_pointers, svn_ptrs_p, sizes_p, flags, num_events, events, event )
245
+ error_check( error )
246
+ return Event::new( event.read_ptr, false )
247
+ end
248
+
212
249
  end
@@ -95,6 +95,7 @@ module OpenCL
95
95
  PLATFORM_NAME = 0x0902
96
96
  PLATFORM_VENDOR = 0x0903
97
97
  PLATFORM_EXTENSIONS = 0x0904
98
+ PLATFORM_HOST_TIMER_RESOLUTION = 0x0905
98
99
  DEVICE_TYPE_DEFAULT = (1 << 0)
99
100
  DEVICE_TYPE_CPU = (1 << 1)
100
101
  DEVICE_TYPE_GPU = (1 << 2)
@@ -192,6 +193,9 @@ module OpenCL
192
193
  DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT = 0x1058
193
194
  DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT = 0x1059
194
195
  DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT = 0x105A
196
+ DEVICE_IL_VERSION = 0x105B
197
+ DEVICE_MAX_NUM_SUB_GROUPS = 0x105C
198
+ DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 0x105D
195
199
  FP_DENORM = (1 << 0)
196
200
  FP_INF_NAN = (1 << 1)
197
201
  FP_ROUND_TO_NEAREST = (1 << 2)
@@ -236,6 +240,7 @@ module OpenCL
236
240
  QUEUE_REFERENCE_COUNT = 0x1092
237
241
  QUEUE_PROPERTIES = 0x1093
238
242
  QUEUE_SIZE = 0x1094
243
+ QUEUE_DEVICE_DEFAULT = 0x1095
239
244
  MEM_READ_WRITE = (1 << 0)
240
245
  MEM_WRITE_ONLY = (1 << 1)
241
246
  MEM_READ_ONLY = (1 << 2)
@@ -264,10 +269,18 @@ module OpenCL
264
269
  RGBx = 0x10BC
265
270
  DEPTH = 0x10BD
266
271
  DEPTH_STENCIL = 0x10BE
267
- sRGB = 0x10BF
268
- sRGBx = 0x10C0
269
- sRGBA = 0x10C1
270
- sBGRA = 0x10C2
272
+ def self.sRGB
273
+ return 0x10BF
274
+ end
275
+ def self.sRGBx
276
+ return 0x10C0
277
+ end
278
+ def self.sRGBA
279
+ return 0x10C1
280
+ end
281
+ def self.sBGRA
282
+ return 0x10C2
283
+ end
271
284
  ABGR = 0x10C3
272
285
  SNORM_INT8 = 0x10D0
273
286
  SNORM_INT16 = 0x10D1
@@ -285,6 +298,7 @@ module OpenCL
285
298
  HALF_FLOAT = 0x10DD
286
299
  FLOAT = 0x10DE
287
300
  UNORM_INT24 = 0x10DF
301
+ UNORM_INT_101010_2 = 0x10E0
288
302
  MEM_OBJECT_BUFFER = 0x10F0
289
303
  MEM_OBJECT_IMAGE2D = 0x10F1
290
304
  MEM_OBJECT_IMAGE3D = 0x10F2
@@ -343,6 +357,7 @@ module OpenCL
343
357
  PROGRAM_BINARIES = 0x1166
344
358
  PROGRAM_NUM_KERNELS = 0x1167
345
359
  PROGRAM_KERNEL_NAMES = 0x1168
360
+ PROGRAM_IL = 0x1169
346
361
  PROGRAM_BUILD_STATUS = 0x1181
347
362
  PROGRAM_BUILD_OPTIONS = 0x1182
348
363
  PROGRAM_BUILD_LOG = 0x1183
@@ -386,6 +401,11 @@ module OpenCL
386
401
  KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x11B3
387
402
  KERNEL_PRIVATE_MEM_SIZE = 0x11B4
388
403
  KERNEL_GLOBAL_WORK_SIZE = 0x11B5
404
+ KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE = 0x2033
405
+ KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE = 0x2034
406
+ KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT = 0x11B8
407
+ KERNEL_MAX_NUM_SUB_GROUPS = 0x11B9
408
+ KERNEL_COMPILE_NUM_SUB_GROUPS = 0x11BA
389
409
  KERNEL_EXEC_INFO_SVM_PTRS = 0x11B6
390
410
  KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = 0x11B7
391
411
  EVENT_COMMAND_QUEUE = 0x11D0
@@ -444,7 +464,6 @@ module OpenCL
444
464
  GL_TEXTURE_TARGET = 0x2004
445
465
  GL_MIPMAP_LEVEL = 0x2005
446
466
  GL_NUM_SAMPLES = 0x2012
447
- cl_khr_gl_sharing = 1
448
467
  INVALID_GL_SHAREGROUP_REFERENCE_KHR = -1000
449
468
  CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 0x2006
450
469
  DEVICES_FOR_GL_CONTEXT_KHR = 0x2007
@@ -454,15 +473,11 @@ module OpenCL
454
473
  WGL_HDC_KHR = 0x200B
455
474
  CGL_SHAREGROUP_KHR = 0x200C
456
475
  DEVICE_HALF_FP_CONFIG = 0x1033
457
- cl_APPLE_SetMemObjectDestructor = 1
458
- cl_APPLE_ContextLoggingFunctions = 1
459
- cl_khr_icd = 1
460
476
  PLATFORM_ICD_SUFFIX_KHR = 0x0920
461
477
  PLATFORM_NOT_FOUND_KHR = -1001
462
478
  CONTEXT_MEMORY_INITIALIZE_KHR = 0x200E
463
479
  DEVICE_TERMINATE_CAPABILITY_KHR = 0x200F
464
480
  CONTEXT_TERMINATE_KHR = 0x2010
465
- cl_khr_terminate_context = 1
466
481
  DEVICE_SPIR_VERSIONS = 0x40E0
467
482
  PROGRAM_BINARY_TYPE_INTERMEDIATE = 0x40E1
468
483
  DEVICE_COMPUTE_CAPABILITY_MAJOR_NV = 0x4000
@@ -483,6 +498,16 @@ module OpenCL
483
498
  MEM_HOST_WRITETHROUGH_QCOM = 0x40A6
484
499
  MEM_HOST_WRITE_COMBINING_QCOM = 0x40A7
485
500
  MEM_ION_HOST_PTR_QCOM = 0x40A8
501
+ KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR = 0x2033
502
+ KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR = 0x2034
503
+ QUEUE_PRIORITY_KHR = 0x1096
504
+ QUEUE_PRIORITY_HIGH_KHR = (1<<0)
505
+ QUEUE_PRIORITY_MED_KHR = (1<<1)
506
+ QUEUE_PRIORITY_LOW_KHR = (1<<2)
507
+ QUEUE_THROTTLE_KHR = 0x1097
508
+ QUEUE_THROTTLE_HIGH_KHR = (1<<0)
509
+ QUEUE_THROTTLE_MED_KHR = (1<<1)
510
+ QUEUE_THROTTLE_LOW_KHR = (1<<2)
486
511
  #:startdoc:
487
512
  # Parent claas to map OpenCL errors, and is used to raise unknown errors
488
513
  class Error < StandardError
@@ -2310,6 +2335,7 @@ module OpenCL
2310
2335
  FFI.typedef :cl_uint, :cl_kernel_arg_access_qualifier
2311
2336
  FFI.typedef :cl_bitfield, :cl_kernel_arg_type_qualifier
2312
2337
  FFI.typedef :cl_uint, :cl_kernel_work_group_info
2338
+ FFI.typedef :cl_uint, :cl_kernel_sub_group_info
2313
2339
  FFI.typedef :cl_uint, :cl_event_info
2314
2340
  FFI.typedef :cl_uint, :cl_command_type
2315
2341
  FFI.typedef :cl_uint, :cl_profiling_info
@@ -2481,6 +2507,7 @@ module OpenCL
2481
2507
  NAME = 0x0902
2482
2508
  VENDOR = 0x0903
2483
2509
  EXTENSIONS = 0x0904
2510
+ HOST_TIMER_RESOLUTION = 0x0905
2484
2511
  ICD_SUFFIX_KHR = 0x0920
2485
2512
 
2486
2513
  # Creates a new Platform and retains it if specified and aplicable
@@ -2603,6 +2630,9 @@ module OpenCL
2603
2630
  PREFERRED_PLATFORM_ATOMIC_ALIGNMENT = 0x1058
2604
2631
  PREFERRED_GLOBAL_ATOMIC_ALIGNMENT = 0x1059
2605
2632
  PREFERRED_LOCAL_ATOMIC_ALIGNMENT = 0x105A
2633
+ IL_VERSION = 0x105B
2634
+ MAX_NUM_SUB_GROUPS = 0x105C
2635
+ SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 0x105D
2606
2636
  PARTITION_EQUALLY = 0x1086
2607
2637
  PARTITION_BY_COUNTS = 0x1087
2608
2638
  PARTITION_BY_COUNTS_LIST_END = 0x0
@@ -2832,7 +2862,15 @@ module OpenCL
2832
2862
  REFERENCE_COUNT = 0x1092
2833
2863
  PROPERTIES = 0x1093
2834
2864
  SIZE = 0x1094
2835
-
2865
+ DEVICE_DEFAULT = 0x1095
2866
+ PRIORITY_KHR = 0x1096
2867
+ PRIORITY_HIGH_KHR = (1<<0)
2868
+ PRIORITY_MED_KHR = (1<<1)
2869
+ PRIORITY_LOW_KHR = (1<<2)
2870
+ THROTTLE_KHR = 0x1097
2871
+ THROTTLE_HIGH_KHR = (1<<0)
2872
+ THROTTLE_MED_KHR = (1<<1)
2873
+ THROTTLE_LOW_KHR = (1<<2)
2836
2874
  # Creates a new CommandQueue and retains it if specified and aplicable
2837
2875
  def initialize(ptr, retain = true)
2838
2876
  super(ptr)
@@ -3036,6 +3074,7 @@ module OpenCL
3036
3074
  BINARIES = 0x1166
3037
3075
  NUM_KERNELS = 0x1167
3038
3076
  KERNEL_NAMES = 0x1168
3077
+ IL = 0x1169
3039
3078
  BUILD_STATUS = 0x1181
3040
3079
  BUILD_OPTIONS = 0x1182
3041
3080
  BUILD_LOG = 0x1183
@@ -3129,6 +3168,11 @@ module OpenCL
3129
3168
  PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x11B3
3130
3169
  PRIVATE_MEM_SIZE = 0x11B4
3131
3170
  GLOBAL_WORK_SIZE = 0x11B5
3171
+ MAX_SUB_GROUP_SIZE_FOR_NDRANGE = 0x2033
3172
+ SUB_GROUP_COUNT_FOR_NDRANGE = 0x2034
3173
+ LOCAL_SIZE_FOR_SUB_GROUP_COUNT = 0x11B8
3174
+ MAX_NUM_SUB_GROUPS = 0x11B9
3175
+ COMPILE_NUM_SUB_GROUPS = 0x11BA
3132
3176
  EXEC_INFO_SVM_PTRS = 0x11B6
3133
3177
  EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = 0x11B7
3134
3178
 
@@ -3380,10 +3424,18 @@ module OpenCL
3380
3424
  RGBx = 0x10BC
3381
3425
  DEPTH = 0x10BD
3382
3426
  DEPTH_STENCIL = 0x10BE
3383
- sRGB = 0x10BF
3384
- sRGBx = 0x10C0
3385
- sRGBA = 0x10C1
3386
- sBGRA = 0x10C2
3427
+ def self.sRGB
3428
+ return 0x10BF
3429
+ end
3430
+ def self.sRGBx
3431
+ return 0x10C0
3432
+ end
3433
+ def self.sRGBA
3434
+ return 0x10C1
3435
+ end
3436
+ def self.sBGRA
3437
+ return 0x10C2
3438
+ end
3387
3439
  ABGR = 0x10C3
3388
3440
  @@codes[0x10B0] = 'R'
3389
3441
  @@codes[0x10B1] = 'A'
@@ -3429,6 +3481,7 @@ module OpenCL
3429
3481
  HALF_FLOAT = 0x10DD
3430
3482
  FLOAT = 0x10DE
3431
3483
  UNORM_INT24 = 0x10DF
3484
+ UNORM_INT_101010_2 = 0x10E0
3432
3485
  @@codes[0x10D0] = 'SNORM_INT8'
3433
3486
  @@codes[0x10D1] = 'SNORM_INT16'
3434
3487
  @@codes[0x10D2] = 'UNORM_INT8'
@@ -3445,6 +3498,7 @@ module OpenCL
3445
3498
  @@codes[0x10DD] = 'HALF_FLOAT'
3446
3499
  @@codes[0x10DE] = 'FLOAT'
3447
3500
  @@codes[0x10DF] = 'UNORM_INT24'
3501
+ @@codes[0x10E0] = 'UNORM_INT_101010_2'
3448
3502
  # Returns a String representing the Enum value name
3449
3503
  def name
3450
3504
  return @@codes[@val]
@@ -3768,6 +3822,17 @@ module OpenCL
3768
3822
  attach_function :clEnqueueSVMMemFill, [CommandQueue,:pointer,:pointer,:size_t,:size_t,:cl_uint,:pointer,:pointer], :cl_int
3769
3823
  attach_function :clEnqueueSVMMap, [CommandQueue,:cl_bool,:cl_map_flags,:pointer,:size_t,:cl_uint,:pointer,:pointer], :cl_int
3770
3824
  attach_function :clEnqueueSVMUnmap, [CommandQueue,:pointer,:cl_uint,:pointer,:pointer], :cl_int
3825
+ begin
3826
+ attach_function :clSetDefaultDeviceCommandQueue, [Context,Device,CommandQueue], :cl_int
3827
+ attach_function :clGetDeviceAndHostTimer, [Device,:pointer,:pointer], :cl_int
3828
+ attach_function :clGetHostTimer, [Device,:pointer], :cl_int
3829
+ attach_function :clCreateProgramWithIL, [Context,:pointer,:size_t,:pointer], Program
3830
+ attach_function :clCloneKernel, [Kernel,:pointer], Kernel
3831
+ attach_function :clGetKernelSubGroupInfo, [Kernel,Device,:cl_kernel_sub_group_info,:size_t,:pointer,:size_t,:pointer,:pointer], :cl_int
3832
+ attach_function :clEnqueueSVMMigrateMem, [CommandQueue,:cl_uint,:pointer,:pointer,:cl_mem_migration_flags,:cl_uint,:pointer,:pointer], :cl_int
3833
+ rescue FFI::NotFoundError => e
3834
+ warn "Warning OpenCL 2.0 loader detected!"
3835
+ end
3771
3836
  rescue FFI::NotFoundError => e
3772
3837
  warn "Warning OpenCL 1.2 loader detected!"
3773
3838
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'opencl_ruby_ffi'
3
- s.version = "1.0.4"
3
+ s.version = "1.0.5"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "brice.videau@imag.fr"
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.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Videau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: narray