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

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.69 by root, Sat May 5 02:30:27 2012 UTC vs.
Revision 1.72 by root, Sat May 5 12:54:04 2012 UTC

57typedef cl_kernel OpenCL__Kernel; 57typedef cl_kernel OpenCL__Kernel;
58typedef cl_event OpenCL__Event; 58typedef cl_event OpenCL__Event;
59typedef cl_event OpenCL__UserEvent; 59typedef cl_event OpenCL__UserEvent;
60 60
61typedef struct mapped * OpenCL__Mapped; 61typedef struct mapped * OpenCL__Mapped;
62
63typedef SV *FUTURE;
64 62
65static HV 63static HV
66 *stash_platform, 64 *stash_platform,
67 *stash_device, 65 *stash_device,
68 *stash_subdevice, 66 *stash_subdevice,
246#define XPUSH_CLOBJ(stash,id) XPUSHs (new_clobj ((stash), (IV)(id))) 244#define XPUSH_CLOBJ(stash,id) XPUSHs (new_clobj ((stash), (IV)(id)))
247 245
248/* cl objects are either \$iv, or [$iv, ...] */ 246/* cl objects are either \$iv, or [$iv, ...] */
249/* they can be upgraded at runtime to the array form */ 247/* they can be upgraded at runtime to the array form */
250static void * ecb_noinline 248static void * ecb_noinline
251SvCLOBJ (const char *func, const char *svname, SV *sv, const char *pkg) 249SvCLOBJ (CV *cv, const char *svname, SV *sv, const char *pkg)
252{ 250{
253 // sv_derived_from is quite slow :( 251 // sv_derived_from is quite slow :(
254 if (SvROK (sv) && sv_derived_from (sv, pkg)) 252 if (SvROK (sv) && sv_derived_from (sv, pkg))
255 return (void *)SvIV (SvRV (sv)); 253 return (void *)SvIV (SvRV (sv));
256 254
257 croak ("%s: %s is not of type %s", func, svname, pkg); 255 croak ("%s: %s is not of type %s", cv_get_name (cv), svname, pkg);
258} 256}
259 257
260// the "no-inherit" version of the above 258// the "no-inherit" version of the above
261static void * ecb_noinline 259static void * ecb_noinline
262SvCLOBJ_ni (const char *func, const char *svname, SV *sv, HV *stash) 260SvCLOBJ_ni (CV *cv, const char *svname, SV *sv, HV *stash)
263{ 261{
264 if (SvROK (sv) && SvSTASH (SvRV (sv)) == stash) 262 if (SvROK (sv) && SvSTASH (SvRV (sv)) == stash)
265 return (void *)SvIV (SvRV (sv)); 263 return (void *)SvIV (SvRV (sv));
266 264
267 croak ("%s: %s is not of type %s", func, svname, HvNAME (stash)); 265 croak ("%s: %s is not of type %s", cv_get_name (cv), svname, HvNAME (stash));
268} 266}
269 267
270/*****************************************************************************/ 268/*****************************************************************************/
271 269
272static cl_context_properties * ecb_noinline 270static cl_context_properties * ecb_noinline
273SvCONTEXTPROPERTIES (const char *func, const char *svname, SV *sv, cl_context_properties *extra, int extracount) 271SvCONTEXTPROPERTIES (CV *cv, const char *svname, SV *sv, cl_context_properties *extra, int extracount)
274{ 272{
275 if (!sv || !SvOK (sv)) 273 if (!sv || !SvOK (sv))
276 if (extra) 274 if (extra)
277 sv = sv_2mortal (newRV_noinc ((SV *)newAV ())); // slow, but rarely used hopefully 275 sv = sv_2mortal (newRV_noinc ((SV *)newAV ())); // slow, but rarely used hopefully
278 else 276 else
284 int i, len = av_len (av) + 1; 282 int i, len = av_len (av) + 1;
285 cl_context_properties *p = tmpbuf (sizeof (cl_context_properties) * (len + extracount + 1)); 283 cl_context_properties *p = tmpbuf (sizeof (cl_context_properties) * (len + extracount + 1));
286 cl_context_properties *l = p; 284 cl_context_properties *l = p;
287 285
288 if (len & 1) 286 if (len & 1)
289 croak ("%s: %s is not a property list (must contain an even number of elements)", func, svname); 287 croak ("%s: %s is not a property list (must contain an even number of elements)", cv_get_name (cv), svname);
290 288
291 while (extracount--) 289 while (extracount--)
292 *l++ = *extra++; 290 *l++ = *extra++;
293 291
294 for (i = 0; i < len; i += 2) 292 for (i = 0; i < len; i += 2)
299 297
300 switch (t) 298 switch (t)
301 { 299 {
302 case CL_CONTEXT_PLATFORM: 300 case CL_CONTEXT_PLATFORM:
303 if (SvROK (p_sv)) 301 if (SvROK (p_sv))
304 v = (cl_context_properties)SvCLOBJ (func, svname, p_sv, "OpenCL::Platform"); 302 v = (cl_context_properties)SvCLOBJ (cv, svname, p_sv, "OpenCL::Platform");
305 break; 303 break;
306 304
307 case CL_GLX_DISPLAY_KHR: 305 case CL_GLX_DISPLAY_KHR:
308 if (!SvOK (p_sv)) 306 if (!SvOK (p_sv))
309 { 307 {
334 *l = 0; 332 *l = 0;
335 333
336 return p; 334 return p;
337 } 335 }
338 336
339 croak ("%s: %s is not a property list (either undef or [type => value, ...])", func, svname); 337 croak ("%s: %s is not a property list (either undef or [type => value, ...])", cv_get_name (cv), svname);
340} 338}
341 339
340// parse an array of CLOBJ into a void ** array in C - works only for CLOBJs whose representation
341// is a pointer (and only on well-behaved systems).
342static void * ecb_noinline 342static void * ecb_noinline
343object_list (CV *cv, int or_undef, const char *argname, SV *arg, const char *klass, cl_uint *rcount) 343object_list (CV *cv, int or_undef, const char *argname, SV *arg, const char *klass, cl_uint *rcount)
344{ 344{
345 const char *funcname = cv_get_name (cv);
346
347 if (!SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV) 345 if (!SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV)
348 croak ("%s: '%s' parameter must be %sa reference to an array of %s objects", 346 croak ("%s: '%s' parameter must be %sa reference to an array of %s objects",
349 funcname, argname, or_undef ? "undef or " : "", klass); 347 cv_get_name (cv), argname, or_undef ? "undef or " : "", klass);
350 348
351 AV *av = (AV *)SvRV (arg); 349 AV *av = (AV *)SvRV (arg);
352 void **list = 0; 350 void **list = 0;
353 cl_uint count = av_len (av) + 1; 351 cl_uint count = av_len (av) + 1;
354 352
355 if (count) 353 if (count)
356 { 354 {
357 list = tmpbuf (sizeof (*list) * count); 355 list = tmpbuf (sizeof (*list) * count);
358 int i; 356 int i;
359 for (i = 0; i < count; ++i) 357 for (i = 0; i < count; ++i)
360 list [i] = SvCLOBJ (funcname, argname, *av_fetch (av, i, 1), klass); 358 list [i] = SvCLOBJ (cv, argname, *av_fetch (av, i, 1), klass);
361 } 359 }
362 360
363 if (!count && !or_undef) 361 if (!count && !or_undef)
364 croak ("%s: '%s' must contain at least one %s object", 362 croak ("%s: '%s' must contain at least one %s object",
365 funcname, argname, klass); 363 cv_get_name (cv), argname, klass);
366 364
367 *rcount = count; 365 *rcount = count;
368 return (void *)list; 366 return (void *)list;
369} 367}
370 368
628 clGetImageInfo (img, CL_IMAGE_ROW_PITCH, sizeof (res), &res, 0); 626 clGetImageInfo (img, CL_IMAGE_ROW_PITCH, sizeof (res), &res, 0);
629 return res; 627 return res;
630} 628}
631 629
632static cl_event * ecb_noinline 630static cl_event * ecb_noinline
633event_list (SV **items, cl_uint *rcount, cl_event extra) 631event_list (CV *cv, SV **items, cl_uint *rcount, cl_event extra)
634{ 632{
635 cl_uint count = *rcount; 633 cl_uint count = *rcount;
636 634
637 if (count > 0x7fffffffU) // yeah, it's a hack - the caller might have underflowed 635 if (count > 0x7fffffffU) // yeah, it's a hack - the caller might have underflowed
638 *rcount = count = 0; 636 *rcount = count = 0;
643 cl_event *list = tmpbuf (sizeof (cl_event) * (count + 1)); 641 cl_event *list = tmpbuf (sizeof (cl_event) * (count + 1));
644 int i = 0; 642 int i = 0;
645 643
646 while (count--) 644 while (count--)
647 if (SvOK (items [count])) 645 if (SvOK (items [count]))
648 list [i++] = SvCLOBJ ("clEnqueue", "wait_events", items [count], "OpenCL::Event"); 646 list [i++] = SvCLOBJ (cv, "wait_events", items [count], "OpenCL::Event");
649 647
650 if (extra) 648 if (extra)
651 list [i++] = extra; 649 list [i++] = extra;
652 650
653 *rcount = i; 651 *rcount = i;
655 return i ? list : 0; 653 return i ? list : 0;
656} 654}
657 655
658#define EVENT_LIST(skip) \ 656#define EVENT_LIST(skip) \
659 cl_uint event_list_count = items - (skip); \ 657 cl_uint event_list_count = items - (skip); \
660 cl_event *event_list_ptr = event_list (&ST (skip), &event_list_count, 0) 658 cl_event *event_list_ptr = event_list (cv, &ST (skip), &event_list_count, 0)
661 659
662#define INFO(class) \ 660#define INFO(class) \
663{ \ 661{ \
664 size_t size; \ 662 size_t size; \
665 NEED_SUCCESS (Get ## class ## Info, (self, name, 0, 0, &size)); \ 663 NEED_SUCCESS (Get ## class ## Info, (self, name, 0, 0, &size)); \
747 745
748 mapped->ptr = 0; 746 mapped->ptr = 0;
749} 747}
750 748
751static void 749static void
752mapped_unmap (SV *self, OpenCL__Mapped mapped, cl_command_queue queue, SV **wait_list, cl_uint event_list_count) 750mapped_unmap (CV *cv, SV *self, OpenCL__Mapped mapped, cl_command_queue queue, SV **wait_list, cl_uint event_list_count)
753{ 751{
754 cl_event *event_list_ptr = event_list (wait_list, &event_list_count, mapped->event); 752 cl_event *event_list_ptr = event_list (cv, wait_list, &event_list_count, mapped->event);
755 cl_event ev; 753 cl_event ev;
756 754
757 NEED_SUCCESS (EnqueueUnmapMemObject, (queue, mapped->memobj, mapped->ptr, event_list_count, event_list_ptr, &ev)); 755 NEED_SUCCESS (EnqueueUnmapMemObject, (queue, mapped->memobj, mapped->ptr, event_list_count, event_list_ptr, &ev));
758 756
759 clReleaseEvent (mapped->event); 757 clReleaseEvent (mapped->event);
792 { sizeof (cl_long ), "SIZEOF_LONG" }, 790 { sizeof (cl_long ), "SIZEOF_LONG" },
793 { sizeof (cl_ulong ), "SIZEOF_ULONG" }, 791 { sizeof (cl_ulong ), "SIZEOF_ULONG" },
794 { sizeof (cl_half ), "SIZEOF_HALF" }, 792 { sizeof (cl_half ), "SIZEOF_HALF" },
795 { sizeof (cl_float ), "SIZEOF_FLOAT" }, 793 { sizeof (cl_float ), "SIZEOF_FLOAT" },
796 { sizeof (cl_double), "SIZEOF_DOUBLE" }, 794 { sizeof (cl_double), "SIZEOF_DOUBLE" },
795 { PREFER_1_1 , "PREFER_1_1" },
797#include "constiv.h" 796#include "constiv.h"
798 }; 797 };
799 798
800 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) 799 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
801 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 800 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
861 CONTEXT_NOTIFY_CALLBACK; 860 CONTEXT_NOTIFY_CALLBACK;
862 NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (properties, type, pfn_notify, user_data, &res)); 861 NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (properties, type, pfn_notify, user_data, &res));
863 XPUSH_CLOBJ_CONTEXT; 862 XPUSH_CLOBJ_CONTEXT;
864 863
865void 864void
866context (FUTURE properties, FUTURE devices, FUTURE notify) 865context (cl_context_properties *properties, SV *devices, SV *notify = &PL_sv_undef)
867 PPCODE: 866 PPCODE:
868 /* der Gipfel der Kunst */ 867 cl_uint device_count;
868 cl_device_id *device_list = object_list (cv, 0, "devices", devices, "OpenCL::Device", &device_count);
869
870 CONTEXT_NOTIFY_CALLBACK;
871 NEED_SUCCESS_ARG (cl_context ctx, CreateContext, (properties, device_count, device_list, pfn_notify, user_data, &res));
872 XPUSH_CLOBJ_CONTEXT;
869 873
870void 874void
871wait_for_events (...) 875wait_for_events (...)
872 CODE: 876 CODE:
873 EVENT_LIST (0); 877 EVENT_LIST (0);
924 EXTEND (SP, count); 928 EXTEND (SP, count);
925 for (i = 0; i < count; ++i) 929 for (i = 0; i < count; ++i)
926 PUSH_CLOBJ (stash_device, list [i]); 930 PUSH_CLOBJ (stash_device, list [i]);
927 931
928void 932void
929context (OpenCL::Platform self, SV *properties = 0, SV *devices, SV *notify = &PL_sv_undef) 933context (OpenCL::Platform self, SV *properties, SV *devices, SV *notify = &PL_sv_undef)
930 PPCODE: 934 PPCODE:
931 cl_context_properties extra[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)self }; 935 cl_context_properties extra[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)self };
932 cl_context_properties *props = SvCONTEXTPROPERTIES ("OpenCL::Platform::context", "properties", properties, extra, 2); 936 cl_context_properties *props = SvCONTEXTPROPERTIES (cv, "properties", properties, extra, 2);
933 937
934 cl_uint device_count = 0; 938 cl_uint device_count;
935 cl_device_id *device_list = object_list (cv, 0, "devices", devices, "OpenCL::Device", &device_count); 939 cl_device_id *device_list = object_list (cv, 0, "devices", devices, "OpenCL::Device", &device_count);
936 940
937 CONTEXT_NOTIFY_CALLBACK; 941 CONTEXT_NOTIFY_CALLBACK;
938 NEED_SUCCESS_ARG (cl_context ctx, CreateContext, (props, device_count, device_list, pfn_notify, user_data, &res)); 942 NEED_SUCCESS_ARG (cl_context ctx, CreateContext, (props, device_count, device_list, pfn_notify, user_data, &res));
939 XPUSH_CLOBJ_CONTEXT; 943 XPUSH_CLOBJ_CONTEXT;
940 944
941void 945void
942context_from_type (OpenCL::Platform self, SV *properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, SV *notify = &PL_sv_undef) 946context_from_type (OpenCL::Platform self, SV *properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, SV *notify = &PL_sv_undef)
943 PPCODE: 947 PPCODE:
944 cl_context_properties extra[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)self }; 948 cl_context_properties extra[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)self };
945 cl_context_properties *props = SvCONTEXTPROPERTIES ("OpenCL::Platform::context_from_type", "properties", properties, extra, 2); 949 cl_context_properties *props = SvCONTEXTPROPERTIES (cv, "properties", properties, extra, 2);
946 950
947 CONTEXT_NOTIFY_CALLBACK; 951 CONTEXT_NOTIFY_CALLBACK;
948 NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (props, type, pfn_notify, user_data, &res)); 952 NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (props, type, pfn_notify, user_data, &res));
949 XPUSH_CLOBJ_CONTEXT; 953 XPUSH_CLOBJ_CONTEXT;
950 954
1274 const cl_image_desc desc = { 1278 const cl_image_desc desc = {
1275 type, 1279 type,
1276 width, height, depth, 1280 width, height, depth,
1277 array_size, row_pitch, slice_pitch, 1281 array_size, row_pitch, slice_pitch,
1278 num_mip_level, num_samples, 1282 num_mip_level, num_samples,
1279 type == CL_MEM_OBJECT_IMAGE1D_BUFFER ? (cl_mem)SvCLOBJ ("OpenCL::Context::Image", "data", data, "OpenCL::Buffer") : 0 1283 type == CL_MEM_OBJECT_IMAGE1D_BUFFER ? (cl_mem)SvCLOBJ (cv, "data", data, "OpenCL::Buffer") : 0
1280 }; 1284 };
1281 NEED_SUCCESS_ARG (cl_mem mem, CreateImage, (self, flags, &format, &desc, ptr, &res)); 1285 NEED_SUCCESS_ARG (cl_mem mem, CreateImage, (self, flags, &format, &desc, ptr, &res));
1282 HV *stash = stash_image; 1286 HV *stash = stash_image;
1283 switch (type) 1287 switch (type)
1284 { 1288 {
1420 XPUSH_CLOBJ (stash_program, prog); 1424 XPUSH_CLOBJ (stash_program, prog);
1421 1425
1422void 1426void
1423program_with_binary (OpenCL::Context self, SV *devices, SV *binaries) 1427program_with_binary (OpenCL::Context self, SV *devices, SV *binaries)
1424 PPCODE: 1428 PPCODE:
1425 if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV) 1429 cl_uint device_count;
1426 croak ("OpenCL::Context::program_with_binary: devices must be specified as reference to an array of device objects"); 1430 cl_device_id *device_list = object_list (cv, 0, "devices", devices, "OpenCL::Device", &device_count);
1427
1428 devices = SvRV (devices);
1429 1431
1430 if (!SvROK (binaries) || SvTYPE (SvRV (binaries)) != SVt_PVAV) 1432 if (!SvROK (binaries) || SvTYPE (SvRV (binaries)) != SVt_PVAV)
1431 croak ("OpenCL::Context::program_with_binary: binaries must be specified as reference to an array of strings"); 1433 croak ("OpenCL::Context::program_with_binary: binaries must be specified as reference to an array of strings");
1432 1434
1433 binaries = SvRV (binaries); 1435 binaries = SvRV (binaries);
1434 1436
1435 if (av_len ((AV *)devices) != av_len ((AV *)binaries)) 1437 if (device_count != av_len ((AV *)binaries) + 1)
1436 croak ("OpenCL::Context::program_with_binary: differing numbers of devices and binaries are not allowed"); 1438 croak ("OpenCL::Context::program_with_binary: differing numbers of devices and binaries are not allowed");
1437 1439
1438 int count = av_len ((AV *)devices) + 1;
1439 cl_device_id *device_list = tmpbuf (sizeof (*device_list) * count);
1440 size_t *length_list = tmpbuf (sizeof (*length_list) * count); 1440 size_t *length_list = tmpbuf (sizeof (*length_list) * device_count);
1441 const unsigned char **binary_list = tmpbuf (sizeof (*binary_list) * count); 1441 const unsigned char **binary_list = tmpbuf (sizeof (*binary_list) * device_count);
1442 cl_int *status_list = tmpbuf (sizeof (*status_list) * count); 1442 cl_int *status_list = tmpbuf (sizeof (*status_list) * device_count);
1443 1443
1444 int i; 1444 int i;
1445 for (i = 0; i < count; ++i) 1445 for (i = 0; i < device_count; ++i)
1446 { 1446 {
1447 device_list [i] = SvCLOBJ ("OpenCL::Context::program_with_binary", "devices", *av_fetch ((AV *)devices, i, 0), "OpenCL::Device");
1448 STRLEN len; 1447 STRLEN len;
1449 binary_list [i] = (const unsigned char *)SvPVbyte (*av_fetch ((AV *)binaries, i, 0), len); 1448 binary_list [i] = (const unsigned char *)SvPVbyte (*av_fetch ((AV *)binaries, i, 0), len);
1450 length_list [i] = len; 1449 length_list [i] = len;
1451 } 1450 }
1452 1451
1453 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithBinary, (self, count, device_list, length_list, binary_list, GIMME_V == G_ARRAY ? status_list : 0, &res)); 1452 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithBinary, (self, device_count, device_list,
1453 length_list, binary_list,
1454 GIMME_V == G_ARRAY ? status_list : 0, &res));
1454 1455
1455 EXTEND (SP, 2); 1456 EXTEND (SP, 2);
1456 PUSH_CLOBJ (stash_program, prog); 1457 PUSH_CLOBJ (stash_program, prog);
1457 1458
1458 if (GIMME_V == G_ARRAY) 1459 if (GIMME_V == G_ARRAY)
1459 { 1460 {
1460 AV *av = newAV (); 1461 AV *av = newAV ();
1461 PUSHs (sv_2mortal (newRV_noinc ((SV *)av))); 1462 PUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
1462 1463
1463 for (i = count; i--; ) 1464 for (i = device_count; i--; )
1464 av_store (av, i, newSViv (status_list [i])); 1465 av_store (av, i, newSViv (status_list [i]));
1465 } 1466 }
1466 1467
1467#if CL_VERSION_1_2 1468#if CL_VERSION_1_2
1468 1469
1469void 1470void
1470program_with_built_in_kernels (OpenCL::Context self, SV *devices, SV *kernel_names) 1471program_with_built_in_kernels (OpenCL::Context self, SV *devices, SV *kernel_names)
1471 PPCODE: 1472 PPCODE:
1472 cl_uint device_count = 0; 1473 cl_uint device_count;
1473 cl_device_id *device_list = object_list (cv, 0, "devices", devices, "OpenCL::Device", &device_count); 1474 cl_device_id *device_list = object_list (cv, 0, "devices", devices, "OpenCL::Device", &device_count);
1474 1475
1475 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithBuiltInKernels, (self, device_count, device_list, SvPVbyte_nolen (kernel_names), &res)); 1476 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithBuiltInKernels, (self, device_count, device_list, SvPVbyte_nolen (kernel_names), &res));
1476 1477
1477 XPUSH_CLOBJ (stash_program, prog); 1478 XPUSH_CLOBJ (stash_program, prog);
1478 1479
1902 XPUSHs (mapped_new (stash_mappedimage, self, img, map_flags, ptr, cb, ev, row_pitch, slice_pitch)); 1903 XPUSHs (mapped_new (stash_mappedimage, self, img, map_flags, ptr, cb, ev, row_pitch, slice_pitch));
1903 1904
1904void 1905void
1905unmap (OpenCL::Queue self, OpenCL::Mapped mapped, ...) 1906unmap (OpenCL::Queue self, OpenCL::Mapped mapped, ...)
1906 PPCODE: 1907 PPCODE:
1907 mapped_unmap (ST (1), mapped, self, &ST (2), items - 2); 1908 mapped_unmap (cv, ST (1), mapped, self, &ST (2), items - 2);
1908 if (GIMME_V != G_VOID) 1909 if (GIMME_V != G_VOID)
1909 { 1910 {
1910 clRetainEvent (mapped->event); 1911 clRetainEvent (mapped->event);
1911 XPUSH_CLOBJ (stash_event, mapped->event); 1912 XPUSH_CLOBJ (stash_event, mapped->event);
1912 } 1913 }
2459 HE *he; 2460 HE *he;
2460 int i = 0; 2461 int i = 0;
2461 while (he = hv_iternext (hv)) 2462 while (he = hv_iternext (hv))
2462 { 2463 {
2463 header_name [i] = SvPVbyte_nolen (HeSVKEY_force (he)); 2464 header_name [i] = SvPVbyte_nolen (HeSVKEY_force (he));
2464 header_list [i] = SvCLOBJ ("clCompileProgram", "headers", HeVAL (he), "OpenCL::Program"); 2465 header_list [i] = SvCLOBJ (cv, "headers", HeVAL (he), "OpenCL::Program");
2465 ++i; 2466 ++i;
2466 } 2467 }
2467 } 2468 }
2468 2469
2469 void *user_data; 2470 void *user_data;
2684 case 'f': arg.cf = SvNV (sv); size = sizeof (arg.cf); break; 2685 case 'f': arg.cf = SvNV (sv); size = sizeof (arg.cf); break;
2685 case 'd': arg.cd = SvNV (sv); size = sizeof (arg.cd); break; 2686 case 'd': arg.cd = SvNV (sv); size = sizeof (arg.cd); break;
2686 2687
2687 case 'z': nullarg = 1; size = SvIV (sv); break; 2688 case 'z': nullarg = 1; size = SvIV (sv); break;
2688 2689
2689 case 'm': nullarg = !SvOK (sv); arg.cm = SvCLOBJ ("OpenCL::Kernel::setf", "m", sv, "OpenCL::Memory" ); size = sizeof (arg.cm); break; 2690 case 'm': nullarg = !SvOK (sv); arg.cm = SvCLOBJ (cv, "m", sv, "OpenCL::Memory" ); size = sizeof (arg.cm); break;
2690 case 'a': nullarg = !SvOK (sv); arg.ca = SvCLOBJ ("OpenCL::Kernel::setf", "a", sv, "OpenCL::Sampler"); size = sizeof (arg.ca); break; 2691 case 'a': nullarg = !SvOK (sv); arg.ca = SvCLOBJ (cv, "a", sv, "OpenCL::Sampler"); size = sizeof (arg.ca); break;
2691 case 'e': nullarg = !SvOK (sv); arg.ca = SvCLOBJ ("OpenCL::Kernel::setf", "e", sv, "OpenCL::Event" ); size = sizeof (arg.ce); break; 2692 case 'e': nullarg = !SvOK (sv); arg.ca = SvCLOBJ (cv, "e", sv, "OpenCL::Event" ); size = sizeof (arg.ce); break;
2692 2693
2693 default: 2694 default:
2694 croak ("OpenCL::Kernel::setf format character '%c' not supported", type); 2695 croak ("OpenCL::Kernel::setf format character '%c' not supported", type);
2695 } 2696 }
2696 2697
3075 Safefree (mapped); 3076 Safefree (mapped);
3076 3077
3077void 3078void
3078unmap (OpenCL::Mapped self, ...) 3079unmap (OpenCL::Mapped self, ...)
3079 CODE: 3080 CODE:
3080 mapped_unmap (ST (0), self, self->queue, &ST (1), items - 1); 3081 mapped_unmap (cv, ST (0), self, self->queue, &ST (1), items - 1);
3081 3082
3082bool 3083bool
3083mapped (OpenCL::Mapped self) 3084mapped (OpenCL::Mapped self)
3084 CODE: 3085 CODE:
3085 RETVAL = !!self->ptr; 3086 RETVAL = !!self->ptr;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines