opencl_ruby_ffi 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28ce76fe3685cbbe05673c5b2b248805ea3e304e
4
- data.tar.gz: 9c8f83e8b61c4f6f5eed749d58def7d83a96ffe4
3
+ metadata.gz: 33c6f6c98f527e3b236c88c4f6ef75f2b9623939
4
+ data.tar.gz: 5596b98c34787aadd5638936dd56f2c13cbff801
5
5
  SHA512:
6
- metadata.gz: e2cf19839650fcbb986c61780a01218a0345ed804be8e1b0bce7fbdc70fd4f176663ba0569b5fa715f3e0d0d996a240c5db4b7ec8b82293cb2e0a824cf9655c4
7
- data.tar.gz: a5d19376e5e6fce5d3bb2c46e9a53880dc7122ef303d41d16fa6bc1dd09f8b0c5195010b707e41664ef6a0e4dcfeacb933880b68fa835e9c822a631c6e1de4ba
6
+ metadata.gz: 907ae966ca95005538844ffcb5a31925994cac4c784fae60622a1179884000ec9d89d39f7a5f32692a4433c1e2b56207abaa5d5e66fdb6b5026576c001f56112
7
+ data.tar.gz: a8d5c6725809770ae832d6221a47ef002a0f086c03dd7190d873d4e8084ebe848b85956b1565f7de33b22171204b527201f10750e6ba890e9621120e4441973d
@@ -0,0 +1,57 @@
1
+ require 'opencl_ruby_ffi'
2
+
3
+ module OpenCL
4
+
5
+ name_p = FFI::MemoryPointer.from_string("clGetGLContextInfoKHR")
6
+ p = clGetExtensionFunctionAddress(name_p)
7
+ if p then
8
+ func = FFI::Function::new(:cl_int, [:pointer, :cl_gl_context_info, :size_t, :pointer, :pointer], p)
9
+ func.attach(OpenCL, "clGetGLContextInfoKHR")
10
+
11
+ def self.get_gl_context_info_khr( properties, param_name )
12
+ props = FFI::MemoryPointer::new( :cl_context_properties, properties.length + 1 )
13
+ properties.each_with_index { |e,i|
14
+ props[i].write_cl_context_properties(e)
15
+ }
16
+ props[properties.length].write_cl_context_properties(0)
17
+ size_p = FFI::MemoryPointer::new( :size_t )
18
+ error = clGetGLContextInfoKHR( props, param_name, 0, nil, size_p )
19
+ error_check(error)
20
+ size = size_p.read_size_t
21
+ nb_devices = size/Device.size
22
+ values = FFI::MemoryPointer::new( Device, nb_devices )
23
+ error = clGetGLContextInfoKHR( props, param_name, size, values, nil )
24
+ error_check(error)
25
+ return values.get_array_of_pointer(0, nb_devices).collect { |device_ptr|
26
+ Device::new(device_ptr, false)
27
+ }
28
+ end
29
+ end
30
+
31
+ name_p = FFI::MemoryPointer.from_string("clCreateEventFromGLsyncKHR")
32
+ p = clGetExtensionFunctionAddress(name_p)
33
+ if p then
34
+ func = FFI::Function::new(OpenCL::find_type(Event), [OpenCL::find_type(Context), :pointer, :pointer], p)
35
+ func.attach(OpenCL, "clCreateEventFromGLsyncKHR")
36
+
37
+ def self.create_event_from_glsync_khr( context, sync)
38
+ error_check(INVALID_OPERATION) if context.platform.version_number < 1.1
39
+ error_p = FFI::MemoryPointer::new( :cl_int )
40
+ event = clCreateEventFromGLsyncKHR( context, sync, error_p )
41
+ error_check(error_p.read_cl_int)
42
+ return Event::new( event, false )
43
+ end
44
+ end
45
+
46
+ class Context
47
+ def get_gl_info_khr( param_name )
48
+ error_check(INVALID_OPERATION) unless self.platform.extensions.include?( "cl_khr_gl_sharing" )
49
+ return OpenCL.get_gl_context_info_khr( self.properties, param_name )
50
+ end
51
+
52
+ def create_event_from_glsync_khr( sync )
53
+ error_check(INVALID_OPERATION) unless self.platform.extensions.include?( "cl_khr_gl_sharing" )
54
+ return OpenCL.create_event_from_glsync_khr( self, sync )
55
+ end
56
+ end
57
+ end
@@ -44,7 +44,7 @@ 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
- error_check(INVALID_OPERATION) if self.version_number < 1.2
47
+ error_check(INVALID_OPERATION) if platform.version_number < 1.2
48
48
  name_p = FFI::MemoryPointer.from_string(name)
49
49
  ptr = clGetExtensionFunctionAddressForPlatform( platform, name_p )
50
50
  return nil if ptr.null?
@@ -152,11 +152,7 @@ module OpenCL
152
152
  # * +param_types+ - an Array of types, corresponding to the parameters type
153
153
  # * +options+ - if given, a hash of named options that will be given to FFI::Function::new. See FFI doc for details.
154
154
  def get_extension_function( name, return_type, param_types, options = {} )
155
- error_check(INVALID_OPERATION) if self.version_number < 1.2
156
- name_p = FFI::MemoryPointer.from_string(name)
157
- ptr = OpenCL.clGetExtensionFunctionAddressForPlatform( self, name_p )
158
- return nil if ptr.null?
159
- return FFI::Function::new(return_type, param_types, ptr, options)
155
+ return OpenCL.get_extension_function( self, name, return_type, param_types, options )
160
156
  end
161
157
 
162
158
  # Creates a Context gathering devices of a certain type and belonging to this Platform
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'opencl_ruby_ffi'
3
- s.version = "1.0.7"
3
+ s.version = "1.0.8"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "brice.videau@imag.fr"
6
6
  s.homepage = "https://github.com/Nanosim-LIG/opencl-ruby"
7
7
  s.summary = "Ruby OpenCL FFI bindings"
8
8
  s.description = "Ruby OpenCL FFI bindings. OpenCL 2.1 ready"
9
- s.files = %w( opencl_ruby_ffi.gemspec LICENSE lib/opencl_ruby_ffi.rb lib/opencl_ruby_ffi/ lib/opencl_ruby_ffi/Arithmetic_gen.rb lib/opencl_ruby_ffi/Buffer.rb lib/opencl_ruby_ffi/CommandQueue.rb lib/opencl_ruby_ffi/Context.rb lib/opencl_ruby_ffi/Device.rb lib/opencl_ruby_ffi/Event.rb lib/opencl_ruby_ffi/Image.rb lib/opencl_ruby_ffi/Kernel.rb lib/opencl_ruby_ffi/Mem.rb lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb lib/opencl_ruby_ffi/Platform.rb lib/opencl_ruby_ffi/Program.rb lib/opencl_ruby_ffi/Sampler.rb lib/opencl_ruby_ffi/Pipe.rb lib/opencl_ruby_ffi/SVM.rb )
9
+ s.files = %w( opencl_ruby_ffi.gemspec LICENSE lib/opencl_ruby_ffi.rb lib/opencl_ruby_ffi/ lib/opencl_ruby_ffi/Arithmetic_gen.rb lib/opencl_ruby_ffi/Buffer.rb lib/opencl_ruby_ffi/CommandQueue.rb lib/opencl_ruby_ffi/Context.rb lib/opencl_ruby_ffi/Device.rb lib/opencl_ruby_ffi/Event.rb lib/opencl_ruby_ffi/Image.rb lib/opencl_ruby_ffi/Kernel.rb lib/opencl_ruby_ffi/Mem.rb lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb lib/opencl_ruby_ffi/Platform.rb lib/opencl_ruby_ffi/Program.rb lib/opencl_ruby_ffi/Sampler.rb lib/opencl_ruby_ffi/Pipe.rb lib/opencl_ruby_ffi/SVM.rb lib/opencl_ruby_ffi/GLExt.rb )
10
10
  s.has_rdoc = true
11
11
  s.license = 'BSD'
12
12
  s.required_ruby_version = '>= 1.8.7'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opencl_ruby_ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Videau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-18 00:00:00.000000000 Z
11
+ date: 2015-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: narray
@@ -84,6 +84,7 @@ files:
84
84
  - lib/opencl_ruby_ffi/Context.rb
85
85
  - lib/opencl_ruby_ffi/Device.rb
86
86
  - lib/opencl_ruby_ffi/Event.rb
87
+ - lib/opencl_ruby_ffi/GLExt.rb
87
88
  - lib/opencl_ruby_ffi/Image.rb
88
89
  - lib/opencl_ruby_ffi/Kernel.rb
89
90
  - lib/opencl_ruby_ffi/Mem.rb