… | |
… | |
105 | for my $platform (OpenCL::platforms) { |
105 | for my $platform (OpenCL::platforms) { |
106 | printf "platform: %s\n", $platform->name; |
106 | printf "platform: %s\n", $platform->name; |
107 | printf "extensions: %s\n", $platform->extensions; |
107 | printf "extensions: %s\n", $platform->extensions; |
108 | for my $device ($platform->devices) { |
108 | for my $device ($platform->devices) { |
109 | printf "+ device: %s\n", $device->name; |
109 | printf "+ device: %s\n", $device->name; |
110 | my $ctx = $device->context; |
110 | my $ctx = $platform->context (undef, [$device]); |
111 | # do stuff |
111 | # do stuff |
112 | } |
112 | } |
113 | } |
113 | } |
114 | |
114 | |
115 | =head2 Get a useful context and a command queue. |
115 | =head2 Get a useful context and a command queue. |
… | |
… | |
149 | |
149 | |
150 | =head2 Create and build a program, then create a kernel out of one of its |
150 | =head2 Create and build a program, then create a kernel out of one of its |
151 | functions. |
151 | functions. |
152 | |
152 | |
153 | my $src = ' |
153 | my $src = ' |
154 | __kernel void |
154 | kernel void |
155 | squareit (__global float *input, __global float *output) |
155 | squareit (global float *input, global float *output) |
156 | { |
156 | { |
157 | $id = get_global_id (0); |
157 | $id = get_global_id (0); |
158 | output [id] = input [id] * input [id]; |
158 | output [id] = input [id] * input [id]; |
159 | } |
159 | } |
160 | '; |
160 | '; |
… | |
… | |
271 | ulong IV - Q |
271 | ulong IV - Q |
272 | float NV float f |
272 | float NV float f |
273 | half IV ushort S |
273 | half IV ushort S |
274 | double NV double d |
274 | double NV double d |
275 | |
275 | |
|
|
276 | =head2 OpenGL sharing |
|
|
277 | |
|
|
278 | This module can be optionally compiled with support for |
|
|
279 | OpenGL sharing. The sharing functions are only available when |
|
|
280 | C<OpenCL::HAVE_OPENGL> returns true, otherwise they are absent and cannot |
|
|
281 | be called. |
|
|
282 | |
276 | =head2 THE OpenCL PACKAGE |
283 | =head2 THE OpenCL PACKAGE |
277 | |
284 | |
278 | =over 4 |
285 | =over 4 |
279 | |
286 | |
280 | =item $int = OpenCL::errno |
287 | =item $int = OpenCL::errno |
… | |
… | |
286 | |
293 | |
287 | Comverts an error value into a human readable string. |
294 | Comverts an error value into a human readable string. |
288 | |
295 | |
289 | =item $str = OpenCL::enum2str $enum |
296 | =item $str = OpenCL::enum2str $enum |
290 | |
297 | |
291 | Converts most enum values (inof parameter names, image format constants, |
298 | Converts most enum values (of parameter names, image format constants, |
292 | object types, addressing and filter modes, command types etc.) into a |
299 | object types, addressing and filter modes, command types etc.) into a |
293 | human readbale string. When confronted with some random integer it can be |
300 | human readable string. When confronted with some random integer it can be |
294 | very helpful to pass it through this function to maybe get some readable |
301 | very helpful to pass it through this function to maybe get some readable |
295 | string out of it. |
302 | string out of it. |
296 | |
303 | |
297 | =item @platforms = OpenCL::platforms |
304 | =item @platforms = OpenCL::platforms |
298 | |
305 | |
… | |
… | |
326 | |
333 | |
327 | Tries to create a context. Never worked for me, and you need devices explicitly anyway. |
334 | Tries to create a context. Never worked for me, and you need devices explicitly anyway. |
328 | |
335 | |
329 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
336 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
330 | |
337 | |
331 | =item $ctx = $device->context ($properties = undef, @$devices, $notify = undef) |
338 | =item $ctx = $platform->context ($properties = undef, @$devices, $notify = undef) |
332 | |
339 | |
333 | Create a new OpenCL::Context object using the given device object(s)- a |
340 | Create a new OpenCL::Context object using the given device object(s)- a |
334 | CL_CONTEXT_PLATFORM property is supplied automatically. |
341 | CL_CONTEXT_PLATFORM property is supplied automatically. |
335 | |
342 | |
336 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
343 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
… | |
… | |
1302 | package OpenCL; |
1309 | package OpenCL; |
1303 | |
1310 | |
1304 | use common::sense; |
1311 | use common::sense; |
1305 | |
1312 | |
1306 | BEGIN { |
1313 | BEGIN { |
1307 | our $VERSION = '0.91'; |
1314 | our $VERSION = '0.92'; |
1308 | |
1315 | |
1309 | require XSLoader; |
1316 | require XSLoader; |
1310 | XSLoader::load (__PACKAGE__, $VERSION); |
1317 | XSLoader::load (__PACKAGE__, $VERSION); |
1311 | |
1318 | |
1312 | @OpenCL::Buffer::ISA = |
1319 | @OpenCL::Buffer::ISA = |