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.70 by root, Sat May 5 02:33:55 2012 UTC

1420 XPUSH_CLOBJ (stash_program, prog); 1420 XPUSH_CLOBJ (stash_program, prog);
1421 1421
1422void 1422void
1423program_with_binary (OpenCL::Context self, SV *devices, SV *binaries) 1423program_with_binary (OpenCL::Context self, SV *devices, SV *binaries)
1424 PPCODE: 1424 PPCODE:
1425 if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV) 1425 cl_uint device_count;
1426 croak ("OpenCL::Context::program_with_binary: devices must be specified as reference to an array of device objects"); 1426 cl_device_id *device_list = object_list (cv, 0, "devices", devices, "OpenCL::Device", &device_count);
1427
1428 devices = SvRV (devices);
1429 1427
1430 if (!SvROK (binaries) || SvTYPE (SvRV (binaries)) != SVt_PVAV) 1428 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"); 1429 croak ("OpenCL::Context::program_with_binary: binaries must be specified as reference to an array of strings");
1432 1430
1433 binaries = SvRV (binaries); 1431 binaries = SvRV (binaries);
1434 1432
1435 if (av_len ((AV *)devices) != av_len ((AV *)binaries)) 1433 if (device_count != av_len ((AV *)binaries) + 1)
1436 croak ("OpenCL::Context::program_with_binary: differing numbers of devices and binaries are not allowed"); 1434 croak ("OpenCL::Context::program_with_binary: differing numbers of devices and binaries are not allowed");
1437 1435
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); 1436 size_t *length_list = tmpbuf (sizeof (*length_list) * device_count);
1441 const unsigned char **binary_list = tmpbuf (sizeof (*binary_list) * count); 1437 const unsigned char **binary_list = tmpbuf (sizeof (*binary_list) * device_count);
1442 cl_int *status_list = tmpbuf (sizeof (*status_list) * count); 1438 cl_int *status_list = tmpbuf (sizeof (*status_list) * device_count);
1443 1439
1444 int i; 1440 int i;
1445 for (i = 0; i < count; ++i) 1441 for (i = 0; i < device_count; ++i)
1446 { 1442 {
1447 device_list [i] = SvCLOBJ ("OpenCL::Context::program_with_binary", "devices", *av_fetch ((AV *)devices, i, 0), "OpenCL::Device");
1448 STRLEN len; 1443 STRLEN len;
1449 binary_list [i] = (const unsigned char *)SvPVbyte (*av_fetch ((AV *)binaries, i, 0), len); 1444 binary_list [i] = (const unsigned char *)SvPVbyte (*av_fetch ((AV *)binaries, i, 0), len);
1450 length_list [i] = len; 1445 length_list [i] = len;
1451 } 1446 }
1452 1447
1453 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithBinary, (self, count, device_list, length_list, binary_list, GIMME_V == G_ARRAY ? status_list : 0, &res)); 1448 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithBinary, (self, device_count, device_list,
1449 length_list, binary_list,
1450 GIMME_V == G_ARRAY ? status_list : 0, &res));
1454 1451
1455 EXTEND (SP, 2); 1452 EXTEND (SP, 2);
1456 PUSH_CLOBJ (stash_program, prog); 1453 PUSH_CLOBJ (stash_program, prog);
1457 1454
1458 if (GIMME_V == G_ARRAY) 1455 if (GIMME_V == G_ARRAY)
1459 { 1456 {
1460 AV *av = newAV (); 1457 AV *av = newAV ();
1461 PUSHs (sv_2mortal (newRV_noinc ((SV *)av))); 1458 PUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
1462 1459
1463 for (i = count; i--; ) 1460 for (i = device_count; i--; )
1464 av_store (av, i, newSViv (status_list [i])); 1461 av_store (av, i, newSViv (status_list [i]));
1465 } 1462 }
1466 1463
1467#if CL_VERSION_1_2 1464#if CL_VERSION_1_2
1468 1465

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines