opencl_ruby_ffi 0.95 → 0.96

Sign up to get free protection for your applications and to get access to all the features.
@@ -212,9 +212,9 @@ module OpenCL
212
212
  c_strs[i].write_pointer(p)
213
213
  c_strs_length[i].write_size_t(p.size)
214
214
  }
215
- pointer_err = FFI::MemoryPointer::new( :cl_int )
216
- program_ptr = OpenCL.clCreateProgramWithSource(context, c_strs_p.size, c_strs, c_strs_length, pointer_err)
217
- OpenCL.error_check(pointer_err.read_cl_int)
215
+ error = FFI::MemoryPointer::new( :cl_int )
216
+ program_ptr = OpenCL.clCreateProgramWithSource(context, c_strs_p.size, c_strs, c_strs_length, error)
217
+ OpenCL.error_check(error.read_cl_int)
218
218
  return OpenCL::Program::new( program_ptr, false )
219
219
  end
220
220
 
@@ -260,6 +260,18 @@ module OpenCL
260
260
  # Returns the concatenated Program sources
261
261
  eval OpenCL.get_info("Program", :string, "SOURCE")
262
262
 
263
+ # Returns the total amount in byte used by the Program variables in the global address space for the Device(s) specified. Returns an Array of tuple [ Device, size ] (2.0 only)
264
+ def build_global_variable_total_size(devs = nil)
265
+ devs = self.devices if not devs
266
+ devs = [devs].flatten
267
+ ptr = FFI::MemoryPointer::new( :size_t )
268
+ return devs.collect { |dev|
269
+ error = OpenCL.clGetProgramBuildInfo(self, dev, OpenCL::Program::BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, ptr.size, ptr, nil)
270
+ OpenCL.error_check(error)
271
+ [dev, ptr.read_size_t]
272
+ }
273
+ end
274
+
263
275
  # Returns the BuildStatus of the Program for each device associated to the Program or the Device(s) specified. Returns an Array of tuple [ Device, BuildStatus ]
264
276
  def build_status(devs = nil)
265
277
  devs = self.devices if not devs
@@ -0,0 +1,184 @@
1
+ module OpenCL
2
+
3
+ # maps the SVM pointer type
4
+ class SVMPointer < FFI::Pointer
5
+
6
+ def initialize( address, context )
7
+ super( address )
8
+ @context = context
9
+ end
10
+
11
+ def +( offset )
12
+ return OpenCL::SVMPointer::new( self.address + offset, @context )
13
+ end
14
+
15
+ def free
16
+ return OpenCL::svm_free( @context, self )
17
+ end
18
+
19
+ end
20
+
21
+ def self.svm_alloc(context, size, options = {})
22
+ OpenCL.error_check(OpenCL::INVALID_OPERATION) if context.platform.version_number < 2.0
23
+ flags = OpenCL::get_flags(options)
24
+ alignment = 0
25
+ alignment = options[:alignment] if options[:alignment]
26
+ ptr = OpenCL.clSVMAlloc( context, flags, size, alignment )
27
+ raise OpenCL::Error::new(OpenCL::Error.getErrorString(OpenCL::Error::MEM_OBJECT_ALLOCATION_FAILURE)) if ptr.null?
28
+ return OpenCL::SVMPointer::new( ptr, context )
29
+ end
30
+
31
+ def self.svm_free(context, svm_pointer)
32
+ OpenCL.error_check(OpenCL::INVALID_OPERATION) if context.platform.version_number < 2.0
33
+ return OpenCL.clSVMFree( context, svm_pointer )
34
+ end
35
+
36
+ # Set the index th argument of Kernel to value. Value must be within a SVM memory area
37
+ def self.set_kernel_arg_svm_pointer( kernel, index, value )
38
+ OpenCL.error_check(OpenCL::INVALID_OPERATION) if kernel.context.platform.version_number < 2.0
39
+ error = OpenCL.clSetKernelArgSVMPointer( kernel, index, val )
40
+ OpenCL.error_check(error)
41
+ end
42
+
43
+ # Enqueues a command that frees SVMPointers (or Pointers using a callback)
44
+ #
45
+ # ==== Attributes
46
+ #
47
+ # * +command_queue+ - CommandQueue used to execute the write command
48
+ # * +svm_pointer+ - a single or an Array of SVMPointer (or Pointer)
49
+ # * +options+ - a hash containing named options
50
+ # * +block+ - if provided, a callback invoked to free the pointers. Signature of the callback is { |CommandQueue, num_pointers, FFI::Pointer to an array of num_pointers Pointers, FFI::Pointer to user_data| ... }
51
+ #
52
+ # ==== Options
53
+ #
54
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
55
+ # * +:user_data+ - if provided, a Pointer (or convertible to using to_ptr) that will be passed to the callback
56
+ #
57
+ # ==== Returns
58
+ #
59
+ # the Event associated with the command
60
+ def self.enqueue_svm_free(command_queue, svm_pointers, options = {}, &block)
61
+ pointers = [svm_pointers].flatten
62
+ num_pointers = pointers.length
63
+ ptr = FFI::MemoryPointer::new( :pointer, num_pointers)
64
+ pointers.each_with_index { |p, indx|
65
+ ptr[indx].write_pointer(p)
66
+ }
67
+ num_events, events = OpenCL.get_event_wait_list( options )
68
+ event = FFI::MemoryPointer::new( OpenCL::Event )
69
+ error = OpenCL.clEnqueueSVMFree(command_queue, num_pointers, ptr, block, options[:user_data], num_events, events, event)
70
+ OpenCL.error_check(error)
71
+ return OpenCL::Event::new(event.read_pointer, false)
72
+ end
73
+
74
+ # Enqueues a command to copy from or to an SVMPointer
75
+ #
76
+ # ==== Attributes
77
+ #
78
+ # * +command_queue+ - CommandQueue used to execute the write command
79
+ # * +dst_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be written to
80
+ # * +src_ptr+ - the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be read from
81
+ # * +size+ - the size of data to copy
82
+ # * +options+ - a hash containing named options
83
+ #
84
+ # ==== Options
85
+ #
86
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
87
+ # * +:blocking_copy+ - if provided indicates if the command blocks until the copy finishes
88
+ # * +:blocking+ - if provided indicates if the command blocks until the copy finishes
89
+ #
90
+ # ==== Returns
91
+ #
92
+ # the Event associated with the command
93
+ def self.enqueue_svm_memcpy(command_queue, dst_ptr, src_ptr, size, options = {})
94
+ OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 2.0
95
+ blocking = OpenCL::FALSE
96
+ blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_copy]
97
+ num_events, events = OpenCL.get_event_wait_list( options )
98
+ event = FFI::MemoryPointer::new( OpenCL::Event )
99
+ error = OpenCL.clEnqueueSVMMemcpy(command_queue, blocking, dst_ptr, src_ptr, size, num_events, events, event)
100
+ OpenCL.error_check(error)
101
+ return OpenCL::Event::new(event.read_pointer, false)
102
+ end
103
+
104
+ # Enqueues a command to fill a an SVM memory area
105
+ #
106
+ # ==== Attributes
107
+ #
108
+ # * +command_queue+ - CommandQueue used to execute the write command
109
+ # * +svm_ptr+ - the SVMPointer to the area to fill
110
+ # * +pattern+ - the Pointer (or convertible to Pointer using to_ptr) to the memory area where the pattern is stored
111
+ # * +size+ - the size of the area to fill
112
+ #
113
+ # ==== Options
114
+ #
115
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
116
+ # * +:pattern_size+ - if provided indicates the size of the pattern, else the maximum pattern data is used
117
+ #
118
+ # ==== Returns
119
+ #
120
+ # the Event associated with the command
121
+ def self.enqueue_svm_fill(command_queue, svm_ptr, pattern, size, options = {})
122
+ num_events, events = OpenCL.get_event_wait_list( options )
123
+ pattern_size = pattern.size
124
+ pattern_size = options[:pattern_size] if options[:pattern_size]
125
+ event = FFI::MemoryPointer::new( OpenCL::Event )
126
+ error = OpenCL.clEnqueueSVMFill(command_queue, svm_ptr, pattern, pattern_size, size, num_events, events, event)
127
+ OpenCL.error_check(error)
128
+ return OpenCL::Event::new(event.read_pointer, false)
129
+ end
130
+
131
+ # Enqueues a command to map an Image into host memory
132
+ #
133
+ # ==== Attributes
134
+ #
135
+ # * +command_queue+ - CommandQueue used to execute the map command
136
+ # * +svm_ptr+ - the SVMPointer to the area to map
137
+ # * +size+ - the size of the region to map
138
+ # * +map_flags+ - a single or an Array of :cl_map_flags flags
139
+ # * +options+ - a hash containing named options
140
+ #
141
+ # ==== Options
142
+ #
143
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
144
+ # * +:blocking_map+ - if provided indicates if the command blocks until the region is mapped
145
+ # * +:blocking+ - if provided indicates if the command blocks until the region is mapped
146
+ #
147
+ # ==== Returns
148
+ #
149
+ # the Event associated with the command
150
+ def self.enqueue_svm_map( command_queue, svm_ptr, size, map_flags, options = {} )
151
+ blocking = OpenCL::FALSE
152
+ blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_map]
153
+ flags = OpenCL.get_flags( {:flags => map_flags} )
154
+ num_events, events = OpenCL.get_event_wait_list( options )
155
+ event = FFI::MemoryPointer::new( OpenCL::Event )
156
+ error = OpenCL.clEnqueueSVMMap( command_queue, blocking, flags, svm_ptr, size, num_events, events, event )
157
+ OpenCL.error_check( error.read_cl_int )
158
+ return OpenCL::Event::new( event.read_ptr, false )
159
+ end
160
+
161
+ # Enqueues a command to unmap a previously mapped SVM memory area
162
+ #
163
+ # ==== Attributes
164
+ #
165
+ # * +command_queue+ - CommandQueue used to execute the unmap command
166
+ # * +svm_ptr+ - the SVMPointer of the area to be unmapped
167
+ # * +options+ - a hash containing named options
168
+ #
169
+ # ==== Options
170
+ #
171
+ # * +:event_wait_list+ - if provided, a list of Event to wait upon before executing the command
172
+ #
173
+ # ==== Returns
174
+ #
175
+ # the Event associated with the command
176
+ def self.enqueue_svm_unmap( command_queue, svm_ptr, options = {} )
177
+ num_events, events = OpenCL.get_event_wait_list( options )
178
+ event = FFI::MemoryPointer::new( OpenCL::Event )
179
+ error = OpenCL.clEnqueueSVMUnmap( command_queue, svm_ptr, num_events, events, event )
180
+ OpenCL.error_check( error )
181
+ return OpenCL::Event::new( event.read_ptr, false )
182
+ end
183
+
184
+ end
@@ -5,12 +5,56 @@ module OpenCL
5
5
  # ==== Attributes
6
6
  #
7
7
  # * +context+ - Context the created Sampler will be associated to
8
- # * +normalized_coords+ - a :cl_bool specifying if the image coordinates are normalized
9
- # * +addressing_mode+ - a :cl_addressing_mode specifying how out-of-range image coordinates are handled when reading from an image
10
- # * +filter_mode+ - a :cl_filter_mode specifying the type of filter that must be applied when reading an image
11
- def self.create_sampler( context, normalized_coords, addressing_mode, filter_mode )
8
+ #
9
+ # ==== Options
10
+ #
11
+ # * +:normalized_coords+ - a :cl_bool specifying if the image coordinates are normalized
12
+ # * +:addressing_mode+ - a :cl_addressing_mode specifying how out-of-range image coordinates are handled when reading from an image
13
+ # * +:filter_mode+ - a :cl_filter_mode specifying the type of filter that must be applied when reading an image
14
+ # * +:mip_filter_mode+ - the filtering mode to use if using mimaps (default CL_FILTER_NONE, requires cl_khr_mipmap_image)
15
+ # * +:lod_min+ - floating point value representing the minimal LOD (default 0.0f, requires cl_khr_mipmap_image)
16
+ # * +:lod_max+ - floating point value representing the maximal LOD (default MAXFLOAT, requires cl_khr_mipmap_image)
17
+ def self.create_sampler( context, options = {} )
18
+ normalized_coords = OpenCL::TRUE
19
+ normalized_coords = options[:normalized_coords] if options[:normalized_coords]
20
+ addressing_mode = OpenCL::AddressingMode::CLAMP
21
+ addressing_mode = options[:addressing_mode] if options[:addressing_mode]
22
+ filter_mode = OpenCL::FilterMode::NEAREST
23
+ filter_mode = options[:filter_mode] if options[:filter_mode]
12
24
  error = FFI::MemoryPointer::new( :cl_int )
13
- sampler_ptr = OpenCL.clCreateSampler( context, normalized_coords, addressing_mode, filter_mode, error )
25
+ if context.platform.version_number < 2.0 then
26
+ sampler_ptr = OpenCL.clCreateSampler( context, normalized_coords, addressing_mode, filter_mode, error )
27
+ else
28
+ prop_size = 7
29
+ prop_size += 2 if options[:mip_filter_mode]
30
+ prop_size += 2 if options[:lod_min]
31
+ prop_size += 2 if options[:lod_max]
32
+ properties = FFI::MemoryPointer::new( :cl_sampler_properties)
33
+ properties[0].write_cl_sampler_properties( OpenCL::Sampler::NORMALIZED_COORDS )
34
+ properties[1].write_cl_sampler_properties( normalized_coords )
35
+ properties[2].write_cl_sampler_properties( OpenCL::Sampler::ADDRESSING_MODE )
36
+ properties[3].write_cl_sampler_properties( addressing_mode )
37
+ properties[4].write_cl_sampler_properties( OpenCL::Sampler::FILTER_MODE )
38
+ properties[5].write_cl_sampler_properties( filter_mode )
39
+ prop_indx = 6
40
+ if options[:mip_filter_mode] then
41
+ properties[prop_indx].write_cl_sampler_properties( OpenCL::Sampler::MIP_FILTER_MODE )
42
+ properties[prop_indx+1].write_cl_sampler_properties( options[:mip_filter_mode] )
43
+ prop_indx += 2
44
+ end
45
+ if options[:lod_min] then
46
+ properties[prop_indx].write_cl_sampler_properties( OpenCL::Sampler::LOD_MIN )
47
+ properties[prop_indx+1].write_float( options[:lod_min] )
48
+ prop_indx += 2
49
+ end
50
+ if options[:lod_max] then
51
+ properties[prop_indx].write_cl_sampler_properties( OpenCL::Sampler::LOD_MAX )
52
+ properties[prop_indx+1].write_float( options[:lod_max] )
53
+ prop_indx += 2
54
+ end
55
+ properties[prop_indx].write_cl_sampler_properties( 0 )
56
+ sampler_ptr = OpenCL.clCreateSamplerWithProperties( context, properties, error )
57
+ end
14
58
  OpenCL.error_check(error.read_cl_int)
15
59
  OpenCL::Sampler::new(sampler_ptr, false)
16
60
  end
@@ -44,6 +44,7 @@ module OpenCL
44
44
  :cl_device_exec_capabilities => OpenCL::Device::ExecCapabilities,
45
45
  :cl_command_queue_properties => OpenCL::CommandQueue::Properties,
46
46
  :cl_device_affinity_domain => OpenCL::Device::AffinityDomain,
47
+ :cl_device_svm_capabilities => OpenCL::Device::SVMCapabilities,
47
48
  :cl_channel_order => OpenCL::ChannelOrder,
48
49
  :cl_channel_type => OpenCL::ChannelType,
49
50
  :cl_mem_flags => OpenCL::Mem::Flags,
@@ -195,12 +196,12 @@ module OpenCL
195
196
 
196
197
  # Extracts the :properties named option (for a CommandQueue) from the hash given and returns the properties values
197
198
  def self.get_command_queue_properties( options )
198
- properties = 0
199
+ properties = OpenCL::CommandQueue::Properties::new(0)
199
200
  if options[:properties] then
200
201
  if options[:properties].respond_to?(:each) then
201
202
  options[:properties].each { |f| properties = properties | f }
202
203
  else
203
- properties = options[:properties]
204
+ properties = properties | options[:properties]
204
205
  end
205
206
  end
206
207
  return properties
@@ -67,9 +67,12 @@ module OpenCL
67
67
  INVALID_COMPILER_OPTIONS = -66
68
68
  INVALID_LINKER_OPTIONS = -67
69
69
  INVALID_DEVICE_PARTITION_COUNT = -68
70
+ INVALID_PIPE_SIZE = -69
71
+ INVALID_DEVICE_QUEUE = -70
70
72
  VERSION_1_0 = 1
71
73
  VERSION_1_1 = 1
72
74
  VERSION_1_2 = 1
75
+ VERSION_2_0 = 1
73
76
  FALSE = 0
74
77
  TRUE = 1
75
78
  BLOCKING = TRUE
@@ -128,6 +131,7 @@ module OpenCL
128
131
  DEVICE_COMPILER_AVAILABLE = 0x1028
129
132
  DEVICE_EXECUTION_CAPABILITIES = 0x1029
130
133
  DEVICE_QUEUE_PROPERTIES = 0x102A
134
+ DEVICE_QUEUE_ON_HOST_PROPERTIES = 0x102A
131
135
  DEVICE_NAME = 0x102B
132
136
  DEVICE_VENDOR = 0x102C
133
137
  DRIVER_VERSION = 0x102D
@@ -160,6 +164,21 @@ module OpenCL
160
164
  DEVICE_PRINTF_BUFFER_SIZE = 0x1049
161
165
  DEVICE_IMAGE_PITCH_ALIGNMENT = 0x104A
162
166
  DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT = 0x104B
167
+ DEVICE_MAX_READ_WRITE_IMAGE_ARGS = 0x104C
168
+ DEVICE_MAX_GLOBAL_VARIABLE_SIZE = 0x104D
169
+ DEVICE_QUEUE_ON_DEVICE_PROPERTIES = 0x104E
170
+ DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE = 0x104F
171
+ DEVICE_QUEUE_ON_DEVICE_MAX_SIZE = 0x1050
172
+ DEVICE_MAX_ON_DEVICE_QUEUES = 0x1051
173
+ DEVICE_MAX_ON_DEVICE_EVENTS = 0x1052
174
+ DEVICE_SVM_CAPABILITIES = 0x1053
175
+ DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE = 0x1054
176
+ DEVICE_MAX_PIPE_ARGS = 0x1055
177
+ DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS = 0x1056
178
+ DEVICE_PIPE_MAX_PACKET_SIZE = 0x1057
179
+ DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT = 0x1058
180
+ DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT = 0x1059
181
+ DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT = 0x105A
163
182
  FP_DENORM = (1 << 0)
164
183
  FP_INF_NAN = (1 << 1)
165
184
  FP_ROUND_TO_NEAREST = (1 << 2)
@@ -177,6 +196,8 @@ module OpenCL
177
196
  EXEC_NATIVE_KERNEL = (1 << 1)
178
197
  QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0)
179
198
  QUEUE_PROFILING_ENABLE = (1 << 1)
199
+ QUEUE_ON_DEVICE = (1 << 2)
200
+ QUEUE_ON_DEVICE_DEFAULT = (1 << 3)
180
201
  CONTEXT_REFERENCE_COUNT = 0x1080
181
202
  CONTEXT_DEVICES = 0x1081
182
203
  CONTEXT_PROPERTIES = 0x1082
@@ -193,10 +214,15 @@ module OpenCL
193
214
  DEVICE_AFFINITY_DOMAIN_L2_CACHE = (1 << 3)
194
215
  DEVICE_AFFINITY_DOMAIN_L1_CACHE = (1 << 4)
195
216
  DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = (1 << 5)
217
+ DEVICE_SVM_COARSE_GRAIN_BUFFER = (1 << 0)
218
+ DEVICE_SVM_FINE_GRAIN_BUFFER = (1 << 1)
219
+ DEVICE_SVM_FINE_GRAIN_SYSTEM = (1 << 2)
220
+ DEVICE_SVM_ATOMICS = (1 << 3)
196
221
  QUEUE_CONTEXT = 0x1090
197
222
  QUEUE_DEVICE = 0x1091
198
223
  QUEUE_REFERENCE_COUNT = 0x1092
199
224
  QUEUE_PROPERTIES = 0x1093
225
+ QUEUE_SIZE = 0x1094
200
226
  MEM_READ_WRITE = (1 << 0)
201
227
  MEM_WRITE_ONLY = (1 << 1)
202
228
  MEM_READ_ONLY = (1 << 2)
@@ -206,6 +232,8 @@ module OpenCL
206
232
  MEM_HOST_WRITE_ONLY = (1 << 7)
207
233
  MEM_HOST_READ_ONLY = (1 << 8)
208
234
  MEM_HOST_NO_ACCESS = (1 << 9)
235
+ MEM_SVM_FINE_GRAIN_BUFFER = (1 << 10)
236
+ MEM_SVM_ATOMICS = (1 << 11)
209
237
  MIGRATE_MEM_OBJECT_HOST = (1 << 0)
210
238
  MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED = (1 << 1)
211
239
  R = 0x10B0
@@ -223,6 +251,11 @@ module OpenCL
223
251
  RGBx = 0x10BC
224
252
  DEPTH = 0x10BD
225
253
  DEPTH_STENCIL = 0x10BE
254
+ sRGB = 0x10BF
255
+ sRGBx = 0x10C0
256
+ sRGBA = 0x10C1
257
+ sBGRA = 0x10C2
258
+ ABGR = 0x10C3
226
259
  SNORM_INT8 = 0x10D0
227
260
  SNORM_INT16 = 0x10D1
228
261
  UNORM_INT8 = 0x10D2
@@ -246,6 +279,7 @@ module OpenCL
246
279
  MEM_OBJECT_IMAGE1D = 0x10F4
247
280
  MEM_OBJECT_IMAGE1D_ARRAY = 0x10F5
248
281
  MEM_OBJECT_IMAGE1D_BUFFER = 0x10F6
282
+ MEM_OBJECT_PIPE = 0x10F7
249
283
  MEM_TYPE = 0x1100
250
284
  MEM_FLAGS = 0x1101
251
285
  MEM_SIZE = 0x1102
@@ -255,6 +289,7 @@ module OpenCL
255
289
  MEM_CONTEXT = 0x1106
256
290
  MEM_ASSOCIATED_MEMOBJECT = 0x1107
257
291
  MEM_OFFSET = 0x1108
292
+ MEM_USES_SVM_POINTER = 0x1109
258
293
  IMAGE_FORMAT = 0x1110
259
294
  IMAGE_ELEMENT_SIZE = 0x1111
260
295
  IMAGE_ROW_PITCH = 0x1112
@@ -266,6 +301,8 @@ module OpenCL
266
301
  IMAGE_BUFFER = 0x1118
267
302
  IMAGE_NUM_MIP_LEVELS = 0x1119
268
303
  IMAGE_NUM_SAMPLES = 0x111A
304
+ PIPE_PACKET_SIZE = 0x1120
305
+ PIPE_MAX_PACKETS = 0x1121
269
306
  ADDRESS_NONE = 0x1130
270
307
  ADDRESS_CLAMP_TO_EDGE = 0x1131
271
308
  ADDRESS_CLAMP = 0x1132
@@ -278,6 +315,9 @@ module OpenCL
278
315
  SAMPLER_NORMALIZED_COORDS = 0x1152
279
316
  SAMPLER_ADDRESSING_MODE = 0x1153
280
317
  SAMPLER_FILTER_MODE = 0x1154
318
+ SAMPLER_MIP_FILTER_MODE = 0x1155
319
+ SAMPLER_LOD_MIN = 0x1156
320
+ SAMPLER_LOD_MAX = 0x1157
281
321
  MAP_READ = (1 << 0)
282
322
  MAP_WRITE = (1 << 1)
283
323
  MAP_WRITE_INVALIDATE_REGION = (1 << 2)
@@ -294,6 +334,7 @@ module OpenCL
294
334
  PROGRAM_BUILD_OPTIONS = 0x1182
295
335
  PROGRAM_BUILD_LOG = 0x1183
296
336
  PROGRAM_BINARY_TYPE = 0x1184
337
+ PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE = 0x1185
297
338
  PROGRAM_BINARY_TYPE_NONE = 0x0
298
339
  PROGRAM_BINARY_TYPE_COMPILED_OBJECT = 0x1
299
340
  PROGRAM_BINARY_TYPE_LIBRARY = 0x2
@@ -325,12 +366,15 @@ module OpenCL
325
366
  KERNEL_ARG_TYPE_CONST = (1 << 0)
326
367
  KERNEL_ARG_TYPE_RESTRICT = (1 << 1)
327
368
  KERNEL_ARG_TYPE_VOLATILE = (1 << 2)
369
+ KERNEL_ARG_TYPE_PIPE = (1 << 3)
328
370
  KERNEL_WORK_GROUP_SIZE = 0x11B0
329
371
  KERNEL_COMPILE_WORK_GROUP_SIZE = 0x11B1
330
372
  KERNEL_LOCAL_MEM_SIZE = 0x11B2
331
373
  KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x11B3
332
374
  KERNEL_PRIVATE_MEM_SIZE = 0x11B4
333
375
  KERNEL_GLOBAL_WORK_SIZE = 0x11B5
376
+ KERNEL_EXEC_INFO_SVM_PTRS = 0x11B6
377
+ KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = 0x11B7
334
378
  EVENT_COMMAND_QUEUE = 0x11D0
335
379
  EVENT_COMMAND_TYPE = 0x11D1
336
380
  EVENT_REFERENCE_COUNT = 0x11D2
@@ -361,6 +405,11 @@ module OpenCL
361
405
  COMMAND_MIGRATE_MEM_OBJECTS = 0x1206
362
406
  COMMAND_FILL_BUFFER = 0x1207
363
407
  COMMAND_FILL_IMAGE = 0x1208
408
+ COMMAND_SVM_FREE = 0x1209
409
+ COMMAND_SVM_MEMCPY = 0x120A
410
+ COMMAND_SVM_MEMFILL = 0x120B
411
+ COMMAND_SVM_MAP = 0x120C
412
+ COMMAND_SVM_UNMAP = 0x120D
364
413
  COMPLETE = 0x0
365
414
  RUNNING = 0x1
366
415
  SUBMITTED = 0x2
@@ -370,6 +419,7 @@ module OpenCL
370
419
  PROFILING_COMMAND_SUBMIT = 0x1281
371
420
  PROFILING_COMMAND_START = 0x1282
372
421
  PROFILING_COMMAND_END = 0x1283
422
+ PROFILING_COMMAND_COMPLETE = 0x1284
373
423
  GL_OBJECT_BUFFER = 0x2000
374
424
  GL_OBJECT_TEXTURE2D = 0x2001
375
425
  GL_OBJECT_TEXTURE3D = 0x2002
@@ -400,6 +450,8 @@ module OpenCL
400
450
  DEVICE_TERMINATE_CAPABILITY_KHR = 0x200F
401
451
  CONTEXT_TERMINATE_KHR = 0x2010
402
452
  cl_khr_terminate_context = 1
453
+ DEVICE_SPIR_VERSIONS = 0x40E0
454
+ PROGRAM_BINARY_TYPE_INTERMEDIATE = 0x40E1
403
455
  DEVICE_COMPUTE_CAPABILITY_MAJOR_NV = 0x4000
404
456
  DEVICE_COMPUTE_CAPABILITY_MINOR_NV = 0x4001
405
457
  DEVICE_REGISTERS_PER_BLOCK_NV = 0x4002
@@ -407,26 +459,9 @@ module OpenCL
407
459
  DEVICE_GPU_OVERLAP_NV = 0x4004
408
460
  DEVICE_KERNEL_EXEC_TIMEOUT_NV = 0x4005
409
461
  DEVICE_INTEGRATED_MEMORY_NV = 0x4006
410
- cl_amd_device_memory_flags = 1
411
- MEM_USE_PERSISTENT_MEM_AMD = (1 << 6)
412
- DEVICE_MAX_ATOMIC_COUNTERS_EXT = 0x4032
413
462
  DEVICE_PROFILING_TIMER_OFFSET_AMD = 0x4036
414
- DEVICE_TOPOLOGY_AMD = 0x4037
415
- DEVICE_BOARD_NAME_AMD = 0x4038
416
- DEVICE_GLOBAL_FREE_MEMORY_AMD = 0x4039
417
- DEVICE_SIMD_PER_COMPUTE_UNIT_AMD = 0x4040
418
- DEVICE_SIMD_WIDTH_AMD = 0x4041
419
- DEVICE_SIMD_INSTRUCTION_WIDTH_AMD = 0x4042
420
- DEVICE_WAVEFRONT_WIDTH_AMD = 0x4043
421
- DEVICE_GLOBAL_MEM_CHANNELS_AMD = 0x4044
422
- DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD = 0x4045
423
- DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD = 0x4046
424
- DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD = 0x4047
425
- DEVICE_LOCAL_MEM_BANKS_AMD = 0x4048
426
- DEVICE_TOPOLOGY_TYPE_PCIE_AMD = 1
427
- CONTEXT_OFFLINE_DEVICES_AMD = 0x403F
428
- MEM_EXT_HOST_PTR_QCOM = (1 << 29)
429
- DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM = 0x40A0
463
+ PRINTF_CALLBACK_ARM = 0x40B0
464
+ PRINTF_BUFFERSIZE_ARM = 0x40B1
430
465
  DEVICE_PAGE_SIZE_QCOM = 0x40A1
431
466
  IMAGE_ROW_ALIGNMENT_QCOM = 0x40A2
432
467
  IMAGE_SLICE_ALIGNMENT_QCOM = 0x40A3
@@ -444,6 +479,8 @@ module OpenCL
444
479
  @@codes[-3] = 'COMPILER_NOT_AVAILABLE'
445
480
  @@codes[-2] = 'DEVICE_NOT_AVAILABLE'
446
481
  @@codes[-1] = 'DEVICE_NOT_FOUND'
482
+ @@codes[-70] = 'INVALID_DEVICE_QUEUE'
483
+ @@codes[-69] = 'INVALID_PIPE_SIZE'
447
484
  @@codes[-68] = 'INVALID_DEVICE_PARTITION_COUNT'
448
485
  @@codes[-67] = 'INVALID_LINKER_OPTIONS'
449
486
  @@codes[-66] = 'INVALID_COMPILER_OPTIONS'
@@ -532,15 +569,18 @@ module OpenCL
532
569
  FFI.typedef :cl_uint, :cl_device_mem_cache_type
533
570
  FFI.typedef :cl_uint, :cl_device_local_mem_type
534
571
  FFI.typedef :cl_bitfield, :cl_device_exec_capabilities
572
+ FFI.typedef :cl_bitfield, :cl_device_svm_capabilities
535
573
  FFI.typedef :cl_bitfield, :cl_command_queue_properties
536
574
  FFI.typedef :pointer, :cl_device_partition_property
537
575
  FFI.typedef :cl_bitfield, :cl_device_affinity_domain
538
576
  FFI.typedef :pointer, :cl_context_properties
539
577
  FFI.typedef :cl_uint, :cl_context_info
578
+ FFI.typedef :cl_bitfield, :cl_queue_properties
540
579
  FFI.typedef :cl_uint, :cl_command_queue_info
541
580
  FFI.typedef :cl_uint, :cl_channel_order
542
581
  FFI.typedef :cl_uint, :cl_channel_type
543
582
  FFI.typedef :cl_bitfield, :cl_mem_flags
583
+ FFI.typedef :cl_bitfield, :cl_svm_mem_flags
544
584
  FFI.typedef :cl_uint, :cl_mem_object_type
545
585
  FFI.typedef :cl_uint, :cl_mem_info
546
586
  FFI.typedef :cl_bitfield, :cl_mem_migration_flags
@@ -550,6 +590,8 @@ module OpenCL
550
590
  FFI.typedef :cl_uint, :cl_filter_mode
551
591
  FFI.typedef :cl_uint, :cl_sampler_info
552
592
  FFI.typedef :cl_bitfield, :cl_map_flags
593
+ FFI.typedef :pointer, :cl_pipe_properties
594
+ FFI.typedef :cl_uint, :cl_pipe_info
553
595
  FFI.typedef :cl_uint, :cl_program_info
554
596
  FFI.typedef :cl_uint, :cl_program_build_info
555
597
  FFI.typedef :cl_uint, :cl_program_binary_type
@@ -563,6 +605,8 @@ module OpenCL
563
605
  FFI.typedef :cl_uint, :cl_event_info
564
606
  FFI.typedef :cl_uint, :cl_command_type
565
607
  FFI.typedef :cl_uint, :cl_profiling_info
608
+ FFI.typedef :cl_bitfield, :cl_sampler_properties
609
+ FFI.typedef :cl_uint, :cl_kernel_exec_info
566
610
  FFI.typedef :cl_uint, :cl_gl_object_type
567
611
  FFI.typedef :cl_uint, :cl_gl_texture_info
568
612
  FFI.typedef :cl_uint, :cl_gl_platform_info
@@ -606,6 +650,11 @@ module OpenCL
606
650
  return @val
607
651
  end
608
652
 
653
+ # Returns the integer representing the Enum value
654
+ def to_int
655
+ return @val
656
+ end
657
+
609
658
  # #:stopdoc:
610
659
  # def self.to_native(value, context)
611
660
  # if value then
@@ -663,19 +712,24 @@ module OpenCL
663
712
  return @val
664
713
  end
665
714
 
715
+ # Returns the integer representing the Bitfield value
716
+ def to_int
717
+ return @val
718
+ end
719
+
666
720
  # Returns the bitwise & operation between f and the internal Bitfield representation
667
721
  def &(f)
668
- return @val & f
722
+ return self.class::new( @val & f )
669
723
  end
670
724
 
671
725
  # Returns the bitwise ^ operation between f and the internal Bitfield representation
672
726
  def ^(f)
673
- return @val ^ f
727
+ return self.class::new( @val ^ f )
674
728
  end
675
729
 
676
730
  # Returns the bitwise | operation between f and the internal Bitfield representation
677
731
  def |(f)
678
- return @val | f
732
+ return self.class::new( @val | f )
679
733
  end
680
734
 
681
735
  # Returns the internal representation of the Bitfield
@@ -687,7 +741,7 @@ module OpenCL
687
741
  def flags=(val)
688
742
  @val = val
689
743
  end
690
-
744
+
691
745
  # #:stopdoc:
692
746
  # def self.to_native(value, context)
693
747
  # if value then
@@ -793,6 +847,7 @@ module OpenCL
793
847
  COMPILER_AVAILABLE = 0x1028
794
848
  EXECUTION_CAPABILITIES = 0x1029
795
849
  QUEUE_PROPERTIES = 0x102A
850
+ QUEUE_ON_HOST_PROPERTIES = 0x102A
796
851
  NAME = 0x102B
797
852
  VENDOR = 0x102C
798
853
  PROFILE = 0x102E
@@ -824,6 +879,21 @@ module OpenCL
824
879
  PRINTF_BUFFER_SIZE = 0x1049
825
880
  IMAGE_PITCH_ALIGNMENT = 0x104A
826
881
  IMAGE_BASE_ADDRESS_ALIGNMENT = 0x104B
882
+ MAX_READ_WRITE_IMAGE_ARGS = 0x104C
883
+ MAX_GLOBAL_VARIABLE_SIZE = 0x104D
884
+ QUEUE_ON_DEVICE_PROPERTIES = 0x104E
885
+ QUEUE_ON_DEVICE_PREFERRED_SIZE = 0x104F
886
+ QUEUE_ON_DEVICE_MAX_SIZE = 0x1050
887
+ MAX_ON_DEVICE_QUEUES = 0x1051
888
+ MAX_ON_DEVICE_EVENTS = 0x1052
889
+ SVM_CAPABILITIES = 0x1053
890
+ GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE = 0x1054
891
+ MAX_PIPE_ARGS = 0x1055
892
+ PIPE_MAX_ACTIVE_RESERVATIONS = 0x1056
893
+ PIPE_MAX_PACKET_SIZE = 0x1057
894
+ PREFERRED_PLATFORM_ATOMIC_ALIGNMENT = 0x1058
895
+ PREFERRED_GLOBAL_ATOMIC_ALIGNMENT = 0x1059
896
+ PREFERRED_LOCAL_ATOMIC_ALIGNMENT = 0x105A
827
897
  PARTITION_EQUALLY = 0x1086
828
898
  PARTITION_BY_COUNTS = 0x1087
829
899
  PARTITION_BY_COUNTS_LIST_END = 0x0
@@ -834,8 +904,13 @@ module OpenCL
834
904
  AFFINITY_DOMAIN_L2_CACHE = (1 << 3)
835
905
  AFFINITY_DOMAIN_L1_CACHE = (1 << 4)
836
906
  AFFINITY_DOMAIN_NEXT_PARTITIONABLE = (1 << 5)
907
+ SVM_COARSE_GRAIN_BUFFER = (1 << 0)
908
+ SVM_FINE_GRAIN_BUFFER = (1 << 1)
909
+ SVM_FINE_GRAIN_SYSTEM = (1 << 2)
910
+ SVM_ATOMICS = (1 << 3)
837
911
  HALF_FP_CONFIG = 0x1033
838
912
  TERMINATE_CAPABILITY_KHR = 0x200F
913
+ SPIR_VERSIONS = 0x40E0
839
914
  COMPUTE_CAPABILITY_MAJOR_NV = 0x4000
840
915
  COMPUTE_CAPABILITY_MINOR_NV = 0x4001
841
916
  REGISTERS_PER_BLOCK_NV = 0x4002
@@ -843,22 +918,7 @@ module OpenCL
843
918
  GPU_OVERLAP_NV = 0x4004
844
919
  KERNEL_EXEC_TIMEOUT_NV = 0x4005
845
920
  INTEGRATED_MEMORY_NV = 0x4006
846
- MAX_ATOMIC_COUNTERS_EXT = 0x4032
847
921
  PROFILING_TIMER_OFFSET_AMD = 0x4036
848
- TOPOLOGY_AMD = 0x4037
849
- BOARD_NAME_AMD = 0x4038
850
- GLOBAL_FREE_MEMORY_AMD = 0x4039
851
- SIMD_PER_COMPUTE_UNIT_AMD = 0x4040
852
- SIMD_WIDTH_AMD = 0x4041
853
- SIMD_INSTRUCTION_WIDTH_AMD = 0x4042
854
- WAVEFRONT_WIDTH_AMD = 0x4043
855
- GLOBAL_MEM_CHANNELS_AMD = 0x4044
856
- GLOBAL_MEM_CHANNEL_BANKS_AMD = 0x4045
857
- GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD = 0x4046
858
- LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD = 0x4047
859
- LOCAL_MEM_BANKS_AMD = 0x4048
860
- TOPOLOGY_TYPE_PCIE_AMD = 1
861
- EXT_MEM_PADDING_IN_BYTES_QCOM = 0x40A0
862
922
  PAGE_SIZE_QCOM = 0x40A1
863
923
  #:startdoc:
864
924
 
@@ -964,7 +1024,6 @@ module OpenCL
964
1024
  @@codes[0x1] = 'READ_ONLY_CACHE'
965
1025
  @@codes[0x2] = 'READ_WRITE_CACHE'
966
1026
  #:startdoc:
967
-
968
1027
  # Returns a String representing the Enum value name
969
1028
  def name
970
1029
  return @@codes[@val]
@@ -979,7 +1038,6 @@ module OpenCL
979
1038
  @@codes[0x1] = 'LOCAL'
980
1039
  @@codes[0x2] = 'GLOBAL'
981
1040
  #:startdoc:
982
-
983
1041
  # Returns a String representing the Enum value name
984
1042
  def name
985
1043
  return @@codes[@val]
@@ -1006,6 +1064,24 @@ module OpenCL
1006
1064
  end
1007
1065
  end
1008
1066
 
1067
+ # Bitfield that maps the :cl_device_svm_capabilities
1068
+ class SVMCapabilities < OpenCL::Bitfield
1069
+ #:stopdoc:
1070
+ COARSE_GRAIN_BUFFER = (1 << 0)
1071
+ FINE_GRAIN_BUFFER = (1 << 1)
1072
+ FINE_GRAIN_SYSTEM = (1 << 2)
1073
+ ATOMICS = (1 << 3)
1074
+ #:startdoc:
1075
+ # Returns an Array of String representing the different flags set
1076
+ def names
1077
+ fs = []
1078
+ %w( COARSE_GRAIN_BUFFER FINE_GRAIN_BUFFER FINE_GRAIN_SYSTEM ATOMICS ).each { |f|
1079
+ fs.push(f) if self.include?( self.class.const_get(f) )
1080
+ }
1081
+ return fs
1082
+ end
1083
+ end
1084
+
1009
1085
  end
1010
1086
  class Context < FFI::ManagedStruct
1011
1087
  layout :dummy, :pointer
@@ -1018,7 +1094,6 @@ module OpenCL
1018
1094
  INTEROP_USER_SYNC = 0x1085
1019
1095
  MEMORY_INITIALIZE_KHR = 0x200E
1020
1096
  TERMINATE_KHR = 0x2010
1021
- OFFLINE_DEVICES_AMD = 0x403F
1022
1097
  #:startdoc:
1023
1098
 
