opencl_ruby_ffi 0.993 → 0.994

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,12 +12,12 @@ module OpenCL
12
12
  #
13
13
  # * +:flags+ - a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Pipe
14
14
  def self.create_pipe( context, pipe_packet_size, pipe_max_packets, options = {} )
15
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if self.context.platform.version_number < 2.0
16
- flags = OpenCL.get_flags( options )
15
+ error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.0
16
+ flags = get_flags( options )
17
17
  error = FFI::MemoryPointer::new( :cl_int )
18
- pipe_ptr = OpenCL::clCreatePipe( context, flags, pipe_packet_size, pipe_max_packets, nil, error)
19
- OpenCL.error_check(error.read_cl_int)
20
- return OpenCL::Pipe::new(pipe_ptr, false)
18
+ pipe_ptr = clCreatePipe( context, flags, pipe_packet_size, pipe_max_packets, nil, error)
19
+ error_check(error.read_cl_int)
20
+ return Pipe::new(pipe_ptr, false)
21
21
  end
22
22
 
23
23
  # Maps the cl_mem OpenCL objects of type CL_MEM_OBJECT_PIPE
@@ -6,16 +6,16 @@ module OpenCL
6
6
  #
7
7
  # * +platform+ - the Platform to have it's compiler unloaded
8
8
  def self.unload_platform_compiler(platform)
9
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if self.version_number < 1.2
10
- error = OpenCL.clUnloadPlatformCompiler( platform )
11
- OpenCL.error_check(error)
9
+ error_check(INVALID_OPERATION) if self.version_number < 1.2
10
+ error = clUnloadPlatformCompiler( platform )
11
+ error_check(error)
12
12
  return platform
13
13
  end
14
14
 
15
15
  # Unloads the compiler
16
16
  def self.unload_compiler
17
- error = OpenCL.clUnloadCompiler()
18
- OpenCL.error_check(error)
17
+ error = clUnloadCompiler()
18
+ error_check(error)
19
19
  return nil
20
20
  end
21
21
 
@@ -29,7 +29,7 @@ module OpenCL
29
29
  # * +options+ - if given, a hash of named options that will be given to FFI::Function::new. See FFI doc for details.
30
30
  def self.get_extension_function( name, return_type, param_types, options = {} )
31
31
  name_p = FFI::MemoryPointer.from_string(name)
32
- ptr = OpenCL.clGetExtensionFunctionAddress( name_p )
32
+ ptr = clGetExtensionFunctionAddress( name_p )
33
33
  return nil if ptr.null?
34
34
  return FFI::Function::new(return_type, param_types, ptr, options)
35
35
  end
@@ -44,9 +44,9 @@ module OpenCL
44
44
  # * +param_types+ - an Array of types, corresponding to the parameters type
45
45
  # * +options+ - if given, a hash of named options that will be given to FFI::Function::new. See FFI doc for details.
46
46
  def self.get_extension_function_for_platform( platform, name, return_type, param_types, options = {} )
47
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if self.version_number < 1.2
47
+ error_check(INVALID_OPERATION) if self.version_number < 1.2
48
48
  name_p = FFI::MemoryPointer.from_string(name)
49
- ptr = OpenCL.clGetExtensionFunctionAddressForPlatform( platform, name_p )
49
+ ptr = clGetExtensionFunctionAddressForPlatform( platform, name_p )
50
50
  return nil if ptr.null?
51
51
  return FFI::Function::new(return_type, param_types, ptr, options)
52
52
  end
@@ -55,13 +55,13 @@ module OpenCL
55
55
  def self.get_platforms
56
56
  ptr1 = FFI::MemoryPointer::new(:cl_uint , 1)
57
57
 
58
- error = OpenCL::clGetPlatformIDs(0, nil, ptr1)
59
- OpenCL.error_check(error)
58
+ error = clGetPlatformIDs(0, nil, ptr1)
59
+ error_check(error)
60
60
  ptr2 = FFI::MemoryPointer::new(:pointer, ptr1.read_uint)
61
- error = OpenCL::clGetPlatformIDs(ptr1.read_uint(), ptr2, nil)
62
- OpenCL.error_check(error)
61
+ error = clGetPlatformIDs(ptr1.read_uint(), ptr2, nil)
62
+ error_check(error)
63
63
  return ptr2.get_array_of_pointer(0,ptr1.read_uint()).collect { |platform_ptr|
64
- OpenCL::Platform::new(platform_ptr, false)
64
+ Platform::new(platform_ptr, false)
65
65
  }
66
66
  end
67
67
 
@@ -94,10 +94,10 @@ module OpenCL
94
94
  # Returns an Array of string corresponding to the Platform extensions
95
95
  def extensions
96
96
  extensions_size = FFI::MemoryPointer::new( :size_t )
97
- error = OpenCL.clGetPlatformInfo( self, OpenCL::Platform::EXTENSIONS, 0, nil, extensions_size)
97
+ error = OpenCL.clGetPlatformInfo( self, EXTENSIONS, 0, nil, extensions_size)
98
98
  OpenCL.error_check(error)
99
99
  ext = FFI::MemoryPointer::new( extensions_size.read_size_t )
100
- error = OpenCL.clGetPlatformInfo( self, OpenCL::Platform::EXTENSIONS, extensions_size.read_size_t, ext, nil)
100
+ error = OpenCL.clGetPlatformInfo( self, EXTENSIONS, extensions_size.read_size_t, ext, nil)
101
101
  OpenCL.error_check(error)
102
102
  ext_string = ext.read_string
103
103
  return ext_string.split(" ")
@@ -107,10 +107,10 @@ module OpenCL
107
107
  # The type of the desired devices can be specified
108
108
  def devices(type = OpenCL::Device::Type::ALL)
109
109
  ptr1 = FFI::MemoryPointer::new(:cl_uint , 1)
110
- error = OpenCL::clGetDeviceIDs(self, type, 0, nil, ptr1)
110
+ error = OpenCL.clGetDeviceIDs(self, type, 0, nil, ptr1)
111
111
  OpenCL.error_check(error)
112
112
  ptr2 = FFI::MemoryPointer::new(:pointer, ptr1.read_uint)
113
- error = OpenCL::clGetDeviceIDs(self, type, ptr1.read_uint(), ptr2, nil)
113
+ error = OpenCL.clGetDeviceIDs(self, type, ptr1.read_uint(), ptr2, nil)
114
114
  OpenCL.error_check(error)
115
115
  return ptr2.get_array_of_pointer(0, ptr1.read_uint()).collect { |device_ptr|
116
116
  OpenCL::Device::new(device_ptr, false)
@@ -29,8 +29,8 @@ module OpenCL
29
29
  opt = ""
30
30
  opt = options[:options] if options[:options]
31
31
  options_p = FFI::MemoryPointer.from_string(opt)
32
- error = OpenCL.clBuildProgram(program, num_devices, devices_p, options_p, block, options[:user_data] )
33
- OpenCL.error_check(error)
32
+ error = clBuildProgram(program, num_devices, devices_p, options_p, block, options[:user_data] )
33
+ error_check(error)
34
34
  return program
35
35
  end
36
36
 
@@ -71,9 +71,9 @@ module OpenCL
71
71
  programs_p[i].write_pointer(e)
72
72
  }
73
73
  error = FFI::MemoryPointer::new( :cl_int )
74
- prog = OpenCL.clLinkProgram( context, num_devices, devices_p, options_p, num_programs, programs_p, block, options[:user_data], error)
75
- OpenCL.error_check(error.read_cl_int)
76
- return OpenCL::Program::new( prog, false )
74
+ prog = clLinkProgram( context, num_devices, devices_p, options_p, num_programs, programs_p, block, options[:user_data], error)
75
+ error_check(error.read_cl_int)
76
+ return Program::new( prog, false )
77
77
  end
78
78
 
79
79
  # Compiles a Program created from sources
@@ -121,8 +121,8 @@ module OpenCL
121
121
  indx = indx + 1
122
122
  }
123
123
  end
124
- error = OpenCL.clCompileProgram(program, num_devices, devices_p, options_p, num_headers, headers_p, header_include_names, block, options[:user_data] )
125
- OpenCL.error_check(error)
124
+ error = clCompileProgram(program, num_devices, devices_p, options_p, num_headers, headers_p, header_include_names, block, options[:user_data] )
125
+ error_check(error)
126
126
  return program
127
127
  end
128
128
 
@@ -143,9 +143,9 @@ module OpenCL
143
143
  names = [kernel_names].flatten.join(",")
144
144
  names_p = FFI::MemoryPointer.from_string(names)
145
145
  error = FFI::MemoryPointer::new( :cl_int )
146
- prog = OpenCL.clCreateProgramWithBuiltInKernels( context, num_devices, devices_p, names_p, error )
147
- OpenCL.error_check(error.read_cl_int)
148
- return OpenCL::Program::new(prog, false)
146
+ prog = clCreateProgramWithBuiltInKernels( context, num_devices, devices_p, names_p, error )
147
+ error_check(error.read_cl_int)
148
+ return Program::new(prog, false)
149
149
  end
150
150
 
151
151
  # Creates a Program from binary
@@ -153,13 +153,13 @@ module OpenCL
153
153
  # ==== Attributes
154
154
  #
155
155
  # * +context+ - Context the created Program will be associated to
156
- # * +device_list+ - an Array of Device to create the program for. Can throw an OpenCL::Invalid value if the number of supplied devices is different from the number of supplied binaries.
156
+ # * +device_list+ - an Array of Device to create the program for. Can throw an Error::INVALID_VALUE if the number of supplied devices is different from the number of supplied binaries.
157
157
  # * +binaries+ - Array of binaries
