opencl_ruby_ffi 0.993 → 0.994

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,8 @@ module OpenCL
6
6
  #
7
7
  # * +command_queue+ - the CommandQueue to finish
8
8
  def self.finish( command_queue )
9
- error = OpenCL.clFinish( command_queue )
10
- OpenCL.error_check( error )
9
+ error = clFinish( command_queue )
10
+ error_check( error )
11
11
  return command_queue
12
12
  end
13
13
 
@@ -17,8 +17,8 @@ module OpenCL
17
17
  #
18
18
  # * +command_queue+ - the CommandQueue to flush
19
19
  def self.flush( command_queue )
20
- error = OpenCL.clFlush( command_queue )
21
- OpenCL.error_check( error )
20
+ error = clFlush( command_queue )
21
+ error_check( error )
22
22
  return command_queue
23
23
  end
24
24
 
@@ -35,11 +35,11 @@ module OpenCL
35
35
  # * +:properties+ - a single or an Array of :cl_command_queue_properties
36
36
  # * +:size+ - the size of the command queue ( if ON_DEVICE is specified in the properties ) 2.0+ only
37
37
  def self.create_command_queue( context, device, options = {} )
38
- properties = OpenCL.get_command_queue_properties( options )
38
+ properties = get_command_queue_properties( options )
39
39
  size = options[:size]
40
40
  error = FFI::MemoryPointer::new( :cl_int )
41
41
  if context.platform.version_number < 2.0 then
42
- cmd = OpenCL.clCreateCommandQueue( context, device, properties, error )
42
+ cmd = clCreateCommandQueue( context, device, properties, error )
43
43
  else
44
44
  props = nil
45
45
  if properties.to_i != 0 or size then
@@ -50,21 +50,21 @@ module OpenCL
50
50
  props = FFI::MemoryPointer::new( :cl_queue_properties, props_size )
51
51
  i=0
52
52
  if properties.to_i != 0 then
53
- props[i].write_cl_queue_properties( OpenCL::Queue::PROPERTIES )
53
+ props[i].write_cl_queue_properties( Queue::PROPERTIES )
54
54
  props[i+1].write_cl_queue_properties( properties.to_i )
55
55
  i += 2
56
56
  end
57
57
  if size then
58
- props[i].write_cl_queue_properties( OpenCL::Queue::SIZE )
58
+ props[i].write_cl_queue_properties( Queue::SIZE )
59
59
  props[i+1].write_cl_queue_properties( size )
60
60
  i += 2
61
61
  end
62
62
  props[i].write_cl_queue_properties( 0 )
63
63
  end
64
- cmd = OpenCL.clCreateCommandQueueWithProperties( context, device, props, error )
64
+ cmd = clCreateCommandQueueWithProperties( context, device, props, error )
65
65
  end
66
- OpenCL.error_check(error.read_cl_int)
67
- return OpenCL::CommandQueue::new(cmd, false)
66
+ error_check(error.read_cl_int)
67
+ return CommandQueue::new(cmd, false)
68
68
  end
69
69
 
70
70
  # Enqueues a command to indicate which device a set of memory objects should be migrated to
@@ -84,21 +84,21 @@ module OpenCL
84
84
  #
85
85
  # the Event associated with the command
86
86
  def self.enqueue_migrate_mem_objects( command_queue, mem_objects, options = {} )
87
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.2
87
+ error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.2
88
88
  num_mem_objects = [mem_objects].flatten.length
89
89
  mem_list = nil
90
90
  if num_mem_objects > 0 then
91
- mem_list = FFI::MemoryPointer::new( OpenCL::Mem, num_mem_objects )
91
+ mem_list = FFI::MemoryPointer::new( Mem, num_mem_objects )
92
92
  [mem_objects].flatten.each_with_index { |e, i|
93
93
  mem_list[i].write_pointer(e)
94
94
  }
95
95
  end
96
- flags = OpenCL.get_flags( options )
97
- num_events, events = OpenCL.get_event_wait_list( options )
98
- event = FFI::MemoryPointer::new( OpenCL::Event )
99
- error = OpenCL.clEnqueueMigrateMemObjects( command_queue, num_mem_objects, mem_list, flags, num_events, events, event )
100
- OpenCL.error_check( error )
101
- return OpenCL::Event::new( event.read_ptr, false )
96
+ flags = get_flags( options )
97
+ num_events, events = get_event_wait_list( options )
98
+ event = FFI::MemoryPointer::new( Event )
99
+ error = clEnqueueMigrateMemObjects( command_queue, num_mem_objects, mem_list, flags, num_events, events, event )
100
+ error_check( error )
101
+ return Event::new( event.read_ptr, false )
102
102
  end
103
103
 
104
104
  # Enqueues a command to map an Image into host memory
@@ -126,20 +126,20 @@ module OpenCL
126
126
  # * +image_row_pitch+ - the row pitch of the mapped region
127
127
  # * +image_slice_pitch+ - the slice pitch of the mapped region
128
128
  def self.enqueue_map_image( command_queue, image, map_flags, options = {} )
129
- blocking = OpenCL::FALSE
130
- blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_map]
131
- flags = OpenCL.get_flags( {:flags => map_flags} )
129
+ blocking = FALSE
130
+ blocking = TRUE if options[:blocking] or options[:blocking_map]
131
+ flags = get_flags( {:flags => map_flags} )
132
132
 
133
- origin, region = OpenCL.get_origin_region( image, options, :origin, :region )
133
+ origin, region = get_origin_region( image, options, :origin, :region )
134
134
 
135
- num_events, events = OpenCL.get_event_wait_list( options )
135
+ num_events, events = get_event_wait_list( options )
136
136
  image_row_pitch = FFI::MemoryPointer::new( :size_t )
137
137
  image_slice_pitch = FFI::MemoryPointer::new( :size_t )
138
- event = FFI::MemoryPointer::new( OpenCL::Event )
138
+ event = FFI::MemoryPointer::new( Event )
139
139
  error = FFI::MemoryPointer::new( :cl_int )
140
- ptr = OpenCL.clEnqueueMapImage( command_queue, image, blocking, flags, origin, region, image_row_pitch, image_slice_pitch, num_events, events, event, error )
141
- OpenCL.error_check( error.read_cl_int )
142
- ev = OpenCL::Event::new( event.read_ptr, false )
140
+ ptr = clEnqueueMapImage( command_queue, image, blocking, flags, origin, region, image_row_pitch, image_slice_pitch, num_events, events, event, error )
141
+ error_check( error.read_cl_int )
142
+ ev = Event::new( event.read_ptr, false )
143
143
  return [ev, ptr, image_row_pitch.read_size_t, image_slice_pitch.read_size_t]
144
144
  end
145
145
 
@@ -166,20 +166,20 @@ module OpenCL
166
166
  # * +event+ - the Event associated with the command
167
167
  # * +pointer+ - a Pointer to the mapped memory region
168
168
  def self.enqueue_map_buffer( command_queue, buffer, map_flags, options = {} )
169
- blocking = OpenCL::FALSE
170
- blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_map]
171
- flags = OpenCL.get_flags( {:flags => map_flags} )
169
+ blocking = FALSE
170
+ blocking = TRUE if options[:blocking] or options[:blocking_map]
171
+ flags = get_flags( {:flags => map_flags} )
172
172
 
173
173
  offset = 0
174
174
  offset = options[:offset] if options[:offset]
175
175
  size = buffer.size - offset
176
176
  size = options[:size] - offset if options[:size]
177
- num_events, events = OpenCL.get_event_wait_list( options )
178
- event = FFI::MemoryPointer::new( OpenCL::Event )
177
+ num_events, events = get_event_wait_list( options )
178
+ event = FFI::MemoryPointer::new( Event )
179
179
  error = FFI::MemoryPointer::new( :cl_int )
180
- ptr = OpenCL.clEnqueueMapBuffer( command_queue, buffer, blocking, flags, offset, size, num_events, events, event, error )
181
- OpenCL.error_check( error.read_cl_int )
182
- ev = OpenCL::Event::new( event.read_ptr, false )
180
+ ptr = clEnqueueMapBuffer( command_queue, buffer, blocking, flags, offset, size, num_events, events, event, error )
181
+ error_check( error.read_cl_int )
182
+ ev = Event::new( event.read_ptr, false )
183
183
  return [ev, ptr]
184
184
  end
185
185
 
@@ -200,11 +200,11 @@ module OpenCL
200
200
  #
201
201
  # the Event associated with the command
202
202
  def self.enqueue_unmap_mem_object( command_queue, mem_obj, mapped_ptr, options = {} )
203
- num_events, events = OpenCL.get_event_wait_list( options )
204
- event = FFI::MemoryPointer::new( OpenCL::Event )
205
- error = OpenCL.clEnqueueUnmapMemObject( command_queue, mem_obj, mapped_ptr, num_events, events, event )
206
- OpenCL.error_check( error )
207
- return OpenCL::Event::new( event.read_ptr, false )
203
+ num_events, events = get_event_wait_list( options )
204
+ event = FFI::MemoryPointer::new( Event )
205
+ error = clEnqueueUnmapMemObject( command_queue, mem_obj, mapped_ptr, num_events, events, event )
206
+ error_check( error )
207
+ return Event::new( event.read_ptr, false )
208
208
  end
209
209
 
210
210
  # Enqueues a command to read from a rectangular region from a Buffer object to host memory
@@ -233,9 +233,9 @@ module OpenCL
233
233
  #
234
234
  # the Event associated with the command
235
235
  def self.enqueue_read_buffer_rect( command_queue, buffer, ptr, region, options = {} )
236
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
237
- blocking = OpenCL::FALSE
238
- blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_read]
236
+ error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
237
+ blocking = FALSE
238
+ blocking = TRUE if options[:blocking] or options[:blocking_read]
239
239
 
240
240
  buffer_origin = FFI::MemoryPointer::new( :size_t, 3 )
241
241
  (0..2).each { |i| buffer_origin[i].write_size_t(0) }
@@ -277,11 +277,11 @@ module OpenCL
277
277
  if not host_slice_pitch then
278
278
  host_slice_pitch = 0
279
279
  end
280
- num_events, events = OpenCL.get_event_wait_list( options )
281
- event = FFI::MemoryPointer::new( OpenCL::Event )
282
- error = OpenCL.clEnqueueReadBufferRect(command_queue, buffer, blocking, buffer_origin, host_origin, r, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events, events, event)
283
- OpenCL.error_check(error)
284
- return OpenCL::Event::new(event.read_pointer, false)
280
+ num_events, events = get_event_wait_list( options )
281
+ event = FFI::MemoryPointer::new( Event )
282
+ error = clEnqueueReadBufferRect(command_queue, buffer, blocking, buffer_origin, host_origin, r, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events, events, event)
283
+ error_check(error)
284
+ return Event::new(event.read_pointer, false)
285
285
  end
286
286
 
287
287
  # Enqueues a command to write to a rectangular region in a Buffer object from host memory
@@ -310,9 +310,9 @@ module OpenCL
310
310
  #
311
311
  # the Event associated with the command
312
312
  def self.enqueue_write_buffer_rect(command_queue, buffer, ptr, region, options = {})
313
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
314
- blocking = OpenCL::FALSE
315
- blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_write]
313
+ error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
314
+ blocking = FALSE
315
+ blocking = TRUE if options[:blocking] or options[:blocking_write]
316
316
 
317
317
  buffer_origin = FFI::MemoryPointer::new( :size_t, 3 )
318
318
  (0..2).each { |i| buffer_origin[i].write_size_t(0) }
@@ -354,11 +354,11 @@ module OpenCL
354
354
  if not host_slice_pitch then
355
355
  host_slice_pitch = 0
356
356
  end
357
- num_events, events = OpenCL.get_event_wait_list( options )
358
- event = FFI::MemoryPointer::new( OpenCL::Event )
359
- error = OpenCL.clEnqueueWriteBufferRect(command_queue, buffer, blocking, buffer_origin, host_origin, r, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events, events, event)
360
- OpenCL.error_check(error)
361
- return OpenCL::Event::new(event.read_pointer, false)
357
+ num_events, events = get_event_wait_list( options )
358
+ event = FFI::MemoryPointer::new( Event )
359
+ error = clEnqueueWriteBufferRect(command_queue, buffer, blocking, buffer_origin, host_origin, r, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events, events, event)
360
+ error_check(error)
361
+ return Event::new(event.read_pointer, false)
362
362
  end
363
363
 
364
364
  # Enqueues a command to copy a rectangular region into a Buffer object from another Buffer object
@@ -385,7 +385,7 @@ module OpenCL
385
385
  #
386
386
  # the Event associated with the command
387
387
  def self.enqueue_copy_buffer_rect(command_queue, src_buffer, dst_buffer, region, options = {})
388
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
388
+ error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
389
389
 
390
390
  src_origin = FFI::MemoryPointer::new( :size_t, 3 )
391
391
  (0..2).each { |i| src_origin[i].write_size_t(0) }
@@ -425,11 +425,11 @@ module OpenCL
425
425
  if not dst_slice_pitch then
426
426
  dst_slice_pitch = 0
427
427
  end
428
- num_events, events = OpenCL.get_event_wait_list( options )
429
- event = FFI::MemoryPointer::new( OpenCL::Event )
430
- error = OpenCL.clEnqueueCopyBufferRect(command_queue, src_buffer, dst_buffer, src_origin, dst_origin, r, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, num_events, events, event)
431
- OpenCL.error_check(error)
432
- return OpenCL::Event::new(event.read_pointer, false)
428
+ num_events, events = get_event_wait_list( options )
429
+ event = FFI::MemoryPointer::new( Event )
430
+ error = clEnqueueCopyBufferRect(command_queue, src_buffer, dst_buffer, src_origin, dst_origin, r, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, num_events, events, event)
431
+ error_check(error)
432
+ return Event::new(event.read_pointer, false)
433
433
  end
434
434
 
435
435
  # Enqueues a command to copy data from a Buffer object into another Buffer object
@@ -458,11 +458,11 @@ module OpenCL
458
458
  dst_offset = options[:dst_offset] if options[:dst_offset]
459
459
  size = [ src_buffer.size - src_offset, dst_buffer.size - dst_offset ].min
460
460
  size = options[:size] if options[:size]
461
- num_events, events = OpenCL.get_event_wait_list( options )
462
- event = FFI::MemoryPointer::new( OpenCL::Event )
463
- error = OpenCL.clEnqueueCopyBuffer(command_queue, src_buffer, dst_buffer, src_offset, dst_offset, size, num_events, events, event)
464
- OpenCL.error_check(error)
465
- return OpenCL::Event::new(event.read_pointer, false)
461
+ num_events, events = get_event_wait_list( options )
462
+ event = FFI::MemoryPointer::new( Event )
463
+ error = clEnqueueCopyBuffer(command_queue, src_buffer, dst_buffer, src_offset, dst_offset, size, num_events, events, event)
464
+ error_check(error)
465
+ return Event::new(event.read_pointer, false)
466
466
  end
467
467
 
468
468
 
@@ -487,17 +487,17 @@ module OpenCL
487
487
  #
488
488
  # the Event associated with the command
489
489
  def self.enqueue_write_buffer( command_queue, buffer, ptr, options = {} )
490
- blocking = OpenCL::FALSE
491
- blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_write]
490
+ blocking = FALSE
491
+ blocking = TRUE if options[:blocking] or options[:blocking_write]
492
492
  offset = 0
493
493
  offset = options[:offset] if options[:offset]
494
494
  size = buffer.size - offset
495
495
  size = options[:size] if options[:size]
496
- num_events, events = OpenCL.get_event_wait_list( options )
497
- event = FFI::MemoryPointer::new( OpenCL::Event )
498
- error = OpenCL.clEnqueueWriteBuffer(command_queue, buffer, blocking, offset, size, ptr, num_events, events, event)
499
- OpenCL.error_check(error)
500
- return OpenCL::Event::new(event.read_pointer, false)
496
+ num_events, events = get_event_wait_list( options )
497
+ event = FFI::MemoryPointer::new( Event )
498
+ error = clEnqueueWriteBuffer(command_queue, buffer, blocking, offset, size, ptr, num_events, events, event)
499
+ error_check(error)
500
+ return Event::new(event.read_pointer, false)
501
501
  end
502
502
 
503
503
  # Enqueues a command to read from a Buffer object to host memory
@@ -521,17 +521,17 @@ module OpenCL
521
521
  #
522
522
  # the Event associated with the command
523
523
  def self.enqueue_read_buffer( command_queue, buffer, ptr, options = {} )
524
- blocking = OpenCL::FALSE
525
- blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_read]
524
+ blocking = FALSE
525
+ blocking = TRUE if options[:blocking] or options[:blocking_read]
526
526
  offset = 0
527
527
  offset = options[:offset] if options[:offset]
528
528
  size = buffer.size - offset
529
529
  size = options[:size] if options[:size]
530
- num_events, events = OpenCL.get_event_wait_list( options )
531
- event = FFI::MemoryPointer::new( OpenCL::Event )
532
- error = OpenCL.clEnqueueReadBuffer(command_queue, buffer, blocking, offset, size, ptr, num_events, events, event)
533
- OpenCL.error_check(error)
534
- return OpenCL::Event::new(event.read_pointer, false)
530
+ num_events, events = get_event_wait_list( options )
531
+ event = FFI::MemoryPointer::new( Event )
532
+ error = clEnqueueReadBuffer(command_queue, buffer, blocking, offset, size, ptr, num_events, events, event)
533
+ error_check(error)
534
+ return Event::new(event.read_pointer, false)
535
535
  end
536
536
 
537
537
  # Acquire OpenCL Mem objects that have been created from OpenGL objects
@@ -553,16 +553,16 @@ module OpenCL
553
553
  num_objs = [mem_objects].flatten.length
554
554
  objs = nil
555
555
  if num_objs > 0 then
556
- objs = FFI::MemoryPointer::new( OpenCL::Mem, num_objs )
556
+ objs = FFI::MemoryPointer::new( Mem, num_objs )
557
557
  [mem_objects].flatten.each_with_index { |o, i|
558
558
  objs[i].write_pointer(e)
559
559
  }
560
560
  end
561
- num_events, events = OpenCL.get_event_wait_list( options )
562
- event = FFI::MemoryPointer::new( OpenCL::Event )
563
- error = OpenCL.clEnqueueAcquireGLObject( command_queue, num_objs, objs, num_events, events, event )
564
- OpenCL.error_check(error)
565
- return OpenCL::Event::new(event.read_pointer, false)
561
+ num_events, events = get_event_wait_list( options )
562
+ event = FFI::MemoryPointer::new( Event )
563
+ error = clEnqueueAcquireGLObject( command_queue, num_objs, objs, num_events, events, event )
564
+ error_check(error)
565
+ return Event::new(event.read_pointer, false)
566
566
  end
567
567
 
568
568
  # Release OpenCL Mem objects that have been created from OpenGL objects and previously acquired
@@ -584,16 +584,16 @@ module OpenCL
584
584
  num_objs = [mem_objects].flatten.length
585
585
  objs = nil
586
586
  if num_objs > 0 then
587
- objs = FFI::MemoryPointer::new( OpenCL::Mem, num_objs )
587
+ objs = FFI::MemoryPointer::new( Mem, num_objs )
588
588
  [mem_objects].flatten.each_with_index { |o, i|
589
589
  objs[i].write_pointer(e)
590
590
  }
591
591
  end
592
- num_events, events = OpenCL.get_event_wait_list( options )
593
- event = FFI::MemoryPointer::new( OpenCL::Event )
594
- error = OpenCL.clEnqueueReleaseGLObject( command_queue, num_objs, objs, num_events, events, event )
595
- OpenCL.error_check(error)
596
- return OpenCL::Event::new(event.read_pointer, false)
592
+ num_events, events = get_event_wait_list( options )
593
+ event = FFI::MemoryPointer::new( Event )
594
+ error = clEnqueueReleaseGLObject( command_queue, num_objs, objs, num_events, events, event )
595
+ error_check(error)
596
+ return Event::new(event.read_pointer, false)
597
597
  end
598
598
 
599
599
  # Enqueues a command to fill a Buffer with the given pattern
@@ -616,18 +616,18 @@ module OpenCL
616
616
  #
617
617
  # the Event associated with the command
618
618
  def self.enqueue_fill_buffer( command_queue, buffer, pattern, options = {} )
619
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
619
+ error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
620
620
  offset = 0
621
621
  offset = options[:offset] if options[:offset]
622
622
  pattern_size = pattern.size
623
623
  pattern_size = options[:pattern_size] if options[:pattern_size]
624
624
  size = (buffer.size - offset) % pattern_size
625
625
  size = options[:size] if options[:size]
626
- num_events, events = OpenCL.get_event_wait_list( options )
627
- event = FFI::MemoryPointer::new( OpenCL::Event )
628
- error = OpenCL.clEnqueueFillBuffer( command_queue, buffer, pattern, pattern_size, offset, size, num_events, events, event )
629
- OpenCL.error_check(error)
630
- return OpenCL::Event::new(event.read_pointer, false)
626
+ num_events, events = get_event_wait_list( options )
627
+ event = FFI::MemoryPointer::new( Event )
628
+ error = clEnqueueFillBuffer( command_queue, buffer, pattern, pattern_size, offset, size, num_events, events, event )
629
+ error_check(error)
630
+ return Event::new(event.read_pointer, false)
631
631
  end
632
632
 
633
633
  # Enqueues a command to fill an Image with the given color
@@ -649,13 +649,13 @@ module OpenCL
649
649
  #
650
650
  # the Event associated with the command
651
651
  def self.enqueue_fill_image( command_queue, image, fill_color, options = {} )
652
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
653
- origin, region = OpenCL.get_origin_region( image, options, :origin, :region )
654
- num_events, events = OpenCL.get_event_wait_list( options )
655
- event = FFI::MemoryPointer::new( OpenCL::Event )
656
- error = OpenCL.clEnqueueFillImage( command_queue, image, fill_color, origin, region, num_events, events, event )
657
- OpenCL.error_check(error)
658
- return OpenCL::Event::new(event.read_pointer, false)
652
+ error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
653
+ origin, region = get_origin_region( image, options, :origin, :region )
654
+ num_events, events = get_event_wait_list( options )
655
+ event = FFI::MemoryPointer::new( Event )
656
+ error = clEnqueueFillImage( command_queue, image, fill_color, origin, region, num_events, events, event )
657
+ error_check(error)
658
+ return Event::new(event.read_pointer, false)
659
659
  end
660
660
 
661
661
  # Enqueues a command to copy an Image into a Buffer
@@ -678,14 +678,14 @@ module OpenCL
678
678
  #
679
679
  # the Event associated with the command
680
680
  def self.enqueue_copy_image_to_buffer( command_queue, src_image, dst_buffer, options = {} )
681
- src_origin, region = OpenCL.get_origin_region( src_image, options, :src_origin, :region )
681
+ src_origin, region = get_origin_region( src_image, options, :src_origin, :region )
682
682
  dst_offset = 0
683
683
  dst_offset = options[:dst_offset] if options[:dst_offset]
684
- num_events, events = OpenCL.get_event_wait_list( options )
685
- event = FFI::MemoryPointer::new( OpenCL::Event )
686
- error = OpenCL.clEnqueueCopyImageToBuffer( command_queue, src_image, dst_buffer, src_origin, region, dst_offset, num_events, events, event )
687
- OpenCL.error_check(error)
688
- return OpenCL::Event::new(event.read_pointer, false)
684
+ num_events, events = get_event_wait_list( options )
685
+ event = FFI::MemoryPointer::new( Event )
686
+ error = clEnqueueCopyImageToBuffer( command_queue, src_image, dst_buffer, src_origin, region, dst_offset, num_events, events, event )
687
+ error_check(error)
688
+ return Event::new(event.read_pointer, false)
689
689
  end
690
690
 
691
691
  # Enqueues a command to copy a Buffer into an Image
@@ -708,14 +708,14 @@ module OpenCL
708
708
  #
709
709
  # the Event associated with the command
710
710
  def self.enqueue_copy_buffer_to_image(command_queue, src_buffer, dst_image, options = {})
711
- dst_origin, region = OpenCL.get_origin_region( dst_image, options, :dst_origin, :region )
711
+ dst_origin, region = get_origin_region( dst_image, options, :dst_origin, :region )
712
712
  src_offset = 0
713
713
  src_offset = options[:src_offset] if options[:src_offset]
714
- num_events, events = OpenCL.get_event_wait_list( options )
715
- event = FFI::MemoryPointer::new( OpenCL::Event )
716
- error = OpenCL.clEnqueueCopyBufferToImage( command_queue, src_buffer, dst_image, src_offset, dst_origin, region, num_events, events, event )
717
- OpenCL.error_check(error)
718
- return OpenCL::Event::new(event.read_pointer, false)
714
+ num_events, events = get_event_wait_list( options )
715
+ event = FFI::MemoryPointer::new( Event )
716
+ error = clEnqueueCopyBufferToImage( command_queue, src_buffer, dst_image, src_offset, dst_origin, region, num_events, events, event )
717
+ error_check(error)
718
+ return Event::new(event.read_pointer, false)
719
719
  end
720
720
 
721
721
  # Enqueues a command to copy from host memory into an Image
@@ -741,20 +741,20 @@ module OpenCL
741
741
  #
742
742
  # the Event associated with the command
743
743
  def self.enqueue_write_image(command_queue, image, ptr, options = {})
744
- blocking = OpenCL::FALSE
745
- blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_write]
744
+ blocking = FALSE
745
+ blocking = TRUE if options[:blocking] or options[:blocking_write]
746
746
 
747
- origin, region = OpenCL.get_origin_region( image, options, :origin, :region )
747
+ origin, region = get_origin_region( image, options, :origin, :region )
748
748
 
749
749
  input_row_pitch = 0
750
750
  input_row_pitch = options[:input_row_pitch] if options[:input_row_pitch]
751
751
  input_slice_pitch = 0
752
752
  input_slice_pitch = options[:input_slice_pitch] if options[:input_slice_pitch]
753
- num_events, events = OpenCL.get_event_wait_list( options )
754
- event = FFI::MemoryPointer::new( OpenCL::Event )
755
- error = OpenCL.clEnqueueWriteImage( command_queue, image, blocking, origin, region, input_row_pitch, input_slice_pitch, ptr, num_events, events, event )
756
- OpenCL.error_check(error)
757
- return OpenCL::Event::new(event.read_pointer, false)
753
+ num_events, events = get_event_wait_list( options )
754
+ event = FFI::MemoryPointer::new( Event )
755
+ error = clEnqueueWriteImage( command_queue, image, blocking, origin, region, input_row_pitch, input_slice_pitch, ptr, num_events, events, event )
756
+ error_check(error)
757
+ return Event::new(event.read_pointer, false)
758
758
  end
759
759
 
760
760
  # Enqueues a command to copy from an Image into an Image
@@ -777,17 +777,17 @@ module OpenCL
777
777
  #
778
778
  # the Event associated with the command
779
779
  def self.enqueue_copy_image( command_queue, src_image, dst_image, options = {} )
780
- src_origin, src_region = OpenCL.get_origin_region( src_image, options, :src_origin, :region )
781
- dst_origin, dst_region = OpenCL.get_origin_region( dst_image, options, :dst_origin, :region )
780
+ src_origin, src_region = get_origin_region( src_image, options, :src_origin, :region )
781
+ dst_origin, dst_region = get_origin_region( dst_image, options, :dst_origin, :region )
782
782
  region = FFI::MemoryPointer::new( :size_t, 3 )
783
783
  (0..2).each { |i|
784
784
  region[i].write_size_t( [src_region[i].read_size_t, dst_region[i].read_size_t].min )
785
785
  }
786
- num_events, events = OpenCL.get_event_wait_list( options )
787
- event = FFI::MemoryPointer::new( OpenCL::Event )
788
- error = OpenCL.clEnqueueCopyImage( command_queue, src_image, dst_image, src_origin, dst_origin, region, num_events, events, event )
789
- OpenCL.error_check(error)
790
- return OpenCL::Event::new(event.read_pointer, false)
786
+ num_events, events = get_event_wait_list( options )
787
+ event = FFI::MemoryPointer::new( Event )
788
+ error = clEnqueueCopyImage( command_queue, src_image, dst_image, src_origin, dst_origin, region, num_events, events, event )
789
+ error_check(error)
790
+ return Event::new(event.read_pointer, false)
791
791
  end
792
792
 
793
793
  # Enqueues a command to copy from an Image into host memory
@@ -813,19 +813,19 @@ module OpenCL
813
813
  #
814
814
  # the Event associated with the command
815
815
  def self.enqueue_read_image( command_queue, image, ptr, options = {} )
816
- blocking = OpenCL::FALSE
817
- blocking = OpenCL::TRUE if options[:blocking] or options[:blocking_read]
816
+ blocking = FALSE
817
+ blocking = TRUE if options[:blocking] or options[:blocking_read]
818
818
 
819
- origin, region = OpenCL.get_origin_region( image, options, :origin, :region )
819
+ origin, region = get_origin_region( image, options, :origin, :region )
820
820
  row_pitch = 0
821
821
  row_pitch = options[:row_pitch] if options[:row_pitch]
822
822
  slice_pitch = 0
823
823
  slice_pitch = options[:slice_pitch] if options[:slice_pitch]
824
- num_events, events = OpenCL.get_event_wait_list( options )
825
- event = FFI::MemoryPointer::new( OpenCL::Event )
826
- error = OpenCL.clEnqueueReadImage( command_queue, image, blocking, origin, region, row_pitch, slice_pitch, ptr, num_events, events, event )
827
- OpenCL.error_check(error)
828
- return OpenCL::Event::new(event.read_pointer, false)
824
+ num_events, events = get_event_wait_list( options )
825
+ event = FFI::MemoryPointer::new( Event )
826
+ error = clEnqueueReadImage( command_queue, image, blocking, origin, region, row_pitch, slice_pitch, ptr, num_events, events, event )
827
+ error_check(error)
828
+ return Event::new(event.read_pointer, false)
829
829
  end
830
830
 
831
831
  # Enqueues a native kernel
@@ -865,7 +865,7 @@ module OpenCL
865
865
  if options[:mem_list] then
866
866
  num_mem_objects = options[:mem_list].length
867
867
  if num_mem_objects > 0 then
868
- mem_list = FFI::MemoryPointer::new( OpenCL::Mem, num_mem_objects )
868
+ mem_list = FFI::MemoryPointer::new( Mem, num_mem_objects )
869
869
  mem_loc = FFI::MemoryPointer::new( :pointer, num_mem_objects )
870
870
  i = 0
871
871
  options[:mem_list].each { |key, value|
@@ -875,11 +875,11 @@ module OpenCL
875
875
  }
876
876
  end
877
877
  end
878
- num_events, events = OpenCL.get_event_wait_list( options )
879
- event = FFI::MemoryPointer::new( OpenCL::Event )
880
- error = OpenCL.clEnqueueNativeKernel( command_queue, func, args, args_size, num_mem_objects, mem_list, mem_loc, num_events, events, event )
881
- OpenCL.error_check(error)
882
- return OpenCL::Event::new(event.read_pointer, false)
878
+ num_events, events = get_event_wait_list( options )
879
+ event = FFI::MemoryPointer::new( Event )
880
+ error = clEnqueueNativeKernel( command_queue, func, args, args_size, num_mem_objects, mem_list, mem_loc, num_events, events, event )
881
+ error_check(error)
882
+ return Event::new(event.read_pointer, false)
883
883
  end
884
884
 
885
885
  # Enqueues a kernel as a task
@@ -899,15 +899,15 @@ module OpenCL
899
899
  # the Event associated with the command
900
900
  def self.enqueue_task( command_queue, kernel, options = {} )
901
901
  if queue.context.platform.version_number < 2.0 then
902
- num_events, events = OpenCL.get_event_wait_list( options )
903
- event = FFI::MemoryPointer::new( OpenCL::Event )
904
- error = OpenCL.clEnqueueTask( command_queue, kernel, num_events, events, event )
905
- OpenCL.error_check(error)
906
- return OpenCL::Event::new(event.read_pointer, false)
902
+ num_events, events = get_event_wait_list( options )
903
+ event = FFI::MemoryPointer::new( Event )
904
+ error = clEnqueueTask( command_queue, kernel, num_events, events, event )
905
+ error_check(error)
906
+ return Event::new(event.read_pointer, false)
907
907
  else
908
908
  opts = options.dup
909
909
  opts[:local_work_size] = [1]
910
- return OpenCL.enqueue_NDrange_kernel( command_queue, kernel, [1], opts )
910
+ return enqueue_NDrange_kernel( command_queue, kernel, [1], opts )
911
911
  end
912
912
  end
913
913
 
@@ -948,11 +948,11 @@ module OpenCL
948
948
  gwo[i].write_size_t(options[:global_work_offset][i])
949
949
  }
950
950
  end
951
- num_events, events = OpenCL.get_event_wait_list( options )
952
- event = FFI::MemoryPointer::new( OpenCL::Event )
953
- error = OpenCL.clEnqueueNDRangeKernel(command_queue, kernel, global_work_size.length, gwo, gws, lws, num_events, events, event)
954
- OpenCL.error_check(error)
955
- return OpenCL::Event::new(event.read_pointer, false)
951
+ num_events, events = get_event_wait_list( options )
952
+ event = FFI::MemoryPointer::new( Event )
953
+ error = clEnqueueNDRangeKernel(command_queue, kernel, global_work_size.length, gwo, gws, lws, num_events, events, event)
954
+ error_check(error)
955
+ return Event::new(event.read_pointer, false)
956
956
  end
957
957
 
958
958
  # Enqueues a barrier on a list of envents
@@ -966,7 +966,7 @@ module OpenCL
966
966
  #
967
967
  # an Event if implementation version is >= 1.2, nil otherwise
968
968
  def self.enqueue_wait_for_events( command_queue, events )
969
- return OpenCL.enqueue_barrier( command_queue, events )
969
+ return enqueue_barrier( command_queue, events )
970
970
  end
971
971
 
972
972
  # Enqueues a barrier that prevents subsequent execution to take place in the command queue, until the barrier is considered finished
@@ -983,29 +983,29 @@ module OpenCL
983
983
  if command_queue.context.platform.version_number < 1.2 then
984
984
  num_events = [events].flatten.length
985
985
  if num_events > 0 then
986
- evts = FFI::MemoryPointer::new( OpenCL::Event, num_events )
986
+ evts = FFI::MemoryPointer::new( Event, num_events )
987
987
  [events].flatten.each_with_index { |e, i|
988
988
  evts[i].write_pointer(e)
989
989
  }
990
- error = OpenCL.clnqueueWaitForEvents( command_queue, num_events, evts )
990
+ error = clnqueueWaitForEvents( command_queue, num_events, evts )
991
991
  else
992
- error = OpenCL.clEnqueueBarrier( command_queue )
992
+ error = clEnqueueBarrier( command_queue )
993
993
  end
994
- OpenCL.error_check(error)
994
+ error_check(error)
995
995
  return nil
996
996
  else
997
997
  num_events = [events].flatten.length
998
998
  evts = nil
999
999
  if num_events > 0 then
1000
- evts = FFI::MemoryPointer::new( OpenCL::Event, num_events )
1000
+ evts = FFI::MemoryPointer::new( Event, num_events )
1001
1001
  [events].flatten.each_with_index { |e, i|
1002
1002
  evts[i].write_pointer(e)
1003
1003
  }
1004
1004
  end
1005
- event = FFI::MemoryPointer::new( OpenCL::Event )
1006
- error = OpenCL.clEnqueueBarrierWithWaitList( command_queue, num_events, evts, event )
1007
- OpenCL.error_check(error)
1008
- return OpenCL::Event::new(event.read_pointer, false)
1005
+ event = FFI::MemoryPointer::new( Event )
1006
+ error = clEnqueueBarrierWithWaitList( command_queue, num_events, evts, event )
1007
+ error_check(error)
1008
+ return Event::new(event.read_pointer, false)
1009
1009
  end
1010
1010
  end
1011
1011
 
@@ -1020,22 +1020,22 @@ module OpenCL
1020
1020
  #
1021
1021
  # an Event
1022
1022
  def self.enqueue_marker( command_queue, events = [] )
1023
- event = FFI::MemoryPointer::new( OpenCL::Event )
1023
+ event = FFI::MemoryPointer::new( Event )
1024
1024
  if command_queue.context.platform.version_number < 1.2 then
1025
- error = OpenCL.clEnqueueMarker( command_queue, event )
1025
+ error = clEnqueueMarker( command_queue, event )
1026
1026
  else
1027
1027
  num_events = [events].flatten.length
1028
1028
  evts = nil
1029
1029
  if num_events > 0 then
1030
- evts = FFI::MemoryPointer::new( OpenCL::Event, num_events )
1030
+ evts = FFI::MemoryPointer::new( Event, num_events )
1031
1031
  [events].flatten.each_with_index { |e, i|
1032
1032
  evts[i].write_pointer(e)
1033
1033
  }
1034
1034
  end
1035
- error = OpenCL.clEnqueueMarkerWithWaitList( command_queue, num_events, evts, event )
1035
+ error = clEnqueueMarkerWithWaitList( command_queue, num_events, evts, event )
1036
1036
  end
1037
- OpenCL.error_check(error)
1038
- return OpenCL::Event::new(event.read_pointer, false)
1037
+ error_check(error)
1038
+ return Event::new(event.read_pointer, false)
1039
1039
  end
1040
1040
 
1041
1041
  # Maps the cl_command_queue object of OpenCL
@@ -1044,7 +1044,7 @@ module OpenCL
1044
1044
  # Returns the Context associated to the CommandQueue
1045
1045
  def context
1046
1046
  ptr = FFI::MemoryPointer::new( OpenCL::Context )
1047
- error = OpenCL.clGetCommandQueueInfo(self, OpenCL::CommandQueue::CONTEXT, Context.size, ptr, nil)
1047
+ error = OpenCL.clGetCommandQueueInfo(self, CONTEXT, Context.size, ptr, nil)
1048
1048
  OpenCL.error_check(error)
1049
1049
  return OpenCL::Context::new( ptr.read_pointer )
1050
1050
  end
@@ -1052,7 +1052,7 @@ module OpenCL
1052
1052
  # Returns the Device associated to the CommandQueue
1053
1053
  def device
1054
1054
  ptr = FFI::MemoryPointer::new( OpenCL::Device )
1055
- error = OpenCL.clGetCommandQueueInfo(self, OpenCL::CommandQueue::DEVICE, Device.size, ptr, nil)
1055
+ error = OpenCL.clGetCommandQueueInfo(self, DEVICE, Device.size, ptr, nil)
1056
1056
  OpenCL.error_check(error)
1057
1057
  return OpenCL::Device::new( ptr.read_pointer )
1058
1058
  end