opencl_ruby_ffi 1.3.3 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/opencl_ruby_ffi/Buffer.rb +7 -1
- data/lib/opencl_ruby_ffi/CommandQueue.rb +27 -12
- data/lib/opencl_ruby_ffi/Context.rb +79 -7
- data/lib/opencl_ruby_ffi/Device.rb +95 -13
- data/lib/opencl_ruby_ffi/Event.rb +13 -4
- data/lib/opencl_ruby_ffi/Image.rb +7 -1
- data/lib/opencl_ruby_ffi/Kernel.rb +30 -10
- data/lib/opencl_ruby_ffi/Mem.rb +28 -12
- data/lib/opencl_ruby_ffi/Pipe.rb +8 -0
- data/lib/opencl_ruby_ffi/Platform.rb +33 -6
- data/lib/opencl_ruby_ffi/Program.rb +127 -14
- data/lib/opencl_ruby_ffi/SVM.rb +23 -11
- data/lib/opencl_ruby_ffi/Sampler.rb +2 -1
- data/lib/opencl_ruby_ffi/ext.rb +1 -0
- data/lib/opencl_ruby_ffi/intel/accelerator.rb +152 -0
- data/lib/opencl_ruby_ffi/intel/advanced_motion_estimation.rb +65 -0
- data/lib/opencl_ruby_ffi/intel/driver_diagnostics.rb +19 -0
- data/lib/opencl_ruby_ffi/intel/kernel_profiling.rb +38 -0
- data/lib/opencl_ruby_ffi/intel/motion_estimation.rb +26 -0
- data/lib/opencl_ruby_ffi/intel/unified_shared_memory_preview.rb +586 -0
- data/lib/opencl_ruby_ffi/intel/unofficial.rb +95 -0
- data/lib/opencl_ruby_ffi/khr/device_uuid.rb +119 -0
- data/lib/opencl_ruby_ffi/opencl_arithmetic_gen.rb +220 -110
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb +249 -18
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb +115 -7
- data/lib/opencl_ruby_ffi/opencl_types.rb +4 -0
- data/opencl_ruby_ffi.gemspec +4 -5
- metadata +13 -6
@@ -35,7 +35,7 @@ module OpenCL
|
|
35
35
|
class Union < FFI::Union
|
36
36
|
end
|
37
37
|
|
38
|
-
@@callbacks =
|
38
|
+
@@callbacks = {}
|
39
39
|
|
40
40
|
# Maps the :cl_image_fomat type of OpenCL
|
41
41
|
class ImageFormat < Struct
|
@@ -126,6 +126,76 @@ module OpenCL
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
class Version
|
130
|
+
include Comparable
|
131
|
+
MAJOR_BITS = 10
|
132
|
+
MINOR_BITS = 10
|
133
|
+
PATCH_BITS = 12
|
134
|
+
MAJOR_MASK = (1 << MAJOR_BITS) - 1
|
135
|
+
MINOR_MASK = (1 << MINOR_BITS) - 1
|
136
|
+
PATCH_MASK = (1 << PATCH_BITS) - 1
|
137
|
+
|
138
|
+
attr_reader :major, :minor, :patch
|
139
|
+
def initialize(major, minor = 0, patch = 0)
|
140
|
+
@major = major
|
141
|
+
@minor = minor
|
142
|
+
@patch = patch
|
143
|
+
end
|
144
|
+
|
145
|
+
def to_int
|
146
|
+
Version.make(@major, @minor, @patch)
|
147
|
+
end
|
148
|
+
alias to_i to_int
|
149
|
+
|
150
|
+
def <=>(other)
|
151
|
+
res = (@major <=> other.major)
|
152
|
+
res = (@minor <=> other.minor) if res == 0
|
153
|
+
res = (@patch <=> other.patch) if res == 0
|
154
|
+
res
|
155
|
+
end
|
156
|
+
|
157
|
+
def to_s
|
158
|
+
"#{@major}.#{@minor}.#{@patch}"
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.major(v)
|
162
|
+
v >> (MINOR_BITS + PATCH_BITS)
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.minor(v)
|
166
|
+
(v >> (PATCH_BITS)) & MINOR_MASK
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.patch(v)
|
170
|
+
v & PATCH_MASK
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.make(major, minor = 0, patch = 0)
|
174
|
+
((major & MAJOR_MASK) << (MINOR_BITS + PATCH_BITS)) +
|
175
|
+
((minor & MINOR_MASK) << PATCH_BITS) +
|
176
|
+
(patch & PATCH_MASK)
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.from_int(v)
|
180
|
+
self.new(major(v), minor(v), patch(v))
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
# Maps the :cl_name_version type of OpenCL
|
185
|
+
class NameVersion < Struct
|
186
|
+
MAX_NAME_SIZE = 64
|
187
|
+
layout :version, :cl_version,
|
188
|
+
:name, [:char, MAX_NAME_SIZE]
|
189
|
+
|
190
|
+
def version
|
191
|
+
Version.from_int(self[:version])
|
192
|
+
end
|
193
|
+
|
194
|
+
def name
|
195
|
+
self[:name].to_s
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
129
199
|
module InnerInterface
|
130
200
|
|
131
201
|
private
|
@@ -169,7 +239,7 @@ module OpenCL
|
|
169
239
|
end
|
170
240
|
return properties
|
171
241
|
end
|
172
|
-
|
242
|
+
|
173
243
|
# Extracts the origin_symbol and region_symbol named options for image from the given hash. Returns the read (or detemined suitable) origin and region in a tuple
|
174
244
|
def get_origin_region( image, options, origin_symbol, region_symbol )
|
175
245
|
origin = MemoryPointer::new( :size_t, 3 )
|
@@ -214,6 +284,19 @@ module OpenCL
|
|
214
284
|
return properties
|
215
285
|
end
|
216
286
|
|
287
|
+
# EXtracts the :properties named option (for a Mem) from the hash given and returns the properties values
|
288
|
+
def get_mem_properties( options )
|
289
|
+
properties = nil
|
290
|
+
if options[:properties] then
|
291
|
+
properties = MemoryPointer::new( :cl_mem_properties, options[:properties].length + 1 )
|
292
|
+
options[:properties].each_with_index { |e,i|
|
293
|
+
properties[i].write_cl_mem_properties(e.respond_to?(:to_ptr) ? e : e.to_i)
|
294
|
+
}
|
295
|
+
properties[options[:properties].length].write_cl_mem_properties(0)
|
296
|
+
end
|
297
|
+
return properties
|
298
|
+
end
|
299
|
+
|
217
300
|
# Extracts the :device_list named option from the hash given and returns [ number of devices, an Pointer to the list of Device or nil ]
|
218
301
|
def get_device_list( options )
|
219
302
|
devices = options[:device_list]
|
@@ -248,6 +331,7 @@ module OpenCL
|
|
248
331
|
:cl_command_queue_properties => CommandQueue::Properties,
|
249
332
|
:cl_device_affinity_domain => Device::AffinityDomain,
|
250
333
|
:cl_device_svm_capabilities => Device::SVMCapabilities,
|
334
|
+
:cl_device_atomic_capabilities => Device::AtomicCapabilities,
|
251
335
|
:cl_channel_order => ChannelOrder,
|
252
336
|
:cl_channel_type => ChannelType,
|
253
337
|
:cl_mem_flags => Mem::Flags,
|
@@ -284,27 +368,156 @@ module OpenCL
|
|
284
368
|
include InnerInterface
|
285
369
|
end
|
286
370
|
|
371
|
+
module ExtensionInnerGenerator
|
372
|
+
|
373
|
+
private
|
374
|
+
|
375
|
+
# @!macro [attach] get_info_ext
|
376
|
+
# @!method $3
|
377
|
+
# Returns the OpenCL::$1::$3 info
|
378
|
+
# @return $2
|
379
|
+
def get_info_ext(klass, type, name, function, memoizable = false)
|
380
|
+
if memoizable
|
381
|
+
s = <<EOF
|
382
|
+
def #{name.downcase}
|
383
|
+
return @_#{name.downcase} if @_#{name.downcase}
|
384
|
+
f = platform.get_extension_function("#{function}", :cl_int, [#{klass}, :cl_uint, :size_t, :pointer, :pointer])
|
385
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
386
|
+
|
387
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
388
|
+
error = f.call(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
389
|
+
error_check(error)
|
390
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
391
|
+
error = f.call(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
392
|
+
error_check(error)
|
393
|
+
if(convert_type(:#{type})) then
|
394
|
+
@_#{name.downcase} = convert_type(:#{type})::new(ptr2.read_#{type})
|
395
|
+
else
|
396
|
+
@_#{name.downcase} = ptr2.read_#{type}
|
397
|
+
end
|
398
|
+
return @_#{name.downcase}
|
399
|
+
end
|
400
|
+
EOF
|
401
|
+
else
|
402
|
+
s = <<EOF
|
403
|
+
def #{name.downcase}
|
404
|
+
f = platform.get_extension_function("#{function}", :cl_int, [#{klass}, :cl_uint, :size_t, :pointer, :pointer])
|
405
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
406
|
+
|
407
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
408
|
+
error = f.call(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
409
|
+
error_check(error)
|
410
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
411
|
+
error = f.call(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
412
|
+
error_check(error)
|
413
|
+
if(convert_type(:#{type})) then
|
414
|
+
return convert_type(:#{type})::new(ptr2.read_#{type})
|
415
|
+
else
|
416
|
+
return ptr2.read_#{type}
|
417
|
+
end
|
418
|
+
end
|
419
|
+
EOF
|
420
|
+
end
|
421
|
+
if type == :cl_bool then
|
422
|
+
s += <<EOF
|
423
|
+
def #{name.downcase}?
|
424
|
+
#{name.downcase} == 0 ? false : true
|
425
|
+
end
|
426
|
+
EOF
|
427
|
+
end
|
428
|
+
module_eval s
|
429
|
+
end
|
430
|
+
|
431
|
+
# @!macro [attach] get_info_array_ext
|
432
|
+
# @!method $3
|
433
|
+
# Returns the OpenCL::$1::$3 info
|
434
|
+
# @return an Array of $2
|
435
|
+
def get_info_array_ext(klass, type, name, function, memoizable = false)
|
436
|
+
if memoizable
|
437
|
+
s = <<EOF
|
438
|
+
def #{name.downcase}
|
439
|
+
return @_#{name.downcase} if @_#{name.downcase}
|
440
|
+
f = platform.get_extension_function("#{function}", :cl_int, [#{klass}, :cl_uint, :size_t, :pointer, :pointer])
|
441
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
442
|
+
|
443
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
444
|
+
error = f.call(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
445
|
+
error_check(error)
|
446
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
447
|
+
error = f.call(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
448
|
+
error_check(error)
|
449
|
+
arr = ptr2.get_array_of_#{type}(0, ptr1.read_size_t / OpenCL.find_type(:#{type}).size)
|
450
|
+
if(convert_type(:#{type})) then
|
451
|
+
@_#{name.downcase} = arr.collect { |e| convert_type(:#{type})::new(e) }
|
452
|
+
else
|
453
|
+
@_#{name.downcase} = arr
|
454
|
+
end
|
455
|
+
return @_#{name.downcase}
|
456
|
+
end
|
457
|
+
EOF
|
458
|
+
else
|
459
|
+
s = <<EOF
|
460
|
+
def #{name.downcase}
|
461
|
+
f = platform.get_extension_function("#{function}", :cl_int, [#{klass}, :cl_uint, :size_t, :pointer, :pointer])
|
462
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
463
|
+
|
464
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
465
|
+
error = f.call(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
466
|
+
error_check(error)
|
467
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
468
|
+
error = f.call(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
469
|
+
error_check(error)
|
470
|
+
arr = ptr2.get_array_of_#{type}(0, ptr1.read_size_t / OpenCL.find_type(:#{type}).size)
|
471
|
+
if(convert_type(:#{type})) then
|
472
|
+
return arr.collect { |e| convert_type(:#{type})::new(e) }
|
473
|
+
else
|
474
|
+
return arr
|
475
|
+
end
|
476
|
+
end
|
477
|
+
EOF
|
478
|
+
end
|
479
|
+
module_eval s
|
480
|
+
end
|
481
|
+
|
482
|
+
end
|
483
|
+
private_constant :ExtensionInnerGenerator
|
484
|
+
|
287
485
|
module InnerGenerator
|
288
486
|
|
289
487
|
private
|
290
488
|
|
291
|
-
# Generates a new method for klass that use the apropriate clGetKlassInfo, to read an info of the given type. The info queried is specified by name.
|
292
|
-
# @param [String] klass the property is to be found
|
293
|
-
# @param [Symbol] type of the property
|
294
|
-
# @param [String] name of the property
|
295
489
|
# @!macro [attach] get_info
|
296
490
|
# @!method $3
|
297
491
|
# Returns the OpenCL::$1::$3 info
|
298
492
|
# @return $2
|
299
|
-
def get_info(klass, type, name)
|
493
|
+
def get_info(klass, type, name, memoizable = false)
|
300
494
|
klass_name = klass
|
301
495
|
klass_name = "MemObject" if klass == "Mem"
|
496
|
+
if memoizable
|
302
497
|
s = <<EOF
|
303
498
|
def #{name.downcase}
|
304
|
-
|
499
|
+
return @_#{name.downcase} if @_#{name.downcase}
|
500
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
305
501
|
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
306
502
|
error_check(error)
|
307
|
-
ptr2 = MemoryPointer::new(
|
503
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
504
|
+
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
505
|
+
error_check(error)
|
506
|
+
if(convert_type(:#{type})) then
|
507
|
+
@_#{name.downcase} = convert_type(:#{type})::new(ptr2.read_#{type})
|
508
|
+
else
|
509
|
+
@_#{name.downcase} = ptr2.read_#{type}
|
510
|
+
end
|
511
|
+
return @_#{name.downcase}
|
512
|
+
end
|
513
|
+
EOF
|
514
|
+
else
|
515
|
+
s = <<EOF
|
516
|
+
def #{name.downcase}
|
517
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
518
|
+
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
519
|
+
error_check(error)
|
520
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
308
521
|
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
309
522
|
error_check(error)
|
310
523
|
if(convert_type(:#{type})) then
|
@@ -314,6 +527,7 @@ module OpenCL
|
|
314
527
|
end
|
315
528
|
end
|
316
529
|
EOF
|
530
|
+
end
|
317
531
|
if type == :cl_bool then
|
318
532
|
s += <<EOF
|
319
533
|
def #{name.downcase}?
|
@@ -324,26 +538,42 @@ EOF
|
|
324
538
|
module_eval s
|
325
539
|
end
|
326
540
|
|
327
|
-
# Generates a new method for klass that use the apropriate clGetKlassInfo, to read an Array of element of the given type. The info queried is specified by name.
|
328
|
-
# @param [String] klass the property is to be found
|
329
|
-
# @param [Symbol] type of the property
|
330
|
-
# @param [String] name of the property
|
331
541
|
# @!macro [attach] get_info_array
|
332
542
|
# @!method $3
|
333
543
|
# Returns the OpenCL::$1::$3 info
|
334
544
|
# @return an Array of $2
|
335
|
-
def get_info_array(klass, type, name)
|
545
|
+
def get_info_array(klass, type, name, memoizable = false)
|
336
546
|
klass_name = klass
|
337
547
|
klass_name = "MemObject" if klass == "Mem"
|
338
|
-
|
548
|
+
if memoizable
|
549
|
+
s = <<EOF
|
550
|
+
def #{name.downcase}
|
551
|
+
return @_#{name.downcase} if @_#{name.downcase}
|
552
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
553
|
+
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
554
|
+
error_check(error)
|
555
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
556
|
+
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
557
|
+
error_check(error)
|
558
|
+
arr = ptr2.get_array_of_#{type}(0, ptr1.read_size_t / OpenCL.find_type(:#{type}).size)
|
559
|
+
if(convert_type(:#{type})) then
|
560
|
+
@_#{name.downcase} = arr.collect { |e| convert_type(:#{type})::new(e) }
|
561
|
+
else
|
562
|
+
@_#{name.downcase} = arr
|
563
|
+
end
|
564
|
+
return @_#{name.downcase}
|
565
|
+
end
|
566
|
+
EOF
|
567
|
+
else
|
568
|
+
s = <<EOF
|
339
569
|
def #{name.downcase}
|
340
|
-
ptr1 = MemoryPointer::new(
|
570
|
+
ptr1 = MemoryPointer::new(:size_t, 1)
|
341
571
|
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, 0, nil, ptr1)
|
342
572
|
error_check(error)
|
343
|
-
ptr2 = MemoryPointer::new(
|
573
|
+
ptr2 = MemoryPointer::new(ptr1.read_size_t)
|
344
574
|
error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name.upcase}, ptr1.read_size_t, ptr2, nil)
|
345
575
|
error_check(error)
|
346
|
-
arr = ptr2.get_array_of_#{type}(0, ptr1.read_size_t/ OpenCL.find_type(:#{type}).size)
|
576
|
+
arr = ptr2.get_array_of_#{type}(0, ptr1.read_size_t / OpenCL.find_type(:#{type}).size)
|
347
577
|
if(convert_type(:#{type})) then
|
348
578
|
return arr.collect { |e| convert_type(:#{type})::new(e) }
|
349
579
|
else
|
@@ -351,6 +581,7 @@ EOF
|
|
351
581
|
end
|
352
582
|
end
|
353
583
|
EOF
|
584
|
+
end
|
354
585
|
module_eval s
|
355
586
|
end
|
356
587
|
|
@@ -2,7 +2,11 @@ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
|
|
2
2
|
# Maps the OpenCL API using FFI
|
3
3
|
module OpenCL
|
4
4
|
begin
|
5
|
-
|
5
|
+
if ENV["LIBOPENCL_SO"]
|
6
|
+
ffi_lib ENV["LIBOPENCL_SO"]
|
7
|
+
else
|
8
|
+
raise LoadError
|
9
|
+
end
|
6
10
|
rescue LoadError => e
|
7
11
|
begin
|
8
12
|
ffi_lib "OpenCL"
|
@@ -79,12 +83,15 @@ module OpenCL
|
|
79
83
|
INVALID_DEVICE_PARTITION_COUNT = -68
|
80
84
|
INVALID_PIPE_SIZE = -69
|
81
85
|
INVALID_DEVICE_QUEUE = -70
|
86
|
+
INVALID_SPEC_ID = -71
|
87
|
+
MAX_SIZE_RESTRICTION_EXCEEDED = -72
|
82
88
|
INVALID_PARTITION_NAME_EXT = -1059
|
83
89
|
VERSION_1_0 = 1
|
84
90
|
VERSION_1_1 = 1
|
85
91
|
VERSION_1_2 = 1
|
86
92
|
VERSION_2_0 = 1
|
87
93
|
VERSION_2_1 = 1
|
94
|
+
VERSION_2_2 = 1
|
88
95
|
FALSE = 0
|
89
96
|
TRUE = 1
|
90
97
|
BLOCKING = TRUE
|
@@ -95,6 +102,8 @@ module OpenCL
|
|
95
102
|
PLATFORM_VENDOR = 0x0903
|
96
103
|
PLATFORM_EXTENSIONS = 0x0904
|
97
104
|
PLATFORM_HOST_TIMER_RESOLUTION = 0x0905
|
105
|
+
PLATFORM_NUMERIC_VERSION = 0x0906
|
106
|
+
PLATFORM_EXTENSIONS_WITH_VERSION = 0x0907
|
98
107
|
DEVICE_TYPE_DEFAULT = (1 << 0)
|
99
108
|
DEVICE_TYPE_CPU = (1 << 1)
|
100
109
|
DEVICE_TYPE_GPU = (1 << 2)
|
@@ -194,6 +203,20 @@ module OpenCL
|
|
194
203
|
DEVICE_IL_VERSION = 0x105B
|
195
204
|
DEVICE_MAX_NUM_SUB_GROUPS = 0x105C
|
196
205
|
DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 0x105D
|
206
|
+
DEVICE_NUMERIC_VERSION = 0x105E
|
207
|
+
DEVICE_EXTENSIONS_WITH_VERSION = 0x1060
|
208
|
+
DEVICE_ILS_WITH_VERSION = 0x1061
|
209
|
+
DEVICE_BUILT_IN_KERNELS_WITH_VERSION = 0x1062
|
210
|
+
DEVICE_ATOMIC_MEMORY_CAPABILITIES = 0x1063
|
211
|
+
DEVICE_ATOMIC_FENCE_CAPABILITIES = 0x1064
|
212
|
+
DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT = 0x1065
|
213
|
+
DEVICE_OPENCL_C_ALL_VERSIONS = 0x1066
|
214
|
+
DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x1067
|
215
|
+
DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT = 0x1068
|
216
|
+
DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT = 0x1069
|
217
|
+
DEVICE_OPENCL_C_FEATURES = 0x106F
|
218
|
+
DEVICE_DEVICE_ENQUEUE_SUPPORT = 0x1070
|
219
|
+
DEVICE_PIPE_SUPPORT = 0x1071
|
197
220
|
FP_DENORM = (1 << 0)
|
198
221
|
FP_INF_NAN = (1 << 1)
|
199
222
|
FP_ROUND_TO_NEAREST = (1 << 2)
|
@@ -233,12 +256,20 @@ module OpenCL
|
|
233
256
|
DEVICE_SVM_FINE_GRAIN_BUFFER = (1 << 1)
|
234
257
|
DEVICE_SVM_FINE_GRAIN_SYSTEM = (1 << 2)
|
235
258
|
DEVICE_SVM_ATOMICS = (1 << 3)
|
259
|
+
DEVICE_ATOMIC_ORDER_RELAXED = (1 << 0)
|
260
|
+
DEVICE_ATOMIC_ORDER_ACQ_REL = (1 << 1)
|
261
|
+
DEVICE_ATOMIC_ORDER_SEQ_CST = (1 << 2)
|
262
|
+
DEVICE_ATOMIC_SCOPE_WORK_ITEM = (1 << 3)
|
263
|
+
DEVICE_ATOMIC_SCOPE_WORK_GROUP = (1 << 4)
|
264
|
+
DEVICE_ATOMIC_SCOPE_DEVICE = (1 << 5)
|
265
|
+
DEVICE_ATOMIC_SCOPE_ALL_DEVICES = (1 << 6)
|
236
266
|
QUEUE_CONTEXT = 0x1090
|
237
267
|
QUEUE_DEVICE = 0x1091
|
238
268
|
QUEUE_REFERENCE_COUNT = 0x1092
|
239
269
|
QUEUE_PROPERTIES = 0x1093
|
240
270
|
QUEUE_SIZE = 0x1094
|
241
271
|
QUEUE_DEVICE_DEFAULT = 0x1095
|
272
|
+
QUEUE_PROPERTIES_ARRAY = 0x1098
|
242
273
|
MEM_READ_WRITE = (1 << 0)
|
243
274
|
MEM_WRITE_ONLY = (1 << 1)
|
244
275
|
MEM_READ_ONLY = (1 << 2)
|
@@ -316,6 +347,7 @@ module OpenCL
|
|
316
347
|
MEM_ASSOCIATED_MEMOBJECT = 0x1107
|
317
348
|
MEM_OFFSET = 0x1108
|
318
349
|
MEM_USES_SVM_POINTER = 0x1109
|
350
|
+
MEM_PROPERTIES = 0x110A
|
319
351
|
IMAGE_FORMAT = 0x1110
|
320
352
|
IMAGE_ELEMENT_SIZE = 0x1111
|
321
353
|
IMAGE_ROW_PITCH = 0x1112
|
@@ -329,6 +361,7 @@ module OpenCL
|
|
329
361
|
IMAGE_NUM_SAMPLES = 0x111A
|
330
362
|
PIPE_PACKET_SIZE = 0x1120
|
331
363
|
PIPE_MAX_PACKETS = 0x1121
|
364
|
+
PIPE_PROPERTIES = 0x1122
|
332
365
|
ADDRESS_NONE = 0x1130
|
333
366
|
ADDRESS_CLAMP_TO_EDGE = 0x1131
|
334
367
|
ADDRESS_CLAMP = 0x1132
|
@@ -357,6 +390,8 @@ module OpenCL
|
|
357
390
|
PROGRAM_NUM_KERNELS = 0x1167
|
358
391
|
PROGRAM_KERNEL_NAMES = 0x1168
|
359
392
|
PROGRAM_IL = 0x1169
|
393
|
+
PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT = 0x116A
|
394
|
+
PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT = 0x116B
|
360
395
|
PROGRAM_BUILD_STATUS = 0x1181
|
361
396
|
PROGRAM_BUILD_OPTIONS = 0x1182
|
362
397
|
PROGRAM_BUILD_LOG = 0x1183
|
@@ -442,6 +477,7 @@ module OpenCL
|
|
442
477
|
COMMAND_SVM_MEMFILL = 0x120B
|
443
478
|
COMMAND_SVM_MAP = 0x120C
|
444
479
|
COMMAND_SVM_UNMAP = 0x120D
|
480
|
+
COMMAND_SVM_MIGRATE_MEM = 0x120E
|
445
481
|
COMPLETE = 0x0
|
446
482
|
RUNNING = 0x1
|
447
483
|
SUBMITTED = 0x2
|
@@ -473,6 +509,13 @@ module OpenCL
|
|
473
509
|
MEM_HOST_WRITETHROUGH_QCOM = 0x40A6
|
474
510
|
MEM_HOST_WRITE_COMBINING_QCOM = 0x40A7
|
475
511
|
MEM_ION_HOST_PTR_QCOM = 0x40A8
|
512
|
+
NAME_VERSION_MAX_NAME_SIZE = 64
|
513
|
+
VERSION_MAJOR_BITS = 10
|
514
|
+
VERSION_MINOR_BITS = 10
|
515
|
+
VERSION_PATCH_BITS = 12
|
516
|
+
VERSION_MAJOR_MASK = (1 << VERSION_MAJOR_BITS) - 1
|
517
|
+
VERSION_MINOR_MASK = (1 << VERSION_MINOR_BITS) - 1
|
518
|
+
VERSION_PATCH_MASK = (1 << VERSION_PATCH_BITS) - 1
|
476
519
|
# Parent class to map OpenCL errors, and is used to raise unknown errors
|
477
520
|
class Error < StandardError
|
478
521
|
attr_reader :code
|
@@ -593,6 +636,8 @@ EOF
|
|
593
636
|
[:INVALID_DEVICE_PARTITION_COUNT, :InvalidDevicePartitionCount],
|
594
637
|
[:INVALID_PIPE_SIZE, :InvalidPipeSize],
|
595
638
|
[:INVALID_DEVICE_QUEUE, :InvalidDeviceQueue],
|
639
|
+
[:INVALID_SPEC_ID, :InvalidSpecID],
|
640
|
+
[:MAX_SIZE_RESTRICTION_EXCEEDED, :MaxSizeRestrictionExceeded],
|
596
641
|
[:INVALID_PARTITION_NAME_EXT, :InvalidPartitionNameEXT]
|
597
642
|
].each { |name, capitalized_name|
|
598
643
|
eval error_class_constructor( name, capitalized_name )
|
@@ -684,8 +729,7 @@ EOF
|
|
684
729
|
|
685
730
|
# Returns true if flag is bitwise included in the Bitfield
|
686
731
|
def include?(flag)
|
687
|
-
return
|
688
|
-
return false
|
732
|
+
return ( @val & flag ) == flag
|
689
733
|
end
|
690
734
|
|
691
735
|
# Returns a String corresponding to the Bitfield description
|
@@ -733,7 +777,7 @@ EOF
|
|
733
777
|
return @val
|
734
778
|
end
|
735
779
|
|
736
|
-
#
|
780
|
+
# Sets the internal representation of the Bitfield to val
|
737
781
|
def flags=(val)
|
738
782
|
@val = val
|
739
783
|
end
|
@@ -751,7 +795,7 @@ EOF
|
|
751
795
|
# @!parse include $2
|
752
796
|
# @private
|
753
797
|
def self.register_extension(name, mod, cond)
|
754
|
-
self.send(:
|
798
|
+
self.send(:prepend, mod)
|
755
799
|
end
|
756
800
|
|
757
801
|
else
|
@@ -788,6 +832,8 @@ EOF
|
|
788
832
|
VENDOR = 0x0903
|
789
833
|
EXTENSIONS = 0x0904
|
790
834
|
HOST_TIMER_RESOLUTION = 0x0905
|
835
|
+
NUMERIC_VERSION = 0x0906
|
836
|
+
EXTENSIONS_WITH_VERSION = 0x0907
|
791
837
|
|
792
838
|
# Creates a new Platform and retains it if specified and aplicable
|
793
839
|
def initialize(ptr, retain = true)
|
@@ -903,6 +949,20 @@ EOF
|
|
903
949
|
IL_VERSION = 0x105B
|
904
950
|
MAX_NUM_SUB_GROUPS = 0x105C
|
905
951
|
SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 0x105D
|
952
|
+
NUMERIC_VERSION = 0x105E
|
953
|
+
EXTENSIONS_WITH_VERSION = 0x1060
|
954
|
+
ILS_WITH_VERSION = 0x1061
|
955
|
+
BUILT_IN_KERNELS_WITH_VERSION = 0x1062
|
956
|
+
ATOMIC_MEMORY_CAPABILITIES = 0x1063
|
957
|
+
ATOMIC_FENCE_CAPABILITIES = 0x1064
|
958
|
+
NON_UNIFORM_WORK_GROUP_SUPPORT = 0x1065
|
959
|
+
OPENCL_C_ALL_VERSIONS = 0x1066
|
960
|
+
PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x1067
|
961
|
+
WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT = 0x1068
|
962
|
+
GENERIC_ADDRESS_SPACE_SUPPORT = 0x1069
|
963
|
+
OPENCL_C_FEATURES = 0x106F
|
964
|
+
DEVICE_ENQUEUE_SUPPORT = 0x1070
|
965
|
+
PIPE_SUPPORT = 0x1071
|
906
966
|
PARTITION_EQUALLY = 0x1086
|
907
967
|
PARTITION_BY_COUNTS = 0x1087
|
908
968
|
PARTITION_BY_COUNTS_LIST_END = 0x0
|
@@ -918,6 +978,13 @@ EOF
|
|
918
978
|
SVM_FINE_GRAIN_SYSTEM = (1 << 2)
|
919
979
|
SVM_ATOMICS = (1 << 3)
|
920
980
|
PAGE_SIZE_QCOM = 0x40A1
|
981
|
+
ATOMIC_ORDER_RELAXED = (1 << 0)
|
982
|
+
ATOMIC_ORDER_ACQ_REL = (1 << 1)
|
983
|
+
ATOMIC_ORDER_SEQ_CST = (1 << 2)
|
984
|
+
ATOMIC_SCOPE_WORK_ITEM = (1 << 3)
|
985
|
+
ATOMIC_SCOPE_WORK_GROUP = (1 << 4)
|
986
|
+
ATOMIC_SCOPE_DEVICE = (1 << 5)
|
987
|
+
ATOMIC_SCOPE_ALL_DEVICES = (1 << 6)
|
921
988
|
|
922
989
|
#DEFINED in ext/device_fission.rb
|
923
990
|
# # Creates a new Device and retains it if specified and aplicable
|
@@ -1068,6 +1135,25 @@ EOF
|
|
1068
1135
|
end
|
1069
1136
|
end
|
1070
1137
|
|
1138
|
+
# Bitfield that maps the :cl_device_atomic_capabilities
|
1139
|
+
class AtomicCapabilities < Bitfield
|
1140
|
+
ORDER_RELAXED = (1 << 0)
|
1141
|
+
ORDER_ACQ_REL = (1 << 1)
|
1142
|
+
ORDER_SEQ_CST = (1 << 2)
|
1143
|
+
SCOPE_WORK_ITEM = (1 << 3)
|
1144
|
+
SCOPE_WORK_GROUP = (1 << 4)
|
1145
|
+
SCOPE_DEVICE = (1 << 5)
|
1146
|
+
SCOPE_ALL_DEVICES = (1 << 6)
|
1147
|
+
# Returns an Array of String representing the different flags set
|
1148
|
+
def names
|
1149
|
+
fs = []
|
1150
|
+
%w( ORDER_RELAXED ORDER_ACQ_REL ORDER_SEQ_CST SCOPE_WORK_ITEM SCOPE_WORK_GROUP SCOPE_DEVICE SCOPE_ALL_DEVICES ).each { |f|
|
1151
|
+
fs.push(f) if self.include?( self.class.const_get(f) )
|
1152
|
+
}
|
1153
|
+
return fs
|
1154
|
+
end
|
1155
|
+
end
|
1156
|
+
|
1071
1157
|
end
|
1072
1158
|
class Context < ExtendedStruct
|
1073
1159
|
layout :dummy, :pointer
|
@@ -1121,6 +1207,7 @@ EOF
|
|
1121
1207
|
PROPERTIES = 0x1093
|
1122
1208
|
SIZE = 0x1094
|
1123
1209
|
DEVICE_DEFAULT = 0x1095
|
1210
|
+
PROPERTIES_ARRAY = 0x1098
|
1124
1211
|
# Creates a new CommandQueue and retains it if specified and aplicable
|
1125
1212
|
def initialize(ptr, retain = true)
|
1126
1213
|
super(ptr)
|
@@ -1191,6 +1278,7 @@ EOF
|
|
1191
1278
|
ASSOCIATED_MEMOBJECT = 0x1107
|
1192
1279
|
OFFSET = 0x1108
|
1193
1280
|
USES_SVM_POINTER = 0x1109
|
1281
|
+
PROPERTIES = 0x110A
|
1194
1282
|
HOST_UNCACHED_QCOM = 0x40A4
|
1195
1283
|
HOST_WRITEBACK_QCOM = 0x40A5
|
1196
1284
|
HOST_WRITETHROUGH_QCOM = 0x40A6
|
@@ -1308,6 +1396,8 @@ EOF
|
|
1308
1396
|
NUM_KERNELS = 0x1167
|
1309
1397
|
KERNEL_NAMES = 0x1168
|
1310
1398
|
IL = 0x1169
|
1399
|
+
SCOPE_GLOBAL_CTORS_PRESENT = 0x116A
|
1400
|
+
SCOPE_GLOBAL_DTORS_PRESENT = 0x116B
|
1311
1401
|
BUILD_STATUS = 0x1181
|
1312
1402
|
BUILD_OPTIONS = 0x1182
|
1313
1403
|
BUILD_LOG = 0x1183
|
@@ -1724,6 +1814,7 @@ EOF
|
|
1724
1814
|
SVM_MEMFILL = 0x120B
|
1725
1815
|
SVM_MAP = 0x120C
|
1726
1816
|
SVM_UNMAP = 0x120D
|
1817
|
+
SVM_MIGRATE_MEM = 0x120E
|
1727
1818
|
@codes = {}
|
1728
1819
|
@codes[0x11F0] = 'NDRANGE_KERNEL'
|
1729
1820
|
@codes[0x11F1] = 'TASK'
|
@@ -1755,6 +1846,7 @@ EOF
|
|
1755
1846
|
@codes[0x120B] = 'SVM_MEMFILL'
|
1756
1847
|
@codes[0x120C] = 'SVM_MAP'
|
1757
1848
|
@codes[0x120D] = 'SVM_UNMAP'
|
1849
|
+
@codes[0x120E] = 'SVM_MIGRATE_MEM'
|
1758
1850
|
end
|
1759
1851
|
|
1760
1852
|
# Enum that maps the :cl_gl_object_type type
|
@@ -1826,14 +1918,15 @@ EOF
|
|
1826
1918
|
layout :dummy, :pointer
|
1827
1919
|
PACKET_SIZE = 0x1120
|
1828
1920
|
MAX_PACKETS = 0x1121
|
1921
|
+
PROPERTIES = 0x1122
|
1829
1922
|
end
|
1830
1923
|
attach_function :clGetPlatformIDs, [:cl_uint,:pointer,:pointer], :cl_int
|
1831
1924
|
attach_function :clGetPlatformInfo, [Platform,:cl_platform_info,:size_t,:pointer,:pointer], :cl_int
|
1832
1925
|
attach_function :clGetDeviceIDs, [Platform,:cl_device_type,:cl_uint,:pointer,:pointer], :cl_int
|
1833
1926
|
attach_function :clGetDeviceInfo, [Device,:cl_device_info,:size_t,:pointer,:pointer], :cl_int
|
1834
|
-
callback :clCreateContext_notify, [:
|
1927
|
+
callback :clCreateContext_notify, [:string,:pointer,:size_t,:pointer], :void
|
1835
1928
|
attach_function :clCreateContext, [:pointer,:cl_uint,:pointer,:clCreateContext_notify,:pointer,:pointer], Context
|
1836
|
-
callback :clCreateContextFromType_notify, [:
|
1929
|
+
callback :clCreateContextFromType_notify, [:string,:pointer,:size_t,:pointer], :void
|
1837
1930
|
attach_function :clCreateContextFromType, [:pointer,:cl_device_type,:clCreateContextFromType_notify,:pointer,:pointer], Context
|
1838
1931
|
attach_function :clRetainContext, [Context], :cl_int
|
1839
1932
|
attach_function :clReleaseContext, [Context], :cl_int
|
@@ -1957,6 +2050,21 @@ EOF
|
|
1957
2050
|
attach_function :clCloneKernel, [Kernel,:pointer], Kernel
|
1958
2051
|
attach_function :clGetKernelSubGroupInfo, [Kernel,Device,:cl_kernel_sub_group_info,:size_t,:pointer,:size_t,:pointer,:pointer], :cl_int
|
1959
2052
|
attach_function :clEnqueueSVMMigrateMem, [CommandQueue,:cl_uint,:pointer,:pointer,:cl_mem_migration_flags,:cl_uint,:pointer,:pointer], :cl_int
|
2053
|
+
begin # OpenCL 2.2
|
2054
|
+
callback :clSetProgramReleaseCallback_notify, [Program.by_ref,:pointer], :void
|
2055
|
+
attach_function :clSetProgramReleaseCallback, [Program,:clSetProgramReleaseCallback_notify,:pointer], :cl_int
|
2056
|
+
attach_function :clSetProgramSpecializationConstant, [Program,:cl_uint,:size_t,:pointer], :cl_int
|
2057
|
+
begin # OpenCL 3.0
|
2058
|
+
attach_function :clCreateBufferWithProperties, [Context,:pointer,:cl_mem_flags,:size_t,:pointer,:pointer], Mem
|
2059
|
+
attach_function :clCreateImageWithProperties, [Context,:pointer,:cl_mem_flags,:pointer,:pointer,:pointer,:pointer], Mem
|
2060
|
+
callback :clSetContextDestructorCallback_notify, [Context.by_ref,:pointer], :void
|
2061
|
+
attach_function :clSetContextDestructorCallback, [Context,:clSetContextDestructorCallback_notify,:pointer], :cl_int
|
2062
|
+
rescue NotFoundError => e
|
2063
|
+
warn "Warning OpenCL 2.2 loader detected!"
|
2064
|
+
end
|
2065
|
+
rescue NotFoundError => e
|
2066
|
+
warn "Warning OpenCL 2.1 loader detected!"
|
2067
|
+
end
|
1960
2068
|
rescue NotFoundError => e
|
1961
2069
|
warn "Warning OpenCL 2.0 loader detected!"
|
1962
2070
|
end
|