158
158
  def self.create_program_with_binary(context, device_list, binaries)
159
159
  bins = [binaries].flatten
160
160
  num_devices = bins.length
161
161
  devices = [device_list].flatten
162
- OpenCL.error_check(OpenCL::INVALID_VALUE) if devices.length != bins.length
162
+ error_check(INVALID_VALUE) if devices.length != bins.length
163
163
  devices_p = FFI::MemoryPointer::new( Device, num_devices )
164
164
  lengths = FFI::MemoryPointer::new( :size_t, num_devices )
165
165
  binaries_p = FFI::MemoryPointer::new( :pointer, num_devices )
@@ -172,13 +172,13 @@ module OpenCL
172
172
  }
173
173
  binary_status = FFI::MemoryPointer::new( :cl_int, num_devices )
174
174
  error = FFI::MemoryPointer::new( :cl_int )
175
- prog = OpenCL.clCreateProgramWithBinary(context, num_devices, devices_p, lengths, binaries_p, binary_status, error)
176
- OpenCL.error_check(error.read_cl_int)
175
+ prog = clCreateProgramWithBinary(context, num_devices, devices_p, lengths, binaries_p, binary_status, error)
176
+ error_check(error.read_cl_int)
177
177
  d_s = []
178
178
  num_devices.times { |indx|
179
179
  d_s.push [ devices[indx], binary_status[indx].read_cl_int ]
180
180
  }
181
- return [ OpenCL::Program::new(prog, false), d_s ]
181
+ return [ Program::new(prog, false), d_s ]
182
182
  end
183
183
 
184
184
  # Creates a Program from sources
@@ -190,7 +190,7 @@ module OpenCL
190
190
  def self.create_program_with_source(context, strings)
191
191
  strs = nil
192
192
  if not strings then
193
- OpenCL.error_check(OpenCL::INVALID_VALUE)
193
+ error_check(INVALID_VALUE)
194
194
  else
195
195
  strs = [strings].flatten
196
196
  end
@@ -204,7 +204,7 @@ module OpenCL
204
204
  c_strs_p.push (FFI::MemoryPointer.from_string(str))
205
205
  end
206
206
  }
207
- OpenCL.error_check(OpenCL::INVALID_VALUE) if c_strs_p.size == 0
207
+ error_check(INVALID_VALUE) if c_strs_p.size == 0
208
208
 
209
209
  c_strs = FFI::MemoryPointer::new( :pointer, c_strs_p.size )
210
210
  c_strs_length = FFI::MemoryPointer::new( :size_t, c_strs_p.size )
@@ -213,9 +213,9 @@ module OpenCL
213
213
  c_strs_length[i].write_size_t(p.size)
214
214
  }
215
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
- return OpenCL::Program::new( program_ptr, false )
216
+ program_ptr = clCreateProgramWithSource(context, c_strs_p.size, c_strs, c_strs_length, error)
217
+ error_check(error.read_cl_int)
218
+ return Program::new( program_ptr, false )
219
219
  end
220
220
 
221
221
  # Maps the cl_program object of OpenCL
@@ -248,10 +248,10 @@ module OpenCL
248
248
  # Returns an Array of String representing the Kernel names inside the Program
249
249
  def kernel_names
250
250
  kernel_names_size = FFI::MemoryPointer::new( :size_t )
251
- error = OpenCL.clGetProgramInfo( self, OpenCL::Program::KERNEL_NAMES, 0, nil, kernel_names_size)
251
+ error = OpenCL.clGetProgramInfo( self, KERNEL_NAMES, 0, nil, kernel_names_size)
252
252
  OpenCL.error_check(error)
253
253
  k_names = FFI::MemoryPointer::new( kernel_names_size.read_size_t )
254
- error = OpenCL.clGetProgramInfo( self, OpenCL::Program::KERNEL_NAMES, kernel_names_size.read_size_t, k_names, nil)
254
+ error = OpenCL.clGetProgramInfo( self, KERNEL_NAMES, kernel_names_size.read_size_t, k_names, nil)
255
255
  OpenCL.error_check(error)
256
256
  k_names_string = k_names.read_string
257
257
  returns k_names_string.split(";")
@@ -266,7 +266,7 @@ module OpenCL
266
266
  devs = [devs].flatten
267
267
  ptr = FFI::MemoryPointer::new( :size_t )
268
268
  return devs.collect { |dev|
269
- error = OpenCL.clGetProgramBuildInfo(self, dev, OpenCL::Program::BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, ptr.size, ptr, nil)
269
+ error = OpenCL.clGetProgramBuildInfo(self, dev, BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, ptr.size, ptr, nil)
270
270
  OpenCL.error_check(error)
271
271
  [dev, ptr.read_size_t]
272
272
  }
@@ -278,7 +278,7 @@ module OpenCL
278
278
  devs = [devs].flatten
279
279
  ptr = FFI::MemoryPointer::new( :cl_build_status )
280
280
  return devs.collect { |dev|
281
- error = OpenCL.clGetProgramBuildInfo(self, dev, OpenCL::Program::BUILD_STATUS, ptr.size, ptr, nil)
281
+ error = OpenCL.clGetProgramBuildInfo(self, dev, BUILD_STATUS, ptr.size, ptr, nil)
282
282
  OpenCL.error_check(error)
283
283
  [dev, OpenCL::BuildStatus::new(ptr.read_cl_build_status)]
284
284
  }
@@ -290,7 +290,7 @@ module OpenCL
290
290
  devs = [devs].flatten
291
291
  ptr = FFI::MemoryPointer::new( :cl_program_binary_type )
292
292
  return devs.collect { |dev|
293
- error = OpenCL.clGetProgramBuildInfo(self, dev, OpenCL::Program::BINARY_TYPE, ptr.size, ptr, nil)
293
+ error = OpenCL.clGetProgramBuildInfo(self, dev, BINARY_TYPE, ptr.size, ptr, nil)
294
294
  OpenCL.error_check(error)
295
295
  [dev, OpenCL::Program::BinaryType::new(ptr.read_cl_program_binary_type)]
296
296
  }
@@ -302,10 +302,10 @@ module OpenCL
302
302
  devs = [devs].flatten
303
303
  return devs.collect { |dev|
304
304
  ptr1 = FFI::MemoryPointer::new( :size_t, 1)
305
- error = OpenCL.clGetProgramBuildInfo(self, dev, OpenCL::Program::BUILD_OPTIONS, 0, nil, ptr1)
305
+ error = OpenCL.clGetProgramBuildInfo(self, dev, BUILD_OPTIONS, 0, nil, ptr1)
306
306
  OpenCL.error_check(error)
307
307
  ptr2 = FFI::MemoryPointer::new( ptr1.read_size_t )
308
- error = OpenCL.clGetProgramBuildInfo(self, dev, OpenCL::Program::BUILD_OPTIONS, ptr1.read_size_t, ptr2, nil)
308
+ error = OpenCL.clGetProgramBuildInfo(self, dev, BUILD_OPTIONS, ptr1.read_size_t, ptr2, nil)
309
309
  OpenCL.error_check(error)
310
310
  [dev, ptr2.read_string]
311
311
  }
@@ -317,10 +317,10 @@ module OpenCL
317
317
  devs = [devs].flatten
318
318
  return devs.collect { |dev|
319
319
  ptr1 = FFI::MemoryPointer::new( :size_t, 1)
320
- error = OpenCL.clGetProgramBuildInfo(self, dev, OpenCL::Program::BUILD_LOG, 0, nil, ptr1)
320
+ error = OpenCL.clGetProgramBuildInfo(self, dev, BUILD_LOG, 0, nil, ptr1)
321
321
  OpenCL.error_check(error)
322
322
  ptr2 = FFI::MemoryPointer::new( ptr1.read_size_t )
323
- error = OpenCL.clGetProgramBuildInfo(self, dev, OpenCL::Program::BUILD_LOG, ptr1.read_size_t, ptr2, nil)
323
+ error = OpenCL.clGetProgramBuildInfo(self, dev, BUILD_LOG, ptr1.read_size_t, ptr2, nil)
324
324
  OpenCL.error_check(error)
325
325
  [dev, ptr2.read_string]
326
326
  }
@@ -336,7 +336,7 @@ module OpenCL
336
336
  total_size += s
337
337
  bin_array[i].write_pointer(FFI::MemoryPointer::new(s))
338
338
  }
339
- error = OpenCL.clGetProgramInfo(self, OpenCL::Program::BINARIES, total_size, bin_array, nil)
339
+ error = OpenCL.clGetProgramInfo(self, BINARIES, total_size, bin_array, nil)
340
340
  OpenCL.error_check(error)
341
341
  bins = []
342
342
  devs = self.devices
@@ -381,7 +381,7 @@ module OpenCL
381
381
  # Returns the Context the Program is associated to
382
382
  def context
383
383
  ptr = FFI::MemoryPointer::new( Context )
384
- error = OpenCL.clGetProgramInfo(self, OpenCL::Program::CONTEXT, Context.size, ptr, nil)
384
+ error = OpenCL.clGetProgramInfo(self, CONTEXT, Context.size, ptr, nil)
385
385
  OpenCL.error_check(error)
386
386
  return OpenCL::Context::new( ptr.read_pointer )
387
387
  end
@@ -401,7 +401,7 @@ module OpenCL
401
401
  def devices
402
402
  n = self.num_devices
403
403
  ptr2 = FFI::MemoryPointer::new( Device, n )
404
- error = OpenCL.clGetProgramInfo(self, OpenCL::Program::DEVICES, Device.size*n, ptr2, nil)
404
+ error = OpenCL.clGetProgramInfo(self, DEVICES, Device.size*n, ptr2, nil)
405
405
  OpenCL.error_check(error)
406
406
  return ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
407
407
  OpenCL::Device::new(device_ptr)
@@ -11,7 +11,7 @@ module OpenCL
11
11
 
12
12
  # creates a new SVMPointer relative to an existing one from an offset
13
13
  def +( offset )
14
- return OpenCL::SVMPointer::new( self.address + offset, @context )
14
+ return SVMPointer::new( self.address + offset, @context )
15
15
  end
16
16
 
17
17
  # frees the SVMPointer (must not be called on an SVMPointer obtained from an offset)
@@ -34,13 +34,13 @@ module OpenCL
34
34
  #
35
35
  # * +:alignment+ - imposes the minimum alignment in byte
36
36
  def self.svm_alloc(context, size, options = {})
37
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if context.platform.version_number < 2.0
38
- flags = OpenCL::get_flags(options)
37
+ error_check(INVALID_OPERATION) if context.platform.version_number < 2.0
38
+ flags = get_flags(options)
39
39
  alignment = 0
40
40
  alignment = options[:alignment] if options[:alignment]
41
- ptr = OpenCL.clSVMAlloc( context, flags, size, alignment )
42
- OpenCL.error_check(OpenCL::MEM_OBJECT_ALLOCATION_FAILURE) if ptr.null?
43
- return OpenCL::SVMPointer::new( ptr, context )
41
+ ptr = clSVMAlloc( context, flags, size, alignment )
42
+ error_check(MEM_OBJECT_ALLOCATION_FAILURE) if ptr.null?
43
+ return SVMPointer::new( ptr, context )
44
44
  end
45
45
 
46
46
  # Frees an SVMPointer
@@ -50,15 +50,15 @@ module OpenCL
50
50
  # * +context+ - the Context in which to deallocate the memory
51
51
  # * +svm_pointer+ - the SVMPointer to deallocate
52
52
  def self.svm_free(context, svm_pointer)
53
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if context.platform.version_number < 2.0
54
- return OpenCL.clSVMFree( context, svm_pointer )
53
+ error_check(INVALID_OPERATION) if context.platform.version_number < 2.0
54
+ return clSVMFree( context, svm_pointer )
55
55
  end
56
56
 
57
57
  # Set the index th argument of Kernel to value. Value must be within a SVM memory area
58
58
  def self.set_kernel_arg_svm_pointer( kernel, index, value )
59
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if kernel.context.platform.version_number < 2.0
60
- error = OpenCL.clSetKernelArgSVMPointer( kernel, index, val )
61
- OpenCL.error_check(error)
59
+ error_check(INVALID_OPERATION) if kernel.context.platform.version_number < 2.0
60
+ error = clSetKernelArgSVMPointer( kernel, index, val )
61
+ error_check(error)
62
62
  return kernel
63
63
  end
64
64
 
@@ -86,11 +86,11 @@ module OpenCL
86
86
  pointers.each_with_index { |p, indx|
87
87
  ptr[indx].write_pointer(p)
88
88
  }
89
- num_events, events = OpenCL.get_event_wait_list( options )
90
- event = FFI::MemoryPointer::new( OpenCL::Event )
91
- error = OpenCL.clEnqueueSVMFree(command_queue, num_pointers, ptr, block, options[:user_data], num_events, events, event)
92
- OpenCL.error_check(error)
93
- return OpenCL::Event::new(event.read_pointer, false)
89
+ num_events, events = get_event_wait_list( options )
90
+ event = FFI::MemoryPointer::new( Event )
91
+ error = clEnqueueSVMFree(command_queue, num_pointers, ptr, block, options[:user_data], num_events, events, event)
92
+ error_check(error)
93
+ return Event::new(event.read_pointer, false)
94
94
  end
95
95
 
96
96
  # Enqueues a command to copy from or to an SVMPointer
@@ -113,14 +113,14 @@ module OpenCL
113
113
  #
114
114
  # the Event associated with the command
115
115
  def self.enqueue_svm_memcpy(command_queue, dst_ptr, src_ptr, size, options = {})
116
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 2.0
117
- blocking = OpenCL::FALSE
118
- blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_copy]
119
- num_events, events = OpenCL.get_event_wait_list( options )
120
- event = FFI::MemoryPointer::new( OpenCL::Event )
121
- error = OpenCL.clEnqueueSVMMemcpy(command_queue, blocking, dst_ptr, src_ptr, size, num_events, events, event)
122
- OpenCL.error_check(error)
123
- return OpenCL::Event::new(event.read_pointer, false)
116
+ error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 2.0
117
+ blocking = FALSE
118
+ blocking = TRUE if options[:blocking] or options[:blocking_copy]
119
+ num_events, events = get_event_wait_list( options )
120
+ event = FFI::MemoryPointer::new( Event )
121
+ error = clEnqueueSVMMemcpy(command_queue, blocking, dst_ptr, src_ptr, size, num_events, events, event)
122
+ error_check(error)
123
+ return Event::new(event.read_pointer, false)
124
124
  end
