opencl_ruby_ffi 1.3.3 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/opencl_ruby_ffi/SVM.rb
CHANGED
@@ -5,7 +5,7 @@ module OpenCL
|
|
5
5
|
class SVMPointer < Pointer
|
6
6
|
|
7
7
|
# create a new SVMPointer from its address and the context it pertains to
|
8
|
-
def initialize( address, context,
|
8
|
+
def initialize( address, context, base = nil )
|
9
9
|
super( address )
|
10
10
|
@context = context
|
11
11
|
if base then
|
@@ -13,16 +13,20 @@ module OpenCL
|
|
13
13
|
else
|
14
14
|
@base = address
|
15
15
|
end
|
16
|
-
@size = size
|
17
16
|
end
|
18
17
|
|
19
18
|
def inspect
|
20
|
-
return "#<#{self.class.name}: #{
|
19
|
+
return "#<#{self.class.name}: 0x#{address.to_s(16)} (#{size})>"
|
20
|
+
end
|
21
|
+
|
22
|
+
def slice(offset, size)
|
23
|
+
res = super(offset, size)
|
24
|
+
return slef.class.new( res, @context, @base )
|
21
25
|
end
|
22
26
|
|
23
27
|
# creates a new SVMPointer relative to an existing one from an offset
|
24
28
|
def +( offset )
|
25
|
-
|
29
|
+
self.slice(offset, self.size - offset)
|
26
30
|
end
|
27
31
|
|
28
32
|
# frees the parent memory region associated to this SVMPointer
|
@@ -51,7 +55,7 @@ module OpenCL
|
|
51
55
|
alignment = options[:alignment] if options[:alignment]
|
52
56
|
ptr = clSVMAlloc( context, flags, size, alignment )
|
53
57
|
error_check(MEM_OBJECT_ALLOCATION_FAILURE) if ptr.null?
|
54
|
-
return SVMPointer::new( ptr,
|
58
|
+
return SVMPointer::new( ptr.slice(0, size), context )
|
55
59
|
end
|
56
60
|
|
57
61
|
# Frees an SVMPointer
|
@@ -112,11 +116,11 @@ module OpenCL
|
|
112
116
|
# * +command_queue+ - CommandQueue used to execute the write command
|
113
117
|
# * +dst_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be written to
|
114
118
|
# * +src_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be read from
|
115
|
-
# * +size+ - the size of data to copy
|
116
119
|
# * +options+ - a hash containing named options
|
117
120
|
#
|
118
121
|
# ==== Options
|
119
122
|
#
|
123
|
+
# * +:size+ - the size of data to copy
|
120
124
|
# * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
|
121
125
|
# * +:blocking_copy+ - if provided indicates if the command blocks until the copy finishes
|
122
126
|
# * +:blocking+ - if provided indicates if the command blocks until the copy finishes
|
@@ -124,10 +128,12 @@ module OpenCL
|
|
124
128
|
# ==== Returns
|
125
129
|
#
|
126
130
|
# the Event associated with the command
|
127
|
-
def self.enqueue_svm_memcpy(command_queue, dst_ptr, src_ptr,
|
131
|
+
def self.enqueue_svm_memcpy(command_queue, dst_ptr, src_ptr, options = {})
|
128
132
|
error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 2.0
|
129
133
|
blocking = FALSE
|
130
134
|
blocking = TRUE if options[:blocking] or options[:blocking_copy]
|
135
|
+
size = [dst_ptr.size, src_ptr.size].min
|
136
|
+
size = options[:size] if options[:size]
|
131
137
|
num_events, events = get_event_wait_list( options )
|
132
138
|
event = MemoryPointer::new( Event )
|
133
139
|
error = clEnqueueSVMMemcpy(command_queue, blocking, dst_ptr, src_ptr, size, num_events, events, event)
|
@@ -142,10 +148,10 @@ module OpenCL
|
|
142
148
|
# * +command_queue+ - CommandQueue used to execute the write command
|
143
149
|
# * +svm_ptr+ - the SVMPointer to the area to fill
|
144
150
|
# * +pattern+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area where the pattern is stored
|
145
|
-
# * +size+ - the size of the area to fill
|
146
151
|
#
|
147
152
|
# ==== Options
|
148
153
|
#
|
154
|
+
# * +:size+ - the size of the area to fill
|
149
155
|
# * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
|
150
156
|
# * +:pattern_size+ - if provided indicates the size of the pattern, else the maximum pattern data is used
|
151
157
|
#
|
@@ -157,24 +163,28 @@ module OpenCL
|
|
157
163
|
num_events, events = get_event_wait_list( options )
|
158
164
|
pattern_size = pattern.size
|
159
165
|
pattern_size = options[:pattern_size] if options[:pattern_size]
|
166
|
+
size = svm_ptr.size
|
167
|
+
size = options[:size] if options[:size]
|
160
168
|
event = MemoryPointer::new( Event )
|
161
169
|
error = clEnqueueSVMMemFill(command_queue, svm_ptr, pattern, pattern_size, size, num_events, events, event)
|
162
170
|
error_check(error)
|
163
171
|
return Event::new(event.read_pointer, false)
|
164
172
|
end
|
165
173
|
|
174
|
+
singleton_class.send(:alias_method, :enqueue_svm_mem_fill, :enqueue_svm_memfill)
|
175
|
+
|
166
176
|
# Enqueues a command to map an Image into host memory
|
167
177
|
#
|
168
178
|
# ==== Attributes
|
169
179
|
#
|
170
180
|
# * +command_queue+ - CommandQueue used to execute the map command
|
171
181
|
# * +svm_ptr+ - the SVMPointer to the area to map
|
172
|
-
# * +size+ - the size of the region to map
|
173
182
|
# * +map_flags+ - a single or an Array of :cl_map_flags flags
|
174
183
|
# * +options+ - a hash containing named options
|
175
184
|
#
|
176
185
|
# ==== Options
|
177
186
|
#
|
187
|
+
# * +:size+ - the size of the region to map
|
178
188
|
# * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
|
179
189
|
# * +:blocking_map+ - if provided indicates if the command blocks until the region is mapped
|
180
190
|
# * +:blocking+ - if provided indicates if the command blocks until the region is mapped
|
@@ -182,11 +192,13 @@ module OpenCL
|
|
182
192
|
# ==== Returns
|
183
193
|
#
|
184
194
|
# the Event associated with the command
|
185
|
-
def self.enqueue_svm_map( command_queue, svm_ptr,
|
195
|
+
def self.enqueue_svm_map( command_queue, svm_ptr, map_flags, options = {} )
|
186
196
|
error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 2.0
|
187
197
|
blocking = FALSE
|
188
198
|
blocking = TRUE if options[:blocking] or options[:blocking_map]
|
189
199
|
flags = get_flags( {:flags => map_flags} )
|
200
|
+
size = svm_ptr.size
|
201
|
+
size = options[:size] if options[:size]
|
190
202
|
num_events, events = get_event_wait_list( options )
|
191
203
|
event = MemoryPointer::new( Event )
|
192
204
|
error = clEnqueueSVMMap( command_queue, blocking, flags, svm_ptr, size, num_events, events, event )
|
@@ -251,7 +263,7 @@ module OpenCL
|
|
251
263
|
sizes_p[i].write_size_t(sizes[i])
|
252
264
|
}
|
253
265
|
event = MemoryPointer::new( Event )
|
254
|
-
error =
|
266
|
+
error = clEnqueueSVMMigrateMem( command_queue, num_svm_pointers, svn_ptrs_p, sizes_p, flags, num_events, events, event )
|
255
267
|
error_check( error )
|
256
268
|
return Event::new( event.read_pointer, false )
|
257
269
|
end
|
@@ -71,10 +71,11 @@ module OpenCL
|
|
71
71
|
|
72
72
|
# Returns the context associated with the Sampler
|
73
73
|
def context
|
74
|
+
return @_context if @_context
|
74
75
|
ptr = MemoryPointer::new( Context )
|
75
76
|
error = OpenCL.clGetSamplerInfo(self, CONTEXT, Context.size, ptr, nil)
|
76
77
|
error_check(error)
|
77
|
-
|
78
|
+
@_context = Context::new( ptr.read_pointer )
|
78
79
|
end
|
79
80
|
|
80
81
|
get_info("Sampler", :cl_uint, "reference_count")
|
data/lib/opencl_ruby_ffi/ext.rb
CHANGED
@@ -0,0 +1,152 @@
|
|
1
|
+
module OpenCL
|
2
|
+
|
3
|
+
ACCELERATOR_DESCRIPTOR_INTEL = 0x4090
|
4
|
+
ACCELERATOR_REFERENCE_COUNT_INTEL = 0x4091
|
5
|
+
ACCELERATOR_CONTEXT_INTEL = 0x4092
|
6
|
+
ACCELERATOR_TYPE_INTEL = 0x4093
|
7
|
+
INVALID_ACCELERATOR_INTEL = -1094
|
8
|
+
INVALID_ACCELERATOR_TYPE_INTEL = -1095
|
9
|
+
INVALID_ACCELERATOR_DESCRIPTOR_INTEL = -1096
|
10
|
+
ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL = -1097
|
11
|
+
|
12
|
+
typedef :cl_uint, :cl_accelerator_type_intel
|
13
|
+
typedef :cl_uint, :cl_accelerator_info_intel
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
|
18
|
+
module OpenCLRefinements
|
19
|
+
refine FFI::Pointer do
|
20
|
+
methods_prefix = [:put, :get, :write, :read, :put_array_of, :get_array_of]
|
21
|
+
[[:cl_uint, :cl_accelerator_type_intel],
|
22
|
+
[:cl_uint, :cl_accelerator_info_intel]].each { |orig, add|
|
23
|
+
methods_prefix.each { |meth|
|
24
|
+
alias_method "#{meth}_#{add}".to_sym, "#{meth}_#{orig}".to_sym
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
using OpenCLRefinements
|
30
|
+
else
|
31
|
+
class FFI::Pointer
|
32
|
+
methods_prefix = [:put, :get, :write, :read, :put_array_of, :get_array_of]
|
33
|
+
[[:cl_uint, :cl_accelerator_type_intel],
|
34
|
+
[:cl_uint, :cl_accelerator_info_intel]].each { |orig, add|
|
35
|
+
methods_prefix.each { |meth|
|
36
|
+
alias_method "#{meth}_#{add}".to_sym, "#{meth}_#{orig}".to_sym
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module OpenCL
|
43
|
+
|
44
|
+
class Error
|
45
|
+
eval error_class_constructor( :INVALID_ACCELERATOR_INTEL, :InvalidAcceleratorINTEL )
|
46
|
+
eval error_class_constructor( :INVALID_ACCELERATOR_TYPE_INTEL, :InvalidAcceleratorTypeINTEL )
|
47
|
+
eval error_class_constructor( :INVALID_ACCELERATOR_DESCRIPTOR_INTEL, :InvalidAcceleratorDescriptorINTEL )
|
48
|
+
eval error_class_constructor( :ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL, :AcceleratorTypeNotSupportedINTEL )
|
49
|
+
end
|
50
|
+
|
51
|
+
class AcceleratorINTEL < ExtendedStruct
|
52
|
+
class AcceleratorINTELPointer < FFI::Pointer
|
53
|
+
attr_accessor :context
|
54
|
+
def initialize(ptr, context)
|
55
|
+
super(ptr)
|
56
|
+
@context = context
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
include InnerInterface
|
61
|
+
extend ExtensionInnerGenerator
|
62
|
+
layout :dummy, :pointer
|
63
|
+
DESCRIPTOR_INTEL = 0x4090
|
64
|
+
REFERENCE_COUNT_INTEL = 0x4091
|
65
|
+
CONTEXT_INTEL = 0x4092
|
66
|
+
TYPE_INTEL = 0x4093
|
67
|
+
|
68
|
+
def platform
|
69
|
+
@context.platform
|
70
|
+
end
|
71
|
+
|
72
|
+
def initialize(ptr, context = ptr.context, retain = true)
|
73
|
+
super(AcceleratorINTELPointer::new(ptr, context))
|
74
|
+
@context = context
|
75
|
+
context.__retain_accelerator_intel(ptr) if retain
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.release(ptr)
|
79
|
+
ptr.context.__release_accelerator_intel(ptr)
|
80
|
+
end
|
81
|
+
|
82
|
+
def descriptor_intel
|
83
|
+
f = platform.get_extension_function("clGetAcceleratorInfoINTEL", :cl_int,
|
84
|
+
[OpenCL::AcceleratorINTEL, :cl_accelerator_info_intel, :size_t, :pointer, :pointer])
|
85
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
86
|
+
|
87
|
+
ptr1 = MemoryPointer::new( :size_t, 1)
|
88
|
+
error = f.call(self, DESCRIPTOR_INTEL, 0, nil, ptr1)
|
89
|
+
error_check(error)
|
90
|
+
ptr2 = MemoryPointer::new( ptr1.read_size_t )
|
91
|
+
error = f.call(self, DESCRIPTOR_INTEL, ptr1.read_size_t, ptr2, nil)
|
92
|
+
error_check(error)
|
93
|
+
return ptr2
|
94
|
+
end
|
95
|
+
|
96
|
+
def context_intel
|
97
|
+
f = platform.get_extension_function("clGetAcceleratorInfoINTEL", :cl_int,
|
98
|
+
[OpenCL::AcceleratorINTEL, :cl_accelerator_info_intel, :size_t, :pointer, :pointer])
|
99
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
100
|
+
|
101
|
+
ptr = MemoryPointer::new( Context )
|
102
|
+
error = f.call(self, CONTEXT_INTEL, Context.size, ptr, nil)
|
103
|
+
error_check(error)
|
104
|
+
return Context::new( ptr.read_pointer )
|
105
|
+
end
|
106
|
+
|
107
|
+
get_info_ext("AcceleratorINTEL", :cl_uint, "reference_count_intel", "clGetAcceleratorInfoINTEL")
|
108
|
+
get_info_ext("AcceleratorINTEL", :cl_uint, "type_intel", "clGetAcceleratorInfoINTEL")
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
class Context
|
113
|
+
module AcceleratorINTEL
|
114
|
+
|
115
|
+
def create_accelerator_intel(accelerator_type, descriptor, options = {})
|
116
|
+
name = "clCreateAcceleratorINTEL"
|
117
|
+
return_type = OpenCL::AcceleratorINTEL
|
118
|
+
params = [Context, :cl_accelerator_type_intel, :size_t, :pointer, :pointer]
|
119
|
+
f = platform.get_extension_function(name, return_type, params)
|
120
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
121
|
+
error = MemoryPointer::new( :cl_int )
|
122
|
+
size = descriptor.size
|
123
|
+
acc = f.call(self, accelerator_type, size, descriptor, error)
|
124
|
+
error_check(error.read_cl_int)
|
125
|
+
return OpenCL::AcceleratorINTEL::new( acc, self, false )
|
126
|
+
end
|
127
|
+
|
128
|
+
def __release_accelerator_intel(ptr)
|
129
|
+
name = "clReleaseAcceleratorINTEL"
|
130
|
+
return_type = :cl_int
|
131
|
+
params = [OpenCL::AcceleratorINTEL]
|
132
|
+
f = platform.get_extension_function(name, return_type, params)
|
133
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
134
|
+
error = f.call(ptr)
|
135
|
+
error_check(error)
|
136
|
+
end
|
137
|
+
|
138
|
+
def __retain_accelerator_intel(ptr)
|
139
|
+
name = "clRetainAcceleratorINTEL"
|
140
|
+
return_type = :cl_int
|
141
|
+
params = [OpenCL::AcceleratorINTEL]
|
142
|
+
f = platform.get_extension_function(name, return_type, params)
|
143
|
+
error_check(OpenCL::INVALID_OPERATION) unless f
|
144
|
+
error = f.call(ptr)
|
145
|
+
error_check(error)
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
register_extension( :cl_intel_accelerator, AcceleratorINTEL, "platform.extensions.include?(\"cl_intel_accelerator\")" )
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
|
2
|
+
|
3
|
+
require_relative 'motion_estimation'
|
4
|
+
|
5
|
+
module OpenCL
|
6
|
+
|
7
|
+
DEVICE_ME_VERSION_INTEL = 0x407E
|
8
|
+
|
9
|
+
ME_CHROMA_INTRA_PREDICT_ENABLED_INTEL = 0x1
|
10
|
+
ME_LUMA_INTRA_PREDICT_ENABLED_INTEL = 0x2
|
11
|
+
|
12
|
+
ME_SKIP_BLOCK_TYPE_16x16_INTEL = 0x0
|
13
|
+
ME_SKIP_BLOCK_TYPE_8x8_INTEL = 0x4
|
14
|
+
|
15
|
+
ME_COST_PENALTY_NONE_INTEL = 0x0
|
16
|
+
ME_COST_PENALTY_LOW_INTEL = 0x1
|
17
|
+
ME_COST_PENALTY_NORMAL_INTEL = 0x2
|
18
|
+
ME_COST_PENALTY_HIGH_INTEL = 0x3
|
19
|
+
|
20
|
+
ME_COST_PRECISION_QPEL_INTEL = 0x0
|
21
|
+
ME_COST_PRECISION_HEL_INTEL = 0x1
|
22
|
+
ME_COST_PRECISION_PEL_INTEL = 0x2
|
23
|
+
ME_COST_PRECISION_DPEL_INTEL = 0x3
|
24
|
+
|
25
|
+
ME_LUMA_PREDICTOR_MODE_VERTICAL_INTEL = 0x0
|
26
|
+
ME_LUMA_PREDICTOR_MODE_HORIZONTAL_INTEL = 0x1
|
27
|
+
ME_LUMA_PREDICTOR_MODE_DC_INTEL = 0x2
|
28
|
+
ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_LEFT_INTEL = 0x3
|
29
|
+
|
30
|
+
ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_RIGHT_INTEL = 0x4
|
31
|
+
ME_LUMA_PREDICTOR_MODE_PLANE_INTEL = 0x4
|
32
|
+
ME_LUMA_PREDICTOR_MODE_VERTICAL_RIGHT_INTEL = 0x5
|
33
|
+
ME_LUMA_PREDICTOR_MODE_HORIZONTAL_DOWN_INTEL = 0x6
|
34
|
+
ME_LUMA_PREDICTOR_MODE_VERTICAL_LEFT_INTEL = 0x7
|
35
|
+
ME_LUMA_PREDICTOR_MODE_HORIZONTAL_UP_INTEL = 0x8
|
36
|
+
|
37
|
+
ME_CHROMA_PREDICTOR_MODE_DC_INTEL = 0x0
|
38
|
+
ME_CHROMA_PREDICTOR_MODE_HORIZONTAL_INTEL = 0x1
|
39
|
+
ME_CHROMA_PREDICTOR_MODE_VERTICAL_INTEL = 0x2
|
40
|
+
ME_CHROMA_PREDICTOR_MODE_PLANE_INTEL = 0x3
|
41
|
+
|
42
|
+
ME_VERSION_LEGACY_INTEL = 0x0
|
43
|
+
ME_VERSION_ADVANCED_VER_1_INTEL = 0x1
|
44
|
+
ME_VERSION_ADVANCED_VER_2_INTEL = 0x2
|
45
|
+
|
46
|
+
ME_FORWARD_INPUT_MODE_INTEL = 0x1
|
47
|
+
ME_BACKWARD_INPUT_MODE_INTEL = 0x2
|
48
|
+
ME_BIDIRECTION_INPUT_MODE_INTEL = 0x3
|
49
|
+
|
50
|
+
ME_BIDIR_WEIGHT_QUARTER_INTEL = 0x10
|
51
|
+
ME_BIDIR_WEIGHT_THIRD_INTEL = 0x15
|
52
|
+
ME_BIDIR_WEIGHT_HALF_INTEL = 0x20
|
53
|
+
ME_BIDIR_WEIGHT_TWO_THIRD_INTEL = 0x2B
|
54
|
+
ME_BIDIR_WEIGHT_THREE_QUARTER_INTEL = 0x30
|
55
|
+
|
56
|
+
class Device
|
57
|
+
ME_VERSION_INTEL = 0x407E
|
58
|
+
module AdvanceMotionEstimationINTEL
|
59
|
+
extend InnerGenerator
|
60
|
+
get_info("Device", :cl_uint, "me_version_intel")
|
61
|
+
|
62
|
+
end
|
63
|
+
register_extension( :cl_intel_advanced_motion_estimation, AdvanceMotionEstimationINTEL, "platform.extensions.include?(\"cl_intel_advanced_motion_estimation\")" )
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
|
2
|
+
|
3
|
+
module OpenCL
|
4
|
+
CONTEXT_DRIVER_DIAGNOSTICS_INTEL = 0x4106
|
5
|
+
CONTEXT_SHOW_DIAGNOSTICS_INTEL = 0x4106
|
6
|
+
CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL = 0x1
|
7
|
+
CONTEXT_DIAGNOSTICS_LEVEL_BAD_INTEL = 0x2
|
8
|
+
CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL = 0x4
|
9
|
+
|
10
|
+
class Context
|
11
|
+
DRIVER_DIAGNOSTICS_INTEL = 0x4106
|
12
|
+
SHOW_DIAGNOSTICS_INTEL = 0x4106
|
13
|
+
DIAGNOSTICS_LEVEL_GOOD_INTEL = 0x1
|
14
|
+
DIAGNOSTICS_LEVEL_BAD_INTEL = 0x2
|
15
|
+
DIAGNOSTICS_LEVEL_NEUTRAL_INTEL = 0x4
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
|
2
|
+
module OpenCL
|
3
|
+
|
4
|
+
CONTEXT_KERNEL_PROFILING_MODES_COUNT_INTEL = 0x407A
|
5
|
+
CONTEXT_KERNEL_PROFILING_MODE_INFO_INTEL = 0x407B
|
6
|
+
KERNEL_IL_SYMBOLS_INTEL = 0x407C
|
7
|
+
KERNEL_BINARY_PROGRAM_INTEL = 0x407D
|
8
|
+
|
9
|
+
class Kernel
|
10
|
+
IL_SYMBOLS_INTEL = 0x407C
|
11
|
+
BINARY_PROGRAM_INTEL = 0x407D
|
12
|
+
module KernelProfilingINTEL
|
13
|
+
def binary_program_intel(device = program.devices.first)
|
14
|
+
ptr_bin = nil
|
15
|
+
begin
|
16
|
+
ptr = MemoryPointer::new( :size_t )
|
17
|
+
error = OpenCL.clGetKernelWorkGroupInfo(self, device, BINARY_PROGRAM_INTEL, 0, nil, ptr)
|
18
|
+
error_check(error)
|
19
|
+
bin_size = ptr.read_size_t
|
20
|
+
ptr_bin = MemoryPointer::new(bin_size)
|
21
|
+
error = OpenCL.clGetKernelWorkGroupInfo(self, device, BINARY_PROGRAM_INTEL, bin_size, ptr_bin, nil)
|
22
|
+
error_check(error)
|
23
|
+
rescue OpenCL::Error::INVALID_VALUE
|
24
|
+
ptr = MemoryPointer::new( :size_t )
|
25
|
+
error = OpenCL.clGetKernelInfo(self, BINARY_PROGRAM_INTEL, 0, nil, ptr)
|
26
|
+
error_check(error)
|
27
|
+
bin_size = ptr.read_size_t
|
28
|
+
ptr_bin = MemoryPointer::new(bin_size)
|
29
|
+
error = OpenCL.clGetKernelInfo(self, BINARY_PROGRAM_INTEL, bin_size, ptr_bin, nil)
|
30
|
+
error_check(error)
|
31
|
+
end
|
32
|
+
return ptr_bin.read_bytes(bin_size)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
register_extension(:cl_intel_kernel_profiling, KernelProfilingINTEL, "true")
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
|
2
|
+
|
3
|
+
require_relative 'accelerator'
|
4
|
+
|
5
|
+
module OpenCL
|
6
|
+
ACCELERATOR_TYPE_MOTION_ESTIMATION_INTEL = 0x0
|
7
|
+
ME_MB_TYPE_16x16_INTEL = 0x0
|
8
|
+
ME_MB_TYPE_8x8_INTEL = 0x1
|
9
|
+
ME_MB_TYPE_4x4_INTEL = 0x2
|
10
|
+
ME_SUBPIXEL_MODE_INTEGER_INTEL = 0x0
|
11
|
+
ME_SUBPIXEL_MODE_HPEL_INTEL = 0x1
|
12
|
+
ME_SUBPIXEL_MODE_QPEL_INTEL = 0x2
|
13
|
+
ME_SAD_ADJUST_MODE_NONE_INTEL = 0x0
|
14
|
+
ME_SAD_ADJUST_MODE_HAAR_INTEL = 0x1
|
15
|
+
ME_SEARCH_PATH_RADIUS_2_2_INTEL = 0x0
|
16
|
+
ME_SEARCH_PATH_RADIUS_4_4_INTEL = 0x1
|
17
|
+
ME_SEARCH_PATH_RADIUS_16_12_INTEL = 0x5
|
18
|
+
|
19
|
+
class MotionEstimationDescINTEL < FFI::Struct
|
20
|
+
layout :mb_block_type, :cl_uint,
|
21
|
+
:subpixel_mode, :cl_uint,
|
22
|
+
:sad_adjust_mode, :cl_uint,
|
23
|
+
:search_path_type, :cl_uint
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|