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
@@ -0,0 +1,120 @@
1
+ require 'opencl_ruby_ffi'
2
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
3
+
4
+ module OpenCL
5
+
6
+ INVALID_D3D11_DEVICE_KHR = -1006
7
+ INVALID_D3D11_RESOURCE_KHR = -1007
8
+ D3D11_RESOURCE_ALREADY_ACQUIRED_KHR = -1008
9
+ D3D11_RESOURCE_NOT_ACQUIRED_KHR = -1009
10
+
11
+ D3D11_DEVICE_KHR = 0x4019
12
+ D3D11_DXGI_ADAPTER_KHR = 0x401A
13
+ PREFERRED_DEVICES_FOR_D3D11_KHR = 0x401B
14
+ ALL_DEVICES_FOR_D3D11_KHR = 0x401C
15
+ CONTEXT_D3D11_DEVICE_KHR = 0x401D
16
+ CONTEXT_D3D11_PREFER_SHARED_RESOURCES_KHR = 0x402D
17
+ MEM_D3D11_RESOURCE_KHR = 0x401E
18
+ IMAGE_D3D11_SUBRESOURCE_KHR = 0x401F
19
+ COMMAND_ACQUIRE_D3D11_OBJECTS_KHR = 0x4020
20
+ COMMAND_RELEASE_D3D11_OBJECTS_KHR = 0x4021
21
+
22
+ class Error
23
+
24
+ eval error_class_constructor( :INVALID_D3D11_DEVICE_KHR, :InvalidD3D11DeviceKHR )
25
+ eval error_class_constructor( :INVALID_D3D11_RESOURCE_KHR, :InvalidD3D11ResourceKHR )
26
+ eval error_class_constructor( :D3D11_RESOURCE_ALREADY_ACQUIRED_KHR, :D3D11ResourceAlreadyAcquiredKHR )
27
+ eval error_class_constructor( :D3D11_RESOURCE_NOT_ACQUIRED_KHR, :D3D11ResourceNotAcquiredKHR )
28
+
29
+ end
30
+
31
+ class Context
32
+ D3D11_DEVICE_KHR = 0x401D
33
+ D3D11_PREFER_SHARED_RESOURCES_KHR = 0x402D
34
+
35
+ class Properties
36
+ D3D11_DEVICE_KHR = 0x401D
37
+ D3D11_PREFER_SHARED_RESOURCES_KHR = 0x402D
38
+ @codes[0x401D] = 'D3D11_DEVICE_KHR'
39
+ @codes[0x402D] = 'D3D11_PREFER_SHARED_RESOURCES_KHR'
40
+ end
41
+
42
+ end
43
+
44
+ class Mem
45
+ D3D11_RESOURCE_KHR = 0x401E
46
+ end
47
+
48
+ class Image
49
+ D3D11_SUBRESOURCE_KHR = 0x401F
50
+ end
51
+
52
+ class CommandType
53
+ ACQUIRE_D3D11_OBJECTS_KHR = 0x4020
54
+ RELEASE_D3D11_OBJECTS_KHR = 0x4021
55
+ @codes[0x4020] = 'ACQUIRE_D3D11_OBJECTS_KHR'
56
+ @codes[0x4021] = 'RELEASE_D3D11_OBJECTS_KHR'
57
+ end
58
+
59
+ [
60
+ [ "clGetDeviceIDsFromD3D11KHR",
61
+ :cl_int,
62
+ [ Platform,
63
+ :cl_d3d11_device_source_khr,
64
+ :pointer,
65
+ :cl_d3d11_device_set_khr,
66
+ :cl_uint,
67
+ :pointer,
68
+ :pointer
69
+ ]
70
+ ], [
71
+ "clCreateFromD3D11BufferKHR",
72
+ Mem,
73
+ [ Context,
74
+ :cl_mem_flags,
75
+ :pointer,
76
+ :pointer ]
77
+ ], [
78
+ "clCreateFromD3D11Texture2DKHR",
79
+ Mem,
80
+ [ Context,
81
+ :cl_mem_flags,
82
+ :pointer,
83
+ :cl_uint,
84
+ :pointer
85
+ ]
86
+ ], [
87
+ "clCreateFromD3D11Texture3DKHR",
88
+ Mem,
89
+ [ Context,
90
+ :cl_mem_flags,
91
+ :pointer,
92
+ :cl_uint,
93
+ :pointer
94
+ ]
95
+ ], [
96
+ "clEnqueueAcquireD3D11ObjectsKHR",
97
+ :cl_int,
98
+ [ CommandQueue,
99
+ :cl_uint,
100
+ :pointer,
101
+ :cl_uint,
102
+ :pointer,
103
+ :pointer,
104
+ ]
105
+ ], [
106
+ "clEnqueueReleaseD3D11ObjectsKHR",
107
+ :cl_int,
108
+ [ CommandQueue,
109
+ :cl_uint,
110
+ :pointer,
111
+ :cl_uint,
112
+ :pointer,
113
+ :pointer,
114
+ ]
115
+ ]
116
+ ].each { |name, return_type, args|
117
+ attach_extension_function(name, return_type, args)
118
+ }
119
+
120
+ end
@@ -0,0 +1,113 @@
1
+ require 'opencl_ruby_ffi'
2
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
3
+
4
+ module OpenCL
5
+
6
+ INVALID_DX9_MEDIA_ADAPTER_KHR = -1010
7
+ INVALID_DX9_MEDIA_SURFACE_KHR = -1011
8
+ DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR = -1012
9
+ DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR = -1013
10
+
11
+ ADAPTER_D3D9_KHR = 0x2020
12
+ ADAPTER_D3D9EX_KHR = 0x2021
13
+ ADAPTER_DXVA_KHR = 0x2022
14
+ PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR = 0x2023
15
+ ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR = 0x2024
16
+ CONTEXT_ADAPTER_D3D9_KHR = 0x2025
17
+ CONTEXT_ADAPTER_D3D9EX_KHR = 0x2026
18
+ CONTEXT_ADAPTER_DXVA_KHR = 0x2027
19
+ MEM_DX9_MEDIA_ADAPTER_TYPE_KHR = 0x2028
20
+ MEM_DX9_MEDIA_SURFACE_INFO_KHR = 0x2029
21
+ IMAGE_DX9_MEDIA_PLANE_KHR = 0x202A
22
+ COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR = 0x202B
23
+ COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR = 0x202C
24
+
25
+ class Error
26
+
27
+ eval error_class_constructor( :INVALID_DX9_MEDIA_ADAPTER_KHR, :InvalidDX9MediaAdapterKHR )
28
+ eval error_class_constructor( :INVALID_DX9_MEDIA_SURFACE_KHR, :InvalidDX9MediaSurfaceKHR )
29
+ eval error_class_constructor( :DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR, :DX9MediaSurfaceAlreadyAcquiredKHR )
30
+ eval error_class_constructor( :DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR, :DX9MediaSurfaceNotAcquiredKHR )
31
+
32
+ end
33
+
34
+ class Context
35
+ ADAPTER_D3D9_KHR = 0x2025
36
+ ADAPTER_D3D9EX_KHR = 0x2026
37
+ ADAPTER_DXVA_KHR = 0x2027
38
+
39
+ class Properties
40
+ ADAPTER_D3D9_KHR = 0x2025
41
+ ADAPTER_D3D9EX_KHR = 0x2026
42
+ ADAPTER_DXVA_KHR = 0x2027
43
+ @codes[0x2025] = 'ADAPTER_D3D9_KHR'
44
+ @codes[0x2026] = 'ADAPTER_D3D9EX_KHR'
45
+ @codes[0x2026] = 'ADAPTER_DXVA_KHR'
46
+ end
47
+
48
+ end
49
+
50
+ class Mem
51
+ DX9_MEDIA_ADAPTER_TYPE_KHR = 0x2028
52
+ DX9_MEDIA_SURFACE_INFO_KHR = 0x2029
53
+ end
54
+
55
+ class Image
56
+ DX9_MEDIA_PLANE_KHR = 0x202A
57
+ end
58
+
59
+ class CommandType
60
+ ACQUIRE_DX9_MEDIA_SURFACES_KHR = 0x202B
61
+ RELEASE_DX9_MEDIA_SURFACES_KHR = 0x202C
62
+ @codes[0x202B] = 'ACQUIRE_DX9_MEDIA_SURFACES_KHR'
63
+ @codes[0x202C] = 'RELEASE_DX9_MEDIA_SURFACES_KHR'
64
+ end
65
+
66
+ [
67
+ [ "clGetDeviceIDsFromDX9MediaAdapterKHR",
68
+ :cl_int,
69
+ [ Platform,
70
+ :cl_uint,
71
+ :pointer,
72
+ :pointer,
73
+ :cl_dx9_media_adapter_set_khr,
74
+ :cl_uint,
75
+ :pointer,
76
+ :pointer
77
+ ]
78
+ ], [
79
+ "clCreateFromDX9MediaSurfaceKHR",
80
+ Mem,
81
+ [ Context,
82
+ :cl_mem_flags,
83
+ :cl_dx9_media_adapter_type_khr,
84
+ :pointer,
85
+ :cl_uint,
86
+ :pointer
87
+ ]
88
+ ], [
89
+ "clEnqueueAcquireDX9MediaSurfacesKHR",
90
+ :cl_int,
91
+ [ CommandQueue,
92
+ :cl_uint,
93
+ :pointer,
94
+ :cl_uint,
95
+ :pointer,
96
+ :pointer,
97
+ ]
98
+ ], [
99
+ "clEnqueueReleaseDX9MediaSurfacesKHR",
100
+ :cl_int,
101
+ [ CommandQueue,
102
+ :cl_uint,
103
+ :pointer,
104
+ :cl_uint,
105
+ :pointer,
106
+ :pointer,
107
+ ]
108
+ ]
109
+ ].each { |name, return_type, args|
110
+ attach_extension_function(name, return_type, args)
111
+ }
112
+
113
+ end
@@ -0,0 +1,15 @@
1
+ require 'opencl_ruby_ffi'
2
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
3
+
4
+ module OpenCL
5
+
6
+ COMMAND_EGL_FENCE_SYNC_OBJECT_KHR = 0x202F
7
+
8
+ class CommandType
9
+ EGL_FENCE_SYNC_OBJECT_KHR = 0x202F
10
+ @codes[0x202F] = 'EGL_FENCE_SYNC_OBJECT_KHR'
11
+ end
12
+
13
+ attach_extension_function( "clCreateEventFromEGLSyncKHR", Event, [Context, :cl_egl_sync_khr, :cl_egl_display_khr, :pointer] )
14
+
15
+ end
@@ -0,0 +1,58 @@
1
+ require 'opencl_ruby_ffi'
2
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
3
+
4
+ module OpenCL
5
+
6
+ INVALID_EGL_OBJECT_KHR = -1093
7
+ EGL_RESOURCE_NOT_ACQUIRED_KHR = -1092
8
+
9
+ COMMAND_ACQUIRE_EGL_OBJECTS_KHR = 0x202D
10
+ COMMAND_RELEASE_EGL_OBJECTS_KHR = 0x202E
11
+
12
+ class Error
13
+
14
+ eval error_class_constructor( :INVALID_EGL_OBJECT_KHR, :InvalidEGLObjectKHR )
15
+ eval error_class_constructor( :EGL_RESOURCE_NOT_ACQUIRED_KHR, :EGLResourceNotAcquiredKHR )
16
+
17
+ end
18
+
19
+ class CommandType
20
+ ACQUIRE_EGL_OBJECTS_KHR = 0x202D
21
+ RELEASE_EGL_OBJECTS_KHR = 0x202E
22
+ @codes[0x202D] = 'ACQUIRE_EGL_OBJECTS_KHR'
23
+ @codes[0x202E] = 'RELEASE_EGL_OBJECTS_KHR'
24
+ end
25
+
26
+ [
27
+ [ "clCreateFromEGLImageKHR",
28
+ Mem,
29
+ [ Context,
30
+ :cl_egl_display_khr,
31
+ :cl_egl_image_khr,
32
+ :cl_mem_flags,
33
+ :pointer,
34
+ :pointer ]
35
+ ], [
36
+ "clEnqueueAcquireEGLObjectsKHR",
37
+ :cl_int,
38
+ [ CommandQueue,
39
+ :cl_uint,
40
+ :pointer,
41
+ :cl_uint,
42
+ :pointer,
43
+ :pointer]
44
+ ], [
45
+ "clEnqueueReleaseEGLObjectsKHR",
46
+ :cl_int,
47
+ [ CommandQueue,
48
+ :cl_uint,
49
+ :pointer,
50
+ :cl_uint,
51
+ :pointer,
52
+ :pointer]
53
+ ]
54
+ ].each { |name, return_type, args|
55
+ f = attach_extension_function(name, return_type, args)
56
+ }
57
+
58
+ end
@@ -0,0 +1,23 @@
1
+ require 'opencl_ruby_ffi'
2
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
3
+
4
+ module OpenCL
5
+
6
+ DEVICE_HALF_FP_CONFIG = 0x1033
7
+
8
+ class Device
9
+
10
+ HALF_FP_CONFIG = 0x1033
11
+
12
+ module KHRFP16
13
+ extend InnerGenerator
14
+
15
+ get_info("Device", :cl_device_fp_config, "half_fp_config")
16
+
17
+ end
18
+
19
+ register_extension( :cl_khr_fp16, KHRFP16, "extensions.include?(\"cl_khr_fp16\")" )
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,23 @@
1
+ require 'opencl_ruby_ffi'
2
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
3
+
4
+ module OpenCL
5
+
6
+ DEVICE_DOUBLE_FP_CONFIG = 0x1032
7
+
8
+ class Device
9
+
10
+ DOUBLE_FP_CONFIG = 0x1032
11
+
12
+ module KHRFP64
13
+ extend InnerGenerator
14
+
15
+ get_info("Device", :cl_device_fp_config, "double_fp_config")
16
+
17
+ end
18
+
19
+ register_extension( :cl_khr_fp64, KHRFP64, "platform.version_number >= 1.2 or extensions.include?(\"cl_khr_fp64\")" )
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,38 @@
1
+ require 'opencl_ruby_ffi'
2
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
3
+
4
+ module OpenCL
5
+
6
+ COMMAND_GL_FENCE_SYNC_OBJECT_KHR = 0x200D
7
+
8
+ attach_extension_function( "clCreateEventFromGLsyncKHR", Event, [Context, :pointer, :pointer] )
9
+
10
+ def self.create_event_from_glsync_khr( context, sync)
11
+ error_check(INVALID_OPERATION) unless context.platform.extensions.include?( "cl_khr_gl_event" ) or devices.first.extensions.include?("cl_khr_gl_event")
12
+ error_p = MemoryPointer::new( :cl_int )
13
+ event = clCreateEventFromGLsyncKHR( context, sync, error_p )
14
+ error_check(error_p.read_cl_int)
15
+ return Event::new( event, false )
16
+ end
17
+
18
+ class CommandType
19
+ GL_FENCE_SYNC_OBJECT_KHR = 0x200D
20
+ @codes[0x200D] = 'GL_FENCE_SYNC_OBJECT_KHR'
21
+ end
22
+
23
+ class Context
24
+
25
+ module KHRGLEvent
26
+
27
+ def create_event_from_glsync_khr( sync )
28
+ return OpenCL.create_event_from_glsync_khr( self, sync )
29
+ end
30
+ alias create_event_from_GLsync_KHR create_event_from_glsync_khr
31
+
32
+ end
33
+
34
+ register_extension( :cl_khr_gl_event, KHRGLEvent, "platform.extensions.include?(\"cl_khr_gl_event\") or devices.first.extensions.include?(\"cl_khr_gl_event\")" )
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,79 @@
1
+ require 'opencl_ruby_ffi'
2
+ using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
3
+
4
+ module OpenCL
5
+
6
+ INVALID_GL_SHAREGROUP_REFERENCE_KHR = -1000
7
+
8
+ CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 0x2006
9
+ DEVICES_FOR_GL_CONTEXT_KHR = 0x2007
10
+
11
+ GL_CONTEXT_KHR = 0x2008
12
+ EGL_DISPLAY_KHR = 0x2009
13
+ GLX_DISPLAY_KHR = 0x200A
14
+ WGL_HDC_KHR = 0x200B
15
+ CGL_SHAREGROUP_KHR = 0x200C
16
+
17
+ class Error
18
+
19
+ eval error_class_constructor( :INVALID_GL_SHAREGROUP_REFERENCE_KHR, :InvalidGLSharegroupReferenceKHR )
20
+
21
+ end
22
+
23
+ f = attach_extension_function( "clGetGLContextInfoKHR", :cl_int, [:pointer, :cl_gl_context_info, :size_t, :pointer, :pointer] )
24
+
25
+ def self.get_gl_context_info_khr( properties, param_name )
26
+ props = MemoryPointer::new( :cl_context_properties, properties.length + 1 )
27
+ properties.each_with_index { |e,i|
28
+ props[i].write_cl_context_properties(e)
29
+ }
30
+ props[properties.length].write_cl_context_properties(0)
31
+ size_p = MemoryPointer::new( :size_t )
32
+ error = clGetGLContextInfoKHR( props, param_name, 0, nil, size_p )
33
+ error_check(error)
34
+ size = size_p.read_size_t
35
+ nb_devices = size/Device.size
36
+ values = MemoryPointer::new( Device, nb_devices )
37
+ error = clGetGLContextInfoKHR( props, param_name, size, values, nil )
38
+ error_check(error)
39
+ return values.get_array_of_pointer(0, nb_devices).collect { |device_ptr|
40
+ Device::new(device_ptr, false)
41
+ }
42
+ end
43
+
44
+ class GLContextInfo < Enum
45
+ CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 0x2006
46
+ DEVICES_FOR_GL_CONTEXT_KHR = 0x2007
47
+ @codes = {}
48
+ @codes[0x2006] = CURRENT_DEVICE_FOR_GL_CONTEXT_KHR
49
+ @codes[0x2007] = DEVICES_FOR_GL_CONTEXT_KHR
50
+ end
51
+
52
+ class Context
53
+
54
+ class Properties
55
+ GL_CONTEXT_KHR = 0x2008
56
+ CGL_SHAREGROUP_KHR = 0x200C
57
+ EGL_DISPLAY_KHR = 0x2009
58
+ GLX_DISPLAY_KHR = 0x200A
59
+ WGL_HDC_KHR = 0x200B
60
+ @codes[0x2008] = 'GL_CONTEXT_KHR'
61
+ @codes[0x200C] = 'CGL_SHAREGROUP_KHR'
62
+ @codes[0x2009] = 'EGL_DISPLAY_KHR'
63
+ @codes[0x200A] = 'GLX_DISPLAY_KHR'
64
+ @codes[0x200B] = 'WGL_HDC_KHR'
65
+ end
66
+
67
+ module KHRGLSharing
68
+
69
+ def get_gl_info_khr( param_name )
70
+ return OpenCL.get_gl_context_info_khr( self.properties, param_name )
71
+ end
72
+
73
+ end
74
+
75
+ register_extension( :cl_khr_gl_sharing, KHRGLSharing, "platform.extensions.include?(\"cl_khr_gl_sharing\") or devices.first.extensions.include?(\"cl_khr_gl_sharing\")" )
76
+
77
+ end
78
+
79
+ end