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.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/lib/opencl_ruby_ffi.rb +2 -0
- data/lib/opencl_ruby_ffi/Buffer.rb +18 -13
- data/lib/opencl_ruby_ffi/CommandQueue.rb +301 -302
- data/lib/opencl_ruby_ffi/Context.rb +158 -158
- data/lib/opencl_ruby_ffi/Device.rb +270 -224
- data/lib/opencl_ruby_ffi/Event.rb +40 -36
- data/lib/opencl_ruby_ffi/Image.rb +34 -57
- data/lib/opencl_ruby_ffi/Kernel.rb +251 -191
- data/lib/opencl_ruby_ffi/Mem.rb +49 -70
- data/lib/opencl_ruby_ffi/Pipe.rb +3 -14
- data/lib/opencl_ruby_ffi/Platform.rb +46 -48
- data/lib/opencl_ruby_ffi/Program.rb +131 -124
- data/lib/opencl_ruby_ffi/Sampler.rb +6 -24
- data/lib/opencl_ruby_ffi/amd/device_attribute_query.rb +100 -0
- data/lib/opencl_ruby_ffi/egl.rb +2 -0
- data/lib/opencl_ruby_ffi/ext.rb +11 -0
- data/lib/opencl_ruby_ffi/ext/device_fission.rb +264 -0
- data/lib/opencl_ruby_ffi/gl_ext.rb +2 -0
- data/lib/opencl_ruby_ffi/khr/d3d10_sharing.rb +120 -0
- data/lib/opencl_ruby_ffi/khr/d3d11_sharing.rb +120 -0
- data/lib/opencl_ruby_ffi/khr/dx9_media_sharing.rb +113 -0
- data/lib/opencl_ruby_ffi/khr/egl_event.rb +15 -0
- data/lib/opencl_ruby_ffi/khr/egl_image.rb +58 -0
- data/lib/opencl_ruby_ffi/khr/fp16.rb +23 -0
- data/lib/opencl_ruby_ffi/khr/fp64.rb +23 -0
- data/lib/opencl_ruby_ffi/khr/gl_event.rb +38 -0
- data/lib/opencl_ruby_ffi/khr/gl_sharing.rb +79 -0
- data/lib/opencl_ruby_ffi/khr/icd.rb +30 -0
- data/lib/opencl_ruby_ffi/khr/initalize_memory.rb +19 -0
- data/lib/opencl_ruby_ffi/khr/priority_hints.rb +48 -0
- data/lib/opencl_ruby_ffi/khr/spir.rb +45 -0
- data/lib/opencl_ruby_ffi/khr/sub_groups.rb +49 -0
- data/lib/opencl_ruby_ffi/khr/terminate_context.rb +46 -0
- data/lib/opencl_ruby_ffi/khr/throttle_hints.rb +47 -0
- data/lib/opencl_ruby_ffi/nv/device_attribute_query.rb +50 -0
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb +40 -13
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb +214 -2114
- data/lib/opencl_ruby_ffi/opencl_types.rb +15 -3
- data/opencl_ruby_ffi.gemspec +4 -4
- data/templates_custom/default/module/setup.rb +9 -0
- metadata +29 -6
- data/lib/opencl_ruby_ffi/GLExt.rb +0 -58
- data/lib/opencl_ruby_ffi/Stream.rb +0 -127
@@ -60,13 +60,10 @@ module OpenCL
|
|
60
60
|
Sampler::new(sampler_ptr, false)
|
61
61
|
end
|
62
62
|
|
63
|
-
# Maps the
|
63
|
+
# Maps the cl_sampler object of OpenCL
|
64
64
|
class Sampler
|
65
65
|
include InnerInterface
|
66
|
-
|
67
|
-
class << self
|
68
|
-
include InnerGenerator
|
69
|
-
end
|
66
|
+
extend InnerGenerator
|
70
67
|
|
71
68
|
def inspect
|
72
69
|
return "#<#{self.class.name}: #{addressing_mode} #{filter_mode} normalized: #{normalized_coords}>"
|
@@ -80,25 +77,10 @@ module OpenCL
|
|
80
77
|
return Context::new( ptr.read_pointer )
|
81
78
|
end
|
82
79
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
##
|
89
|
-
# :method: normalized_coords()
|
90
|
-
# returns if the Sampler uses normalized coords
|
91
|
-
eval get_info("Sampler", :cl_bool, "NORMALIZED_COORDS")
|
92
|
-
|
93
|
-
##
|
94
|
-
# :method: addressing_mode()
|
95
|
-
# returns an AddressingMode representing the addressing mode used by the Sampler
|
96
|
-
eval get_info("Sampler", :cl_addressing_mode, "ADDRESSING_MODE")
|
97
|
-
|
98
|
-
##
|
99
|
-
# :method: filter_mode()
|
100
|
-
# returns a FilterMode representing the filtering mode used by the Sampler
|
101
|
-
eval get_info("Sampler", :cl_filter_mode, "FILTER_MODE")
|
80
|
+
get_info("Sampler", :cl_uint, "reference_count")
|
81
|
+
get_info("Sampler", :cl_bool, "normalized_coords")
|
82
|
+
get_info("Sampler", :cl_addressing_mode, "addressing_mode")
|
83
|
+
get_info("Sampler", :cl_filter_mode, "filter_mode")
|
102
84
|
|
103
85
|
end
|
104
86
|
|
@@ -0,0 +1,100 @@
|
|
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_TOPOLOGY_TYPE_PCIE_AMD = 1
|
7
|
+
DEVICE_PROFILING_TIMER_OFFSET_AMD = 0x4036
|
8
|
+
DEVICE_TOPOLOGY_AMD = 0x4037
|
9
|
+
DEVICE_BOARD_NAME_AMD = 0x4038
|
10
|
+
DEVICE_GLOBAL_FREE_MEMORY_AMD = 0x4039
|
11
|
+
DEVICE_SIMD_PER_COMPUTE_UNIT_AMD = 0x4040
|
12
|
+
DEVICE_SIMD_WIDTH_AMD = 0x4041
|
13
|
+
DEVICE_SIMD_INSTRUCTION_WIDTH_AMD = 0x4042
|
14
|
+
DEVICE_WAVEFRONT_WIDTH_AMD = 0x4043
|
15
|
+
DEVICE_GLOBAL_MEM_CHANNELS_AMD = 0x4044
|
16
|
+
DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD = 0x4045
|
17
|
+
DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD = 0x4046
|
18
|
+
DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD = 0x4047
|
19
|
+
DEVICE_LOCAL_MEM_BANKS_AMD = 0x4048
|
20
|
+
DEVICE_THREAD_TRACE_SUPPORTED_AMD = 0x4049
|
21
|
+
DEVICE_GFXIP_MAJOR_AMD = 0x404A
|
22
|
+
DEVICE_GFXIP_MINOR_AMD = 0x404B
|
23
|
+
DEVICE_AVAILABLE_ASYNC_QUEUES_AMD = 0x404C
|
24
|
+
|
25
|
+
class Device
|
26
|
+
|
27
|
+
TOPOLOGY_TYPE_PCIE_AMD = 1
|
28
|
+
PROFILING_TIMER_OFFSET_AMD = 0x4036
|
29
|
+
TOPOLOGY_AMD = 0x4037
|
30
|
+
BOARD_NAME_AMD = 0x4038
|
31
|
+
GLOBAL_FREE_MEMORY_AMD = 0x4039
|
32
|
+
SIMD_PER_COMPUTE_UNIT_AMD = 0x4040
|
33
|
+
SIMD_WIDTH_AMD = 0x4041
|
34
|
+
SIMD_INSTRUCTION_WIDTH_AMD = 0x4042
|
35
|
+
WAVEFRONT_WIDTH_AMD = 0x4043
|
36
|
+
GLOBAL_MEM_CHANNELS_AMD = 0x4044
|
37
|
+
GLOBAL_MEM_CHANNEL_BANKS_AMD = 0x4045
|
38
|
+
GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD = 0x4046
|
39
|
+
LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD = 0x4047
|
40
|
+
LOCAL_MEM_BANKS_AMD = 0x4048
|
41
|
+
THREAD_TRACE_SUPPORTED_AMD = 0x4049
|
42
|
+
GFXIP_MAJOR_AMD = 0x404A
|
43
|
+
GFXIP_MINOR_AMD = 0x404B
|
44
|
+
AVAILABLE_ASYNC_QUEUES_AMD = 0x404C
|
45
|
+
|
46
|
+
module AMDDeviceAttributeQuery
|
47
|
+
extend InnerGenerator
|
48
|
+
|
49
|
+
class AMDTopology < Union
|
50
|
+
class Raw < Struct
|
51
|
+
layout :type, UInt,
|
52
|
+
:data, [UInt, 5]
|
53
|
+
end
|
54
|
+
class PCIE < Struct
|
55
|
+
layout :type, UInt,
|
56
|
+
:unused, [Char, 17],
|
57
|
+
:bus, Char,
|
58
|
+
:device, Char,
|
59
|
+
:function, Char
|
60
|
+
end
|
61
|
+
layout :raw, Raw,
|
62
|
+
:pcie, PCIE
|
63
|
+
end
|
64
|
+
|
65
|
+
get_info("Device", :string, "board_name_amd")
|
66
|
+
|
67
|
+
get_info("Device", :cl_ulong, "profiling_timer_offset_amd")
|
68
|
+
|
69
|
+
get_info("Device", :cl_uint, "simd_per_compute_unit_amd")
|
70
|
+
get_info("Device", :cl_uint, "simd_width_amd")
|
71
|
+
get_info("Device", :cl_uint, "simd_instruction_width_amd")
|
72
|
+
get_info("Device", :cl_uint, "wavefront_width_amd")
|
73
|
+
get_info("Device", :cl_uint, "global_mem_channels_amd")
|
74
|
+
get_info("Device", :cl_uint, "global_mem_channel_banks_amd")
|
75
|
+
get_info("Device", :cl_uint, "global_mem_channel_bank_width_amd")
|
76
|
+
get_info("Device", :cl_uint, "local_mem_banks_amd")
|
77
|
+
get_info("Device", :cl_uint, "gfxip_major_amd")
|
78
|
+
get_info("Device", :cl_uint, "gfxip_minor_amd")
|
79
|
+
get_info("Device", :cl_uint, "available_async_queues_amd")
|
80
|
+
|
81
|
+
get_info("Device", :cl_bool, "thread_trace_supported_amd")
|
82
|
+
|
83
|
+
get_info("Device", :size_t, "local_mem_size_per_compute_unit_amd")
|
84
|
+
|
85
|
+
get_info_array("Device", :size_t, "global_free_memory_amd")
|
86
|
+
|
87
|
+
def topology_amd
|
88
|
+
ptr1 = MemoryPointer::new( AMDTopology )
|
89
|
+
error = OpenCL.clGetDeviceInfo(self, TOPOLOGY_AMD, ptr1.size, ptr1, nil)
|
90
|
+
error_check(error)
|
91
|
+
return AMDTopology::new(ptr1)
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
register_extension( :cl_amd_device_attribute_query, AMDDeviceAttributeQuery, "extensions.include?(\"cl_amd_device_attribute_query\")" )
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "opencl_ruby_ffi/khr/fp64.rb"
|
2
|
+
require "opencl_ruby_ffi/khr/fp16.rb"
|
3
|
+
require "opencl_ruby_ffi/khr/icd.rb"
|
4
|
+
require "opencl_ruby_ffi/khr/initalize_memory.rb"
|
5
|
+
require "opencl_ruby_ffi/khr/spir.rb"
|
6
|
+
require "opencl_ruby_ffi/nv/device_attribute_query.rb"
|
7
|
+
require "opencl_ruby_ffi/amd/device_attribute_query.rb"
|
8
|
+
require "opencl_ruby_ffi/ext/device_fission.rb"
|
9
|
+
require "opencl_ruby_ffi/khr/sub_groups.rb"
|
10
|
+
require "opencl_ruby_ffi/khr/priority_hints.rb"
|
11
|
+
require "opencl_ruby_ffi/khr/throttle_hints.rb"
|
@@ -0,0 +1,264 @@
|
|
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_PARTITION_FAILED_EXT = -1057
|
7
|
+
INVALID_PARTITION_COUNT_EXT = -1058
|
8
|
+
|
9
|
+
DEVICE_PARTITION_EQUALLY_EXT = 0x4050
|
10
|
+
DEVICE_PARTITION_BY_COUNTS_EXT = 0x4051
|
11
|
+
DEVICE_PARTITION_BY_NAMES_EXT = 0x4052
|
12
|
+
DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT = 0x4053
|
13
|
+
|
14
|
+
DEVICE_PARENT_DEVICE_EXT = 0x4054
|
15
|
+
DEVICE_PARTITION_TYPES_EXT = 0x4055
|
16
|
+
DEVICE_AFFINITY_DOMAINS_EXT = 0x4056
|
17
|
+
DEVICE_REFERENCE_COUNT_EXT = 0x4057
|
18
|
+
DEVICE_PARTITION_STYLE_EXT = 0x4058
|
19
|
+
|
20
|
+
AFFINITY_DOMAIN_L1_CACHE_EXT = 0x1
|
21
|
+
AFFINITY_DOMAIN_L2_CACHE_EXT = 0x2
|
22
|
+
AFFINITY_DOMAIN_L3_CACHE_EXT = 0x3
|
23
|
+
AFFINITY_DOMAIN_L4_CACHE_EXT = 0x4
|
24
|
+
AFFINITY_DOMAIN_NUMA_EXT = 0x10
|
25
|
+
AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT = 0x100
|
26
|
+
|
27
|
+
PROPERTIES_LIST_END_EXT = 0
|
28
|
+
PARTITION_BY_COUNTS_LIST_END_EXT = 0
|
29
|
+
PARTITION_BY_NAMES_LIST_END_EXT = -1
|
30
|
+
|
31
|
+
[
|
32
|
+
[ "clReleaseDeviceEXT",
|
33
|
+
:cl_int,
|
34
|
+
[ Device ]
|
35
|
+
], [
|
36
|
+
"clRetainDeviceEXT",
|
37
|
+
:cl_int,
|
38
|
+
[ Device ]
|
39
|
+
], [
|
40
|
+
"clCreateSubDevicesEXT",
|
41
|
+
:cl_int,
|
42
|
+
[ Device,
|
43
|
+
:pointer,
|
44
|
+
:cl_uint,
|
45
|
+
:pointer,
|
46
|
+
:pointer ]
|
47
|
+
]
|
48
|
+
].each { |name, return_type, args|
|
49
|
+
attach_extension_function(name, return_type, args)
|
50
|
+
}
|
51
|
+
|
52
|
+
def self.create_sub_devices_ext( in_device, properties )
|
53
|
+
error_check(INVALID_OPERATION) if in_device.platform.version_number < 1.1 and not in_device.platform.extensions.include? "cl_ext_device_fission"
|
54
|
+
props = MemoryPointer::new( :cl_device_partition_property_ext, properties.length + 1 )
|
55
|
+
properties.each_with_index { |e,i|
|
56
|
+
props[i].write_cl_device_partition_property_ext(e)
|
57
|
+
}
|
58
|
+
props[properties.length].write_cl_device_partition_property_ext(0)
|
59
|
+
device_number_ptr = MemoryPointer::new( :cl_uint )
|
60
|
+
error = clCreateSubDevicesEXT( in_device, props, 0, nil, device_number_ptr )
|
61
|
+
error_check(error)
|
62
|
+
device_number = device_number_ptr.read_cl_uint
|
63
|
+
devices_ptr = MemoryPointer::new( Device, device_number )
|
64
|
+
error = clCreateSubDevicesEXT( in_device, props, device_number, devices_ptr, nil )
|
65
|
+
error_check(error)
|
66
|
+
devices_ptr.get_array_of_pointer(0, device_number).collect { |device_ptr|
|
67
|
+
Device::new(device_ptr, false)
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
class Error
|
72
|
+
|
73
|
+
eval error_class_constructor( :INVALID_PARTITION_COUNT_EXT, :InvalidPartitionCountEXT )
|
74
|
+
eval error_class_constructor( :DEVICE_PARTITION_FAILED_EXT, :DevicePartitionFailedEXT )
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
class Device
|
79
|
+
|
80
|
+
PARTITION_EQUALLY_EXT = 0x4050
|
81
|
+
PARTITION_BY_COUNTS_EXT = 0x4051
|
82
|
+
PARTITION_BY_NAMES_EXT = 0x4052
|
83
|
+
PARTITION_BY_AFFINITY_DOMAIN_EXT = 0x4053
|
84
|
+
|
85
|
+
PARENT_DEVICE_EXT = 0x4054
|
86
|
+
PARTITION_TYPES_EXT = 0x4055
|
87
|
+
AFFINITY_DOMAINS_EXT = 0x4056
|
88
|
+
REFERENCE_COUNT_EXT = 0x4057
|
89
|
+
PARTITION_STYLE_EXT = 0x4058
|
90
|
+
|
91
|
+
# Enum that maps the :cl_device_partition_property_ext type
|
92
|
+
class PartitionEXT < EnumInt
|
93
|
+
EQUALLY_EXT = 0x4050
|
94
|
+
BY_COUNTS_EXT = 0x4051
|
95
|
+
BY_COUNTS_LIST_END_EXT = 0x0
|
96
|
+
BY_NAMES_EXT = 0x4052
|
97
|
+
BY_AFFINITY_DOMAIN_EXT = 0x4053
|
98
|
+
BY_NAMES_LIST_END_EXT = -1
|
99
|
+
@codes = {}
|
100
|
+
@codes[0x4050] = 'EQUALLY_EXT'
|
101
|
+
@codes[0x4051] = 'BY_COUNTS_EXT'
|
102
|
+
@codes[0x0] = 'BY_COUNTS_LIST_END_EXT'
|
103
|
+
@codes[0x4052] = 'BY_NAMES_EXT'
|
104
|
+
@codes[0x4053] = 'BY_AFFINITY_DOMAIN_EXT'
|
105
|
+
@codes[-1] = 'BY_NAMES_LIST_END_EXT'
|
106
|
+
end
|
107
|
+
|
108
|
+
# Bitfield that maps the :cl_device_affinity_domain_ext type
|
109
|
+
class AffinityDomainEXT < Enum
|
110
|
+
L1_CACHE_EXT = 0x1
|
111
|
+
L2_CACHE_EXT = 0x2
|
112
|
+
L3_CACHE_EXT = 0x3
|
113
|
+
L4_CACHE_EXT = 0x4
|
114
|
+
NUMA_EXT = 0x10
|
115
|
+
NEXT_FISSIONABLE_EXT = 0x100
|
116
|
+
@codes = {}
|
117
|
+
@codes[0x1] = 'L1_CACHE_EXT'
|
118
|
+
@codes[0x2] = 'L2_CACHE_EXT'
|
119
|
+
@codes[0x3] = 'L3_CACHE_EXT'
|
120
|
+
@codes[0x4] = 'L4_CACHE_EXT'
|
121
|
+
@codes[0x10] = 'NUMA_EXT'
|
122
|
+
@codes[0x100] = 'NEXT_FISSIONABLE_EXT'
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
module InnerInterface
|
128
|
+
TYPE_CONVERTER[:cl_device_affinity_domain_ext] = Device::AffinityDomainEXT
|
129
|
+
end
|
130
|
+
|
131
|
+
class Device
|
132
|
+
|
133
|
+
# Creates a new Device and retains it if specified and aplicable
|
134
|
+
def initialize(ptr, retain = true)
|
135
|
+
super(ptr)
|
136
|
+
p = platform
|
137
|
+
if p.version_number >= 1.2 and retain then
|
138
|
+
error = OpenCL.clRetainDevice(ptr)
|
139
|
+
error_check( error )
|
140
|
+
elsif p.version_number >= 1.1 and retain and extensions.include? "cl_ext_device_fission" then
|
141
|
+
error = OpenCL.clRetainDeviceEXT(ptr)
|
142
|
+
error_check( error )
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# method called at Device deletion, releases the object if aplicable
|
147
|
+
# @private
|
148
|
+
def self.release(ptr)
|
149
|
+
plat = FFI::MemoryPointer::new( Platform )
|
150
|
+
OpenCL.clGetDeviceInfo( ptr, OpenCL::Device::PLATFORM, plat.size, plat, nil)
|
151
|
+
platform = OpenCL::Platform::new(plat.read_pointer)
|
152
|
+
if platform.version_number >= 1.2 then
|
153
|
+
OpenCL.clReleaseDevice(ptr)
|
154
|
+
elsif platform.version_number >= 1.1
|
155
|
+
ext_size = FFI::MemoryPointer::new( :size_t )
|
156
|
+
OpenCL.clGetDeviceInfo( ptr, OpenCL::Device::EXTENSIONS, 0, nil, ext_size)
|
157
|
+
ext = FFI::MemoryPointer::new( ext.read_size_t )
|
158
|
+
OpenCL.clGetDeviceInfo( ptr, OpenCL::Device::EXTENSIONS, ext.size, ext, nil)
|
159
|
+
extensions = ext.read_string.split(" ")
|
160
|
+
if extensions.include? "cl_ext_device_fission" then
|
161
|
+
OpenCL.clReleaseDeviceEXT(ptr)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
module EXTDeviceFission
|
167
|
+
extend InnerGenerator
|
168
|
+
|
169
|
+
# Returns the list of partition types supported by the Device
|
170
|
+
def partition_types_ext
|
171
|
+
ptr1 = MemoryPointer::new( :size_t, 1)
|
172
|
+
error = OpenCL.clGetDeviceInfo(self, PARTITION_TYPES_EXT, 0, nil, ptr1)
|
173
|
+
error_check(error)
|
174
|
+
ptr2 = MemoryPointer::new( ptr1.read_size_t )
|
175
|
+
error = OpenCL.clGetDeviceInfo(self, PARTITION_TYPES_EXT, ptr1.read_size_t, ptr2, nil)
|
176
|
+
error_check(error)
|
177
|
+
arr = ptr2.get_array_of_cl_device_partition_property_ext(0, ptr1.read_size_t/ OpenCL.find_type(:cl_device_partition_property_ext).size)
|
178
|
+
arr.reject! { |e| e == 0 }
|
179
|
+
return arr.collect { |e| PartitionEXT::new(e.to_i) }
|
180
|
+
end
|
181
|
+
|
182
|
+
get_info_array("Device", :cl_device_affinity_domain_ext, "affinity_domains_ext")
|
183
|
+
|
184
|
+
# Returns the parent Device if it exists
|
185
|
+
def parent_device_ext
|
186
|
+
ptr = MemoryPointer::new( Device )
|
187
|
+
error = OpenCL.clGetDeviceInfo(self, PARENT_DEVICE_EXT, Device.size, ptr, nil)
|
188
|
+
error_check(error)
|
189
|
+
return nil if ptr.null?
|
190
|
+
return Device::new(ptr.read_pointer)
|
191
|
+
end
|
192
|
+
|
193
|
+
get_info("Device", :cl_uint, "reference_count_ext")
|
194
|
+
|
195
|
+
def partition_style_ext
|
196
|
+
ptr1 = MemoryPointer::new( :size_t, 1)
|
197
|
+
error = OpenCL.clGetDeviceInfo(self, PARTITION_STYLE_EXT, 0, nil, ptr1)
|
198
|
+
error_check(error)
|
199
|
+
ptr2 = MemoryPointer::new( ptr1.read_size_t )
|
200
|
+
error = OpenCL.clGetDeviceInfo(self, PARTITION_STYLE_EXT, ptr1.read_size_t, ptr2, nil)
|
201
|
+
error_check(error)
|
202
|
+
arr = ptr2.get_array_of_cl_device_partition_property_ext(0, ptr1.read_size_t/ OpenCL.find_type(:cl_device_partition_property).size)
|
203
|
+
return [] if arr.length == 0
|
204
|
+
ptype = arr.first.to_i
|
205
|
+
arr_2 = []
|
206
|
+
arr_2.push( PartitionEXT::new(ptype) )
|
207
|
+
return arr_2 if arr.length == 1
|
208
|
+
case ptype
|
209
|
+
when PartitionEXT::BY_NAMES_EXT
|
210
|
+
i = 1
|
211
|
+
while arr[i].to_i - (0x1 << Pointer.size * 8) != PartitionEXT::BY_NAMES_LIST_END_EXT do
|
212
|
+
arr_2.push( arr[i].to_i )
|
213
|
+
i += 1
|
214
|
+
return arr_2 if arr.length <= i
|
215
|
+
end
|
216
|
+
arr_2.push( PartitionEXT::new(PartitionEXT::BY_NAMES_LIST_END_EXT) )
|
217
|
+
arr_2.push( 0 )
|
218
|
+
when PartitionEXT::EQUALLY_EXT
|
219
|
+
arr_2.push(arr[1].to_i)
|
220
|
+
arr_2.push( 0 )
|
221
|
+
when PartitionEXT::BY_COUNTS_EXT
|
222
|
+
i = 1
|
223
|
+
while arr[i].to_i != PartitionEXT::BY_COUNTS_LIST_END_EXT do
|
224
|
+
arr_2.push( arr[i].to_i )
|
225
|
+
i += 1
|
226
|
+
return arr_2 if arr.length <= i
|
227
|
+
end
|
228
|
+
arr_2.push( PartitionEXT::new(PartitionEXT::BY_COUNTS_LIST_END_EXT) )
|
229
|
+
arr_2.push( 0 )
|
230
|
+
end
|
231
|
+
return arr_2
|
232
|
+
end
|
233
|
+
|
234
|
+
def create_sub_devices_ext( properties )
|
235
|
+
OpenCL.create_sub_devices_ext( self, properties )
|
236
|
+
end
|
237
|
+
|
238
|
+
def partition_by_affinity_domain_ext( affinity_domain = AffinityDomainEXT::NEXT_FISSIONABLE_EXT )
|
239
|
+
return OpenCL.create_sub_devices_ext( self, [ PartitionEXT::BY_AFFINITY_DOMAIN_EXT, affinity_domain ] )
|
240
|
+
end
|
241
|
+
|
242
|
+
def partition_equally_ext( compute_unit_number = 1 )
|
243
|
+
return OpenCL.create_sub_devices_ext( self, [ PartitionEXT::EQUALLY_EXT, compute_unit_number ] )
|
244
|
+
end
|
245
|
+
|
246
|
+
def partition_by_counts_ext( *compute_unit_count_list )
|
247
|
+
compute_unit_count_list = [1] if compute_unit_count_list == []
|
248
|
+
compute_unit_count_list.flatten!
|
249
|
+
return OpenCL.create_sub_devices_ext( self, [ PartitionEXT::BY_COUNTS_EXT] + compute_unit_count_list + [ PartitionEXT::BY_COUNTS_LIST_END_EXT ] )
|
250
|
+
end
|
251
|
+
|
252
|
+
def partition_by_names_ext( *compute_unit_name_list )
|
253
|
+
compute_unit_name_list = [0] if compute_unit_name_list == []
|
254
|
+
compute_unit_name_list.flatten!
|
255
|
+
return OpenCL.create_sub_devices_ext( self, [ PartitionEXT::BY_NAMES_EXT ] + compute_unit_name_list + [ PartitionEXT::BY_NAMES_LIST_END_EXT ] )
|
256
|
+
end
|
257
|
+
|
258
|
+
end
|
259
|
+
|
260
|
+
register_extension( :cl_ext_device_fission, EXTDeviceFission, "extensions.include?(\"cl_ext_device_fission\")" )
|
261
|
+
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
@@ -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_D3D10_DEVICE_KHR = -1002
|
7
|
+
INVALID_D3D10_RESOURCE_KHR = -1003
|
8
|
+
D3D10_RESOURCE_ALREADY_ACQUIRED_KHR = -1004
|
9
|
+
D3D10_RESOURCE_NOT_ACQUIRED_KHR = -1005
|
10
|
+
|
11
|
+
D3D10_DEVICE_KHR = 0x4010
|
12
|
+
D3D10_DXGI_ADAPTER_KHR = 0x4011
|
13
|
+
PREFERRED_DEVICES_FOR_D3D10_KHR = 0x4012
|
14
|
+
ALL_DEVICES_FOR_D3D10_KHR = 0x4013
|
15
|
+
CONTEXT_D3D10_DEVICE_KHR = 0x4014
|
16
|
+
CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR = 0x402C
|
17
|
+
MEM_D3D10_RESOURCE_KHR = 0x4015
|
18
|
+
IMAGE_D3D10_SUBRESOURCE_KHR = 0x4016
|
19
|
+
COMMAND_ACQUIRE_D3D10_OBJECTS_KHR = 0x4017
|
20
|
+
COMMAND_RELEASE_D3D10_OBJECTS_KHR = 0x4018
|
21
|
+
|
22
|
+
class Error
|
23
|
+
|
24
|
+
eval error_class_constructor( :INVALID_D3D10_DEVICE_KHR, :InvalidD3D10DeviceKHR )
|
25
|
+
eval error_class_constructor( :INVALID_D3D10_RESOURCE_KHR, :InvalidD3D10ResourceKHR )
|
26
|
+
eval error_class_constructor( :D3D10_RESOURCE_ALREADY_ACQUIRED_KHR, :D3D10ResourceAlreadyAcquiredKHR )
|
27
|
+
eval error_class_constructor( :D3D10_RESOURCE_NOT_ACQUIRED_KHR, :D3D10ResourceNotAcquiredKHR )
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
class Context
|
32
|
+
D3D10_DEVICE_KHR = 0x4014
|
33
|
+
D3D10_PREFER_SHARED_RESOURCES_KHR = 0x402C
|
34
|
+
|
35
|
+
class Properties
|
36
|
+
D3D10_DEVICE_KHR = 0x4014
|
37
|
+
D3D10_PREFER_SHARED_RESOURCES_KHR = 0x402C
|
38
|
+
@codes[0x4014] = 'D3D10_DEVICE_KHR'
|
39
|
+
@codes[0x402C] = 'D3D10_PREFER_SHARED_RESOURCES_KHR'
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
class Mem
|
45
|
+
D3D10_RESOURCE_KHR = 0x4015
|
46
|
+
end
|
47
|
+
|
48
|
+
class Image
|
49
|
+
D3D10_SUBRESOURCE_KHR = 0x4016
|
50
|
+
end
|
51
|
+
|
52
|
+
class CommandType
|
53
|
+
ACQUIRE_D3D10_OBJECTS_KHR = 0x4017
|
54
|
+
RELEASE_D3D10_OBJECTS_KHR = 0x4018
|
55
|
+
@codes[0x4017] = 'ACQUIRE_D3D10_OBJECTS_KHR'
|
56
|
+
@codes[0x4018] = 'RELEASE_D3D10_OBJECTS_KHR'
|
57
|
+
end
|
58
|
+
|
59
|
+
[
|
60
|
+
[ "clGetDeviceIDsFromD3D10KHR",
|
61
|
+
:cl_int,
|
62
|
+
[ Platform,
|
63
|
+
:cl_d3d10_device_source_khr,
|
64
|
+
:pointer,
|
65
|
+
:cl_d3d10_device_set_khr,
|
66
|
+
:cl_uint,
|
67
|
+
:pointer,
|
68
|
+
:pointer
|
69
|
+
]
|
70
|
+
], [
|
71
|
+
"clCreateFromD3D10BufferKHR",
|
72
|
+
Mem,
|
73
|
+
[ Context,
|
74
|
+
:cl_mem_flags,
|
75
|
+
:pointer,
|
76
|
+
:pointer ]
|
77
|
+
], [
|
78
|
+
"clCreateFromD3D10Texture2DKHR",
|
79
|
+
Mem,
|
80
|
+
[ Context,
|
81
|
+
:cl_mem_flags,
|
82
|
+
:pointer,
|
83
|
+
:cl_uint,
|
84
|
+
:pointer
|
85
|
+
]
|
86
|
+
], [
|
87
|
+
"clCreateFromD3D10Texture3DKHR",
|
88
|
+
Mem,
|
89
|
+
[ Context,
|
90
|
+
:cl_mem_flags,
|
91
|
+
:pointer,
|
92
|
+
:cl_uint,
|
93
|
+
:pointer
|
94
|
+
]
|
95
|
+
], [
|
96
|
+
"clEnqueueAcquireD3D10ObjectsKHR",
|
97
|
+
:cl_int,
|
98
|
+
[ CommandQueue,
|
99
|
+
:cl_uint,
|
100
|
+
:pointer,
|
101
|
+
:cl_uint,
|
102
|
+
:pointer,
|
103
|
+
:pointer,
|
104
|
+
]
|
105
|
+
], [
|
106
|
+
"clEnqueueReleaseD3D10ObjectsKHR",
|
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
|