125
125
 
126
126
  # Enqueues a command to fill a an SVM memory area
@@ -141,13 +141,13 @@ module OpenCL
141
141
  #
142
142
  # the Event associated with the command
143
143
  def self.enqueue_svm_fill(command_queue, svm_ptr, pattern, size, options = {})
144
- num_events, events = OpenCL.get_event_wait_list( options )
144
+ num_events, events = get_event_wait_list( options )
145
145
  pattern_size = pattern.size
146
146
  pattern_size = options[:pattern_size] if options[:pattern_size]
147
- event = FFI::MemoryPointer::new( OpenCL::Event )
148
- error = OpenCL.clEnqueueSVMFill(command_queue, svm_ptr, pattern, pattern_size, size, num_events, events, event)
149
- OpenCL.error_check(error)
150
- return OpenCL::Event::new(event.read_pointer, false)
147
+ event = FFI::MemoryPointer::new( Event )
148
+ error = clEnqueueSVMFill(command_queue, svm_ptr, pattern, pattern_size, size, num_events, events, event)
149
+ error_check(error)
150
+ return Event::new(event.read_pointer, false)
151
151
  end
152
152
 
153
153
  # Enqueues a command to map an Image into host memory
@@ -170,14 +170,14 @@ module OpenCL
170
170
  #
171
171
  # the Event associated with the command
172
172
  def self.enqueue_svm_map( command_queue, svm_ptr, size, map_flags, options = {} )
173
- blocking = OpenCL::FALSE
174
- blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_map]
175
- flags = OpenCL.get_flags( {:flags => map_flags} )
176
- num_events, events = OpenCL.get_event_wait_list( options )
177
- event = FFI::MemoryPointer::new( OpenCL::Event )
178
- error = OpenCL.clEnqueueSVMMap( command_queue, blocking, flags, svm_ptr, size, num_events, events, event )
179
- OpenCL.error_check( error.read_cl_int )
180
- return OpenCL::Event::new( event.read_ptr, false )
173
+ blocking = FALSE
174
+ blocking = TRUE if options[:blocking] or options[:blocking_map]
175
+ flags = get_flags( {:flags => map_flags} )
176
+ num_events, events = get_event_wait_list( options )
177
+ event = FFI::MemoryPointer::new( Event )
178
+ error = clEnqueueSVMMap( command_queue, blocking, flags, svm_ptr, size, num_events, events, event )
179
+ error_check( error.read_cl_int )
180
+ return Event::new( event.read_ptr, false )
181
181
  end
182
182
 
183
183
  # Enqueues a command to unmap a previously mapped SVM memory area
@@ -196,11 +196,11 @@ module OpenCL
196
196
  #
197
197
  # the Event associated with the command
198
198
  def self.enqueue_svm_unmap( command_queue, svm_ptr, options = {} )
199
- num_events, events = OpenCL.get_event_wait_list( options )
200
- event = FFI::MemoryPointer::new( OpenCL::Event )
201
- error = OpenCL.clEnqueueSVMUnmap( command_queue, svm_ptr, num_events, events, event )
202
- OpenCL.error_check( error )
203
- return OpenCL::Event::new( event.read_ptr, false )
199
+ num_events, events = get_event_wait_list( options )
200
+ event = FFI::MemoryPointer::new( Event )
201
+ error = clEnqueueSVMUnmap( command_queue, svm_ptr, num_events, events, event )
202
+ error_check( error )
203
+ return Event::new( event.read_ptr, false )
204
204
  end
205
205
 
206
206
  end
@@ -15,48 +15,48 @@ module OpenCL
15
15
  # * +:lod_min+ - floating point value representing the minimal LOD (default 0.0f, requires cl_khr_mipmap_image)
16
16
  # * +:lod_max+ - floating point value representing the maximal LOD (default MAXFLOAT, requires cl_khr_mipmap_image)
17
17
  def self.create_sampler( context, options = {} )
18
- normalized_coords = OpenCL::TRUE
18
+ normalized_coords = TRUE
19
19
  normalized_coords = options[:normalized_coords] if options[:normalized_coords]
20
- addressing_mode = OpenCL::AddressingMode::CLAMP
20
+ addressing_mode = AddressingMode::CLAMP
21
21
  addressing_mode = options[:addressing_mode] if options[:addressing_mode]
22
- filter_mode = OpenCL::FilterMode::NEAREST
22
+ filter_mode = FilterMode::NEAREST
23
23
  filter_mode = options[:filter_mode] if options[:filter_mode]
24
24
  error = FFI::MemoryPointer::new( :cl_int )
25
25
  if context.platform.version_number < 2.0 then
26
- sampler_ptr = OpenCL.clCreateSampler( context, normalized_coords, addressing_mode, filter_mode, error )
26
+ sampler_ptr = clCreateSampler( context, normalized_coords, addressing_mode, filter_mode, error )
27
27
  else
28
28
  prop_size = 7
29
29
  prop_size += 2 if options[:mip_filter_mode]
30
30
  prop_size += 2 if options[:lod_min]
31
31
  prop_size += 2 if options[:lod_max]
32
32
  properties = FFI::MemoryPointer::new( :cl_sampler_properties)
33
- properties[0].write_cl_sampler_properties( OpenCL::Sampler::NORMALIZED_COORDS )
33
+ properties[0].write_cl_sampler_properties( Sampler::NORMALIZED_COORDS )
34
34
  properties[1].write_cl_sampler_properties( normalized_coords )
35
- properties[2].write_cl_sampler_properties( OpenCL::Sampler::ADDRESSING_MODE )
35
+ properties[2].write_cl_sampler_properties( Sampler::ADDRESSING_MODE )
36
36
  properties[3].write_cl_sampler_properties( addressing_mode )
37
- properties[4].write_cl_sampler_properties( OpenCL::Sampler::FILTER_MODE )
37
+ properties[4].write_cl_sampler_properties( Sampler::FILTER_MODE )
38
38
  properties[5].write_cl_sampler_properties( filter_mode )
39
39
  prop_indx = 6
40
40
  if options[:mip_filter_mode] then
41
- properties[prop_indx].write_cl_sampler_properties( OpenCL::Sampler::MIP_FILTER_MODE )
41
+ properties[prop_indx].write_cl_sampler_properties( Sampler::MIP_FILTER_MODE )
42
42
  properties[prop_indx+1].write_cl_sampler_properties( options[:mip_filter_mode] )
43
43
  prop_indx += 2
44
44
  end
45
45
  if options[:lod_min] then
46
- properties[prop_indx].write_cl_sampler_properties( OpenCL::Sampler::LOD_MIN )
46
+ properties[prop_indx].write_cl_sampler_properties( Sampler::LOD_MIN )
47
47
  properties[prop_indx+1].write_float( options[:lod_min] )
48
48
  prop_indx += 2
49
49
  end
50
50
  if options[:lod_max] then
51
- properties[prop_indx].write_cl_sampler_properties( OpenCL::Sampler::LOD_MAX )
51
+ properties[prop_indx].write_cl_sampler_properties( Sampler::LOD_MAX )
52
52
  properties[prop_indx+1].write_float( options[:lod_max] )
53
53
  prop_indx += 2
54
54
  end
55
55
  properties[prop_indx].write_cl_sampler_properties( 0 )
56
- sampler_ptr = OpenCL.clCreateSamplerWithProperties( context, properties, error )
56
+ sampler_ptr = clCreateSamplerWithProperties( context, properties, error )
57
57
  end
58
- OpenCL.error_check(error.read_cl_int)
59
- OpenCL::Sampler::new(sampler_ptr, false)
58
+ error_check(error.read_cl_int)
59
+ Sampler::new(sampler_ptr, false)
60
60
  end
61
61
 
62
62
  # Maps the cl_smapler object of OpenCL
@@ -65,7 +65,7 @@ module OpenCL
65
65
  # Returns the context associated with the Sampler
66
66
  def context
67
67
  ptr = FFI::MemoryPointer::new( Context )
68
- error = OpenCL.clGetSamplerInfo(self, Sampler::CONTEXT, Context.size, ptr, nil)
68
+ error = OpenCL.clGetSamplerInfo(self, CONTEXT, Context.size, ptr, nil)
69
69
  OpenCL.error_check(error)
70
70
  return OpenCL::Context::new( ptr.read_pointer )
71
71
  end
@@ -43,28 +43,28 @@ end
43
43
 
44
44
  module OpenCL
45
45
  @@type_converter = {
46
- :cl_device_type => OpenCL::Device::Type,
47
- :cl_device_fp_config => OpenCL::Device::FPConfig,
48
- :cl_device_mem_cache_type => OpenCL::Device::MemCacheType,
49
- :cl_device_local_mem_type => OpenCL::Device::LocalMemType,
50
- :cl_device_exec_capabilities => OpenCL::Device::ExecCapabilities,
51
- :cl_command_queue_properties => OpenCL::CommandQueue::Properties,
52
- :cl_device_affinity_domain => OpenCL::Device::AffinityDomain,
53
- :cl_device_svm_capabilities => OpenCL::Device::SVMCapabilities,
54
- :cl_channel_order => OpenCL::ChannelOrder,
55
- :cl_channel_type => OpenCL::ChannelType,
56
- :cl_mem_flags => OpenCL::Mem::Flags,
57
- :cl_mem_object_type => OpenCL::Mem::Type,
58
- :cl_mem_migration_flags => OpenCL::Mem::MigrationFlags,
59
- :cl_addressing_mode => OpenCL::AddressingMode,
60
- :cl_filter_mode => OpenCL::FilterMode,
61
- :cl_map_flags => OpenCL::MapFlags,
62
- :cl_program_binary_type => OpenCL::Program::BinaryType,
63
- :cl_kernel_arg_address_qualifier => OpenCL::Kernel::Arg::AddressQualifier,
64
- :cl_kernel_arg_access_qualifier => OpenCL::Kernel::Arg::AccessQualifier,
65
- :cl_kernel_arg_type_qualifier => OpenCL::Kernel::Arg::TypeQualifier,
66
- :cl_command_type => OpenCL::CommandType,
67
- :cl_build_status => OpenCL::BuildStatus
46
+ :cl_device_type => Device::Type,
47
+ :cl_device_fp_config => Device::FPConfig,
48
+ :cl_device_mem_cache_type => Device::MemCacheType,
49
+ :cl_device_local_mem_type => Device::LocalMemType,
50
+ :cl_device_exec_capabilities => Device::ExecCapabilities,
51
+ :cl_command_queue_properties => CommandQueue::Properties,
52
+ :cl_device_affinity_domain => Device::AffinityDomain,
53
+ :cl_device_svm_capabilities => Device::SVMCapabilities,
54
+ :cl_channel_order => ChannelOrder,
55
+ :cl_channel_type => ChannelType,
56
+ :cl_mem_flags => Mem::Flags,
57
+ :cl_mem_object_type => Mem::Type,
58
+ :cl_mem_migration_flags => Mem::MigrationFlags,
59
+ :cl_addressing_mode => AddressingMode,
60
+ :cl_filter_mode => FilterMode,
61
+ :cl_map_flags => MapFlags,
62
+ :cl_program_binary_type => Program::BinaryType,
63
+ :cl_kernel_arg_address_qualifier => Kernel::Arg::AddressQualifier,
64
+ :cl_kernel_arg_access_qualifier => Kernel::Arg::AccessQualifier,
65
+ :cl_kernel_arg_type_qualifier => Kernel::Arg::TypeQualifier,
66
+ :cl_command_type => CommandType,
67
+ :cl_build_status => BuildStatus
68
68
  }
69
69
  @@callbacks = []
70
70
 
@@ -196,7 +196,7 @@ module OpenCL
196
196
 
197
197
  # Extracts the :properties named option (for a CommandQueue) from the hash given and returns the properties values
198
198
  def self.get_command_queue_properties( options )
199
- properties = OpenCL::CommandQueue::Properties::new(0)
199
+ properties = CommandQueue::Properties::new(0)
200
200
  if options[:properties] then
201
201
  if options[:properties].respond_to?(:each) then
202
202
  options[:properties].each { |f| properties = properties | f }
@@ -224,12 +224,12 @@ module OpenCL
224
224
  }
225
225
  else
226
226
  region[0].write_size_t( image.width - origin[0].read_size_t )
227
- if image.type == OpenCL::Mem::IMAGE1D_ARRAY then
227
+ if image.type == Mem::IMAGE1D_ARRAY then
228
228
  region[1].write_size_t( image.array_size - origin[1].read_size_t )
229
229
  else
230
230
  region[1].write_size_t( image.height != 0 ? image.height - origin[1].read_size_t : 1 )
231
231
  end
232
- if image.type == OpenCL::Mem::IMAGE2D_ARRAY then
232
+ if image.type == Mem::IMAGE2D_ARRAY then
233
233
  region[2].write_size_t( image.array_size - origin[2].read_size_t )
234
234
  else
235
235
  region[2].write_size_t( image.depth != 0 ? image.depth - origin[2].read_size_t : 1 )
@@ -251,14 +251,14 @@ module OpenCL
251
251
  return properties
252
252
  end
253
253
 
254
- # checks if a :cl_int corresponds to an Error code and raises the apropriate OpenCL::Error
254
+ # checks if a :cl_int corresponds to an error code and raises the apropriate Error
255
255
  def self.error_check(errcode)
256
256
  return nil if errcode == SUCCESS
257
- klass = OpenCL::Error::CLASSES[errcode]
257
+ klass = Error::CLASSES[errcode]
258
258
  if klass then
259
259
  raise klass::new
260
260
  else
261
- raise OpenCL::Error::new("#{errcode}")
261
+ raise Error::new("#{errcode}")
262
262
  end
263
263
  end
264
264
 
@@ -310,7 +310,7 @@ EOF
310
310
  error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name}, ptr1.read_size_t, ptr2, nil)
311
311
  OpenCL.error_check(error)
312
312
  EOF
313
- if(OpenCL::convert_type(type)) then
313
+ if(convert_type(type)) then
314
314
  s += <<EOF
315
315
  return OpenCL::convert_type(:#{type})::new(ptr2.read_#{type})
316
316
  end