opencl_ruby_ffi 0.96 → 0.97

Sign up to get free protection for your applications and to get access to all the features.
@@ -898,11 +898,17 @@ module OpenCL
898
898
  #
899
899
  # the Event associated with the command
900
900
  def self.enqueue_task( command_queue, kernel, options = {} )
901
- num_events, events = OpenCL.get_event_wait_list( options )
902
- event = FFI::MemoryPointer::new( OpenCL::Event )
903
- error = OpenCL.clEnqueueTask( command_queue, kernel, num_events, events, event )
904
- OpenCL.error_check(error)
905
- return OpenCL::Event::new(event.read_pointer, false)
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)
907
+ else
908
+ opts = options.dup
909
+ opts[:local_work_size] = [1]
910
+ return OpenCL.enqueue_NDrange_kernel( command_queue, kernel, [1], opts )
911
+ end
906
912
  end
907
913
 
908
914
  # Enqueues a kernel as a NDrange
@@ -377,6 +377,29 @@ module OpenCL
377
377
  return OpenCL.create_pipe( self, pipe_packet_size, pipe_max_packets, opts )
378
378
  end
379
379
 
380
+ # Creates an SVMPointer pointing to an SVM area of memory in the Context
381
+ #
382
+ # ==== Attributes
383
+ #
384
+ # * +size+ - the size of the mmemory area to allocate
385
+ # * +options+ - a hash containing named options
386
+ #
387
+ # ==== Options
388
+ #
389
+ # * +:alignment+ - imposes the minimum alignment in byte
390
+ def svm_alloc(size, options = {})
391
+ return OpenCL.svm_alloc( self, size, options)
392
+ end
393
+
394
+ # Frees an SVMPointer
395
+ #
396
+ # ==== Attributes
397
+ #
398
+ # * +svm_pointer+ - the SVMPointer to deallocate
399
+ def self.svm_free(svm_pointer)
400
+ return OpenCL.svm_free(self, svm_pointer)
401
+ end
402
+
380
403
  end
381
404
 
382
405
  end
@@ -20,6 +20,7 @@ module OpenCL
20
20
  return OpenCL::Pipe::new(pipe_ptr, false)
21
21
  end
22
22
 
23
+ # Maps the cl_mem OpenCL objects of type CL_MEM_OBJECT_PIPE
23
24
  class Pipe
24
25
 
25
26
  ##
@@ -43,7 +43,7 @@ module OpenCL
43
43
  # * +return_type+ - the type of data returned by the function
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
- def get_extension_function_for_platform( platform, name, return_type, param_types, options = {} )
46
+ def self.get_extension_function_for_platform( platform, name, return_type, param_types, options = {} )
47
47
  OpenCL.error_check(OpenCL::INVALID_OPERATION) if self.version_number < 1.2
48
48
  name_p = FFI::MemoryPointer.from_string(name)
49
49
  ptr = OpenCL.clGetExtensionFunctionAddressForPlatform( platform, name_p )
@@ -3,21 +3,36 @@ module OpenCL
3
3
  # maps the SVM pointer type
4
4
  class SVMPointer < FFI::Pointer
5
5
 
6
+ # create a new SVMPointer from its address and the context it pertains to
6
7
  def initialize( address, context )
7
8
  super( address )
8
9
  @context = context
9
10
  end
10
11
 
12
+ # creates a new SVMPointer relative to an existing one from an offset
11
13
  def +( offset )
12
14
  return OpenCL::SVMPointer::new( self.address + offset, @context )
13
15
  end
14
16
 
17
+ # frees the SVMPointer (must not be called on an SVMPointer obtained from an offset)
15
18
  def free
16
19
  return OpenCL::svm_free( @context, self )
17
20
  end
18
21
 
19
22
  end
20
23
 
24
+
25
+ # Creates an SVMPointer pointing to an SVM area of memory
26
+ #
27
+ # ==== Attributes
28
+ #
29
+ # * +context+ - the Context in which to allocate the memory
30
+ # * +size+ - the size of the mmemory area to allocate
31
+ # * +options+ - a hash containing named options
32
+ #
33
+ # ==== Options
34
+ #
35
+ # * +:alignment+ - imposes the minimum alignment in byte
21
36
  def self.svm_alloc(context, size, options = {})
22
37
  OpenCL.error_check(OpenCL::INVALID_OPERATION) if context.platform.version_number < 2.0
23
38
  flags = OpenCL::get_flags(options)
@@ -28,6 +43,12 @@ module OpenCL
28
43
  return OpenCL::SVMPointer::new( ptr, context )
29
44
  end
30
45
 
46
+ # Frees an SVMPointer
47
+ #
48
+ # ==== Attributes
49
+ #
50
+ # * +context+ - the Context in which to deallocate the memory
51
+ # * +svm_pointer+ - the SVMPointer to deallocate
31
52
  def self.svm_free(context, svm_pointer)
32
53
  OpenCL.error_check(OpenCL::INVALID_OPERATION) if context.platform.version_number < 2.0
33
54
  return OpenCL.clSVMFree( context, svm_pointer )
@@ -38,6 +59,7 @@ module OpenCL
38
59
  OpenCL.error_check(OpenCL::INVALID_OPERATION) if kernel.context.platform.version_number < 2.0
39
60
  error = OpenCL.clSetKernelArgSVMPointer( kernel, index, val )
40
61
  OpenCL.error_check(error)
62
+ return kernel
41
63
  end
42
64
 
43
65
  # Enqueues a command that frees SVMPointers (or Pointers using a callback)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'opencl_ruby_ffi'
3
- s.version = "0.96"
3
+ s.version = "0.97"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "brice.videau@imag.fr"
6
6
  s.homepage = "https://forge.imag.fr/projects/opencl-ruby/"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opencl_ruby_ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.96'
4
+ version: '0.97'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-28 00:00:00.000000000 Z
12
+ date: 2014-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: narray