ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/OpenCL/OpenCL.xs
(Generate patch)

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.8 by root, Thu Nov 17 02:54:14 2011 UTC vs.
Revision 1.16 by root, Tue Nov 22 10:29:18 2011 UTC

2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4 4
5#include <CL/opencl.h> 5#include <CL/opencl.h>
6 6
7typedef cl_platform_id OpenCL__Platform; 7typedef cl_platform_id OpenCL__Platform;
8typedef cl_device_id OpenCL__Device; 8typedef cl_device_id OpenCL__Device;
9typedef cl_context OpenCL__Context; 9typedef cl_context OpenCL__Context;
10typedef cl_command_queue OpenCL__Queue; 10typedef cl_command_queue OpenCL__Queue;
11typedef cl_mem OpenCL__Memory; 11typedef cl_mem OpenCL__Memory;
12typedef cl_mem OpenCL__Buffer; 12typedef cl_mem OpenCL__Buffer;
13typedef cl_mem OpenCL__Image; 13typedef cl_mem OpenCL__Image;
14typedef cl_mem OpenCL__Image2D; 14typedef cl_mem OpenCL__Image2D;
15typedef cl_mem OpenCL__Image3D; 15typedef cl_mem OpenCL__Image3D;
16typedef cl_mem OpenCL__Memory_ornull; 16typedef cl_mem OpenCL__Memory_ornull;
17typedef cl_mem OpenCL__Buffer_ornull; 17typedef cl_mem OpenCL__Buffer_ornull;
18typedef cl_mem OpenCL__Image_ornull; 18typedef cl_mem OpenCL__Image_ornull;
19typedef cl_mem OpenCL__Image2D_ornull; 19typedef cl_mem OpenCL__Image2D_ornull;
20typedef cl_mem OpenCL__Image3D_ornull; 20typedef cl_mem OpenCL__Image3D_ornull;
21typedef cl_sampler OpenCL__Sampler; 21typedef cl_sampler OpenCL__Sampler;
22typedef cl_program OpenCL__Program; 22typedef cl_program OpenCL__Program;
23typedef cl_kernel OpenCL__Kernel; 23typedef cl_kernel OpenCL__Kernel;
24typedef cl_event OpenCL__Event; 24typedef cl_event OpenCL__Event;
25typedef cl_event OpenCL__UserEvent; 25typedef cl_event OpenCL__UserEvent;
26 26
27typedef SV *FUTURE; 27typedef SV *FUTURE;
28 28
29/*****************************************************************************/ 29/*****************************************************************************/
30 30
126 croak ("%s: %s is not of type %s", func, svname, pkg); 126 croak ("%s: %s is not of type %s", func, svname, pkg);
127} 127}
128 128
129/*****************************************************************************/ 129/*****************************************************************************/
130 130
131static size_t
132img_row_pitch (cl_mem img)
133{
134 size_t res;
135 clGetImageInfo (img, CL_IMAGE_ROW_PITCH, sizeof (res), &res, 0);
136 return res;
137}
138
131static cl_event * 139static cl_event *
132event_list (SV **items, int count) 140event_list (SV **items, int count)
133{ 141{
134 cl_event *list = tmpbuf (sizeof (cl_event) * count); 142 cl_event *list = tmpbuf (sizeof (cl_event) * count);
135 143
144 cl_event *event_list_ptr = event_list (&ST (items), event_list_count) 152 cl_event *event_list_ptr = event_list (&ST (items), event_list_count)
145 153
146#define INFO(class) \ 154#define INFO(class) \
147{ \ 155{ \
148 size_t size; \ 156 size_t size; \
149 SV *sv; \
150 \
151 NEED_SUCCESS (Get ## class ## Info, (this, name, 0, 0, &size)); \ 157 NEED_SUCCESS (Get ## class ## Info, (this, name, 0, 0, &size)); \
152 sv = sv_2mortal (newSV (size)); \ 158 SV *sv = sv_2mortal (newSV (size)); \
153 SvUPGRADE (sv, SVt_PV); \ 159 SvUPGRADE (sv, SVt_PV); \
154 SvPOK_only (sv); \ 160 SvPOK_only (sv); \
155 SvCUR_set (sv, size); \ 161 SvCUR_set (sv, size); \
156 NEED_SUCCESS (Get ## class ## Info, (this, name, size, SvPVX (sv), 0)); \ 162 NEED_SUCCESS (Get ## class ## Info, (this, name, size, SvPVX (sv), 0)); \
157 XPUSHs (sv); \ 163 XPUSHs (sv); \
194enum2str (cl_uint value) 200enum2str (cl_uint value)
195 201
196void 202void
197platforms () 203platforms ()
198 PPCODE: 204 PPCODE:
199{
200 cl_platform_id *list; 205 cl_platform_id *list;
201 cl_uint count; 206 cl_uint count;
202 int i; 207 int i;
203 208
204 NEED_SUCCESS (GetPlatformIDs, (0, 0, &count)); 209 NEED_SUCCESS (GetPlatformIDs, (0, 0, &count));
206 NEED_SUCCESS (GetPlatformIDs, (count, list, 0)); 211 NEED_SUCCESS (GetPlatformIDs, (count, list, 0));
207 212
208 EXTEND (SP, count); 213 EXTEND (SP, count);
209 for (i = 0; i < count; ++i) 214 for (i = 0; i < count; ++i)
210 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Platform", list [i])); 215 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Platform", list [i]));
211}
212 216
213void 217void
214context_from_type (FUTURE properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0) 218context_from_type (FUTURE properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0)
215 PPCODE: 219 PPCODE:
216 NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (0, type, 0, 0, &res)); 220 NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (0, type, 0, 0, &res));
222 /* der Gipfel der Kunst */ 226 /* der Gipfel der Kunst */
223 227
224void 228void
225wait_for_events (...) 229wait_for_events (...)
226 CODE: 230 CODE:
227{
228 EVENT_LIST (0, items); 231 EVENT_LIST (0, items);
229 NEED_SUCCESS (WaitForEvents, (event_list_count, event_list_ptr)); 232 NEED_SUCCESS (WaitForEvents, (event_list_count, event_list_ptr));
230}
231 233
232PROTOTYPES: DISABLE 234PROTOTYPES: DISABLE
233 235
234MODULE = OpenCL PACKAGE = OpenCL::Platform 236MODULE = OpenCL PACKAGE = OpenCL::Platform
235 237
236void 238void
237info (OpenCL::Platform this, cl_platform_info name) 239info (OpenCL::Platform this, cl_platform_info name)
238 PPCODE: 240 PPCODE:
239 INFO (Platform) 241 INFO (Platform)
240 242
243#BEGIN:platform
244
245void
246profile (OpenCL::Platform this)
247 ALIAS:
248 profile = CL_PLATFORM_PROFILE
249 version = CL_PLATFORM_VERSION
250 name = CL_PLATFORM_NAME
251 vendor = CL_PLATFORM_VENDOR
252 extensions = CL_PLATFORM_EXTENSIONS
253 PPCODE:
254 size_t size;
255 NEED_SUCCESS (GetPlatformInfo, (this, ix, 0, 0, &size));
256 char *value = tmpbuf (size);
257 NEED_SUCCESS (GetPlatformInfo, (this, ix, size, value, 0));
258 EXTEND (SP, 1);
259 const int i = 0;
260 PUSHs (sv_2mortal (newSVpv (value, 0)));
261
262#END:platform
263
241void 264void
242devices (OpenCL::Platform this, cl_device_type type = CL_DEVICE_TYPE_ALL) 265devices (OpenCL::Platform this, cl_device_type type = CL_DEVICE_TYPE_ALL)
243 PPCODE: 266 PPCODE:
244{
245 cl_device_id *list; 267 cl_device_id *list;
246 cl_uint count; 268 cl_uint count;
247 int i; 269 int i;
248 270
249 NEED_SUCCESS (GetDeviceIDs, (this, type, 0, 0, &count)); 271 NEED_SUCCESS (GetDeviceIDs, (this, type, 0, 0, &count));
251 NEED_SUCCESS (GetDeviceIDs, (this, type, count, list, 0)); 273 NEED_SUCCESS (GetDeviceIDs, (this, type, count, list, 0));
252 274
253 EXTEND (SP, count); 275 EXTEND (SP, count);
254 for (i = 0; i < count; ++i) 276 for (i = 0; i < count; ++i)
255 PUSHs (sv_setref_pv (sv_newmortal (), "OpenCL::Device", list [i])); 277 PUSHs (sv_setref_pv (sv_newmortal (), "OpenCL::Device", list [i]));
256}
257 278
258void 279void
259context (OpenCL::Platform this, FUTURE properties, SV *devices, FUTURE notify = 0) 280context (OpenCL::Platform this, FUTURE properties, SV *devices, FUTURE notify = 0)
260 PPCODE: 281 PPCODE:
261 if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV) 282 if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV)
262 croak ("OpenCL::Platform argument 'device' must be an arrayref with device objects, in call"); 283 croak ("OpenCL::Platform argument 'device' must be an arrayref with device objects, in call");
263 284
264 AV *av = (SV *)SvRV (devices); 285 AV *av = (AV *)SvRV (devices);
265 cl_uint num_devices = av_len (av) + 1; 286 cl_uint num_devices = av_len (av) + 1;
266 cl_device_id *device_list = tmpbuf (sizeof (cl_device_id) * num_devices); 287 cl_device_id *device_list = tmpbuf (sizeof (cl_device_id) * num_devices);
267 int i; 288 int i;
268 289
269 for (i = num_devices; i--; ) 290 for (i = num_devices; i--; )
283 304
284void 305void
285info (OpenCL::Device this, cl_device_info name) 306info (OpenCL::Device this, cl_device_info name)
286 PPCODE: 307 PPCODE:
287 INFO (Device) 308 INFO (Device)
309
310#BEGIN:device
311
312void
313type (OpenCL::Device this)
314 PPCODE:
315 cl_device_type value [1];
316 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_TYPE, sizeof (value), value, 0));
317 EXTEND (SP, 1);
318 const int i = 0;
319 PUSHs (sv_2mortal (newSViv (value [i])));
320
321void
322vendor_id (OpenCL::Device this)
323 ALIAS:
324 vendor_id = CL_DEVICE_VENDOR_ID
325 max_compute_units = CL_DEVICE_MAX_COMPUTE_UNITS
326 max_work_item_dimensions = CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
327 preferred_vector_width_char = CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR
328 preferred_vector_width_short = CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT
329 preferred_vector_width_int = CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT
330 preferred_vector_width_long = CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG
331 preferred_vector_width_float = CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT
332 preferred_vector_width_double = CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE
333 max_clock_frequency = CL_DEVICE_MAX_CLOCK_FREQUENCY
334 max_read_image_args = CL_DEVICE_MAX_READ_IMAGE_ARGS
335 max_write_image_args = CL_DEVICE_MAX_WRITE_IMAGE_ARGS
336 image_support = CL_DEVICE_IMAGE_SUPPORT
337 max_samplers = CL_DEVICE_MAX_SAMPLERS
338 mem_base_addr_align = CL_DEVICE_MEM_BASE_ADDR_ALIGN
339 min_data_type_align_size = CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE
340 global_mem_cacheline_size = CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE
341 max_constant_args = CL_DEVICE_MAX_CONSTANT_ARGS
342 preferred_vector_width_half = CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF
343 native_vector_width_char = CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR
344 native_vector_width_short = CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT
345 native_vector_width_int = CL_DEVICE_NATIVE_VECTOR_WIDTH_INT
346 native_vector_width_long = CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG
347 native_vector_width_float = CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT
348 native_vector_width_double = CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE
349 native_vector_width_half = CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF
350 reference_count_ext = CL_DEVICE_REFERENCE_COUNT_EXT
351 PPCODE:
352 cl_uint value [1];
353 NEED_SUCCESS (GetDeviceInfo, (this, ix, sizeof (value), value, 0));
354 EXTEND (SP, 1);
355 const int i = 0;
356 PUSHs (sv_2mortal (newSVuv (value [i])));
357
358void
359max_work_group_size (OpenCL::Device this)
360 ALIAS:
361 max_work_group_size = CL_DEVICE_MAX_WORK_GROUP_SIZE
362 image2d_max_width = CL_DEVICE_IMAGE2D_MAX_WIDTH
363 image2d_max_height = CL_DEVICE_IMAGE2D_MAX_HEIGHT
364 image3d_max_width = CL_DEVICE_IMAGE3D_MAX_WIDTH
365 image3d_max_height = CL_DEVICE_IMAGE3D_MAX_HEIGHT
366 image3d_max_depth = CL_DEVICE_IMAGE3D_MAX_DEPTH
367 max_parameter_size = CL_DEVICE_MAX_PARAMETER_SIZE
368 profiling_timer_resolution = CL_DEVICE_PROFILING_TIMER_RESOLUTION
369 PPCODE:
370 size_t value [1];
371 NEED_SUCCESS (GetDeviceInfo, (this, ix, sizeof (value), value, 0));
372 EXTEND (SP, 1);
373 const int i = 0;
374 PUSHs (sv_2mortal (newSVuv (value [i])));
375
376void
377max_work_item_sizes (OpenCL::Device this)
378 PPCODE:
379 size_t size;
380 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_MAX_WORK_ITEM_SIZES, 0, 0, &size));
381 size_t *value = tmpbuf (size);
382 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_MAX_WORK_ITEM_SIZES, size, value, 0));
383 int i, n = size / sizeof (*value);
384 EXTEND (SP, n);
385 for (i = 0; i < n; ++i)
386 PUSHs (sv_2mortal (newSVuv (value [i])));
387
388void
389address_bits (OpenCL::Device this)
390 PPCODE:
391 cl_bitfield value [1];
392 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_ADDRESS_BITS, sizeof (value), value, 0));
393 EXTEND (SP, 1);
394 const int i = 0;
395 PUSHs (sv_2mortal (newSVuv (value [i])));
396
397void
398max_mem_alloc_size (OpenCL::Device this)
399 ALIAS:
400 max_mem_alloc_size = CL_DEVICE_MAX_MEM_ALLOC_SIZE
401 global_mem_cache_size = CL_DEVICE_GLOBAL_MEM_CACHE_SIZE
402 global_mem_size = CL_DEVICE_GLOBAL_MEM_SIZE
403 max_constant_buffer_size = CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE
404 local_mem_size = CL_DEVICE_LOCAL_MEM_SIZE
405 PPCODE:
406 cl_ulong value [1];
407 NEED_SUCCESS (GetDeviceInfo, (this, ix, sizeof (value), value, 0));
408 EXTEND (SP, 1);
409 const int i = 0;
410 PUSHs (sv_2mortal (newSVuv (value [i])));
411
412void
413single_fp_config (OpenCL::Device this)
414 ALIAS:
415 single_fp_config = CL_DEVICE_SINGLE_FP_CONFIG
416 double_fp_config = CL_DEVICE_DOUBLE_FP_CONFIG
417 half_fp_config = CL_DEVICE_HALF_FP_CONFIG
418 PPCODE:
419 cl_device_fp_config value [1];
420 NEED_SUCCESS (GetDeviceInfo, (this, ix, sizeof (value), value, 0));
421 EXTEND (SP, 1);
422 const int i = 0;
423 PUSHs (sv_2mortal (newSVuv (value [i])));
424
425void
426global_mem_cache_type (OpenCL::Device this)
427 PPCODE:
428 cl_device_mem_cache_type value [1];
429 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, sizeof (value), value, 0));
430 EXTEND (SP, 1);
431 const int i = 0;
432 PUSHs (sv_2mortal (newSVuv (value [i])));
433
434void
435local_mem_type (OpenCL::Device this)
436 PPCODE:
437 cl_device_local_mem_type value [1];
438 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_LOCAL_MEM_TYPE, sizeof (value), value, 0));
439 EXTEND (SP, 1);
440 const int i = 0;
441 PUSHs (sv_2mortal (newSVuv (value [i])));
442
443void
444error_correction_support (OpenCL::Device this)
445 ALIAS:
446 error_correction_support = CL_DEVICE_ERROR_CORRECTION_SUPPORT
447 endian_little = CL_DEVICE_ENDIAN_LITTLE
448 available = CL_DEVICE_AVAILABLE
449 compiler_available = CL_DEVICE_COMPILER_AVAILABLE
450 host_unified_memory = CL_DEVICE_HOST_UNIFIED_MEMORY
451 PPCODE:
452 cl_bool value [1];
453 NEED_SUCCESS (GetDeviceInfo, (this, ix, sizeof (value), value, 0));
454 EXTEND (SP, 1);
455 const int i = 0;
456 PUSHs (sv_2mortal (value [i] ? &PL_sv_yes : &PL_sv_no));
457
458void
459execution_capabilities (OpenCL::Device this)
460 PPCODE:
461 cl_device_exec_capabilities value [1];
462 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_EXECUTION_CAPABILITIES, sizeof (value), value, 0));
463 EXTEND (SP, 1);
464 const int i = 0;
465 PUSHs (sv_2mortal (newSVuv (value [i])));
466
467void
468properties (OpenCL::Device this)
469 PPCODE:
470 cl_command_queue_properties value [1];
471 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_QUEUE_PROPERTIES, sizeof (value), value, 0));
472 EXTEND (SP, 1);
473 const int i = 0;
474 PUSHs (sv_2mortal (newSViv (value [i])));
475
476void
477platform (OpenCL::Device this)
478 PPCODE:
479 cl_platform_id value [1];
480 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_PLATFORM, sizeof (value), value, 0));
481 EXTEND (SP, 1);
482 const int i = 0;
483 {
484 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Platform", value [i]));
485 }
486
487void
488name (OpenCL::Device this)
489 ALIAS:
490 name = CL_DEVICE_NAME
491 vendor = CL_DEVICE_VENDOR
492 driver_version = CL_DRIVER_VERSION
493 profile = CL_DEVICE_PROFILE
494 version = CL_DEVICE_VERSION
495 extensions = CL_DEVICE_EXTENSIONS
496 PPCODE:
497 size_t size;
498 NEED_SUCCESS (GetDeviceInfo, (this, ix, 0, 0, &size));
499 char *value = tmpbuf (size);
500 NEED_SUCCESS (GetDeviceInfo, (this, ix, size, value, 0));
501 EXTEND (SP, 1);
502 const int i = 0;
503 PUSHs (sv_2mortal (newSVpv (value, 0)));
504
505void
506parent_device_ext (OpenCL::Device this)
507 PPCODE:
508 cl_device_id value [1];
509 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_PARENT_DEVICE_EXT, sizeof (value), value, 0));
510 EXTEND (SP, 1);
511 const int i = 0;
512 {
513 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Device", value [i]));
514 }
515
516void
517partition_types_ext (OpenCL::Device this)
518 ALIAS:
519 partition_types_ext = CL_DEVICE_PARTITION_TYPES_EXT
520 affinity_domains_ext = CL_DEVICE_AFFINITY_DOMAINS_EXT
521 partition_style_ext = CL_DEVICE_PARTITION_STYLE_EXT
522 PPCODE:
523 size_t size;
524 NEED_SUCCESS (GetDeviceInfo, (this, ix, 0, 0, &size));
525 cl_device_partition_property_ext *value = tmpbuf (size);
526 NEED_SUCCESS (GetDeviceInfo, (this, ix, size, value, 0));
527 int i, n = size / sizeof (*value);
528 EXTEND (SP, n);
529 for (i = 0; i < n; ++i)
530 PUSHs (sv_2mortal (newSVuv (value [i])));
531
532#END:device
288 533
289MODULE = OpenCL PACKAGE = OpenCL::Context 534MODULE = OpenCL PACKAGE = OpenCL::Context
290 535
291void 536void
292DESTROY (OpenCL::Context context) 537DESTROY (OpenCL::Context context)
330 575
331 NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (this, flags, len, ptr, &res)); 576 NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (this, flags, len, ptr, &res));
332 XPUSH_NEW_OBJ ("OpenCL::Buffer", mem); 577 XPUSH_NEW_OBJ ("OpenCL::Buffer", mem);
333 578
334void 579void
335image2d (OpenCL::Context this, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, SV *data) 580image2d (OpenCL::Context this, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t row_pitch = 0, SV *data = &PL_sv_undef)
336 PPCODE: 581 PPCODE:
337 STRLEN len; 582 STRLEN len;
338 char *ptr = SvPVbyte (data, len); 583 char *ptr = SvPVbyte (data, len);
339 const cl_image_format format = { channel_order, channel_type }; 584 const cl_image_format format = { channel_order, channel_type };
340 NEED_SUCCESS_ARG (cl_mem mem, CreateImage2D, (this, flags, &format, width, height, len / height, ptr, &res)); 585 NEED_SUCCESS_ARG (cl_mem mem, CreateImage2D, (this, flags, &format, width, height, row_pitch, ptr, &res));
341 XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); 586 XPUSH_NEW_OBJ ("OpenCL::Image2D", mem);
342 587
343void 588void
344image3d (OpenCL::Context this, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t depth, size_t slice_pitch, SV *data) 589image3d (OpenCL::Context this, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t depth, size_t row_pitch = 0, size_t slice_pitch = 0, SV *data = &PL_sv_undef)
345 PPCODE: 590 PPCODE:
346 STRLEN len; 591 STRLEN len;
347 char *ptr = SvPVbyte (data, len); 592 char *ptr = SvPVbyte (data, len);
348 const cl_image_format format = { channel_order, channel_type }; 593 const cl_image_format format = { channel_order, channel_type };
349 NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (this, flags, &format, width, height, 594 NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (this, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res));
350 depth, len / (height * slice_pitch), slice_pitch, ptr, &res));
351 XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); 595 XPUSH_NEW_OBJ ("OpenCL::Image3D", mem);
352 596
353void 597void
354supported_image_formats (OpenCL::Context this, cl_mem_flags flags, cl_mem_object_type image_type) 598supported_image_formats (OpenCL::Context this, cl_mem_flags flags, cl_mem_object_type image_type)
355 PPCODE: 599 PPCODE:
387 631
388 len2 = len; 632 len2 = len;
389 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithSource, (this, 1, &ptr, &len2, &res)); 633 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithSource, (this, 1, &ptr, &len2, &res));
390 XPUSH_NEW_OBJ ("OpenCL::Program", prog); 634 XPUSH_NEW_OBJ ("OpenCL::Program", prog);
391 635
636#BEGIN:context
637
638void
639reference_count (OpenCL::Context this)
640 ALIAS:
641 reference_count = CL_CONTEXT_REFERENCE_COUNT
642 num_devices = CL_CONTEXT_NUM_DEVICES
643 PPCODE:
644 cl_uint value [1];
645 NEED_SUCCESS (GetContextInfo, (this, ix, sizeof (value), value, 0));
646 EXTEND (SP, 1);
647 const int i = 0;
648 PUSHs (sv_2mortal (newSVuv (value [i])));
649
650void
651devices (OpenCL::Context this)
652 PPCODE:
653 size_t size;
654 NEED_SUCCESS (GetContextInfo, (this, CL_CONTEXT_DEVICES, 0, 0, &size));
655 cl_device_id *value = tmpbuf (size);
656 NEED_SUCCESS (GetContextInfo, (this, CL_CONTEXT_DEVICES, size, value, 0));
657 int i, n = size / sizeof (*value);
658 EXTEND (SP, n);
659 for (i = 0; i < n; ++i)
660 {
661 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Device", value [i]));
662 }
663
664void
665properties (OpenCL::Context this)
666 PPCODE:
667 size_t size;
668 NEED_SUCCESS (GetContextInfo, (this, CL_CONTEXT_PROPERTIES, 0, 0, &size));
669 cl_context_properties *value = tmpbuf (size);
670 NEED_SUCCESS (GetContextInfo, (this, CL_CONTEXT_PROPERTIES, size, value, 0));
671 int i, n = size / sizeof (*value);
672 EXTEND (SP, n);
673 for (i = 0; i < n; ++i)
674 PUSHs (sv_2mortal (newSVuv ((UV)value [i])));
675
676#END:context
677
392MODULE = OpenCL PACKAGE = OpenCL::Queue 678MODULE = OpenCL PACKAGE = OpenCL::Queue
393 679
394void 680void
395DESTROY (OpenCL::Queue this) 681DESTROY (OpenCL::Queue this)
396 CODE: 682 CODE:
397 clReleaseCommandQueue (this); 683 clReleaseCommandQueue (this);
398 684
399void 685void
400info (OpenCL::Queue this, cl_command_queue_info name)
401 PPCODE:
402 INFO (CommandQueue)
403
404void
405enqueue_read_buffer (OpenCL::Queue this, OpenCL::Buffer mem, cl_bool blocking, size_t offset, size_t len, SV *data, ...) 686enqueue_read_buffer (OpenCL::Queue this, OpenCL::Buffer mem, cl_bool blocking, size_t offset, size_t len, SV *data, ...)
406 PPCODE: 687 PPCODE:
407{
408 cl_event ev = 0; 688 cl_event ev = 0;
409 EVENT_LIST (6, items - 6); 689 EVENT_LIST (6, items - 6);
410 690
411 SvUPGRADE (data, SVt_PV); 691 SvUPGRADE (data, SVt_PV);
412 SvGROW (data, len); 692 SvGROW (data, len);
414 SvCUR_set (data, len); 694 SvCUR_set (data, len);
415 NEED_SUCCESS (EnqueueReadBuffer, (this, mem, blocking, offset, len, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 695 NEED_SUCCESS (EnqueueReadBuffer, (this, mem, blocking, offset, len, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
416 696
417 if (ev) 697 if (ev)
418 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 698 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
419}
420 699
421void 700void
422enqueue_write_buffer (OpenCL::Queue this, OpenCL::Buffer mem, cl_bool blocking, size_t offset, SV *data, ...) 701enqueue_write_buffer (OpenCL::Queue this, OpenCL::Buffer mem, cl_bool blocking, size_t offset, SV *data, ...)
423 PPCODE: 702 PPCODE:
424{
425 cl_event ev = 0; 703 cl_event ev = 0;
426 STRLEN len; 704 STRLEN len;
427 char *ptr = SvPVbyte (data, len); 705 char *ptr = SvPVbyte (data, len);
428 EVENT_LIST (5, items - 5); 706 EVENT_LIST (5, items - 5);
429 707
430 NEED_SUCCESS (EnqueueReadBuffer, (this, mem, blocking, offset, len, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 708 NEED_SUCCESS (EnqueueReadBuffer, (this, mem, blocking, offset, len, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
431 709
432 if (ev) 710 if (ev)
433 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 711 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
434}
435 712
436void 713void
437enqueue_copy_buffer (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Buffer dst, size_t src_offset, size_t dst_offset, size_t len, ...) 714enqueue_copy_buffer (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Buffer dst, size_t src_offset, size_t dst_offset, size_t len, ...)
438 PPCODE: 715 PPCODE:
439{
440 cl_event ev = 0; 716 cl_event ev = 0;
441 EVENT_LIST (6, items - 6); 717 EVENT_LIST (6, items - 6);
442 718
443 NEED_SUCCESS (EnqueueCopyBuffer, (this, src, dst, src_offset, dst_offset, len, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 719 NEED_SUCCESS (EnqueueCopyBuffer, (this, src, dst, src_offset, dst_offset, len, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
444 720
445 if (ev) 721 if (ev)
446 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 722 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
447}
448
449 /*TODO http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadBufferRect.html */
450 /*TODO http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html */
451 723
452void 724void
453enqueue_read_image (OpenCL::Queue this, OpenCL::Image src, cl_bool blocking, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, SV *data, ...) 725enqueue_read_image (OpenCL::Queue this, OpenCL::Image src, cl_bool blocking, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, SV *data, ...)
454 PPCODE: 726 PPCODE:
455{
456 cl_event ev = 0; 727 cl_event ev = 0;
457 const size_t src_origin[3] = { src_x, src_y, src_z }; 728 const size_t src_origin[3] = { src_x, src_y, src_z };
458 const size_t region[3] = { width, height, depth }; 729 const size_t region[3] = { width, height, depth };
459 size_t len = row_pitch * slice_pitch * depth;
460 EVENT_LIST (11, items - 11); 730 EVENT_LIST (12, items - 12);
731
732 if (!row_pitch)
733 row_pitch = img_row_pitch (src);
734
735 if (depth > 1 && !slice_pitch)
736 slice_pitch = row_pitch * height;
737
738 size_t len = slice_pitch ? slice_pitch * depth : row_pitch * height;
461 739
462 SvUPGRADE (data, SVt_PV); 740 SvUPGRADE (data, SVt_PV);
463 SvGROW (data, len); 741 SvGROW (data, len);
464 SvPOK_only (data); 742 SvPOK_only (data);
465 SvCUR_set (data, len); 743 SvCUR_set (data, len);
466 NEED_SUCCESS (EnqueueReadImage, (this, src, blocking, src_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 744 NEED_SUCCESS (EnqueueReadImage, (this, src, blocking, src_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
467 745
468 if (ev) 746 if (ev)
469 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 747 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
470}
471 748
472void 749void
473enqueue_write_image (OpenCL::Queue this, OpenCL::Image dst, cl_bool blocking, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, size_t row_pitch, SV *data, ...) 750enqueue_write_image (OpenCL::Queue this, OpenCL::Image dst, cl_bool blocking, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, SV *data, ...)
474 PPCODE: 751 PPCODE:
475{
476 cl_event ev = 0; 752 cl_event ev = 0;
477 const size_t dst_origin[3] = { dst_x, dst_y, dst_z }; 753 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
478 const size_t region[3] = { width, height, depth }; 754 const size_t region[3] = { width, height, depth };
479 STRLEN len; 755 STRLEN len;
480 char *ptr = SvPVbyte (data, len); 756 char *ptr = SvPVbyte (data, len);
481 size_t slice_pitch = len / (row_pitch * height);
482 EVENT_LIST (11, items - 11); 757 EVENT_LIST (12, items - 12);
758
759 if (!row_pitch)
760 row_pitch = img_row_pitch (dst);
761
762 if (depth > 1 && !slice_pitch)
763 slice_pitch = row_pitch * height;
764
765 size_t min_len = slice_pitch ? slice_pitch * depth : row_pitch * height;
766
767 if (len < min_len)
768 croak ("clEnqueueWriteImage: data string is shorter than what would be transferred");
483 769
484 NEED_SUCCESS (EnqueueWriteImage, (this, dst, blocking, dst_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 770 NEED_SUCCESS (EnqueueWriteImage, (this, dst, blocking, dst_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
485 771
486 if (ev) 772 if (ev)
487 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 773 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
488}
489 774
490void 775void
491enqueue_copy_buffer_rect (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch, ...) 776enqueue_copy_buffer_rect (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch, ...)
492 PPCODE: 777 PPCODE:
493{
494 cl_event ev = 0; 778 cl_event ev = 0;
495 const size_t src_origin[3] = { src_x, src_y, src_z }; 779 const size_t src_origin[3] = { src_x, src_y, src_z };
496 const size_t dst_origin[3] = { dst_x, dst_y, dst_z }; 780 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
497 const size_t region[3] = { width, height, depth }; 781 const size_t region[3] = { width, height, depth };
498 EVENT_LIST (16, items - 16); 782 EVENT_LIST (16, items - 16);
499 783
500 NEED_SUCCESS (EnqueueCopyBufferRect, (this, src, dst, src_origin, dst_origin, region, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 784 NEED_SUCCESS (EnqueueCopyBufferRect, (this, src, dst, src_origin, dst_origin, region, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
501 785
502 if (ev) 786 if (ev)
503 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 787 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
504}
505 788
506void 789void
507enqueue_copy_buffer_to_image (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Image dst, size_t src_offset, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, ...) 790enqueue_copy_buffer_to_image (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Image dst, size_t src_offset, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, ...)
508 PPCODE: 791 PPCODE:
509{
510 cl_event ev = 0; 792 cl_event ev = 0;
511 const size_t dst_origin[3] = { dst_x, dst_y, dst_z }; 793 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
512 const size_t region[3] = { width, height, depth }; 794 const size_t region[3] = { width, height, depth };
513 EVENT_LIST (10, items - 10); 795 EVENT_LIST (10, items - 10);
514 796
515 NEED_SUCCESS (EnqueueCopyBufferToImage, (this, src, dst, src_offset, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 797 NEED_SUCCESS (EnqueueCopyBufferToImage, (this, src, dst, src_offset, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
516 798
517 if (ev) 799 if (ev)
518 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 800 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
519}
520 801
521void 802void
522enqueue_copy_image (OpenCL::Queue this, OpenCL::Image src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, ...) 803enqueue_copy_image (OpenCL::Queue this, OpenCL::Image src, OpenCL::Image dst, size_t src_x, size_t src_y, size_t src_z, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, ...)
523 PPCODE: 804 PPCODE:
524{
525 cl_event ev = 0; 805 cl_event ev = 0;
526 const size_t src_origin[3] = { src_x, src_y, src_z }; 806 const size_t src_origin[3] = { src_x, src_y, src_z };
527 const size_t dst_origin[3] = { dst_x, dst_y, dst_z }; 807 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
528 const size_t region[3] = { width, height, depth }; 808 const size_t region[3] = { width, height, depth };
529 EVENT_LIST (12, items - 12); 809 EVENT_LIST (12, items - 12);
530 810
531 NEED_SUCCESS (EnqueueCopyImage, (this, src, dst, src_origin, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 811 NEED_SUCCESS (EnqueueCopyImage, (this, src, dst, src_origin, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
532 812
533 if (ev) 813 if (ev)
534 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 814 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
535}
536 815
537void 816void
538enqueue_copy_image_to_buffer (OpenCL::Queue this, OpenCL::Image src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t dst_offset, ...) 817enqueue_copy_image_to_buffer (OpenCL::Queue this, OpenCL::Image src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t dst_offset, ...)
539 PPCODE: 818 PPCODE:
540{
541 cl_event ev = 0; 819 cl_event ev = 0;
542 const size_t src_origin[3] = { src_x, src_y, src_z }; 820 const size_t src_origin[3] = { src_x, src_y, src_z };
543 const size_t region[3] = { width, height, depth }; 821 const size_t region[3] = { width, height, depth };
544 EVENT_LIST (10, items - 10); 822 EVENT_LIST (10, items - 10);
545 823
546 NEED_SUCCESS (EnqueueCopyImageToBuffer, (this, src, dst, src_origin, region, dst_offset, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 824 NEED_SUCCESS (EnqueueCopyImageToBuffer, (this, src, dst, src_origin, region, dst_offset, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
547 825
548 if (ev) 826 if (ev)
549 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 827 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
550}
551 828
552void 829void
553enqueue_task (OpenCL::Queue this, OpenCL::Kernel kernel, ...) 830enqueue_task (OpenCL::Queue this, OpenCL::Kernel kernel, ...)
554 PPCODE: 831 PPCODE:
555{
556 cl_event ev = 0; 832 cl_event ev = 0;
557 EVENT_LIST (2, items - 2); 833 EVENT_LIST (2, items - 2);
558 834
559 NEED_SUCCESS (EnqueueTask, (this, kernel, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 835 NEED_SUCCESS (EnqueueTask, (this, kernel, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
560 836
561 if (ev) 837 if (ev)
562 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 838 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
563}
564 839
565void 840void
566enqueue_nd_range_kernel (OpenCL::Queue this, OpenCL::Kernel kernel, SV *global_work_offset, SV *global_work_size, SV *local_work_size = &PL_sv_undef, ...) 841enqueue_nd_range_kernel (OpenCL::Queue this, OpenCL::Kernel kernel, SV *global_work_offset, SV *global_work_size, SV *local_work_size = &PL_sv_undef, ...)
567 PPCODE: 842 PPCODE:
568{
569 cl_event ev = 0; 843 cl_event ev = 0;
570 size_t *gwo = 0, *gws, *lws = 0; 844 size_t *gwo = 0, *gws, *lws = 0;
571 int gws_len; 845 int gws_len;
572 size_t *lists; 846 size_t *lists;
573 int i; 847 int i;
612 886
613 NEED_SUCCESS (EnqueueNDRangeKernel, (this, kernel, gws_len, gwo, gws, lws, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 887 NEED_SUCCESS (EnqueueNDRangeKernel, (this, kernel, gws_len, gwo, gws, lws, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
614 888
615 if (ev) 889 if (ev)
616 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 890 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
617}
618 891
619void 892void
620enqueue_marker (OpenCL::Queue this) 893enqueue_marker (OpenCL::Queue this)
621 PPCODE: 894 PPCODE:
622{
623 cl_event ev; 895 cl_event ev;
624 NEED_SUCCESS (EnqueueMarker, (this, &ev)); 896 NEED_SUCCESS (EnqueueMarker, (this, &ev));
625 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 897 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
626}
627 898
628void 899void
629enqueue_wait_for_events (OpenCL::Queue this, ...) 900enqueue_wait_for_events (OpenCL::Queue this, ...)
630 CODE: 901 CODE:
631{
632 EVENT_LIST (1, items - 1); 902 EVENT_LIST (1, items - 1);
633 NEED_SUCCESS (EnqueueWaitForEvents, (this, event_list_count, event_list_ptr)); 903 NEED_SUCCESS (EnqueueWaitForEvents, (this, event_list_count, event_list_ptr));
634}
635 904
636void 905void
637enqueue_barrier (OpenCL::Queue this) 906enqueue_barrier (OpenCL::Queue this)
638 CODE: 907 CODE:
639 NEED_SUCCESS (EnqueueBarrier, (this)); 908 NEED_SUCCESS (EnqueueBarrier, (this));
646void 915void
647finish (OpenCL::Queue this) 916finish (OpenCL::Queue this)
648 CODE: 917 CODE:
649 NEED_SUCCESS (Finish, (this)); 918 NEED_SUCCESS (Finish, (this));
650 919
920void
921info (OpenCL::Queue this, cl_command_queue_info name)
922 PPCODE:
923 INFO (CommandQueue)
924
925#BEGIN:command_queue
926
927void
928context (OpenCL::Queue this)
929 PPCODE:
930 cl_context value [1];
931 NEED_SUCCESS (GetCommandQueueInfo, (this, CL_QUEUE_CONTEXT, sizeof (value), value, 0));
932 EXTEND (SP, 1);
933 const int i = 0;
934 {
935 NEED_SUCCESS (RetainContext, (value [i]));
936 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
937 }
938
939void
940device (OpenCL::Queue this)
941 PPCODE:
942 cl_device_id value [1];
943 NEED_SUCCESS (GetCommandQueueInfo, (this, CL_QUEUE_DEVICE, sizeof (value), value, 0));
944 EXTEND (SP, 1);
945 const int i = 0;
946 {
947 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Device", value [i]));
948 }
949
950void
951reference_count (OpenCL::Queue this)
952 PPCODE:
953 cl_uint value [1];
954 NEED_SUCCESS (GetCommandQueueInfo, (this, CL_QUEUE_REFERENCE_COUNT, sizeof (value), value, 0));
955 EXTEND (SP, 1);
956 const int i = 0;
957 PUSHs (sv_2mortal (newSVuv (value [i])));
958
959void
960properties (OpenCL::Queue this)
961 PPCODE:
962 cl_command_queue_properties value [1];
963 NEED_SUCCESS (GetCommandQueueInfo, (this, CL_QUEUE_PROPERTIES, sizeof (value), value, 0));
964 EXTEND (SP, 1);
965 const int i = 0;
966 PUSHs (sv_2mortal (newSViv (value [i])));
967
968#END:command_queue
969
651MODULE = OpenCL PACKAGE = OpenCL::Memory 970MODULE = OpenCL PACKAGE = OpenCL::Memory
652 971
653void 972void
654DESTROY (OpenCL::Memory this) 973DESTROY (OpenCL::Memory this)
655 CODE: 974 CODE:
658void 977void
659info (OpenCL::Memory this, cl_mem_info name) 978info (OpenCL::Memory this, cl_mem_info name)
660 PPCODE: 979 PPCODE:
661 INFO (MemObject) 980 INFO (MemObject)
662 981
982#BEGIN:mem
983
984void
985type (OpenCL::Memory this)
986 PPCODE:
987 cl_mem_object_type value [1];
988 NEED_SUCCESS (GetMemObjectInfo, (this, CL_MEM_TYPE, sizeof (value), value, 0));
989 EXTEND (SP, 1);
990 const int i = 0;
991 PUSHs (sv_2mortal (newSViv (value [i])));
992
993void
994flags (OpenCL::Memory this)
995 PPCODE:
996 cl_mem_flags value [1];
997 NEED_SUCCESS (GetMemObjectInfo, (this, CL_MEM_FLAGS, sizeof (value), value, 0));
998 EXTEND (SP, 1);
999 const int i = 0;
1000 PUSHs (sv_2mortal (newSViv (value [i])));
1001
1002void
1003size (OpenCL::Memory this)
1004 ALIAS:
1005 size = CL_MEM_SIZE
1006 offset = CL_MEM_OFFSET
1007 PPCODE:
1008 size_t value [1];
1009 NEED_SUCCESS (GetMemObjectInfo, (this, ix, sizeof (value), value, 0));
1010 EXTEND (SP, 1);
1011 const int i = 0;
1012 PUSHs (sv_2mortal (newSVuv (value [i])));
1013
1014void
1015host_ptr (OpenCL::Memory this)
1016 PPCODE:
1017 void * value [1];
1018 NEED_SUCCESS (GetMemObjectInfo, (this, CL_MEM_HOST_PTR, sizeof (value), value, 0));
1019 EXTEND (SP, 1);
1020 const int i = 0;
1021 PUSHs (sv_2mortal (newSVuv ((IV)(intptr_t)value [i])));
1022
1023void
1024map_count (OpenCL::Memory this)
1025 ALIAS:
1026 map_count = CL_MEM_MAP_COUNT
1027 reference_count = CL_MEM_REFERENCE_COUNT
1028 PPCODE:
1029 cl_uint value [1];
1030 NEED_SUCCESS (GetMemObjectInfo, (this, ix, sizeof (value), value, 0));
1031 EXTEND (SP, 1);
1032 const int i = 0;
1033 PUSHs (sv_2mortal (newSVuv (value [i])));
1034
1035void
1036context (OpenCL::Memory this)
1037 PPCODE:
1038 cl_context value [1];
1039 NEED_SUCCESS (GetMemObjectInfo, (this, CL_MEM_CONTEXT, sizeof (value), value, 0));
1040 EXTEND (SP, 1);
1041 const int i = 0;
1042 {
1043 NEED_SUCCESS (RetainContext, (value [i]));
1044 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1045 }
1046
1047void
1048associated_memobject (OpenCL::Memory this)
1049 PPCODE:
1050 cl_mem value [1];
1051 NEED_SUCCESS (GetMemObjectInfo, (this, CL_MEM_ASSOCIATED_MEMOBJECT, sizeof (value), value, 0));
1052 EXTEND (SP, 1);
1053 const int i = 0;
1054 {
1055 NEED_SUCCESS (RetainMemObject, (value [i]));
1056 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Memory", value [i]));
1057 }
1058
1059#END:mem
1060
1061MODULE = OpenCL PACKAGE = OpenCL::Image
1062
1063void
1064image_info (OpenCL::Image this, cl_image_info name)
1065 PPCODE:
1066 INFO (Image)
1067
1068#BEGIN:image
1069
1070void
1071element_size (OpenCL::Image this)
1072 ALIAS:
1073 element_size = CL_IMAGE_ELEMENT_SIZE
1074 row_pitch = CL_IMAGE_ROW_PITCH
1075 slice_pitch = CL_IMAGE_SLICE_PITCH
1076 width = CL_IMAGE_WIDTH
1077 height = CL_IMAGE_HEIGHT
1078 depth = CL_IMAGE_DEPTH
1079 PPCODE:
1080 size_t value [1];
1081 NEED_SUCCESS (GetImageInfo, (this, ix, sizeof (value), value, 0));
1082 EXTEND (SP, 1);
1083 const int i = 0;
1084 PUSHs (sv_2mortal (newSVuv (value [i])));
1085
1086#END:image
1087
663MODULE = OpenCL PACKAGE = OpenCL::Sampler 1088MODULE = OpenCL PACKAGE = OpenCL::Sampler
664 1089
665void 1090void
666DESTROY (OpenCL::Sampler this) 1091DESTROY (OpenCL::Sampler this)
667 CODE: 1092 CODE:
670void 1095void
671info (OpenCL::Sampler this, cl_sampler_info name) 1096info (OpenCL::Sampler this, cl_sampler_info name)
672 PPCODE: 1097 PPCODE:
673 INFO (Sampler) 1098 INFO (Sampler)
674 1099
1100#BEGIN:sampler
1101
1102void
1103reference_count (OpenCL::Sampler this)
1104 PPCODE:
1105 cl_uint value [1];
1106 NEED_SUCCESS (GetSamplerInfo, (this, CL_SAMPLER_REFERENCE_COUNT, sizeof (value), value, 0));
1107 EXTEND (SP, 1);
1108 const int i = 0;
1109 PUSHs (sv_2mortal (newSVuv (value [i])));
1110
1111void
1112context (OpenCL::Sampler this)
1113 PPCODE:
1114 cl_context value [1];
1115 NEED_SUCCESS (GetSamplerInfo, (this, CL_SAMPLER_CONTEXT, sizeof (value), value, 0));
1116 EXTEND (SP, 1);
1117 const int i = 0;
1118 {
1119 NEED_SUCCESS (RetainContext, (value [i]));
1120 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1121 }
1122
1123void
1124normalized_coords (OpenCL::Sampler this)
1125 PPCODE:
1126 cl_addressing_mode value [1];
1127 NEED_SUCCESS (GetSamplerInfo, (this, CL_SAMPLER_NORMALIZED_COORDS, sizeof (value), value, 0));
1128 EXTEND (SP, 1);
1129 const int i = 0;
1130 PUSHs (sv_2mortal (newSViv (value [i])));
1131
1132void
1133addressing_mode (OpenCL::Sampler this)
1134 PPCODE:
1135 cl_filter_mode value [1];
1136 NEED_SUCCESS (GetSamplerInfo, (this, CL_SAMPLER_ADDRESSING_MODE, sizeof (value), value, 0));
1137 EXTEND (SP, 1);
1138 const int i = 0;
1139 PUSHs (sv_2mortal (newSViv (value [i])));
1140
1141void
1142filter_mode (OpenCL::Sampler this)
1143 PPCODE:
1144 cl_bool value [1];
1145 NEED_SUCCESS (GetSamplerInfo, (this, CL_SAMPLER_FILTER_MODE, sizeof (value), value, 0));
1146 EXTEND (SP, 1);
1147 const int i = 0;
1148 PUSHs (sv_2mortal (value [i] ? &PL_sv_yes : &PL_sv_no));
1149
1150#END:sampler
1151
675MODULE = OpenCL PACKAGE = OpenCL::Program 1152MODULE = OpenCL PACKAGE = OpenCL::Program
676 1153
677void 1154void
678DESTROY (OpenCL::Program this) 1155DESTROY (OpenCL::Program this)
679 CODE: 1156 CODE:
680 clReleaseProgram (this); 1157 clReleaseProgram (this);
681 1158
682void 1159void
683info (OpenCL::Program this, cl_program_info name)
684 PPCODE:
685 INFO (Program)
686
687void
688build (OpenCL::Program this, OpenCL::Device device, SV *options = &PL_sv_undef) 1160build (OpenCL::Program this, OpenCL::Device device, SV *options = &PL_sv_undef)
689 CODE: 1161 CODE:
690 NEED_SUCCESS (BuildProgram, (this, 1, &device, SvPVbyte_nolen (options), 0, 0)); 1162 NEED_SUCCESS (BuildProgram, (this, 1, &device, SvPVbyte_nolen (options), 0, 0));
691 1163
692void 1164void
693build_info (OpenCL::Program this, OpenCL::Device device, cl_program_build_info name) 1165build_info (OpenCL::Program this, OpenCL::Device device, cl_program_build_info name)
694 PPCODE: 1166 PPCODE:
695{
696 size_t size; 1167 size_t size;
697 SV *sv;
698
699 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, 0, 0, &size)); 1168 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, 0, 0, &size));
700 sv = sv_2mortal (newSV (size)); 1169 SV *sv = sv_2mortal (newSV (size));
701 SvUPGRADE (sv, SVt_PV); 1170 SvUPGRADE (sv, SVt_PV);
702 SvPOK_only (sv); 1171 SvPOK_only (sv);
703 SvCUR_set (sv, size); 1172 SvCUR_set (sv, size);
704 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, size, SvPVX (sv), 0)); 1173 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, size, SvPVX (sv), 0));
705 XPUSHs (sv); 1174 XPUSHs (sv);
706} 1175
1176#BEGIN:program_build
1177
1178void
1179build_status (OpenCL::Program this, OpenCL::Device device)
1180 PPCODE:
1181 cl_build_status value [1];
1182 NEED_SUCCESS (GetProgramBuildInfo, (this, device, CL_PROGRAM_BUILD_STATUS, sizeof (value), value, 0));
1183 EXTEND (SP, 1);
1184 const int i = 0;
1185 PUSHs (sv_2mortal (newSViv (value [i])));
1186
1187void
1188build_options (OpenCL::Program this, OpenCL::Device device)
1189 ALIAS:
1190 build_options = CL_PROGRAM_BUILD_OPTIONS
1191 build_log = CL_PROGRAM_BUILD_LOG
1192 PPCODE:
1193 size_t size;
1194 NEED_SUCCESS (GetProgramBuildInfo, (this, device, ix, 0, 0, &size));
1195 char *value = tmpbuf (size);
1196 NEED_SUCCESS (GetProgramBuildInfo, (this, device, ix, size, value, 0));
1197 EXTEND (SP, 1);
1198 const int i = 0;
1199 PUSHs (sv_2mortal (newSVpv (value, 0)));
1200
1201#END:program_build
707 1202
708void 1203void
709kernel (OpenCL::Program program, SV *function) 1204kernel (OpenCL::Program program, SV *function)
710 PPCODE: 1205 PPCODE:
711 NEED_SUCCESS_ARG (cl_kernel kernel, CreateKernel, (program, SvPVbyte_nolen (function), &res)); 1206 NEED_SUCCESS_ARG (cl_kernel kernel, CreateKernel, (program, SvPVbyte_nolen (function), &res));
712 XPUSH_NEW_OBJ ("OpenCL::Kernel", kernel); 1207 XPUSH_NEW_OBJ ("OpenCL::Kernel", kernel);
713 1208
1209void
1210info (OpenCL::Program this, cl_program_info name)
1211 PPCODE:
1212 INFO (Program)
1213
1214void
1215binaries (OpenCL::Program this)
1216 PPCODE:
1217 cl_uint n, i;
1218 size_t size;
1219
1220 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_NUM_DEVICES , sizeof (n) , &n , 0));
1221 if (!n) XSRETURN_EMPTY;
1222
1223 size_t *sizes = tmpbuf (sizeof (*sizes) * n);
1224 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_BINARY_SIZES, sizeof (*sizes) * n, sizes, &size));
1225 if (size != sizeof (*sizes) * n) XSRETURN_EMPTY;
1226 unsigned char **ptrs = tmpbuf (sizeof (*ptrs) * n);
1227
1228 EXTEND (SP, n);
1229 for (i = 0; i < n; ++i)
1230 {
1231 SV *sv = sv_2mortal (newSV (sizes [i]));
1232 SvUPGRADE (sv, SVt_PV);
1233 SvPOK_only (sv);
1234 SvCUR_set (sv, sizes [i]);
1235 ptrs [i] = SvPVX (sv);
1236 PUSHs (sv);
1237 }
1238
1239 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_BINARIES , sizeof (*ptrs ) * n, ptrs , &size));
1240 if (size != sizeof (*ptrs) * n) XSRETURN_EMPTY;
1241
1242#BEGIN:program
1243
1244void
1245reference_count (OpenCL::Program this)
1246 ALIAS:
1247 reference_count = CL_PROGRAM_REFERENCE_COUNT
1248 num_devices = CL_PROGRAM_NUM_DEVICES
1249 PPCODE:
1250 cl_uint value [1];
1251 NEED_SUCCESS (GetProgramInfo, (this, ix, sizeof (value), value, 0));
1252 EXTEND (SP, 1);
1253 const int i = 0;
1254 PUSHs (sv_2mortal (newSVuv (value [i])));
1255
1256void
1257context (OpenCL::Program this)
1258 PPCODE:
1259 cl_context value [1];
1260 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_CONTEXT, sizeof (value), value, 0));
1261 EXTEND (SP, 1);
1262 const int i = 0;
1263 {
1264 NEED_SUCCESS (RetainContext, (value [i]));
1265 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1266 }
1267
1268void
1269devices (OpenCL::Program this)
1270 PPCODE:
1271 size_t size;
1272 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_DEVICES, 0, 0, &size));
1273 cl_device_id *value = tmpbuf (size);
1274 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_DEVICES, size, value, 0));
1275 int i, n = size / sizeof (*value);
1276 EXTEND (SP, n);
1277 for (i = 0; i < n; ++i)
1278 {
1279 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Device", value [i]));
1280 }
1281
1282void
1283source (OpenCL::Program this)
1284 PPCODE:
1285 size_t size;
1286 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_SOURCE, 0, 0, &size));
1287 char *value = tmpbuf (size);
1288 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_SOURCE, size, value, 0));
1289 EXTEND (SP, 1);
1290 const int i = 0;
1291 PUSHs (sv_2mortal (newSVpv (value, 0)));
1292
1293void
1294binary_sizes (OpenCL::Program this)
1295 PPCODE:
1296 size_t size;
1297 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_BINARY_SIZES, 0, 0, &size));
1298 size_t *value = tmpbuf (size);
1299 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_BINARY_SIZES, size, value, 0));
1300 int i, n = size / sizeof (*value);
1301 EXTEND (SP, n);
1302 for (i = 0; i < n; ++i)
1303 PUSHs (sv_2mortal (newSVuv (value [i])));
1304
1305#END:program
1306
714MODULE = OpenCL PACKAGE = OpenCL::Kernel 1307MODULE = OpenCL PACKAGE = OpenCL::Kernel
715 1308
716void 1309void
717DESTROY (OpenCL::Kernel this) 1310DESTROY (OpenCL::Kernel this)
718 CODE: 1311 CODE:
719 clReleaseKernel (this); 1312 clReleaseKernel (this);
720 1313
721void 1314void
1315set_char (OpenCL::Kernel this, cl_uint idx, cl_char value)
1316 CODE:
1317 clSetKernelArg (this, idx, sizeof (value), &value);
1318
1319void
1320set_uchar (OpenCL::Kernel this, cl_uint idx, cl_uchar value)
1321 CODE:
1322 clSetKernelArg (this, idx, sizeof (value), &value);
1323
1324void
1325set_short (OpenCL::Kernel this, cl_uint idx, cl_short value)
1326 CODE:
1327 clSetKernelArg (this, idx, sizeof (value), &value);
1328
1329void
1330set_ushort (OpenCL::Kernel this, cl_uint idx, cl_ushort value)
1331 CODE:
1332 clSetKernelArg (this, idx, sizeof (value), &value);
1333
1334void
1335set_int (OpenCL::Kernel this, cl_uint idx, cl_int value)
1336 CODE:
1337 clSetKernelArg (this, idx, sizeof (value), &value);
1338
1339void
1340set_uint (OpenCL::Kernel this, cl_uint idx, cl_uint value)
1341 CODE:
1342 clSetKernelArg (this, idx, sizeof (value), &value);
1343
1344void
1345set_long (OpenCL::Kernel this, cl_uint idx, cl_long value)
1346 CODE:
1347 clSetKernelArg (this, idx, sizeof (value), &value);
1348
1349void
1350set_ulong (OpenCL::Kernel this, cl_uint idx, cl_ulong value)
1351 CODE:
1352 clSetKernelArg (this, idx, sizeof (value), &value);
1353
1354void
1355set_half (OpenCL::Kernel this, cl_uint idx, cl_half value)
1356 CODE:
1357 clSetKernelArg (this, idx, sizeof (value), &value);
1358
1359void
1360set_float (OpenCL::Kernel this, cl_uint idx, cl_float value)
1361 CODE:
1362 clSetKernelArg (this, idx, sizeof (value), &value);
1363
1364void
1365set_double (OpenCL::Kernel this, cl_uint idx, cl_double value)
1366 CODE:
1367 clSetKernelArg (this, idx, sizeof (value), &value);
1368
1369void
1370set_memory (OpenCL::Kernel this, cl_uint idx, OpenCL::Memory_ornull value)
1371 CODE:
1372 clSetKernelArg (this, idx, sizeof (value), &value);
1373
1374void
1375set_buffer (OpenCL::Kernel this, cl_uint idx, OpenCL::Buffer_ornull value)
1376 CODE:
1377 clSetKernelArg (this, idx, sizeof (value), &value);
1378
1379void
1380set_image2d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image2D_ornull value)
1381 CODE:
1382 clSetKernelArg (this, idx, sizeof (value), &value);
1383
1384void
1385set_image3d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image3D_ornull value)
1386 CODE:
1387 clSetKernelArg (this, idx, sizeof (value), &value);
1388
1389void
1390set_sampler (OpenCL::Kernel this, cl_uint idx, OpenCL::Sampler value)
1391 CODE:
1392 clSetKernelArg (this, idx, sizeof (value), &value);
1393
1394void
1395set_event (OpenCL::Kernel this, cl_uint idx, OpenCL::Event value)
1396 CODE:
1397 clSetKernelArg (this, idx, sizeof (value), &value);
1398
1399void
722info (OpenCL::Kernel this, cl_kernel_info name) 1400info (OpenCL::Kernel this, cl_kernel_info name)
723 PPCODE: 1401 PPCODE:
724 INFO (Kernel) 1402 INFO (Kernel)
725 1403
1404#BEGIN:kernel
1405
726void 1406void
727set_char (OpenCL::Kernel this, cl_uint idx, cl_char value) 1407function_name (OpenCL::Kernel this)
1408 PPCODE:
1409 size_t size;
1410 NEED_SUCCESS (GetKernelInfo, (this, CL_KERNEL_FUNCTION_NAME, 0, 0, &size));
1411 char *value = tmpbuf (size);
1412 NEED_SUCCESS (GetKernelInfo, (this, CL_KERNEL_FUNCTION_NAME, size, value, 0));
1413 EXTEND (SP, 1);
1414 const int i = 0;
1415 PUSHs (sv_2mortal (newSVpv (value, 0)));
1416
1417void
1418num_args (OpenCL::Kernel this)
1419 ALIAS:
1420 num_args = CL_KERNEL_NUM_ARGS
1421 reference_count = CL_KERNEL_REFERENCE_COUNT
1422 PPCODE:
1423 cl_uint value [1];
1424 NEED_SUCCESS (GetKernelInfo, (this, ix, sizeof (value), value, 0));
1425 EXTEND (SP, 1);
1426 const int i = 0;
1427 PUSHs (sv_2mortal (newSVuv (value [i])));
1428
1429void
1430context (OpenCL::Kernel this)
1431 PPCODE:
1432 cl_context value [1];
1433 NEED_SUCCESS (GetKernelInfo, (this, CL_KERNEL_CONTEXT, sizeof (value), value, 0));
1434 EXTEND (SP, 1);
1435 const int i = 0;
1436 {
1437 NEED_SUCCESS (RetainContext, (value [i]));
1438 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1439 }
1440
1441void
1442program (OpenCL::Kernel this)
1443 PPCODE:
1444 cl_program value [1];
1445 NEED_SUCCESS (GetKernelInfo, (this, CL_KERNEL_PROGRAM, sizeof (value), value, 0));
1446 EXTEND (SP, 1);
1447 const int i = 0;
1448 {
1449 NEED_SUCCESS (RetainProgram, (value [i]));
1450 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Program", value [i]));
1451 }
1452
1453#END:kernel
1454
1455void
1456work_group_info (OpenCL::Kernel this, OpenCL::Device device, cl_kernel_work_group_info name)
728 CODE: 1457 PPCODE:
729 clSetKernelArg (this, idx, sizeof (value), &value); 1458 size_t size;
1459 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, name, 0, 0, &size));
1460 SV *sv = sv_2mortal (newSV (size));
1461 SvUPGRADE (sv, SVt_PV);
1462 SvPOK_only (sv);
1463 SvCUR_set (sv, size);
1464 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, name, size, SvPVX (sv), 0));
1465 XPUSHs (sv);
730 1466
731void 1467#BEGIN:kernel_work_group
732set_uchar (OpenCL::Kernel this, cl_uint idx, cl_uchar value)
733 CODE:
734 clSetKernelArg (this, idx, sizeof (value), &value);
735 1468
736void 1469void
737set_short (OpenCL::Kernel this, cl_uint idx, cl_short value) 1470work_group_size (OpenCL::Kernel this, OpenCL::Device device)
738 CODE: 1471 ALIAS:
739 clSetKernelArg (this, idx, sizeof (value), &value); 1472 work_group_size = CL_KERNEL_WORK_GROUP_SIZE
1473 preferred_work_group_size_multiple = CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE
1474 PPCODE:
1475 size_t value [1];
1476 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, ix, sizeof (value), value, 0));
1477 EXTEND (SP, 1);
1478 const int i = 0;
1479 PUSHs (sv_2mortal (newSVuv (value [i])));
740 1480
741void 1481void
742set_ushort (OpenCL::Kernel this, cl_uint idx, cl_ushort value) 1482compile_work_group_size (OpenCL::Kernel this, OpenCL::Device device)
743 CODE: 1483 PPCODE:
744 clSetKernelArg (this, idx, sizeof (value), &value); 1484 size_t size;
1485 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, 0, 0, &size));
1486 size_t *value = tmpbuf (size);
1487 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, size, value, 0));
1488 int i, n = size / sizeof (*value);
1489 EXTEND (SP, n);
1490 for (i = 0; i < n; ++i)
1491 PUSHs (sv_2mortal (newSVuv (value [i])));
745 1492
746void 1493void
747set_int (OpenCL::Kernel this, cl_uint idx, cl_int value) 1494local_mem_size (OpenCL::Kernel this, OpenCL::Device device)
748 CODE: 1495 ALIAS:
749 clSetKernelArg (this, idx, sizeof (value), &value); 1496 local_mem_size = CL_KERNEL_LOCAL_MEM_SIZE
1497 private_mem_size = CL_KERNEL_PRIVATE_MEM_SIZE
1498 PPCODE:
1499 cl_ulong value [1];
1500 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, ix, sizeof (value), value, 0));
1501 EXTEND (SP, 1);
1502 const int i = 0;
1503 PUSHs (sv_2mortal (newSVuv (value [i])));
750 1504
751void 1505#END:kernel_work_group
752set_uint (OpenCL::Kernel this, cl_uint idx, cl_uint value)
753 CODE:
754 clSetKernelArg (this, idx, sizeof (value), &value);
755
756void
757set_long (OpenCL::Kernel this, cl_uint idx, cl_long value)
758 CODE:
759 clSetKernelArg (this, idx, sizeof (value), &value);
760
761void
762set_ulong (OpenCL::Kernel this, cl_uint idx, cl_ulong value)
763 CODE:
764 clSetKernelArg (this, idx, sizeof (value), &value);
765
766void
767set_half (OpenCL::Kernel this, cl_uint idx, cl_half value)
768 CODE:
769 clSetKernelArg (this, idx, sizeof (value), &value);
770
771void
772set_float (OpenCL::Kernel this, cl_uint idx, cl_float value)
773 CODE:
774 clSetKernelArg (this, idx, sizeof (value), &value);
775
776void
777set_double (OpenCL::Kernel this, cl_uint idx, cl_double value)
778 CODE:
779 clSetKernelArg (this, idx, sizeof (value), &value);
780
781void
782set_memory (OpenCL::Kernel this, cl_uint idx, OpenCL::Memory_ornull value)
783 CODE:
784 clSetKernelArg (this, idx, sizeof (value), &value);
785
786void
787set_buffer (OpenCL::Kernel this, cl_uint idx, OpenCL::Buffer_ornull value)
788 CODE:
789 clSetKernelArg (this, idx, sizeof (value), &value);
790
791void
792set_image2d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image2D_ornull value)
793 CODE:
794 clSetKernelArg (this, idx, sizeof (value), &value);
795
796void
797set_image3d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image3D_ornull value)
798 CODE:
799 clSetKernelArg (this, idx, sizeof (value), &value);
800
801void
802set_sampler (OpenCL::Kernel this, cl_uint idx, OpenCL::Sampler value)
803 CODE:
804 clSetKernelArg (this, idx, sizeof (value), &value);
805
806void
807set_event (OpenCL::Kernel this, cl_uint idx, OpenCL::Event value)
808 CODE:
809 clSetKernelArg (this, idx, sizeof (value), &value);
810 1506
811MODULE = OpenCL PACKAGE = OpenCL::Event 1507MODULE = OpenCL PACKAGE = OpenCL::Event
812 1508
813void 1509void
814DESTROY (OpenCL::Event this) 1510DESTROY (OpenCL::Event this)
815 CODE: 1511 CODE:
816 clReleaseEvent (this); 1512 clReleaseEvent (this);
817 1513
818void 1514void
1515wait (OpenCL::Event this)
1516 CODE:
1517 clWaitForEvents (1, &this);
1518
1519void
819info (OpenCL::Event this, cl_event_info name) 1520info (OpenCL::Event this, cl_event_info name)
820 PPCODE: 1521 PPCODE:
821 INFO (Event) 1522 INFO (Event)
822 1523
1524#BEGIN:event
1525
823void 1526void
1527command_queue (OpenCL::Event this)
1528 PPCODE:
1529 cl_command_queue value [1];
1530 NEED_SUCCESS (GetEventInfo, (this, CL_EVENT_COMMAND_QUEUE, sizeof (value), value, 0));
1531 EXTEND (SP, 1);
1532 const int i = 0;
1533 {
1534 NEED_SUCCESS (RetainCommandQueue, (value [i]));
1535 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Queue", value [i]));
1536 }
1537
1538void
1539command_type (OpenCL::Event this)
1540 PPCODE:
1541 cl_command_type value [1];
1542 NEED_SUCCESS (GetEventInfo, (this, CL_EVENT_COMMAND_TYPE, sizeof (value), value, 0));
1543 EXTEND (SP, 1);
1544 const int i = 0;
1545 PUSHs (sv_2mortal (newSVuv (value [i])));
1546
1547void
1548reference_count (OpenCL::Event this)
1549 ALIAS:
1550 reference_count = CL_EVENT_REFERENCE_COUNT
1551 command_execution_status = CL_EVENT_COMMAND_EXECUTION_STATUS
1552 PPCODE:
1553 cl_uint value [1];
1554 NEED_SUCCESS (GetEventInfo, (this, ix, sizeof (value), value, 0));
1555 EXTEND (SP, 1);
1556 const int i = 0;
1557 PUSHs (sv_2mortal (newSVuv (value [i])));
1558
1559void
824wait (OpenCL::Event this) 1560context (OpenCL::Event this)
1561 PPCODE:
1562 cl_context value [1];
1563 NEED_SUCCESS (GetEventInfo, (this, CL_EVENT_CONTEXT, sizeof (value), value, 0));
1564 EXTEND (SP, 1);
1565 const int i = 0;
1566 {
1567 NEED_SUCCESS (RetainContext, (value [i]));
1568 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1569 }
1570
1571#END:event
1572
1573void
1574profiling_info (OpenCL::Event this, cl_profiling_info name)
825 CODE: 1575 PPCODE:
826 clWaitForEvents (1, &this); 1576 INFO (EventProfiling)
1577
1578#BEGIN:profiling
1579
1580void
1581profiling_command_queued (OpenCL::Event this)
1582 ALIAS:
1583 profiling_command_queued = CL_PROFILING_COMMAND_QUEUED
1584 profiling_command_submit = CL_PROFILING_COMMAND_SUBMIT
1585 profiling_command_start = CL_PROFILING_COMMAND_START
1586 profiling_command_end = CL_PROFILING_COMMAND_END
1587 PPCODE:
1588 cl_ulong value [1];
1589 NEED_SUCCESS (GetEventProfilingInfo, (this, ix, sizeof (value), value, 0));
1590 EXTEND (SP, 1);
1591 const int i = 0;
1592 PUSHs (sv_2mortal (newSVuv (value [i])));
1593
1594#END:profiling
827 1595
828MODULE = OpenCL PACKAGE = OpenCL::UserEvent 1596MODULE = OpenCL PACKAGE = OpenCL::UserEvent
829 1597
830void 1598void
831set_status (OpenCL::UserEvent this, cl_int execution_status) 1599set_status (OpenCL::UserEvent this, cl_int execution_status)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines