opencl_ruby_ffi 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 638c3044b24306b1bfe188646be2b8d6092ebf79
4
- data.tar.gz: c18f431a9059fbfbc2c010b4631a4818853eba62
3
+ metadata.gz: 193e78c54b6d29e4f591b8dbdce9ff66c425347c
4
+ data.tar.gz: b8d6469deb531b4834b4a27f67347ea710ab6a05
5
5
  SHA512:
6
- metadata.gz: f915b5335329de46668b622a1d48c9fa14700a1ba6e76ef490ef76c3d09dce8b4489a365b37484936b10087275d3785c72c04909a45b3136a36bf81a483e5d8e
7
- data.tar.gz: f4b96b25804a03c79bfd37125ec4691b7d58507ace26980fb4cbed44ab4d03f95f1d8ae737d51c93320039df66c81aaffaefbdc82321faab6c4be02ccbdf6757
6
+ metadata.gz: 0df6dfd8dd9487ef052ea835e528f76ec920dd405a5f4541e41072993162e2af293d4e2556555dfa13d240b580a52dd7e3fc75a622aef4ca3989b0c50f0d5464
7
+ data.tar.gz: bcb6a82188d07f0f45e6d92af2af06eb1c007386ee180c86577ce85cf070d47330791ff70cc5cda41f110be2750f6621e26e0f72cfb53ceed344b5e2844fe42b
@@ -1,3 +1,4 @@
1
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
1
2
  module OpenCL
2
3
 
3
4
  # Creates a Buffer
@@ -15,7 +16,7 @@ module OpenCL
15
16
  def self.create_buffer( context, size, options = {} )
16
17
  flags = get_flags( options )
17
18
  host_ptr = options[:host_ptr]
18
- error = FFI::MemoryPointer::new( :cl_int )
19
+ error = MemoryPointer::new( :cl_int )
19
20
  buff = clCreateBuffer(context, flags, size, host_ptr, error)
20
21
  error_check(error.read_cl_int)
21
22
  return Buffer::new( buff, false )
@@ -36,7 +37,7 @@ module OpenCL
36
37
  def self.create_sub_buffer( buffer, type, info, options = {} )
37
38
  error_check(INVALID_OPERATION) if buffer.platform.version_number < 1.1
38
39
  flags = get_flags( options )
39
- error = FFI::MemoryPointer::new( :cl_int )
40
+ error = MemoryPointer::new( :cl_int )
40
41
  buff = clCreateSubBuffer( buffer, flags, type, info, error)
41
42
  error_check(error.read_cl_int)
42
43
  return Buffer::new( buff, false )
@@ -55,7 +56,7 @@ module OpenCL
55
56
  # * +:flags+ - a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image
56
57
  def self.create_from_gl_buffer( context, bufobj, options = {} )
57
58
  flags = get_flags( options )
58
- error = FFI::MemoryPointer::new( :cl_int )
59
+ error = MemoryPointer::new( :cl_int )
59
60
  buff = clCreateFromGLBuffer( context, flags, bufobj, error )
60
61
  error_check(error.read_cl_int)
61
62
  return Buffer::new( buff, false )
@@ -1,3 +1,4 @@
1
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
1
2
  module OpenCL
2
3
 
3
4
  # Blocks until all the commands in the queue have completed
@@ -37,7 +38,7 @@ module OpenCL
37
38
  def self.create_command_queue( context, device, options = {} )
38
39
  properties = get_command_queue_properties( options )
39
40
  size = options[:size]
40
- error = FFI::MemoryPointer::new( :cl_int )
41
+ error = MemoryPointer::new( :cl_int )
41
42
  if context.platform.version_number < 2.0 then
42
43
  cmd = clCreateCommandQueue( context, device, properties, error )
43
44
  else
@@ -47,7 +48,7 @@ module OpenCL
47
48
  props_size += 2 if properties.to_i != 0
48
49
  props_size += 2 if size
49
50
  props_size += 1 if props_size > 0
50
- props = FFI::MemoryPointer::new( :cl_queue_properties, props_size )
51
+ props = MemoryPointer::new( :cl_queue_properties, props_size )
51
52
  i=0
52
53
  if properties.to_i != 0 then
53
54
  props[i].write_cl_queue_properties( CommandQueue::PROPERTIES )
@@ -88,14 +89,14 @@ module OpenCL
88
89
  num_mem_objects = [mem_objects].flatten.length
89
90
  mem_list = nil
90
91
  if num_mem_objects > 0 then
91
- mem_list = FFI::MemoryPointer::new( Mem, num_mem_objects )
92
+ mem_list = MemoryPointer::new( Mem, num_mem_objects )
92
93
  [mem_objects].flatten.each_with_index { |e, i|
93
94
  mem_list[i].write_pointer(e)
94
95
  }
95
96
  end
96
97
  flags = get_flags( options )
97
98
  num_events, events = get_event_wait_list( options )
98
- event = FFI::MemoryPointer::new( Event )
99
+ event = MemoryPointer::new( Event )
99
100
  error = clEnqueueMigrateMemObjects( command_queue, num_mem_objects, mem_list, flags, num_events, events, event )
100
101
  error_check( error )
101
102
  return Event::new( event.read_ptr, false )
@@ -133,10 +134,10 @@ module OpenCL
133
134
  origin, region = get_origin_region( image, options, :origin, :region )
134
135
 
135
136
  num_events, events = get_event_wait_list( options )
136
- image_row_pitch = FFI::MemoryPointer::new( :size_t )
137
- image_slice_pitch = FFI::MemoryPointer::new( :size_t )
138
- event = FFI::MemoryPointer::new( Event )
139
- error = FFI::MemoryPointer::new( :cl_int )
137
+ image_row_pitch = MemoryPointer::new( :size_t )
138
+ image_slice_pitch = MemoryPointer::new( :size_t )
139
+ event = MemoryPointer::new( Event )
140
+ error = MemoryPointer::new( :cl_int )
140
141
  ptr = clEnqueueMapImage( command_queue, image, blocking, flags, origin, region, image_row_pitch, image_slice_pitch, num_events, events, event, error )
141
142
  error_check( error.read_cl_int )
142
143
  ev = Event::new( event.read_ptr, false )
@@ -175,8 +176,8 @@ module OpenCL
175
176
  size = buffer.size - offset
176
177
  size = options[:size] - offset if options[:size]
177
178
  num_events, events = get_event_wait_list( options )
178
- event = FFI::MemoryPointer::new( Event )
179
- error = FFI::MemoryPointer::new( :cl_int )
179
+ event = MemoryPointer::new( Event )
180
+ error = MemoryPointer::new( :cl_int )
180
181
  ptr = clEnqueueMapBuffer( command_queue, buffer, blocking, flags, offset, size, num_events, events, event, error )
181
182
  error_check( error.read_cl_int )
182
183
  ev = Event::new( event.read_ptr, false )
@@ -201,7 +202,7 @@ module OpenCL
201
202
  # the Event associated with the command
202
203
  def self.enqueue_unmap_mem_object( command_queue, mem_obj, mapped_ptr, options = {} )
203
204
  num_events, events = get_event_wait_list( options )
204
- event = FFI::MemoryPointer::new( Event )
205
+ event = MemoryPointer::new( Event )
205
206
  error = clEnqueueUnmapMemObject( command_queue, mem_obj, mapped_ptr, num_events, events, event )
206
207
  error_check( error )
207
208
  return Event::new( event.read_ptr, false )
@@ -237,7 +238,7 @@ module OpenCL
237
238
  blocking = FALSE
238
239
  blocking = TRUE if options[:blocking] or options[:blocking_read]
239
240
 
240
- buffer_origin = FFI::MemoryPointer::new( :size_t, 3 )
241
+ buffer_origin = MemoryPointer::new( :size_t, 3 )
241
242
  (0..2).each { |i| buffer_origin[i].write_size_t(0) }
242
243
  bo = options[:src_origin] ? options[:src_origin] : options[:buffer_origin]
243
244
  if bo then
@@ -246,7 +247,7 @@ module OpenCL
246
247
  }
247
248
  end
248
249
 
249
- host_origin = FFI::MemoryPointer::new( :size_t, 3 )
250
+ host_origin = MemoryPointer::new( :size_t, 3 )
250
251
  (0..2).each { |i| host_origin[i].write_size_t(0) }
251
252
  ho = options[:dst_origin] ? options[:dst_origin] : options[:host_origin]
252
253
  if ho then
@@ -255,7 +256,7 @@ module OpenCL
255
256
  }
256
257
  end
257
258
 
258
- r = FFI::MemoryPointer::new( :size_t, 3 )
259
+ r = MemoryPointer::new( :size_t, 3 )
259
260
  (0..2).each { |i| r[i].write_size_t(0) }
260
261
  region[0..2].each_with_index { |e, i|
261
262
  r[i].write_size_t(e)
@@ -278,7 +279,7 @@ module OpenCL
278
279
  host_slice_pitch = 0
279
280
  end
280
281
  num_events, events = get_event_wait_list( options )
281
- event = FFI::MemoryPointer::new( Event )
282
+ event = MemoryPointer::new( Event )
282
283
  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
284
  error_check(error)
284
285
  return Event::new(event.read_pointer, false)
@@ -314,7 +315,7 @@ module OpenCL
314
315
  blocking = FALSE
315
316
  blocking = TRUE if options[:blocking] or options[:blocking_write]
316
317
 
317
- buffer_origin = FFI::MemoryPointer::new( :size_t, 3 )
318
+ buffer_origin = MemoryPointer::new( :size_t, 3 )
318
319
  (0..2).each { |i| buffer_origin[i].write_size_t(0) }
319
320
  bo = options[:dst_origin] ? options[:dst_origin] : options[:buffer_origin]
320
321
  if bo then
@@ -323,7 +324,7 @@ module OpenCL
323
324
  }
324
325
  end
325
326
 
326
- host_origin = FFI::MemoryPointer::new( :size_t, 3 )
327
+ host_origin = MemoryPointer::new( :size_t, 3 )
327
328
  (0..2).each { |i| host_origin[i].write_size_t(0) }
328
329
  ho = options[:src_origin] ? options[:src_origin] : options[:host_origin]
329
330
  if ho then
@@ -332,7 +333,7 @@ module OpenCL
332
333
  }
333
334
  end
334
335
 
335
- r = FFI::MemoryPointer::new( :size_t, 3 )
336
+ r = MemoryPointer::new( :size_t, 3 )
336
337
  (0..2).each { |i| r[i].write_size_t(0) }
