opencl_ruby_ffi 0.3 → 0.4
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.
- data/lib/opencl_ruby_ffi/Buffer.rb +2 -2
- data/lib/opencl_ruby_ffi/CommandQueue.rb +118 -63
- data/lib/opencl_ruby_ffi/Context.rb +46 -9
- data/lib/opencl_ruby_ffi/Device.rb +5 -5
- data/lib/opencl_ruby_ffi/Event.rb +18 -7
- data/lib/opencl_ruby_ffi/Image.rb +9 -9
- data/lib/opencl_ruby_ffi/Kernel.rb +14 -14
- data/lib/opencl_ruby_ffi/Mem.rb +7 -7
- data/lib/opencl_ruby_ffi/Platform.rb +41 -17
- data/lib/opencl_ruby_ffi/Program.rb +195 -30
- data/lib/opencl_ruby_ffi/Sampler.rb +1 -1
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb +8 -8
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb +101 -7
- data/opencl_ruby_ffi.gemspec +1 -1
- metadata +2 -2
@@ -1,5 +1,16 @@
|
|
1
1
|
module OpenCL
|
2
2
|
|
3
|
+
# Waits for the command identified by Event objects to complete
|
4
|
+
#
|
5
|
+
# ==== Attributes
|
6
|
+
#
|
7
|
+
# * +event_list+ - a single or an Array of Event to wait upon before returning
|
8
|
+
def self.wait_for_events(event_list)
|
9
|
+
num_events, events = OpenCL.get_event_wait_list( {:event_wait_list => event_list } )
|
10
|
+
error = OpenCL.clWaitForEvents(num_events, events)
|
11
|
+
OpenCL.error_check(error)
|
12
|
+
return nil
|
13
|
+
end
|
3
14
|
|
4
15
|
# Attaches a callback to event that will be called on the given transition
|
5
16
|
#
|
@@ -58,7 +69,7 @@ module OpenCL
|
|
58
69
|
|
59
70
|
# Returns the CommandQueue associated with the Event, if it exists
|
60
71
|
def command_queue
|
61
|
-
ptr = FFI::MemoryPointer
|
72
|
+
ptr = FFI::MemoryPointer::new( CommandQueue )
|
62
73
|
error = OpenCL.clGetEventInfo(self, Event::COMMAND_QUEUE, CommandQueue.size, ptr, nil)
|
63
74
|
OpenCL.error_check(error)
|
64
75
|
pt = ptr.read_pointer
|
@@ -71,7 +82,7 @@ module OpenCL
|
|
71
82
|
|
72
83
|
# Returns the Context associated with the Event
|
73
84
|
def context
|
74
|
-
ptr = FFI::MemoryPointer
|
85
|
+
ptr = FFI::MemoryPointer::new( Context )
|
75
86
|
error = OpenCL.clGetEventInfo(self, Event::CONTEXT, Context.size, ptr, nil)
|
76
87
|
OpenCL.error_check(error)
|
77
88
|
return OpenCL::Context::new( ptr.read_pointer )
|
@@ -82,7 +93,7 @@ module OpenCL
|
|
82
93
|
|
83
94
|
# Returns a CommandExecutionStatus corresponding to the status of the command associtated with the Event
|
84
95
|
def command_execution_status
|
85
|
-
ptr = FFI::MemoryPointer
|
96
|
+
ptr = FFI::MemoryPointer::new( :cl_int )
|
86
97
|
error = OpenCL.clGetEventInfo(self, OpenCL::Event::COMMAND_EXECUTION_STATUS, ptr.size, ptr, nil )
|
87
98
|
OpenCL.error_check(error)
|
88
99
|
return OpenCL::CommandExecutionStatus::new( ptr.read_cl_int )
|
@@ -95,7 +106,7 @@ module OpenCL
|
|
95
106
|
|
96
107
|
# Returns the date the command corresponding to Event was queued
|
97
108
|
def profiling_command_queued
|
98
|
-
ptr = FFI::MemoryPointer
|
109
|
+
ptr = FFI::MemoryPointer::new( :cl_ulong )
|
99
110
|
error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_QUEUED, ptr.size, ptr, nil )
|
100
111
|
OpenCL.error_check(error)
|
101
112
|
return ptr.read_cl_ulong
|
@@ -103,7 +114,7 @@ module OpenCL
|
|
103
114
|
|
104
115
|
# Returns the date the command corresponding to Event was submited
|
105
116
|
def profiling_command_submit
|
106
|
-
ptr = FFI::MemoryPointer
|
117
|
+
ptr = FFI::MemoryPointer::new( :cl_ulong )
|
107
118
|
error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_SUBMIT, ptr.size, ptr, nil )
|
108
119
|
OpenCL.error_check(error)
|
109
120
|
return ptr.read_cl_ulong
|
@@ -111,7 +122,7 @@ module OpenCL
|
|
111
122
|
|
112
123
|
# Returns the date the command corresponding to Event started
|
113
124
|
def profiling_command_start
|
114
|
-
ptr = FFI::MemoryPointer
|
125
|
+
ptr = FFI::MemoryPointer::new( :cl_ulong )
|
115
126
|
error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_START, ptr.size, ptr, nil )
|
116
127
|
OpenCL.error_check(error)
|
117
128
|
return ptr.read_cl_ulong
|
@@ -119,7 +130,7 @@ module OpenCL
|
|
119
130
|
|
120
131
|
# Returns the date the command corresponding to Event ended
|
121
132
|
def profiling_command_end
|
122
|
-
ptr = FFI::MemoryPointer
|
133
|
+
ptr = FFI::MemoryPointer::new( :cl_ulong )
|
123
134
|
error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_END, ptr.size, ptr, nil )
|
124
135
|
OpenCL.error_check(error)
|
125
136
|
return ptr.read_cl_ulong
|
@@ -15,7 +15,7 @@ module OpenCL
|
|
15
15
|
def self.create_image( context, format, desc, options = {} )
|
16
16
|
flags = OpenCL.get_flags( options )
|
17
17
|
host_ptr = options[:host_ptr]
|
18
|
-
error = FFI::MemoryPointer
|
18
|
+
error = FFI::MemoryPointer::new( :cl_int )
|
19
19
|
img_ptr = OpenCL.clCreateImage( context, flags, format, desc, host_ptr, error )
|
20
20
|
OpenCL.error_check(error.read_cl_int)
|
21
21
|
return Image::new(img_ptr, false)
|
@@ -64,7 +64,7 @@ module OpenCL
|
|
64
64
|
end
|
65
65
|
flags = OpenCL.get_flags( options )
|
66
66
|
host_ptr = options[:host_ptr]
|
67
|
-
error = FFI::MemoryPointer
|
67
|
+
error = FFI::MemoryPointer::new( :cl_int )
|
68
68
|
img_ptr = OpenCL.clCreateImage2D( context, flags, format, width, heigh, row_pitch, host_ptr, error )
|
69
69
|
OpenCL.error_check(error.read_cl_int)
|
70
70
|
return Image::new(img_ptr, false)
|
@@ -95,7 +95,7 @@ module OpenCL
|
|
95
95
|
end
|
96
96
|
flags = OpenCL.get_flags( options )
|
97
97
|
host_ptr = options[:host_ptr]
|
98
|
-
error = FFI::MemoryPointer
|
98
|
+
error = FFI::MemoryPointer::new( :cl_int )
|
99
99
|
img_ptr = OpenCL.clCreateImage3D( context, fs, format, width, heigh, depth, row_pitch, slice_pitch, d, error )
|
100
100
|
OpenCL.error_check(error.read_cl_int)
|
101
101
|
return Image::new(img_ptr, false)
|
@@ -114,7 +114,7 @@ module OpenCL
|
|
114
114
|
# * +:flags+ - a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image (default OpenCL::Mem::READ_WRITE)
|
115
115
|
def self.create_from_GL_render_buffer( context, renderbuffer, options = {} )
|
116
116
|
flags = OpenCL.get_flags( options )
|
117
|
-
error = FFI::MemoryPointer
|
117
|
+
error = FFI::MemoryPointer::new( :cl_int )
|
118
118
|
img = OpenCL.clCreateFromGLRenderBuffer( context, flags, renderbuffer, error )
|
119
119
|
OpenCL.error_check(error.read_cl_int)
|
120
120
|
return Image::new( img, false )
|
@@ -140,7 +140,7 @@ module OpenCL
|
|
140
140
|
flags = OpenCL.get_flags( options )
|
141
141
|
miplevel = 0
|
142
142
|
miplevel = options[:miplevel] if options[:miplevel]
|
143
|
-
error = FFI::MemoryPointer
|
143
|
+
error = FFI::MemoryPointer::new( :cl_int )
|
144
144
|
img = OpenCL.clCreateFromGLTexture( context, flags, texture_target, miplevel, texture, error )
|
145
145
|
OpenCL.error_check(error.read_cl_int)
|
146
146
|
return Image::new( img, false )
|
@@ -165,7 +165,7 @@ module OpenCL
|
|
165
165
|
flags = OpenCL.get_flags( options )
|
166
166
|
miplevel = 0
|
167
167
|
miplevel = options[:miplevel] if options[:miplevel]
|
168
|
-
error = FFI::MemoryPointer
|
168
|
+
error = FFI::MemoryPointer::new( :cl_int )
|
169
169
|
img = OpenCL.clCreateFromGLTexture2D( context, flags, texture_target, miplevel, texture, error )
|
170
170
|
OpenCL.error_check(error.read_cl_int)
|
171
171
|
return Image::new( img, false )
|
@@ -190,7 +190,7 @@ module OpenCL
|
|
190
190
|
flags = OpenCL.get_flags( options )
|
191
191
|
miplevel = 0
|
192
192
|
miplevel = options[:miplevel] if options[:miplevel]
|
193
|
-
error = FFI::MemoryPointer
|
193
|
+
error = FFI::MemoryPointer::new( :cl_int )
|
194
194
|
img = OpenCL.clCreateFromGLTexture3D( context, flags, texture_target, miplevel, texture, error )
|
195
195
|
OpenCL.error_check(error.read_cl_int)
|
196
196
|
return Image::new( img, false )
|
@@ -249,7 +249,7 @@ module OpenCL
|
|
249
249
|
|
250
250
|
# Returns the ImageFormat corresponding to the image
|
251
251
|
def format
|
252
|
-
image_format = FFI::MemoryPointer
|
252
|
+
image_format = FFI::MemoryPointer::new( ImageFormat )
|
253
253
|
error = OpenCL.clGetImageInfo( self, OpenCL::Image::FORMAT, image_format.size, image_format, nil)
|
254
254
|
OpenCL.error_check(error)
|
255
255
|
return OpenCL::ImageFormat::from_pointer( image_format )
|
@@ -257,7 +257,7 @@ module OpenCL
|
|
257
257
|
|
258
258
|
# Returns the associated Buffer if any, nil otherwise
|
259
259
|
def buffer
|
260
|
-
ptr = FFI::MemoryPointer
|
260
|
+
ptr = FFI::MemoryPointer::new( OpenCL::Buffer )
|
261
261
|
error = OpenCL.clGetImageInfo(self, OpenCL::Image::BUFFER, OpenCL::Buffer.size, ptr, nil)
|
262
262
|
OpenCL.error_check(error)
|
263
263
|
return nil if ptr.null?
|
@@ -2,21 +2,21 @@ module OpenCL
|
|
2
2
|
|
3
3
|
# Creates an Array of Kernel corresponding to the kernels defined inside the Program
|
4
4
|
def self.create_kernels_in_program( program )
|
5
|
-
num_ptr = FFI::MemoryPointer
|
5
|
+
num_ptr = FFI::MemoryPointer::new( :cl_uint )
|
6
6
|
error = OpenCL. clCreateKernelsInProgram( program, 0, nil, num_ptr )
|
7
7
|
OpenCL.error_check(error)
|
8
8
|
num_kernels = num_ptr.read_cl_uint
|
9
|
-
kernels_ptr = FFI::MemoryPointer
|
9
|
+
kernels_ptr = FFI::MemoryPointer::new( OpenCL::Kernel, num_kernels )
|
10
10
|
error = OpenCL. clCreateKernelsInProgram( program, num_kernels, kernels_ptr, 0 )
|
11
11
|
OpenCL.error_check(error)
|
12
12
|
return kernels_ptr.get_array_of_pointer(0, num_kernels).collect { |kernel_ptr|
|
13
|
-
OpenCL::Kernel
|
13
|
+
OpenCL::Kernel::new(kernel_ptr, false)
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
17
|
# Returns the Kernel corresponding the the specified name in the given Program
|
18
18
|
def self.create_kernel(program, name)
|
19
|
-
pointer_err = FFI::MemoryPointer
|
19
|
+
pointer_err = FFI::MemoryPointer::new( :cl_int )
|
20
20
|
kernel_ptr = OpenCL.clCreateKernel(program, name, pointer_err)
|
21
21
|
OpenCL.error_check(pointer_err.read_cl_int)
|
22
22
|
return OpenCL::Kernel::new( kernel_ptr, false )
|
@@ -28,7 +28,7 @@ module OpenCL
|
|
28
28
|
sz = value.class.size if sz == nil
|
29
29
|
val = value
|
30
30
|
if value.kind_of?(OpenCL::Mem) then
|
31
|
-
val = FFI::MemoryPointer
|
31
|
+
val = FFI::MemoryPointer::new( OpenCL::Mem )
|
32
32
|
val.write_pointer(value.to_ptr)
|
33
33
|
end
|
34
34
|
error = OpenCL.clSetKernelArg( kernel, index, sz, val )
|
@@ -54,7 +54,7 @@ module OpenCL
|
|
54
54
|
# Returns an AddressQualifier corresponding to the Arg
|
55
55
|
def address_qualifier
|
56
56
|
OpenCL.error_check(OpenCL::INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
57
|
-
ptr = FFI::MemoryPointer
|
57
|
+
ptr = FFI::MemoryPointer::new( :cl_kernel_arg_address_qualifier )
|
58
58
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, OpenCL::Kernel::Arg::ADDRESS_QUALIFIER, ptr.size, ptr, nil)
|
59
59
|
OpenCL.error_check(error)
|
60
60
|
return OpenCL::Kernel::Arg::AddressQualifier::new( ptr.read_cl_kernel_arg_address_qualifier )
|
@@ -63,7 +63,7 @@ module OpenCL
|
|
63
63
|
# Returns an AccessQualifier corresponding to the Arg
|
64
64
|
def access_qualifier
|
65
65
|
OpenCL.error_check(OpenCL::INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
66
|
-
ptr = FFI::MemoryPointer
|
66
|
+
ptr = FFI::MemoryPointer::new( :cl_kernel_arg_access_qualifier )
|
67
67
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, OpenCL::Kernel::Arg::ACCESS_QUALIFIER, ptr.size, ptr, nil)
|
68
68
|
OpenCL.error_check(error)
|
69
69
|
return OpenCL::Kernel::Arg::AccessQualifier::new( ptr.read_cl_kernel_arg_access_qualifier )
|
@@ -72,7 +72,7 @@ module OpenCL
|
|
72
72
|
# Returns a TypeQualifier corresponding to the Arg
|
73
73
|
def type_qualifier
|
74
74
|
OpenCL.error_check(OpenCL::INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
75
|
-
ptr = FFI::MemoryPointer
|
75
|
+
ptr = FFI::MemoryPointer::new( :cl_kernel_arg_type_qualifier )
|
76
76
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, OpenCL::Kernel::Arg::TYPE_QUALIFIER, ptr.size, ptr, nil)
|
77
77
|
OpenCL.error_check(error)
|
78
78
|
return OpenCL::Kernel::Arg::TypeQualifier::new( ptr.read_cl_kernel_arg_type_qualifier )
|
@@ -81,10 +81,10 @@ module OpenCL
|
|
81
81
|
# Returns a String corresponding to the Arg type name
|
82
82
|
def type_name
|
83
83
|
OpenCL.error_check(OpenCL::INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
84
|
-
ptr1 = FFI::MemoryPointer
|
84
|
+
ptr1 = FFI::MemoryPointer::new( :size_t, 1)
|
85
85
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, OpenCL::Kernel::Arg::TYPE_NAME, 0, nil, ptr1)
|
86
86
|
OpenCL.error_check(error)
|
87
|
-
ptr2 = FFI::MemoryPointer
|
87
|
+
ptr2 = FFI::MemoryPointer::new( ptr1.read_size_t )
|
88
88
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, OpenCL::Kernel::Arg::TYPE_NAME, ptr1.read_size_t, ptr2, nil)
|
89
89
|
OpenCL.error_check(error)
|
90
90
|
return ptr2.read_string
|
@@ -93,10 +93,10 @@ module OpenCL
|
|
93
93
|
# Returns a String corresponding to the Arg name
|
94
94
|
def name
|
95
95
|
OpenCL.error_check(OpenCL::INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
|
96
|
-
ptr1 = FFI::MemoryPointer
|
96
|
+
ptr1 = FFI::MemoryPointer::new( :size_t, 1)
|
97
97
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, OpenCL::Kernel::Arg::NAME, 0, nil, ptr1)
|
98
98
|
OpenCL.error_check(error)
|
99
|
-
ptr2 = FFI::MemoryPointer
|
99
|
+
ptr2 = FFI::MemoryPointer::new( ptr1.read_size_t )
|
100
100
|
error = OpenCL.clGetKernelArgInfo(@kernel, @index, OpenCL::Kernel::Arg::NAME, ptr1.read_size_t, ptr2, nil)
|
101
101
|
OpenCL.error_check(error)
|
102
102
|
return ptr2.read_string
|
@@ -143,7 +143,7 @@ module OpenCL
|
|
143
143
|
|
144
144
|
# Returns the Context the Kernel is associated with
|
145
145
|
def context
|
146
|
-
ptr = FFI::MemoryPointer
|
146
|
+
ptr = FFI::MemoryPointer::new( Context )
|
147
147
|
error = OpenCL.clGetKernelInfo(self, Kernel::CONTEXT, Context.size, ptr, nil)
|
148
148
|
OpenCL.error_check(error)
|
149
149
|
return OpenCL::Context::new( ptr.read_pointer )
|
@@ -151,7 +151,7 @@ module OpenCL
|
|
151
151
|
|
152
152
|
# Returns the Program the Kernel was created from
|
153
153
|
def program
|
154
|
-
ptr = FFI::MemoryPointer
|
154
|
+
ptr = FFI::MemoryPointer::new( Program )
|
155
155
|
error = OpenCL.clGetKernelInfo(self, Kernel::PROGRAM, Program.size, ptr, nil)
|
156
156
|
OpenCL.error_check(error)
|
157
157
|
return OpenCL::Program::new(ptr.read_pointer)
|
data/lib/opencl_ruby_ffi/Mem.rb
CHANGED
@@ -23,7 +23,7 @@ module OpenCL
|
|
23
23
|
|
24
24
|
# Returns the Context associated to the Mem
|
25
25
|
def context
|
26
|
-
ptr = FFI::MemoryPointer
|
26
|
+
ptr = FFI::MemoryPointer::new( Context )
|
27
27
|
error = OpenCL.clGetMemObjectInfo(self, Mem::CONTEXT, Context.size, ptr, nil)
|
28
28
|
OpenCL.error_check(error)
|
29
29
|
return OpenCL::Context::new( ptr.read_pointer )
|
@@ -36,7 +36,7 @@ module OpenCL
|
|
36
36
|
|
37
37
|
# Returns the Buffer this Buffer was created from using create_sub_buffer
|
38
38
|
def associated_memobject
|
39
|
-
ptr = FFI::MemoryPointer
|
39
|
+
ptr = FFI::MemoryPointer::new( Mem )
|
40
40
|
error = OpenCL.clGetMemObjectInfo(self, Mem::ASSOCIATED_MEMOBJECT, Mem.size, ptr, nil)
|
41
41
|
OpenCL.error_check(error)
|
42
42
|
return nil if ptr.read_pointer.null?
|
@@ -96,7 +96,7 @@ module OpenCL
|
|
96
96
|
|
97
97
|
# Returns the texture_target argument specified in create_from_GL_texture for Mem
|
98
98
|
def GL_texture_target
|
99
|
-
param_value = MemoryPointer
|
99
|
+
param_value = MemoryPointer::new( :cl_GLenum )
|
100
100
|
error = OpenCL.clGetGLTextureInfo( self, OpenCL::GL_TEXTURE_TARGET, param_value.size, param_value, nil )
|
101
101
|
OpenCL.error_check(error)
|
102
102
|
return param_value.read_cl_GLenum
|
@@ -104,7 +104,7 @@ module OpenCL
|
|
104
104
|
|
105
105
|
# Returns the miplevel argument specified in create_from_GL_texture for Mem
|
106
106
|
def GL_mimap_level
|
107
|
-
param_value = MemoryPointer
|
107
|
+
param_value = MemoryPointer::new( :cl_GLint )
|
108
108
|
error = OpenCL.clGetGLTextureInfo( self, OpenCL::GL_MIPMAP_LEVEL, param_value.size, param_value, nil )
|
109
109
|
OpenCL.error_check(error)
|
110
110
|
return param_value.read_cl_GLint
|
@@ -112,15 +112,15 @@ module OpenCL
|
|
112
112
|
|
113
113
|
# Returns the type of the GL object associated with Mem
|
114
114
|
def GL_object_type
|
115
|
-
param_value = MemoryPointer
|
115
|
+
param_value = MemoryPointer::new( :cl_gl_object_type )
|
116
116
|
error = OpenCL.clGetGLObjectInfo( self, param_value, nil )
|
117
117
|
OpenCL.error_check(error)
|
118
|
-
return OpenCL::GLObjectType(param_value.read_cl_gl_object_type)
|
118
|
+
return OpenCL::GLObjectType::new(param_value.read_cl_gl_object_type)
|
119
119
|
end
|
120
120
|
|
121
121
|
# Returns the name of the GL object associated with Mem
|
122
122
|
def GL_object_name
|
123
|
-
param_value = MemoryPointer
|
123
|
+
param_value = MemoryPointer::new( :cl_GLuint )
|
124
124
|
error = OpenCL.clGetGLObjectInfo( self, nil, param_value )
|
125
125
|
OpenCL.error_check(error)
|
126
126
|
return param_value.read_cl_GLuint
|
@@ -1,5 +1,24 @@
|
|
1
1
|
module OpenCL
|
2
2
|
|
3
|
+
# Unloads a Platform compiler
|
4
|
+
#
|
5
|
+
# ==== Attributes
|
6
|
+
#
|
7
|
+
# * +platform+ - the Platform to have it's compiler unloaded
|
8
|
+
def self.unload_platform_compiler(platform)
|
9
|
+
OpenCL.error_check(OpenCL::INVALID_OPERATION) if self.version_number < 1.2
|
10
|
+
error = OpenCL.clUnloadPlatformCompiler( platform )
|
11
|
+
OpenCL.error_check(error)
|
12
|
+
return platform
|
13
|
+
end
|
14
|
+
|
15
|
+
# Unloads the compiler
|
16
|
+
def self.unload_compiler
|
17
|
+
error = OpenCL.clUnloadCompiler()
|
18
|
+
OpenCL.error_check(error)
|
19
|
+
return nil
|
20
|
+
end
|
21
|
+
|
3
22
|
# Returns an FFI::Function corresponding to an extension function
|
4
23
|
#
|
5
24
|
# ==== Attributes
|
@@ -15,20 +34,6 @@ module OpenCL
|
|
15
34
|
return FFI::Function::new(return_type, param_types, ptr, options)
|
16
35
|
end
|
17
36
|
|
18
|
-
# Returns an Array of Platforms containing the available OpenCL platforms
|
19
|
-
def self.get_platforms
|
20
|
-
ptr1 = FFI::MemoryPointer.new(:cl_uint , 1)
|
21
|
-
|
22
|
-
error = OpenCL::clGetPlatformIDs(0, nil, ptr1)
|
23
|
-
OpenCL.error_check(error)
|
24
|
-
ptr2 = FFI::MemoryPointer.new(:pointer, ptr1.read_uint)
|
25
|
-
error = OpenCL::clGetPlatformIDs(ptr1.read_uint(), ptr2, nil)
|
26
|
-
OpenCL.error_check(error)
|
27
|
-
return ptr2.get_array_of_pointer(0,ptr1.read_uint()).collect { |platform_ptr|
|
28
|
-
OpenCL::Platform.new(platform_ptr)
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
37
|
# Returns an FFI::Function corresponding to an extension function for the Platform
|
33
38
|
#
|
34
39
|
# ==== Attributes
|
@@ -46,6 +51,20 @@ module OpenCL
|
|
46
51
|
return FFI::Function::new(return_type, param_types, ptr, options)
|
47
52
|
end
|
48
53
|
|
54
|
+
# Returns an Array of Platforms containing the available OpenCL platforms
|
55
|
+
def self.get_platforms
|
56
|
+
ptr1 = FFI::MemoryPointer::new(:cl_uint , 1)
|
57
|
+
|
58
|
+
error = OpenCL::clGetPlatformIDs(0, nil, ptr1)
|
59
|
+
OpenCL.error_check(error)
|
60
|
+
ptr2 = FFI::MemoryPointer::new(:pointer, ptr1.read_uint)
|
61
|
+
error = OpenCL::clGetPlatformIDs(ptr1.read_uint(), ptr2, nil)
|
62
|
+
OpenCL.error_check(error)
|
63
|
+
return ptr2.get_array_of_pointer(0,ptr1.read_uint()).collect { |platform_ptr|
|
64
|
+
OpenCL::Platform::new(platform_ptr, false)
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
49
68
|
|
50
69
|
# Maps the cl_platform_id object of OpenCL
|
51
70
|
class Platform
|
@@ -56,14 +75,14 @@ module OpenCL
|
|
56
75
|
# Returns an Array of Device corresponding to the available devices on the Platform
|
57
76
|
# The type of the desired devices can be specified
|
58
77
|
def devices(type = OpenCL::Device::Type::ALL)
|
59
|
-
ptr1 = FFI::MemoryPointer
|
78
|
+
ptr1 = FFI::MemoryPointer::new(:cl_uint , 1)
|
60
79
|
error = OpenCL::clGetDeviceIDs(self, type, 0, nil, ptr1)
|
61
80
|
OpenCL.error_check(error)
|
62
|
-
ptr2 = FFI::MemoryPointer
|
81
|
+
ptr2 = FFI::MemoryPointer::new(:pointer, ptr1.read_uint)
|
63
82
|
error = OpenCL::clGetDeviceIDs(self, type, ptr1.read_uint(), ptr2, nil)
|
64
83
|
OpenCL.error_check(error)
|
65
84
|
return ptr2.get_array_of_pointer(0, ptr1.read_uint()).collect { |device_ptr|
|
66
|
-
OpenCL::Device
|
85
|
+
OpenCL::Device::new(device_ptr, false)
|
67
86
|
}
|
68
87
|
end
|
69
88
|
|
@@ -74,6 +93,11 @@ module OpenCL
|
|
74
93
|
return n.first.first.to_f
|
75
94
|
end
|
76
95
|
|
96
|
+
# Unloads the Platform compiler
|
97
|
+
def unload_compiler
|
98
|
+
return OpenCL.unload_platform_compiler(self)
|
99
|
+
end
|
100
|
+
|
77
101
|
# Returns an FFI::Function corresponding to an extension function for a Platform
|
78
102
|
#
|
79
103
|
# ==== Attributes
|