opencl_ruby_ffi 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/lib/opencl_ruby_ffi.rb +2 -0
  4. data/lib/opencl_ruby_ffi/Buffer.rb +18 -13
  5. data/lib/opencl_ruby_ffi/CommandQueue.rb +301 -302
  6. data/lib/opencl_ruby_ffi/Context.rb +158 -158
  7. data/lib/opencl_ruby_ffi/Device.rb +270 -224
  8. data/lib/opencl_ruby_ffi/Event.rb +40 -36
  9. data/lib/opencl_ruby_ffi/Image.rb +34 -57
  10. data/lib/opencl_ruby_ffi/Kernel.rb +251 -191
  11. data/lib/opencl_ruby_ffi/Mem.rb +49 -70
  12. data/lib/opencl_ruby_ffi/Pipe.rb +3 -14
  13. data/lib/opencl_ruby_ffi/Platform.rb +46 -48
  14. data/lib/opencl_ruby_ffi/Program.rb +131 -124
  15. data/lib/opencl_ruby_ffi/Sampler.rb +6 -24
  16. data/lib/opencl_ruby_ffi/amd/device_attribute_query.rb +100 -0
  17. data/lib/opencl_ruby_ffi/egl.rb +2 -0
  18. data/lib/opencl_ruby_ffi/ext.rb +11 -0
  19. data/lib/opencl_ruby_ffi/ext/device_fission.rb +264 -0
  20. data/lib/opencl_ruby_ffi/gl_ext.rb +2 -0
  21. data/lib/opencl_ruby_ffi/khr/d3d10_sharing.rb +120 -0
  22. data/lib/opencl_ruby_ffi/khr/d3d11_sharing.rb +120 -0
  23. data/lib/opencl_ruby_ffi/khr/dx9_media_sharing.rb +113 -0
  24. data/lib/opencl_ruby_ffi/khr/egl_event.rb +15 -0
  25. data/lib/opencl_ruby_ffi/khr/egl_image.rb +58 -0
  26. data/lib/opencl_ruby_ffi/khr/fp16.rb +23 -0
  27. data/lib/opencl_ruby_ffi/khr/fp64.rb +23 -0
  28. data/lib/opencl_ruby_ffi/khr/gl_event.rb +38 -0
  29. data/lib/opencl_ruby_ffi/khr/gl_sharing.rb +79 -0
  30. data/lib/opencl_ruby_ffi/khr/icd.rb +30 -0
  31. data/lib/opencl_ruby_ffi/khr/initalize_memory.rb +19 -0
  32. data/lib/opencl_ruby_ffi/khr/priority_hints.rb +48 -0
  33. data/lib/opencl_ruby_ffi/khr/spir.rb +45 -0
  34. data/lib/opencl_ruby_ffi/khr/sub_groups.rb +49 -0
  35. data/lib/opencl_ruby_ffi/khr/terminate_context.rb +46 -0
  36. data/lib/opencl_ruby_ffi/khr/throttle_hints.rb +47 -0
  37. data/lib/opencl_ruby_ffi/nv/device_attribute_query.rb +50 -0
  38. data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb +40 -13
  39. data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb +214 -2114
  40. data/lib/opencl_ruby_ffi/opencl_types.rb +15 -3
  41. data/opencl_ruby_ffi.gemspec +4 -4
  42. data/templates_custom/default/module/setup.rb +9 -0
  43. metadata +29 -6
  44. data/lib/opencl_ruby_ffi/GLExt.rb +0 -58
  45. data/lib/opencl_ruby_ffi/Stream.rb +0 -127
@@ -72,8 +72,20 @@ module OpenCL
72
72
  [ :cl_uint, :cl_gl_platform_info ],
73
73
  [ :cl_uint, :cl_gl_context_info ],
74
74
  [ :cl_uint, :cl_queue_priority_khr ],
75
- [ :cl_uint, :cl_queue_throttle_khr ]
75
+ [ :cl_uint, :cl_queue_throttle_khr ],
76
+ [ :cl_bitfield, :cl_device_partition_property_ext ],
77
+ [ :cl_device_partition_property_ext, :cl_device_affinity_domain_ext ],
78
+ [ :pointer, :cl_egl_display_khr ],
79
+ [ :pointer, :cl_egl_image_khr ],
80
+ [ :pointer, :cl_egl_sync_khr ],
81
+ [ :cl_uint, :cl_d3d10_device_source_khr ],
82
+ [ :cl_uint, :cl_d3d10_device_set_khr ],
83
+ [ :cl_uint, :cl_d3d11_device_source_khr ],
84
+ [ :cl_uint, :cl_d3d11_device_set_khr ],
85
+ [ :cl_uint, :cl_dx9_media_adapter_type_khr ],
86
+ [ :cl_uint, :cl_dx9_media_adapter_set_khr ]
76
87
  ]
88
+ private_constant :TYPES
77
89
 
78
90
  TYPES.each { |orig, add|
79
91
  typedef orig, add
@@ -87,7 +99,7 @@ if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
87
99
 
88
100
  refine FFI::Pointer do
89
101
  methods_prefix = [:put, :get, :write, :read, :put_array_of, :get_array_of]
90
- OpenCL::TYPES.each { |orig, add|
102
+ OpenCL::const_get(:TYPES).each { |orig, add|
91
103
  methods_prefix.each { |meth|
92
104
  alias_method "#{meth}_#{add}".to_sym, "#{meth}_#{orig}".to_sym
93
105
  }
@@ -100,7 +112,7 @@ else
100
112
 
101
113
  class FFI::Pointer
102
114
  methods_prefix = [:put, :get, :write, :read, :put_array_of, :get_array_of]
103
- OpenCL::TYPES.each { |orig, add|
115
+ OpenCL::const_get(:TYPES).each { |orig, add|
104
116
  methods_prefix.each { |meth|
105
117
  alias_method "#{meth}_#{add}".to_sym, "#{meth}_#{orig}".to_sym
106
118
  }
@@ -1,14 +1,14 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'opencl_ruby_ffi'
3
- s.version = "1.2.2"
3
+ s.version = "1.3.0"
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 = Dir[ 'opencl_ruby_ffi.gemspec', 'LICENSE', 'lib/**/*']
10
- s.has_rdoc = true
11
- s.license = 'BSD'
9
+ s.files = Dir[ 'opencl_ruby_ffi.gemspec', 'LICENSE', 'lib/**/**/*', '.yardopts', 'templates_custom/default/module/setup.rb' ]
10
+ s.has_rdoc = false
11
+ s.license = 'BSD-2-Clause'
12
12
  s.required_ruby_version = '>= 1.8.7'
13
13
  s.add_dependency 'narray', '~> 0.6', '>=0.6.0.8'
14
14
  s.add_dependency 'ffi', '~> 1.9', '>=1.9.3'
@@ -0,0 +1,9 @@
1
+ def init
2
+ sections :header, :box_info, :pre_docstring, T('docstring'), :children,
3
+ :attribute_summary, [:item_summary], :inherited_attributes,
4
+ :method_summary, [:item_summary], :inherited_methods,
5
+ :methodmissing, [T('method_details')],
6
+ :attribute_details, [T('method_details')],
7
+ :method_details_list, [T('method_details')],
8
+ :constant_summary, [T('docstring')], :inherited_constants
9
+ end
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.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Videau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-19 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: narray
@@ -76,6 +76,7 @@ executables: []
76
76
  extensions: []
77
77
  extra_rdoc_files: []
78
78
  files:
79
+ - ".yardopts"
79
80
  - LICENSE
80
81
  - lib/opencl_ruby_ffi.rb
81
82
  - lib/opencl_ruby_ffi/Buffer.rb
@@ -83,7 +84,6 @@ files:
83
84
  - lib/opencl_ruby_ffi/Context.rb
84
85
  - lib/opencl_ruby_ffi/Device.rb
85
86
  - lib/opencl_ruby_ffi/Event.rb
86
- - lib/opencl_ruby_ffi/GLExt.rb
87
87
  - lib/opencl_ruby_ffi/Image.rb
88
88
  - lib/opencl_ruby_ffi/Kernel.rb
89
89
  - lib/opencl_ruby_ffi/Mem.rb
@@ -92,15 +92,37 @@ files:
92
92
  - lib/opencl_ruby_ffi/Program.rb
93
93
  - lib/opencl_ruby_ffi/SVM.rb
94
94
  - lib/opencl_ruby_ffi/Sampler.rb
95
- - lib/opencl_ruby_ffi/Stream.rb
95
+ - lib/opencl_ruby_ffi/amd/device_attribute_query.rb
96
+ - lib/opencl_ruby_ffi/egl.rb
97
+ - lib/opencl_ruby_ffi/ext.rb
98
+ - lib/opencl_ruby_ffi/ext/device_fission.rb
99
+ - lib/opencl_ruby_ffi/gl_ext.rb
100
+ - lib/opencl_ruby_ffi/khr/d3d10_sharing.rb
101
+ - lib/opencl_ruby_ffi/khr/d3d11_sharing.rb
102
+ - lib/opencl_ruby_ffi/khr/dx9_media_sharing.rb
103
+ - lib/opencl_ruby_ffi/khr/egl_event.rb
104
+ - lib/opencl_ruby_ffi/khr/egl_image.rb
105
+ - lib/opencl_ruby_ffi/khr/fp16.rb
106
+ - lib/opencl_ruby_ffi/khr/fp64.rb
107
+ - lib/opencl_ruby_ffi/khr/gl_event.rb
108
+ - lib/opencl_ruby_ffi/khr/gl_sharing.rb
109
+ - lib/opencl_ruby_ffi/khr/icd.rb
110
+ - lib/opencl_ruby_ffi/khr/initalize_memory.rb
111
+ - lib/opencl_ruby_ffi/khr/priority_hints.rb
112
+ - lib/opencl_ruby_ffi/khr/spir.rb
113
+ - lib/opencl_ruby_ffi/khr/sub_groups.rb
114
+ - lib/opencl_ruby_ffi/khr/terminate_context.rb
115
+ - lib/opencl_ruby_ffi/khr/throttle_hints.rb
116
+ - lib/opencl_ruby_ffi/nv/device_attribute_query.rb
96
117
  - lib/opencl_ruby_ffi/opencl_arithmetic_gen.rb
97
118
  - lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb
98
119
  - lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb
99
120
  - lib/opencl_ruby_ffi/opencl_types.rb
100
121
  - opencl_ruby_ffi.gemspec
122
+ - templates_custom/default/module/setup.rb
101
123
  homepage: https://github.com/Nanosim-LIG/opencl-ruby
102
124
  licenses:
103
- - BSD
125
+ - BSD-2-Clause
104
126
  metadata: {}
105
127
  post_install_message:
106
128
  rdoc_options: []
@@ -118,8 +140,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
140
  version: '0'
119
141
  requirements: []
120
142
  rubyforge_project:
121
- rubygems_version: 2.2.2
143
+ rubygems_version: 2.5.1
122
144
  signing_key:
123
145
  specification_version: 4
124
146
  summary: Ruby OpenCL FFI bindings
125
147
  test_files: []
148
+ has_rdoc: false
@@ -1,58 +0,0 @@
1
- require 'opencl_ruby_ffi'
2
- using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
3
-
4
- module OpenCL
5
-
6
- name_p = MemoryPointer.from_string("clGetGLContextInfoKHR")
7
- p = clGetExtensionFunctionAddress(name_p)
8
- if p then
9
- func = Function::new( :cl_int, [:pointer, :cl_gl_context_info, :size_t, :pointer, :pointer], p)
10
- func.attach(OpenCL, "clGetGLContextInfoKHR")
11
-
12
- def self.get_gl_context_info_khr( properties, param_name )
13
- props = MemoryPointer::new( :cl_context_properties, properties.length + 1 )
14
- properties.each_with_index { |e,i|
15
- props[i].write_cl_context_properties(e)
16
- }
17
- props[properties.length].write_cl_context_properties(0)
18
- size_p = MemoryPointer::new( :size_t )
19
- error = clGetGLContextInfoKHR( props, param_name, 0, nil, size_p )
20
- error_check(error)
21
- size = size_p.read_size_t
22
- nb_devices = size/Device.size
23
- values = MemoryPointer::new( Device, nb_devices )
24
- error = clGetGLContextInfoKHR( props, param_name, size, values, nil )
25
- error_check(error)
26
- return values.get_array_of_pointer(0, nb_devices).collect { |device_ptr|
27
- Device::new(device_ptr, false)
28
- }
29
- end
30
- end
31
-
32
- name_p = MemoryPointer.from_string("clCreateEventFromGLsyncKHR")
33
- p = clGetExtensionFunctionAddress(name_p)
34
- if p then
35
- func = Function::new( Event, [Context, :pointer, :pointer], p)
36
- func.attach(OpenCL, "clCreateEventFromGLsyncKHR")
37
-
38
- def self.create_event_from_glsync_khr( context, sync)
39
- error_check(INVALID_OPERATION) if context.platform.version_number < 1.1
40
- error_p = MemoryPointer::new( :cl_int )
41
- event = clCreateEventFromGLsyncKHR( context, sync, error_p )
42
- error_check(error_p.read_cl_int)
43
- return Event::new( event, false )
44
- end
45
- end
46
-
47
- class Context
48
- def get_gl_info_khr( param_name )
49
- error_check(INVALID_OPERATION) unless self.platform.extensions.include?( "cl_khr_gl_sharing" )
50
- return OpenCL.get_gl_context_info_khr( self.properties, param_name )
51
- end
52
-
53
- def create_event_from_glsync_khr( sync )
54
- error_check(INVALID_OPERATION) unless self.platform.extensions.include?( "cl_khr_gl_sharing" )
55
- return OpenCL.create_event_from_glsync_khr( self, sync )
56
- end
57
- end
58
- end
@@ -1,127 +0,0 @@
1
- using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
2
- module OpenCL
3
-
4
- module StreamDSL
5
-
6
- class Stream
7
-
8
- def initialize(queue)
9
- @queue = queue
10
- @tail_events = nil
11
- end
12
-
13
- def <<(commands)
14
- events = []
15
- [commands].flatten.each { |c|
16
- events.push ( c.enqueue( queue, @tail_events ) )
17
- }
18
- @tail_events = events
19
- return self
20
- end
21
-
22
- end
23
-
24
- class Command
25
-
26
- def initialize(type, options = {})
27
- @_type = type
28
- @_options = options
29
- @_event = nil
30
- @_func = nil
31
- @_params = []
32
- end
33
-
34
- def enqueue(queue, event_wait_list = nil)
35
- if options and options[:event_wait_list] then
36
- @_event_wait_list = [options[:event_wait_list]].flatten
37
- else
38
- @_event_wait_list = nil
39
- end
40
- if event_wait_list then
41
- if @_event_wait_list then
42
- @_event_wait_list = @_event_wait_list + [event_wait_list].flatten
43
- else
44
- @_event_wait_list = [event_wait_list].flatten
45
- end
46
- end
47
- opts = @_options.dup
48
- opts[:event_wait_list] = @_event_wait_list
49
- @_event, @_result = @_enqueue_proc.call( queue, *@_param, opts, &@f_unc )
50
- end
51
-
52
- def result
53
- return @_result
54
- end
55
-
56
- end
57
-
58
- def self.command_constructor( name, const, function, params)
59
- params_array = params + ["options = {}"]
60
- params_array += ["&func"]
61
- p_variables = params.collect { |p| "@_params.push(@#{p})" }
62
- return <<EOF
63
- class #{name} < Command
64
-
65
- def initialize( #{params_array.join(", ")}, &func )
66
- super(CommandType::#{const}, options)
67
- #{i_variables.join("\n ")}
68
- @_func = func
69
- @_enqueue_proc = OpenCL.method(:enqueue_#{function})
70
- end
71
-
72
- end
73
- EOF
74
- end
75
-
76
- eval command_constructor( :NDRangeKernel, :NDRANGE_KERNEL, :ndrange_kernel, [ :buffer, :global_work_size ] )
77
- eval command_constructor( :Task, :TASK, :task, [ :kernel ] )
78
- eval command_constructor( :NativeKernel, :NATIVE_KERNEL, :native_kernel, [] )
79
- eval command_constructor( :ReadBuffer, :READ_BUFFER, :read_buffer, [ :buffer, :ptr ] )
80
- eval command_constructor( :WriteBuffer, :WRITE_BUFFER, :write_buffer, [ :buffer, :ptr ] )
81
- eval command_constructor( :CopyBuffer, :COPY_BUFFER, :copy_buffer, [ :src_buffer, :dst_buffer ] )
82
- eval command_constructor( :ReadImage, :READ_IMAGE, :read_image, [ :image, :ptr ] )
83
- eval command_constructor( :WriteImage, :WRITE_IMAGE, :write_image, [ :image, :ptr ] )
84
- eval command_constructor( :CopyImage, :COPY_IMAGE, :copy_image, [ :src_image, :dst_image ] )
85
- eval command_constructor( :CopyImageToBuffer, :COPY_IMAGE_TO_BUFFER, :copy_image_to_buffer, [ :src_image, :dst_buffer ] )
86
- eval command_constructor( :CopyBufferToImage, :COPY_BUFFER_TO_IMAGE, :copy_buffer_to_image, [ :src_buffer, :dst_image ] )
87
- eval command_constructor( :MapBuffer, :MAP_BUFFER, :map_buffer, [ :buffer, :map_flags ] )
88
- eval command_constructor( :MapImage, :MAP_IMAGE, :map_image, [ :image, :map_flags ] )
89
- eval command_constructor( :UnmapMemObject, :UNMAP_MEM_OBJECT, :unmap_mem_object, [ :mem_obj, :mapped_ptr ] )
90
-
91
- class Marker < Command
92
-
93
- def initialize( events = [] )
94
- super(CommandType::MARKER, nil)
95
- @events = events
96
- @_enqueue_proc = OpenCL.method(:enqueue_marker)
97
- end
98
-
99
- end
100
-
101
- eval command_constructor( :AcquireGLObjects, :ACQUIRE_GL_OBJECTS, :acquire_gl_objects, [ :mem_objects ] )
102
- eval command_constructor( :ReleaseGLObjects, :RELEASE_GL_OBJECTS, :release_gl_objects, [ :mem_objects ] )
103
- eval command_constructor( :ReadBufferRect, :READ_BUFFER_RECT, :read_buffer_rect, [ :buffer, :ptr, :region ] )
104
- eval command_constructor( :WriteBufferRect, :WRITE_BUFFER_RECT, :write_buffer_rect, [ :buffer, :ptr, :region ] )
105
- eval command_constructor( :CopyBufferRect, :COPY_BUFFER_RECT, :copy_buffer_rect, [ :src_buffer, :dst_buffer, :region ] )
106
-
107
- class Barrier < Command
108
-
109
- def initialize( events = [] )
110
- super(CommandType::BARRIER, nil)
111
- @events = events
112
- @_enqueue_proc = OpenCL.method(:enqueue_barrier)
113
- end
114
-
115
- end
116
-
117
- eval command_constructor( :FillBuffer, :FILL_BUFFER, :fill_buffer, [ :buffer, :pattern ] )
118
- eval command_constructor( :FillImage, :FILL_IMAGE, :fill_image, [ :image, :fill_color ] )
119
- eval command_constructor( :SVMFree, :SVM_FREE, :svm_free, [ :svm_pointers ] )
120
- eval command_constructor( :SVMMemcpy, :SVM_MEMCPY, :svm_memcpy, [ :dst_ptr, :src_ptr, :size ] )
121
- eval command_constructor( :SVMMemFill, :SVM_MEMFILL, :svm_memfill, [ :svm_ptr, :pattern, :size ] )
122
- eval command_constructor( :SVMMap, :SVM_MAP, :svm_map, [ :svm_ptr, :size, :map_flags ] )
123
- eval command_constructor( :SVMUnmap, :SVM_UNMAP, :svm_unmap, [ :svm_ptr ] )
124
-
125
- end
126
-
127
- end