337
338
  region[0..2].each_with_index { |e, i|
338
339
  r[i].write_size_t(e)
@@ -355,7 +356,7 @@ module OpenCL
355
356
  host_slice_pitch = 0
356
357
  end
357
358
  num_events, events = get_event_wait_list( options )
358
- event = FFI::MemoryPointer::new( Event )
359
+ event = MemoryPointer::new( Event )
359
360
  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
361
  error_check(error)
361
362
  return Event::new(event.read_pointer, false)
@@ -387,7 +388,7 @@ module OpenCL
387
388
  def self.enqueue_copy_buffer_rect(command_queue, src_buffer, dst_buffer, region, options = {})
388
389
  error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
389
390
 
390
- src_origin = FFI::MemoryPointer::new( :size_t, 3 )
391
+ src_origin = MemoryPointer::new( :size_t, 3 )
391
392
  (0..2).each { |i| src_origin[i].write_size_t(0) }
392
393
  if options[:src_origin] then
393
394
  options[:src_origin].each_with_index { |e, i|
@@ -395,7 +396,7 @@ module OpenCL
395
396
  }
396
397
  end
397
398
 
398
- dst_origin = FFI::MemoryPointer::new( :size_t, 3 )
399
+ dst_origin = MemoryPointer::new( :size_t, 3 )
399
400
  (0..2).each { |i| dst_origin[i].write_size_t(0) }
400
401
  if options[:dst_origin] then
401
402
  options[:dst_origin].each_with_index { |e, i|
@@ -403,7 +404,7 @@ module OpenCL
403
404
  }
404
405
  end
405
406
 
406
- r = FFI::MemoryPointer::new( :size_t, 3 )
407
+ r = MemoryPointer::new( :size_t, 3 )
407
408
  (0..2).each { |i| r[i].write_size_t(0) }
408
409
  region[0..2].each_with_index { |e, i|
409
410
  r[i].write_size_t(e)
@@ -426,7 +427,7 @@ module OpenCL
426
427
  dst_slice_pitch = 0
427
428
  end
428
429
  num_events, events = get_event_wait_list( options )
429
- event = FFI::MemoryPointer::new( Event )
430
+ event = MemoryPointer::new( Event )
430
431
  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
432
  error_check(error)
432
433
  return Event::new(event.read_pointer, false)
@@ -459,7 +460,7 @@ module OpenCL
459
460
  size = [ src_buffer.size - src_offset, dst_buffer.size - dst_offset ].min
460
461
  size = options[:size] if options[:size]
461
462
  num_events, events = get_event_wait_list( options )
462
- event = FFI::MemoryPointer::new( Event )
463
+ event = MemoryPointer::new( Event )
463
464
  error = clEnqueueCopyBuffer(command_queue, src_buffer, dst_buffer, src_offset, dst_offset, size, num_events, events, event)
464
465
  error_check(error)
465
466
  return Event::new(event.read_pointer, false)
@@ -494,7 +495,7 @@ module OpenCL
494
495
  size = buffer.size - offset
495
496
  size = options[:size] if options[:size]
496
497
  num_events, events = get_event_wait_list( options )
497
- event = FFI::MemoryPointer::new( Event )
498
+ event = MemoryPointer::new( Event )
498
499
  error = clEnqueueWriteBuffer(command_queue, buffer, blocking, offset, size, ptr, num_events, events, event)
499
500
  error_check(error)
500
501
  return Event::new(event.read_pointer, false)
@@ -528,7 +529,7 @@ module OpenCL
528
529
  size = buffer.size - offset
529
530
  size = options[:size] if options[:size]
530
531
  num_events, events = get_event_wait_list( options )
531
- event = FFI::MemoryPointer::new( Event )
532
+ event = MemoryPointer::new( Event )
532
533
  error = clEnqueueReadBuffer(command_queue, buffer, blocking, offset, size, ptr, num_events, events, event)
533
534
  error_check(error)
534
535
  return Event::new(event.read_pointer, false)
@@ -553,13 +554,13 @@ module OpenCL
553
554
  num_objs = [mem_objects].flatten.length
554
555
  objs = nil
555
556
  if num_objs > 0 then
556
- objs = FFI::MemoryPointer::new( Mem, num_objs )
557
+ objs = MemoryPointer::new( Mem, num_objs )
557
558
  [mem_objects].flatten.each_with_index { |o, i|
558
559
  objs[i].write_pointer(e)
559
560
  }
560
561
  end
561
562
  num_events, events = get_event_wait_list( options )
562
- event = FFI::MemoryPointer::new( Event )
563
+ event = MemoryPointer::new( Event )
563
564
  error = clEnqueueAcquireGLObjects( command_queue, num_objs, objs, num_events, events, event )
564
565
  error_check(error)
565
566
  return Event::new(event.read_pointer, false)
@@ -587,13 +588,13 @@ module OpenCL
587
588
  num_objs = [mem_objects].flatten.length
588
589
  objs = nil
589
590
  if num_objs > 0 then
590
- objs = FFI::MemoryPointer::new( Mem, num_objs )
591
+ objs = MemoryPointer::new( Mem, num_objs )
591
592
  [mem_objects].flatten.each_with_index { |o, i|
592
593
  objs[i].write_pointer(e)
593
594
  }
594
595
  end
595
596
  num_events, events = get_event_wait_list( options )
596
- event = FFI::MemoryPointer::new( Event )
597
+ event = MemoryPointer::new( Event )
597
598
  error = clEnqueueReleaseGLObjects( command_queue, num_objs, objs, num_events, events, event )
598
599
  error_check(error)
599
600
  return Event::new(event.read_pointer, false)
@@ -630,7 +631,7 @@ module OpenCL
630
631
  size = (buffer.size - offset) % pattern_size
631
632
  size = options[:size] if options[:size]
632
633
  num_events, events = get_event_wait_list( options )
633
- event = FFI::MemoryPointer::new( Event )
634
+ event = MemoryPointer::new( Event )
634
635
  error = clEnqueueFillBuffer( command_queue, buffer, pattern, pattern_size, offset, size, num_events, events, event )
635
636
  error_check(error)
636
637
  return Event::new(event.read_pointer, false)
@@ -658,7 +659,7 @@ module OpenCL
658
659
  error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1
659
660
  origin, region = get_origin_region( image, options, :origin, :region )
660
661
  num_events, events = get_event_wait_list( options )
661
- event = FFI::MemoryPointer::new( Event )
662
+ event = MemoryPointer::new( Event )
662
663
  error = clEnqueueFillImage( command_queue, image, fill_color, origin, region, num_events, events, event )
663
664
  error_check(error)
664
665
  return Event::new(event.read_pointer, false)
@@ -688,7 +689,7 @@ module OpenCL
688
689
  dst_offset = 0
689
690
  dst_offset = options[:dst_offset] if options[:dst_offset]
690
691
  num_events, events = get_event_wait_list( options )
691
- event = FFI::MemoryPointer::new( Event )
692
+ event = MemoryPointer::new( Event )
692
693
  error = clEnqueueCopyImageToBuffer( command_queue, src_image, dst_buffer, src_origin, region, dst_offset, num_events, events, event )
693
694
  error_check(error)
694
695
  return Event::new(event.read_pointer, false)
@@ -718,7 +719,7 @@ module OpenCL
718
719
  src_offset = 0
719
720
  src_offset = options[:src_offset] if options[:src_offset]
720
721
  num_events, events = get_event_wait_list( options )
721
- event = FFI::MemoryPointer::new( Event )
722
+ event = MemoryPointer::new( Event )
722
723
  error = clEnqueueCopyBufferToImage( command_queue, src_buffer, dst_image, src_offset, dst_origin, region, num_events, events, event )
723
724
  error_check(error)
724
725
  return Event::new(event.read_pointer, false)
@@ -757,7 +758,7 @@ module OpenCL
757
758
  input_slice_pitch = 0
758
759
  input_slice_pitch = options[:input_slice_pitch] if options[:input_slice_pitch]
759
760
  num_events, events = get_event_wait_list( options )
760
- event = FFI::MemoryPointer::new( Event )
761
+ event = MemoryPointer::new( Event )
761
762
  error = clEnqueueWriteImage( command_queue, image, blocking, origin, region, input_row_pitch, input_slice_pitch, ptr, num_events, events, event )
762
763
  error_check(error)
763
764
  return Event::new(event.read_pointer, false)
@@ -785,12 +786,12 @@ module OpenCL
785
786
  def self.enqueue_copy_image( command_queue, src_image, dst_image, options = {} )
786
787
  src_origin, src_region = get_origin_region( src_image, options, :src_origin, :region )
787
788
  dst_origin, dst_region = get_origin_region( dst_image, options, :dst_origin, :region )
788
- region = FFI::MemoryPointer::new( :size_t, 3 )
789
+ region = MemoryPointer::new( :size_t, 3 )
789
790
  (0..2).each { |i|
790
791
  region[i].write_size_t( [src_region[i].read_size_t, dst_region[i].read_size_t].min )
791
792
  }
792
793
  num_events, events = get_event_wait_list( options )
793
- event = FFI::MemoryPointer::new( Event )
794
+ event = MemoryPointer::new( Event )
794
795
  error = clEnqueueCopyImage( command_queue, src_image, dst_image, src_origin, dst_origin, region, num_events, events, event )
795
796
  error_check(error)
796
797
  return Event::new(event.read_pointer, false)
@@ -828,7 +829,7 @@ module OpenCL
828
829
  slice_pitch = 0
829
830
  slice_pitch = options[:slice_pitch] if options[:slice_pitch]
830
831
  num_events, events = get_event_wait_list( options )
831
- event = FFI::MemoryPointer::new( Event )
832
+ event = MemoryPointer::new( Event )
832
833
  error = clEnqueueReadImage( command_queue, image, blocking, origin, region, row_pitch, slice_pitch, ptr, num_events, events, event )
833
834
  error_check(error)
834
835
  return Event::new(event.read_pointer, false)
@@ -861,7 +862,7 @@ module OpenCL
861
862
  arg_offset.push(arg_size)
862
863
  args_size += e.size
863
864
  }
864
- args = FFI::MemoryPointer::new(args_size)
865
+ args = MemoryPointer::new(args_size)
865
866
  [arguments].flatten.each_with_index { |e, i|
866
867
  args.put_bytes(arg_offset[i], e.to_ptr.read_bytes(e.size))
867
868
  }
@@ -871,8 +872,8 @@ module OpenCL
871
872
  if options[:mem_list] then
872
873
  num_mem_objects = options[:mem_list].length
873
874
  if num_mem_objects > 0 then
874
- mem_list = FFI::MemoryPointer::new( Mem, num_mem_objects )
875
- mem_loc = FFI::MemoryPointer::new( :pointer, num_mem_objects )
875
+ mem_list = MemoryPointer::new( Mem, num_mem_objects )
876
+ mem_loc = MemoryPointer::new( :pointer, num_mem_objects )
876
877
  i = 0
877
878
  options[:mem_list].each { |key, value|
878
879
  mem_list[i].write_pointer(key)
@@ -882,7 +883,7 @@ module OpenCL
882
883
  end
883
884
  end
884
885
  num_events, events = get_event_wait_list( options )
885
- event = FFI::MemoryPointer::new( Event )
886
+ event = MemoryPointer::new( Event )
886
887
  error = clEnqueueNativeKernel( command_queue, func, args, args_size, num_mem_objects, mem_list, mem_loc, num_events, events, event )
887
888
  error_check(error)
888
889
  return Event::new(event.read_pointer, false)
@@ -906,7 +907,7 @@ module OpenCL
906
907
  def self.enqueue_task( command_queue, kernel, options = {} )
907
908
  if queue.context.platform.version_number < 2.0 then
908
909
  num_events, events = get_event_wait_list( options )
909
- event = FFI::MemoryPointer::new( Event )
910
+ event = MemoryPointer::new( Event )
910
911
  error = clEnqueueTask( command_queue, kernel, num_events, events, event )
911
912
  error_check(error)
912
913
  return Event::new(event.read_pointer, false)
@@ -936,26 +937,26 @@ module OpenCL
936
937
  #
937
938
  # the Event associated with the command
938
939
  def self.enqueue_ndrange_kernel( command_queue, kernel, global_work_size, options={} )
939
- gws = FFI::MemoryPointer::new( :size_t, global_work_size.length )
940
+ gws = MemoryPointer::new( :size_t, global_work_size.length )
940
941
  global_work_size.each_with_index { |g, i|
941
942
  gws[i].write_size_t(g)
942
943
  }
943
944
  lws = nil
944
945
  if options[:local_work_size] then
945
- lws = FFI::MemoryPointer::new( :size_t, global_work_size.length )
946
+ lws = MemoryPointer::new( :size_t, global_work_size.length )
946
947
  global_work_size.each_index { |i|
947
948
  lws[i].write_size_t(options[:local_work_size][i])
948
949
  }
949
950
  end
950
951
  gwo = nil
951
952
  if options[:global_work_offset] then
952
- gwo = FFI::MemoryPointer::new( :size_t, global_work_size.length )
953
+ gwo = MemoryPointer::new( :size_t, global_work_size.length )
953
954
  global_work_size.each_index { |i|
954
955
  gwo[i].write_size_t(options[:global_work_offset][i])
955
956
  }
956
957
  end
957
958
  num_events, events = get_event_wait_list( options )
958
- event = FFI::MemoryPointer::new( Event )
959
+ event = MemoryPointer::new( Event )
959
960
  error = clEnqueueNDRangeKernel(command_queue, kernel, global_work_size.length, gwo, gws, lws, num_events, events, event)
960
961
  error_check(error)
961
962
  return Event::new(event.read_pointer, false)
@@ -992,7 +993,7 @@ module OpenCL
992
993
  if command_queue.context.platform.version_number < 1.2 then
993
994
  num_events = [events].flatten.length
994
995
  if num_events > 0 then
995
- evts = FFI::MemoryPointer::new( Event, num_events )
996
+ evts = MemoryPointer::new( Event, num_events )
996
997
  [events].flatten.each_with_index { |e, i|
997
998
  evts[i].write_pointer(e)
998
999
  }
@@ -1006,12 +1007,12 @@ module OpenCL
1006
1007
  num_events = [events].flatten.length
1007
1008
  evts = nil
1008
1009
  if num_events > 0 then
1009
- evts = FFI::MemoryPointer::new( Event, num_events )
1010
+ evts = MemoryPointer::new( Event, num_events )
1010
1011
  [events].flatten.each_with_index { |e, i|
1011
1012
  evts[i].write_pointer(e)
1012
1013
  }
1013
1014
  end
1014
- event = FFI::MemoryPointer::new( Event )
1015
+ event = MemoryPointer::new( Event )
1015
1016
  error = clEnqueueBarrierWithWaitList( command_queue, num_events, evts, event )
1016
1017
  error_check(error)
1017
1018
  return Event::new(event.read_pointer, false)
@@ -1029,14 +1030,14 @@ module OpenCL
1029
1030
  #
1030
1031
  # an Event
1031
1032
  def self.enqueue_marker( command_queue, events = [] )
1032
- event = FFI::MemoryPointer::new( Event )
1033
+ event = MemoryPointer::new( Event )
1033
1034
  if command_queue.context.platform.version_number < 1.2 then
1034
1035
  error = clEnqueueMarker( command_queue, event )
1035
1036
  else
1036
1037
  num_events = [events].flatten.length
1037
1038
  evts = nil
1038
1039
  if num_events > 0 then
1039
- evts = FFI::MemoryPointer::new( Event, num_events )
1040
+ evts = MemoryPointer::new( Event, num_events )
1040
1041
  [events].flatten.each_with_index { |e, i|
1041
1042
  evts[i].write_pointer(e)
1042
1043
  }
@@ -1062,7 +1063,7 @@ module OpenCL
1062
1063
 
1063
1064
  # Returns the Context associated to the CommandQueue
1064
1065
  def context
1065
- ptr = FFI::MemoryPointer::new( Context )
1066
+ ptr = MemoryPointer::new( Context )
1066
1067
  error = OpenCL.clGetCommandQueueInfo(self, CONTEXT, Context.size, ptr, nil)
1067
1068
  error_check(error)
1068
1069
  return Context::new( ptr.read_pointer )
@@ -1070,7 +1071,7 @@ module OpenCL
1070
1071
 
1071
1072
  # Returns the Device associated to the CommandQueue
1072
1073
  def device
1073
- ptr = FFI::MemoryPointer::new( Device )
1074
+ ptr = MemoryPointer::new( Device )
1074
1075
  error = OpenCL.clGetCommandQueueInfo(self, DEVICE, Device.size, ptr, nil)
1075
1076
  error_check(error)
1076
1077
  return Device::new( ptr.read_pointer )
@@ -1078,7 +1079,7 @@ module OpenCL
1078
1079
 
1079
1080
  # Return the default CommandQueue for the underlying Device
1080
1081
  def device_default
1081
- ptr = FFI::MemoryPointer::new( CommandQueue )
1082
+ ptr = MemoryPointer::new( CommandQueue )
1082
1083
  error = OpenCL.clGetCommandQueueInfo(self, DEVICE_DEFAULT, CommandQueue.size, ptr, nil)
1083
1084
  error_check(error)
1084
1085
  return CommandQueue::new( ptr.read_pointer )
@@ -1683,7 +1684,7 @@ module OpenCL
1683
1684
  #
1684
1685
  # * +svm_pointer+ - a single or an Array of SVMPointer (or Pointer)
1685
1686
  # * +options+ - a hash containing named options
1686
- # * +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| ... }
1687
+ # * +block+ - if provided, a callback invoked to free the pointers. Signature of the callback is { |CommandQueue, num_pointers, Pointer to an array of num_pointers Pointers, Pointer to user_data| ... }
1687
1688
  #
1688
1689
  # ==== Options
1689
1690
  #
@@ -1,3 +1,4 @@
1
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
1
2
  module OpenCL
2
3
 
3
4
  # Creates an Context using the specified devices
@@ -6,20 +7,20 @@ module OpenCL
6
7
  #
7
8
  # * +devices+ - array of Device or a single Device
8
9
  # * +options+ - a hash containing named options
9
- # * +block+ - if provided, a callback invoked when error arise in the context. Signature of the callback is { |FFI::Pointer to null terminated c string, FFI::Pointer to binary data, :size_t number of bytes of binary data, FFI::Pointer to user_data| ... }
10
+ # * +block+ - if provided, a callback invoked when error arise in the context. Signature of the callback is { |Pointer to null terminated c string, Pointer to binary data, :size_t number of bytes of binary data, Pointer to user_data| ... }
10
11
  #
11
12
  # ==== Options
12
13
  #
13
14
  # * +:properties+ - a list of :cl_context_properties
14
- # * +:user_data+ - an FFI::Pointer or an object that can be converted into one using to_ptr. The pointer is passed to the callback.
15
+ # * +:user_data+ - an Pointer or an object that can be converted into one using to_ptr. The pointer is passed to the callback.
15
16
  def self.create_context(devices, options = {}, &block)
16
17
  @@callbacks.push( block ) if block
17
18
  devs = [devices].flatten
18
- pointer = FFI::MemoryPointer::new( Device, devs.size)
19
+ pointer = MemoryPointer::new( Device, devs.size)
19
20
  pointer.write_array_of_pointer(devs)
20
21
  properties = get_context_properties( options )
21
22
  user_data = options[:user_data]
22
- error = FFI::MemoryPointer::new( :cl_int )
23
+ error = MemoryPointer::new( :cl_int )
23
24
  ptr = clCreateContext(properties, devs.size, pointer, block, user_data, error)
24
25
  error_check(error.read_cl_int)
25
26
  return Context::new(ptr, false)
@@ -31,17 +32,17 @@ module OpenCL
31
32
  #
32
33
  # * +type+ - a Device::Type
33
34
  # * +options+ - a hash containing named options
34
- # * +block+ - if provided, a callback invoked when error arise in the context. Signature of the callback is { |FFI::Pointer to null terminated c string, FFI::Pointer to binary data, :size_t number of bytes of binary data, FFI::Pointer to user_data| ... }
35
+ # * +block+ - if provided, a callback invoked when error arise in the context. Signature of the callback is { |Pointer to null terminated c string, Pointer to binary data, :size_t number of bytes of binary data, Pointer to user_data| ... }
35
36
  #
36
37
  # ==== Options
37
38
  #
38
39
  # * +:properties+ - a list of :cl_context_properties
39
- # * +:user_data+ - an FFI::Pointer or an object that can be converted into one using to_ptr. The pointer is passed to the callback.
40
+ # * +:user_data+ - an Pointer or an object that can be converted into one using to_ptr. The pointer is passed to the callback.
40
41
  def self.create_context_from_type(type, options = {}, &block)
41
42
  @@callbacks.push( block ) if block
42
43
  properties = get_context_properties( options )
43
44
  user_data = options[:user_data]
44
- error = FFI::MemoryPointer::new( :cl_int )
45
+ error = MemoryPointer::new( :cl_int )
45
46
  ptr = clCreateContextFromType(properties, type, block, user_data, error)
46
47
  error_check(error.read_cl_int)
47
48
  return Context::new(ptr, false)
@@ -77,14 +78,14 @@ module OpenCL
77
78
  # :method: properties
78
79
  # the Array of :cl_context_properties used to create the Context
79
80
  def properties
80
- ptr1 = FFI::MemoryPointer::new( :size_t, 1)
81
+ ptr1 = MemoryPointer::new( :size_t, 1)
81
82
  error = OpenCL.clGetContextInfo(self, PROPERTIES, 0, nil, ptr1)
82
83
  error_check(error)
83
84
  return [] if ptr1.read_size_t == 0
84
- ptr2 = FFI::MemoryPointer::new( ptr1.read_size_t )
85
+ ptr2 = MemoryPointer::new( ptr1.read_size_t )
85
86
  error = OpenCL.clGetContextInfo(self, PROPERTIES, ptr1.read_size_t, ptr2, nil)
86
87
  error_check(error)
87
- arr = ptr2.get_array_of_cl_context_properties(0, ptr1.read_size_t/ FFI.find_type(:cl_context_properties).size)
88
+ arr = ptr2.get_array_of_cl_context_properties(0, ptr1.read_size_t/ OpenCL.find_type(:cl_context_properties).size)
88
89
  return arr if arr.length == 1 and arr[0].to_i == 0
89
90
  arr_2 = []
90
91
  while arr.length > 2 do
@@ -110,12 +111,12 @@ module OpenCL
110
111
  # Returns the number of devices associated to the Context
111
112
  def num_devices
112
113
  d_n = 0
113
- ptr = FFI::MemoryPointer::new( :size_t )
114
+ ptr = MemoryPointer::new( :size_t )
114
115
  error = OpenCL.clGetContextInfo(self, DEVICES, 0, nil, ptr)
115
116
  error_check(error)
116
117
  d_n = ptr.read_size_t / Platform.size
117
118
  # else
118
- # ptr = FFI::MemoryPointer::new( :cl_uint )
119
+ # ptr = MemoryPointer::new( :cl_uint )
119
120
  # error = OpenCL.clGetContextInfo(self, OpenCL::Context::NUM_DEVICES, ptr.size, ptr, nil)
120
121
  # OpenCL.error_check(error)
121
122
  # d_n = ptr.read_cl_uint
@@ -126,7 +127,7 @@ module OpenCL
126
127
  # Returns an Array of Device associated to the Context
127
128
  def devices
128
129
  n = self.num_devices
129
- ptr2 = FFI::MemoryPointer::new( Device, n )
130
+ ptr2 = MemoryPointer::new( Device, n )
130
131
  error = OpenCL.clGetContextInfo(self, DEVICES, Device.size*n, ptr2, nil)
131
132
  error_check(error)
132
133
  return ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
@@ -146,15 +147,15 @@ module OpenCL
146
147
  def supported_image_formats( image_type, options = {} )
147
148
  flags = get_flags( options )
148
149
  flags = Mem::Flags::READ_WRITE if flags.to_i == 0 #ensure default READ_WRITE, Intel bug.
149
- num_image_formats = FFI::MemoryPointer::new( :cl_uint )
150
+ num_image_formats = MemoryPointer::new( :cl_uint )
150
151
  error = OpenCL.clGetSupportedImageFormats( self, flags, image_type, 0, nil, num_image_formats )
151
152
  error_check(error)
152
153
  num_entries = num_image_formats.read_cl_uint
153
- image_formats = FFI::MemoryPointer::new( ImageFormat, num_entries )
154
+ image_formats = MemoryPointer::new( ImageFormat, num_entries )
154
155
  error = OpenCL.clGetSupportedImageFormats( self, flags, image_type, num_entries, image_formats, nil )
155
156
  error_check(error)
156
157
  return num_entries.times.collect { |i|
157
- ImageFormat::from_pointer( image_formats + i * ImageFormat.size )
158
+ ImageFormat::new( image_formats + i * ImageFormat.size )
158
159
  }
159
160
  end
160
161
 
@@ -357,7 +358,7 @@ module OpenCL
357
358
  #
358
359
  # * +input_programs+ - a single or an Array of Program
359
360
  # * +options+ - a Hash containing named options
360
- # * +block+ - if provided, a callback invoked when the Program is built. Signature of the callback is { |Program, FFI::Pointer to user_data| ... }
361
+ # * +block+ - if provided, a callback invoked when the Program is built. Signature of the callback is { |Program, Pointer to user_data| ... }
361
362
  #
362
363
  # ==== Options
363
364
  #