1024
1099
  # Creates a new Context and retains it if specified and aplicable
@@ -1053,10 +1128,13 @@ module OpenCL
1053
1128
  #:stopdoc:
1054
1129
  OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0)
1055
1130
  PROFILING_ENABLE = (1 << 1)
1131
+ ON_DEVICE = (1 << 2)
1132
+ ON_DEVICE_DEFAULT = (1 << 3)
1056
1133
  CONTEXT = 0x1090
1057
1134
  DEVICE = 0x1091
1058
1135
  REFERENCE_COUNT = 0x1092
1059
1136
  PROPERTIES = 0x1093
1137
+ SIZE = 0x1094
1060
1138
  #:startdoc:
1061
1139
 
1062
1140
  # Creates a new CommandQueue and retains it if specified and aplicable
@@ -1091,11 +1169,13 @@ module OpenCL
1091
1169
  #:stopdoc:
1092
1170
  OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0)
1093
1171
  PROFILING_ENABLE = (1 << 1)
1172
+ ON_DEVICE = (1 << 2)
1173
+ ON_DEVICE_DEFAULT = (1 << 3)
1094
1174
  #:startdoc:
1095
1175
  # Returns an Array of String representing the different flags set
1096
1176
  def names
1097
1177
  fs = []
1098
- %w( OUT_OF_ORDER_EXEC_MODE_ENABLE PROFILING_ENABLE ).each { |f|
1178
+ %w( OUT_OF_ORDER_EXEC_MODE_ENABLE PROFILING_ENABLE ON_DEVICE ON_DEVICE_DEFAULT ).each { |f|
1099
1179
  fs.push(f) if self.include?( self.class.const_get(f) )
1100
1180
  }
1101
1181
  return fs
@@ -1115,6 +1195,8 @@ module OpenCL
1115
1195
  HOST_WRITE_ONLY = (1 << 7)
1116
1196
  HOST_READ_ONLY = (1 << 8)
1117
1197
  HOST_NO_ACCESS = (1 << 9)
1198
+ SVM_FINE_GRAIN_BUFFER = (1 << 10)
1199
+ SVM_ATOMICS = (1 << 11)
1118
1200
  BUFFER = 0x10F0
1119
1201
  IMAGE2D = 0x10F1
1120
1202
  IMAGE3D = 0x10F2
@@ -1122,6 +1204,7 @@ module OpenCL
1122
1204
  IMAGE1D = 0x10F4
1123
1205
  IMAGE1D_ARRAY = 0x10F5
1124
1206
  IMAGE1D_BUFFER = 0x10F6
1207
+ PIPE = 0x10F7
1125
1208
  TYPE = 0x1100
1126
1209
  FLAGS = 0x1101
1127
1210
  SIZE = 0x1102
@@ -1131,8 +1214,7 @@ module OpenCL
1131
1214
  CONTEXT = 0x1106
1132
1215
  ASSOCIATED_MEMOBJECT = 0x1107
1133
1216
  OFFSET = 0x1108
1134
- USE_PERSISTENT_MEM_AMD = (1 << 6)
1135
- EXT_HOST_PTR_QCOM = (1 << 29)
1217
+ USES_SVM_POINTER = 0x1109
1136
1218
  HOST_UNCACHED_QCOM = 0x40A4
1137
1219
  HOST_WRITEBACK_QCOM = 0x40A5
1138
1220
  HOST_WRITETHROUGH_QCOM = 0x40A6
@@ -1217,6 +1299,7 @@ module OpenCL
1217
1299
  IMAGE1D = 0x10F4
1218
1300
  IMAGE1D_ARRAY = 0x10F5
1219
1301
  IMAGE1D_BUFFER = 0x10F6
1302
+ PIPE = 0x10F7
1220
1303
  @@codes[0x10F0] = 'BUFFER'
1221
1304
  @@codes[0x10F1] = 'IMAGE2D'
1222
1305
  @@codes[0x10F2] = 'IMAGE3D'
@@ -1224,14 +1307,33 @@ module OpenCL
1224
1307
  @@codes[0x10F4] = 'IMAGE1D'
1225
1308
  @@codes[0x10F5] = 'IMAGE1D_ARRAY'
1226
1309
  @@codes[0x10F6] = 'IMAGE1D_BUFFER'
1310
+ @@codes[0x10F7] = 'PIPE'
1227
1311
  #:startdoc:
1228
-
1229
1312
  # Returns a String representing the Enum value name
1230
1313
  def name
1231
1314
  return @@codes[@val]
1232
1315
  end
1233
1316
  end
1234
1317
 
1318
+ # Bitfield that maps the :cl_svm_mem_flags type
1319
+ class SVMFlags < OpenCL::Bitfield
1320
+ #:stopdoc:
1321
+ READ_WRITE = (1 << 0)
1322
+ WRITE_ONLY = (1 << 1)
1323
+ READ_ONLY = (1 << 2)
1324
+ SVM_FINE_GRAIN_BUFFER = (1 << 10)
1325
+ SVM_ATOMICS = (1 << 11)
1326
+ #:startdoc:
1327
+ # Returns an Array of String representing the different flags set
1328
+ def names
1329
+ fs = []
1330
+ %w( READ_WRITE WRITE_ONLY READ_ONLY SVM_FINE_GRAIN_BUFFER SVM_ATOMICS ).each { |f|
1331
+ fs.push(f) if self.include?( self.class.const_get(f) )
1332
+ }
1333
+ return fs
1334
+ end
1335
+ end
1336
+
1235
1337
  end
1236
1338
  class Program < FFI::ManagedStruct
1237
1339
  layout :dummy, :pointer
@@ -1249,10 +1351,12 @@ module OpenCL
1249
1351
  BUILD_OPTIONS = 0x1182
1250
1352
  BUILD_LOG = 0x1183
1251
1353
  BINARY_TYPE = 0x1184
1354
+ BUILD_GLOBAL_VARIABLE_TOTAL_SIZE = 0x1185
1252
1355
  BINARY_TYPE_NONE = 0x0
1253
1356
  BINARY_TYPE_COMPILED_OBJECT = 0x1
1254
1357
  BINARY_TYPE_LIBRARY = 0x2
1255
1358
  BINARY_TYPE_EXECUTABLE = 0x4
1359
+ BINARY_TYPE_INTERMEDIATE = 0x40E1
1256
1360
  #:startdoc:
1257
1361
 
1258
1362
  # Creates a new Program and retains it if specified and aplicable
@@ -1290,12 +1394,13 @@ module OpenCL
1290
1394
  COMPILED_OBJECT = 0x1
1291
1395
  LIBRARY = 0x2
1292
1396
  EXECUTABLE = 0x4
1397
+ INTERMEDIATE = 0x40E1
1293
1398
  @@codes[0x0] = 'NONE'
1294
1399
  @@codes[0x1] = 'COMPILED_OBJECT'
1295
1400
  @@codes[0x2] = 'LIBRARY'
1296
1401
  @@codes[0x4] = 'EXECUTABLE'
1402
+ @@codes[0x40E1] = 'INTERMEDIATE'
1297
1403
  #:startdoc:
1298
-
1299
1404
  # Returns a String representing the Enum value name
1300
1405
  def name
1301
1406
  return @@codes[@val]
@@ -1329,12 +1434,15 @@ module OpenCL
1329
1434
  ARG_TYPE_CONST = (1 << 0)
1330
1435
  ARG_TYPE_RESTRICT = (1 << 1)
1331
1436
  ARG_TYPE_VOLATILE = (1 << 2)
1437
+ ARG_TYPE_PIPE = (1 << 3)
1332
1438
  WORK_GROUP_SIZE = 0x11B0
1333
1439
  COMPILE_WORK_GROUP_SIZE = 0x11B1
1334
1440
  LOCAL_MEM_SIZE = 0x11B2
1335
1441
  PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x11B3
1336
1442
  PRIVATE_MEM_SIZE = 0x11B4
1337
1443
  GLOBAL_WORK_SIZE = 0x11B5
1444
+ EXEC_INFO_SVM_PTRS = 0x11B6
1445
+ EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = 0x11B7
1338
1446
  #:startdoc:
1339
1447
 
1340
1448
  # Creates a new Kernel and retains it if specified and aplicable
@@ -1385,6 +1493,7 @@ module OpenCL
1385
1493
  TYPE_CONST = (1 << 0)
1386
1494
  TYPE_RESTRICT = (1 << 1)
1387
1495
  TYPE_VOLATILE = (1 << 2)
1496
+ TYPE_PIPE = (1 << 3)
1388
1497
  #:startdoc:
1389
1498
  end
1390
1499
 
@@ -1401,7 +1510,6 @@ module OpenCL
1401
1510
  @@codes[0x119D] = 'CONSTANT'
1402
1511
  @@codes[0x119E] = 'PRIVATE'
1403
1512
  #:startdoc:
1404
-
1405
1513
  # Returns a String representing the Enum value name
1406
1514
  def name
1407
1515
  return @@codes[@val]
@@ -1420,7 +1528,6 @@ module OpenCL
1420
1528
  @@codes[0x11A2] = 'READ_WRITE'
1421
1529
  @@codes[0x11A3] = 'NONE'
1422
1530
  #:startdoc:
1423
-
1424
1531
  # Returns a String representing the Enum value name
1425
1532
  def name
1426
1533
  return @@codes[@val]
@@ -1434,11 +1541,12 @@ module OpenCL
1434
1541
  CONST = (1 << 0)
1435
1542
  RESTRICT = (1 << 1)
1436
1543
  VOLATILE = (1 << 2)
1544
+ PIPE = (1 << 3)
1437
1545
  #:startdoc:
1438
1546
  # Returns an Array of String representing the different flags set
1439
1547
  def names
1440
1548
  fs = []
1441
- %w( NONE CONST RESTRICT VOLATILE ).each { |f|
1549
+ %w( NONE CONST RESTRICT VOLATILE PIPE ).each { |f|
1442
1550
  fs.push(f) if self.include?( self.class.const_get(f) )
1443
1551
  }
1444
1552
  return fs
@@ -1492,6 +1600,9 @@ module OpenCL
1492
1600
  NORMALIZED_COORDS = 0x1152
1493
1601
  ADDRESSING_MODE = 0x1153
1494
1602
  FILTER_MODE = 0x1154
1603
+ MIP_FILTER_MODE = 0x1155
1604
+ LOD_MIN = 0x1156
1605
+ LOD_MAX = 0x1157
1495
1606
  #:startdoc:
1496
1607
 
1497
1608
  # Creates a new Sampler and retains it if specified and aplicable
@@ -1521,6 +1632,30 @@ module OpenCL
1521
1632
  end
1522
1633
  end
1523
1634
 
1635
+ class Sampler
1636
+ # Enum that maps the :cl_sampler_properties
1637
+ class Type < OpenCL::Enum
1638
+ #:stopdoc:
1639
+ NORMALIZED_COORDS = 0x1152
1640
+ ADDRESSING_MODE = 0x1153
1641
+ FILTER_MODE = 0x1154
1642
+ MIP_FILTER_MODE = 0x1155
1643
+ LOD_MIN = 0x1156
1644
+ LOD_MAX = 0x1157
1645
+ @@codes[0x1152] = 'NORMALIZED_COORDS'
1646
+ @@codes[0x1153] = 'ADDRESSING_MODE'
1647
+ @@codes[0x1154] = 'FILTER_MODE'
1648
+ @@codes[0x1155] = 'MIP_FILTER_MODE'
1649
+ @@codes[0x1156] = 'LOD_MIN'
1650
+ @@codes[0x1157] = 'LOD_MAX'
1651
+ #:startdoc:
1652
+ # Returns a String representing the Enum value name
1653
+ def name
1654
+ return @@codes[@val]
1655
+ end
1656
+ end
1657
+
1658
+ end
1524
1659
  class GLsync < FFI::ManagedStruct
1525
1660
  layout :dummy, :pointer
1526
1661
  #:stopdoc:
@@ -1564,6 +1699,11 @@ module OpenCL
1564
1699
  RGBx = 0x10BC
1565
1700
  DEPTH = 0x10BD
1566
1701
  DEPTH_STENCIL = 0x10BE
1702
+ sRGB = 0x10BF
1703
+ sRGBx = 0x10C0
1704
+ sRGBA = 0x10C1
1705
+ sBGRA = 0x10C2
1706
+ ABGR = 0x10C3
1567
1707
  @@codes[0x10B0] = 'R'
1568
1708
  @@codes[0x10B1] = 'A'
1569
1709
  @@codes[0x10B2] = 'RG'
@@ -1579,8 +1719,12 @@ module OpenCL
1579
1719
  @@codes[0x10BC] = 'RGBx'
1580
1720
  @@codes[0x10BD] = 'DEPTH'
1581
1721
  @@codes[0x10BE] = 'DEPTH_STENCIL'
1722
+ @@codes[0x10BF] = 'sRGB'
1723
+ @@codes[0x10C0] = 'sRGBx'
1724
+ @@codes[0x10C1] = 'sRGBA'
1725
+ @@codes[0x10C2] = 'sBGRA'
1726
+ @@codes[0x10C3] = 'ABGR'
1582
1727
  #:startdoc:
1583
-
1584
1728
  # Returns a String representing the Enum value name
1585
1729
  def name
1586
1730
  return @@codes[@val]
@@ -1623,7 +1767,6 @@ module OpenCL
1623
1767
  @@codes[0x10DE] = 'FLOAT'
1624
1768
  @@codes[0x10DF] = 'UNORM_INT24'
1625
1769
  #:startdoc:
1626
-
1627
1770
  # Returns a String representing the Enum value name
1628
1771
  def name
1629
1772
  return @@codes[@val]
@@ -1644,7 +1787,6 @@ module OpenCL
1644
1787
  @@codes[0x1133] = 'REPEAT'
1645
1788
  @@codes[0x1134] = 'MIRRORED_REPEAT'
1646
1789
  #:startdoc:
1647
-
1648
1790
  # Returns a String representing the Enum value name
1649
1791
  def name
1650
1792
  return @@codes[@val]
@@ -1659,7 +1801,6 @@ module OpenCL
1659
1801
  @@codes[0x1140] = 'NEAREST'
1660
1802
  @@codes[0x1141] = 'LINEAR'
1661
1803
  #:startdoc:
1662
-
1663
1804
  # Returns a String representing the Enum value name
1664
1805
  def name
1665
1806
  return @@codes[@val]
@@ -1711,6 +1852,11 @@ module OpenCL
1711
1852
  MIGRATE_MEM_OBJECTS = 0x1206
1712
1853
  FILL_BUFFER = 0x1207
1713
1854
  FILL_IMAGE = 0x1208
1855
+ SVM_FREE = 0x1209
1856
+ SVM_MEMCPY = 0x120A
1857
+ SVM_MEMFILL = 0x120B
1858
+ SVM_MAP = 0x120C
1859
+ SVM_UNMAP = 0x120D
1714
1860
  @@codes[0x11F0] = 'NDRANGE_KERNEL'
1715
1861
  @@codes[0x11F1] = 'TASK'
1716
1862
  @@codes[0x11F2] = 'NATIVE_KERNEL'
@@ -1736,8 +1882,12 @@ module OpenCL
1736
1882
  @@codes[0x1206] = 'MIGRATE_MEM_OBJECTS'
1737
1883
  @@codes[0x1207] = 'FILL_BUFFER'
1738
1884
  @@codes[0x1208] = 'FILL_IMAGE'
1885
+ @@codes[0x1209] = 'SVM_FREE'
1886
+ @@codes[0x120A] = 'SVM_MEMCPY'
1887
+ @@codes[0x120B] = 'SVM_MEMFILL'
1888
+ @@codes[0x120C] = 'SVM_MAP'
1889
+ @@codes[0x120D] = 'SVM_UNMAP'
1739
1890
  #:startdoc:
1740
-
1741
1891
  # Returns a String representing the Enum value name
1742
1892
  def name
1743
1893
  return @@codes[@val]
@@ -1764,7 +1914,6 @@ module OpenCL
1764
1914
  @@codes[0x2010] = 'TEXTURE1D_ARRAY'
1765
1915
  @@codes[0x2011] = 'TEXTURE_BUFFER'
1766
1916
  #:startdoc:
1767
-
1768
1917
  # Returns a String representing the Enum value name
1769
1918
  def name
1770
1919
  return @@codes[@val]
@@ -1783,7 +1932,6 @@ module OpenCL
1783
1932
  @@codes[-2] = 'ERROR'
1784
1933
  @@codes[-3] = 'IN_PROGRESS'
1785
1934
  #:startdoc:
1786
-
1787
1935
  # Returns a String representing the Enum value name
1788
1936
  def name
1789
1937
  return @@codes[@val]
@@ -1802,7 +1950,6 @@ module OpenCL
1802
1950
  @@codes[0x2] = 'SUBMITTED'
1803
1951
  @@codes[0x3] = 'QUEUED'
1804
1952
  #:startdoc:
1805
-
1806
1953
  # Returns a String representing the Enum value name
1807
1954
  def name
1808
1955
  return @@codes[@val]
@@ -1829,6 +1976,13 @@ module OpenCL
1829
1976
  SLICE_ALIGNMENT_QCOM = 0x40A3
1830
1977
  #:startdoc:
1831
1978
  end
1979
+ class Pipe < Mem
1980
+ layout :dummy, :pointer
1981
+ #:stopdoc:
1982
+ PACKET_SIZE = 0x1120
1983
+ MAX_PACKETS = 0x1121
1984
+ #:startdoc:
1985
+ end
1832
1986
  attach_function :clGetPlatformIDs, [:cl_uint,:pointer,:pointer], :cl_int
1833
1987
  attach_function :clGetPlatformInfo, [Platform,:cl_platform_info,:size_t,:pointer,:pointer], :cl_int
1834
1988
  attach_function :clGetDeviceIDs, [Platform,:cl_device_type,:cl_uint,:pointer,:pointer], :cl_int
@@ -1840,7 +1994,6 @@ module OpenCL
1840
1994
  attach_function :clRetainContext, [Context], :cl_int
1841
1995
  attach_function :clReleaseContext, [Context], :cl_int
1842
1996
  attach_function :clGetContextInfo, [Context,:cl_context_info,:size_t,:pointer,:pointer], :cl_int
1843
- attach_function :clCreateCommandQueue, [Context,Device,:cl_command_queue_properties,:pointer], CommandQueue
1844
1997
  attach_function :clRetainCommandQueue, [CommandQueue], :cl_int
1845
1998
  attach_function :clReleaseCommandQueue, [CommandQueue], :cl_int
1846
1999
  attach_function :clGetCommandQueueInfo, [CommandQueue,:cl_command_queue_info,:size_t,:pointer,:pointer], :cl_int
@@ -1853,7 +2006,6 @@ module OpenCL
1853
2006
  attach_function :clGetImageInfo, [Mem,:cl_image_info,:size_t,:pointer,:pointer], :cl_int
1854
2007
  callback :clSetMemObjectDestructorCallback_notify, [Mem.by_ref,:pointer], :void
1855
2008
  attach_function :clSetMemObjectDestructorCallback, [Mem,:clSetMemObjectDestructorCallback_notify,:pointer], :cl_int
1856
- attach_function :clCreateSampler, [Context,:cl_bool,:cl_addressing_mode,:cl_filter_mode,:pointer], Sampler
1857
2009
  attach_function :clRetainSampler, [Sampler], :cl_int
1858
2010
  attach_function :clReleaseSampler, [Sampler], :cl_int
1859
2011
  attach_function :clGetSamplerInfo, [Sampler,:cl_sampler_info,:size_t,:pointer,:pointer], :cl_int
@@ -1898,7 +2050,6 @@ module OpenCL
1898
2050
  attach_function :clEnqueueMapImage, [CommandQueue,Mem,:cl_bool,:cl_map_flags,:pointer,:pointer,:pointer,:pointer,:cl_uint,:pointer,:pointer,:pointer], :pointer
1899
2051
  attach_function :clEnqueueUnmapMemObject, [CommandQueue,Mem,:pointer,:cl_uint,:pointer,:pointer], :cl_int
1900
2052
  attach_function :clEnqueueNDRangeKernel, [CommandQueue,Kernel,:cl_uint,:pointer,:pointer,:pointer,:cl_uint,:pointer,:pointer], :cl_int
1901
- attach_function :clEnqueueTask, [CommandQueue,Kernel,:cl_uint,:pointer,:pointer], :cl_int
1902
2053
  callback :clEnqueueNativeKernel_notify, [:pointer], :void
1903
2054
  attach_function :clEnqueueNativeKernel, [CommandQueue,:clEnqueueNativeKernel_notify,:pointer,:size_t,:cl_uint,:pointer,:pointer,:cl_uint,:pointer,:pointer], :cl_int
1904
2055
  attach_function :clCreateImage2D, [Context,:cl_mem_flags,:pointer,:size_t,:size_t,:size_t,:pointer,:pointer], Mem
@@ -1908,6 +2059,9 @@ module OpenCL
1908
2059
  attach_function :clEnqueueBarrier, [CommandQueue], :cl_int
1909
2060
  attach_function :clUnloadCompiler, [:void], :cl_int
1910
2061
  attach_function :clGetExtensionFunctionAddress, [:pointer], :pointer
2062
+ attach_function :clCreateCommandQueue, [Context,Device,:cl_command_queue_properties,:pointer], CommandQueue
2063
+ attach_function :clCreateSampler, [Context,:cl_bool,:cl_addressing_mode,:cl_filter_mode,:pointer], Sampler
2064
+ attach_function :clEnqueueTask, [CommandQueue,Kernel,:cl_uint,:pointer,:pointer], :cl_int
1911
2065
  attach_function :clCreateFromGLBuffer, [Context,:cl_mem_flags,:cl_GLuint,:pointer], Mem
1912
2066
  attach_function :clCreateFromGLRenderbuffer, [Context,:cl_mem_flags,:cl_GLuint,:pointer], Mem
1913
2067
  attach_function :clGetGLObjectInfo, [Mem,:pointer,:pointer], :cl_int
@@ -1935,6 +2089,24 @@ module OpenCL
1935
2089
  attach_function :clEnqueueBarrierWithWaitList, [CommandQueue,:cl_uint,:pointer,:pointer], :cl_int
1936
2090
  attach_function :clGetExtensionFunctionAddressForPlatform, [Platform,:pointer], :pointer
1937
2091
  attach_function :clCreateFromGLTexture, [Context,:cl_mem_flags,:cl_GLenum,:cl_GLint,:cl_GLuint,:pointer], Mem
2092
+ begin
2093
+ attach_function :clCreateCommandQueueWithProperties, [Context,Device,:pointer,:pointer], CommandQueue
2094
+ attach_function :clCreatePipe, [Context,:cl_mem_flags,:cl_uint,:cl_uint,:pointer,:pointer], Mem
2095
+ attach_function :clGetPipeInfo, [Mem,:cl_pipe_info,:size_t,:pointer,:pointer], :cl_int
2096
+ attach_function :clSVMAlloc, [Context,:cl_svm_mem_flags,:size_t,:cl_uint], :pointer
2097
+ attach_function :clSVMFree, [Context,:pointer], :void
2098
+ attach_function :clCreateSamplerWithProperties, [Context,:pointer,:pointer], Sampler
2099
+ attach_function :clSetKernelArgSVMPointer, [Kernel,:cl_uint,:pointer], :cl_int
2100
+ attach_function :clSetKernelExecInfo, [Kernel,:cl_kernel_exec_info,:size_t,:pointer], :cl_int
2101
+ callback :clEnqueueSVMFree_notify, [CommandQueue.by_ref,:cl_uint,:pointer,:pointer], :void
2102
+ attach_function :clEnqueueSVMFree, [CommandQueue,:cl_uint,:pointer,:clEnqueueSVMFree_notify,:pointer,:cl_uint,:pointer,:pointer], :cl_int
2103
+ attach_function :clEnqueueSVMMemcpy, [CommandQueue,:cl_bool,:pointer,:pointer,:size_t,:cl_uint,:pointer,:pointer], :cl_int
2104
+ attach_function :clEnqueueSVMMemFill, [CommandQueue,:pointer,:pointer,:size_t,:size_t,:cl_uint,:pointer,:pointer], :cl_int
2105
+ attach_function :clEnqueueSVMMap, [CommandQueue,:cl_bool,:cl_map_flags,:pointer,:size_t,:cl_uint,:pointer,:pointer], :cl_int
2106
+ attach_function :clEnqueueSVMUnmap, [CommandQueue,:pointer,:cl_uint,:pointer,:pointer], :cl_int
2107
+ rescue FFI::NotFoundError => e
2108
+ STDERR.puts "Warning OpenCL 1.2 loader detected!"
2109
+ end
1938
2110
  rescue FFI::NotFoundError => e
1939
2111
  STDERR.puts "Warning OpenCL 1.1 loader detected!"
1940
2112
  end