--- OpenCL/OpenCL.xs 2012/05/04 14:56:50 1.68 +++ OpenCL/OpenCL.xs 2012/05/05 02:33:55 1.70 @@ -155,6 +155,21 @@ return buf [idx]; } +static const char * ecb_noinline +cv_get_name (CV *cv) +{ + static char fullname [256]; + + GV *gv = CvGV (cv); // gv better be nonzero + + HV *stash = GvSTASH (gv); + const char *hvname = HvNAME_get (stash); // stash also better be nonzero + const char *gvname = GvNAME (gv); + + snprintf (fullname, sizeof (fullname), "%s::%s", hvname, gvname); + return fullname; +} + /*****************************************************************************/ typedef struct @@ -324,6 +339,35 @@ croak ("%s: %s is not a property list (either undef or [type => value, ...])", func, svname); } +static void * ecb_noinline +object_list (CV *cv, int or_undef, const char *argname, SV *arg, const char *klass, cl_uint *rcount) +{ + const char *funcname = cv_get_name (cv); + + if (!SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV) + croak ("%s: '%s' parameter must be %sa reference to an array of %s objects", + funcname, argname, or_undef ? "undef or " : "", klass); + + AV *av = (AV *)SvRV (arg); + void **list = 0; + cl_uint count = av_len (av) + 1; + + if (count) + { + list = tmpbuf (sizeof (*list) * count); + int i; + for (i = 0; i < count; ++i) + list [i] = SvCLOBJ (funcname, argname, *av_fetch (av, i, 1), klass); + } + + if (!count && !or_undef) + croak ("%s: '%s' must contain at least one %s object", + funcname, argname, klass); + + *rcount = count; + return (void *)list; +} + /*****************************************************************************/ /* callback stuff */ @@ -491,9 +535,28 @@ static void CL_CALLBACK eq_program_notify (cl_program program, void *user_data) { + clRetainProgram (program); + eq_enq (&eq_program_vtbl, user_data, (void *)program, 0, 0); } +typedef void (CL_CALLBACK *program_callback)(cl_program program, void *user_data); + +static program_callback ecb_noinline +make_program_callback (SV *notify, void **ruser_data) +{ + if (SvOK (notify)) + { + *ruser_data = SvREFCNT_inc (s_get_cv (notify)); + return eq_program_notify; + } + else + { + *ruser_data = 0; + return 0; + } +} + struct build_args { cl_program program; @@ -865,22 +928,14 @@ void context (OpenCL::Platform self, SV *properties = 0, SV *devices, SV *notify = &PL_sv_undef) PPCODE: - if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV) - croak ("OpenCL::Platform::context argument 'device' must be an arrayref with device objects, in call"); - cl_context_properties extra[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)self }; cl_context_properties *props = SvCONTEXTPROPERTIES ("OpenCL::Platform::context", "properties", properties, extra, 2); - AV *av = (AV *)SvRV (devices); - cl_uint num_devices = av_len (av) + 1; - cl_device_id *device_list = tmpbuf (sizeof (cl_device_id) * num_devices); - - int i; - for (i = num_devices; i--; ) - device_list [i] = SvCLOBJ ("clCreateContext", "devices", *av_fetch (av, i, 0), "OpenCL::Device"); + cl_uint device_count = 0; + cl_device_id *device_list = object_list (cv, 0, "devices", devices, "OpenCL::Device", &device_count); CONTEXT_NOTIFY_CALLBACK; - NEED_SUCCESS_ARG (cl_context ctx, CreateContext, (props, num_devices, device_list, pfn_notify, user_data, &res)); + NEED_SUCCESS_ARG (cl_context ctx, CreateContext, (props, device_count, device_list, pfn_notify, user_data, &res)); XPUSH_CLOBJ_CONTEXT; void @@ -1367,35 +1422,32 @@ void program_with_binary (OpenCL::Context self, SV *devices, SV *binaries) PPCODE: - if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV) - croak ("OpenCL::Context::program_with_binary: devices must be specified as reference to an array of device objects"); - - devices = SvRV (devices); + cl_uint device_count; + cl_device_id *device_list = object_list (cv, 0, "devices", devices, "OpenCL::Device", &device_count); if (!SvROK (binaries) || SvTYPE (SvRV (binaries)) != SVt_PVAV) croak ("OpenCL::Context::program_with_binary: binaries must be specified as reference to an array of strings"); binaries = SvRV (binaries); - if (av_len ((AV *)devices) != av_len ((AV *)binaries)) + if (device_count != av_len ((AV *)binaries) + 1) croak ("OpenCL::Context::program_with_binary: differing numbers of devices and binaries are not allowed"); - int count = av_len ((AV *)devices) + 1; - cl_device_id *device_list = tmpbuf (sizeof (*device_list) * count); - size_t *length_list = tmpbuf (sizeof (*length_list) * count); - const unsigned char **binary_list = tmpbuf (sizeof (*binary_list) * count); - cl_int *status_list = tmpbuf (sizeof (*status_list) * count); + size_t *length_list = tmpbuf (sizeof (*length_list) * device_count); + const unsigned char **binary_list = tmpbuf (sizeof (*binary_list) * device_count); + cl_int *status_list = tmpbuf (sizeof (*status_list) * device_count); int i; - for (i = 0; i < count; ++i) + for (i = 0; i < device_count; ++i) { - device_list [i] = SvCLOBJ ("OpenCL::Context::program_with_binary", "devices", *av_fetch ((AV *)devices, i, 0), "OpenCL::Device"); STRLEN len; binary_list [i] = (const unsigned char *)SvPVbyte (*av_fetch ((AV *)binaries, i, 0), len); length_list [i] = len; } - NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithBinary, (self, count, device_list, length_list, binary_list, GIMME_V == G_ARRAY ? status_list : 0, &res)); + NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithBinary, (self, device_count, device_list, + length_list, binary_list, + GIMME_V == G_ARRAY ? status_list : 0, &res)); EXTEND (SP, 2); PUSH_CLOBJ (stash_program, prog); @@ -1405,7 +1457,7 @@ AV *av = newAV (); PUSHs (sv_2mortal (newRV_noinc ((SV *)av))); - for (i = count; i--; ) + for (i = device_count; i--; ) av_store (av, i, newSViv (status_list [i])); } @@ -1414,19 +1466,30 @@ void program_with_built_in_kernels (OpenCL::Context self, SV *devices, SV *kernel_names) PPCODE: - if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV) - croak ("OpenCL::Context::program_with_built_in_kernels: devices must be specified as reference to an array of device objects"); + cl_uint device_count = 0; + cl_device_id *device_list = object_list (cv, 0, "devices", devices, "OpenCL::Device", &device_count); - devices = SvRV (devices); + NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithBuiltInKernels, (self, device_count, device_list, SvPVbyte_nolen (kernel_names), &res)); - int count = av_len ((AV *)devices) + 1; - cl_device_id *device_list = tmpbuf (sizeof (*device_list) * count); + XPUSH_CLOBJ (stash_program, prog); - int i; - for (i = 0; i < count; ++i) - device_list [i] = SvCLOBJ ("OpenCL::Context::program_with_built_in_kernels", "devices", *av_fetch ((AV *)devices, i, 0), "OpenCL::Device"); +void +link_program (OpenCL::Context self, SV *devices, SV *options, SV *programs, SV *notify = &PL_sv_undef) + CODE: + cl_uint device_count = 0; + cl_device_id *device_list = 0; + + if (SvOK (devices)) + device_list = object_list (cv, 1, "devices", devices, "OpenCL::Device", &device_count); + + cl_uint program_count; + cl_program *program_list = object_list (cv, 0, "programs", programs, "OpenCL::Program", &program_count); + + void *user_data; + program_callback pfn_notify = make_program_callback (notify, &user_data); - NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithBuiltInKernels, (self, count, device_list, SvPVbyte_nolen (kernel_names), &res)); + NEED_SUCCESS_ARG (cl_program prog, LinkProgram, (self, device_count, device_list, SvPVbyte_nolen (options), + program_count, program_list, pfn_notify, user_data, &res)); XPUSH_CLOBJ (stash_program, prog); @@ -1486,13 +1549,14 @@ ALIAS: enqueue_read_buffer = 0 PPCODE: - cl_event ev = 0; EVENT_LIST (6); SvUPGRADE (data, SVt_PV); SvGROW (data, len); SvPOK_only (data); SvCUR_set (data, len); + + cl_event ev = 0; NEED_SUCCESS (EnqueueReadBuffer, (self, mem, blocking, offset, len, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1503,11 +1567,12 @@ ALIAS: enqueue_write_buffer = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (5); + STRLEN len; char *ptr = SvPVbyte (data, len); - EVENT_LIST (5); + cl_event ev = 0; NEED_SUCCESS (EnqueueWriteBuffer, (self, mem, blocking, offset, len, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1520,11 +1585,12 @@ ALIAS: enqueue_fill_buffer = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (5); + STRLEN len; char *ptr = SvPVbyte (data, len); - EVENT_LIST (5); + cl_event ev = 0; NEED_SUCCESS (EnqueueFillBuffer, (self, mem, ptr, len, offset, size, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1535,10 +1601,10 @@ ALIAS: enqueue_fill_image = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (12); + const size_t origin [3] = { x, y, z }; const size_t region [3] = { width, height, depth }; - EVENT_LIST (12); const cl_float c_f [4] = { r, g, b, a }; const cl_uint c_u [4] = { r, g, b, a }; @@ -1551,6 +1617,7 @@ if (format.image_channel_data_type < CL_SNORM_INT8 || CL_FLOAT < format.image_channel_data_type) croak ("enqueue_fill_image: image has unsupported channel type, only opencl 1.2 channel types supported."); + cl_event ev = 0; NEED_SUCCESS (EnqueueFillImage, (self, img, c_fus [fus [format.image_channel_data_type - CL_SNORM_INT8]], origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); @@ -1564,9 +1631,9 @@ ALIAS: enqueue_copy_buffer = 0 PPCODE: - cl_event ev = 0; EVENT_LIST (6); + cl_event ev = 0; NEED_SUCCESS (EnqueueCopyBuffer, (self, src, dst, src_offset, dst_offset, len, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1577,11 +1644,11 @@ ALIAS: enqueue_read_buffer_rect = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (17); + const size_t buf_origin [3] = { buf_x , buf_y , buf_z }; const size_t host_origin[3] = { host_x, host_y, host_z }; const size_t region[3] = { width, height, depth }; - EVENT_LIST (17); if (!buf_row_pitch) buf_row_pitch = region [0]; @@ -1601,6 +1668,8 @@ SvGROW (data, len); SvPOK_only (data); SvCUR_set (data, len); + + cl_event ev = 0; NEED_SUCCESS (EnqueueReadBufferRect, (self, buf, blocking, buf_origin, host_origin, region, buf_row_pitch, buf_slice_pitch, host_row_pitch, host_slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1611,13 +1680,13 @@ ALIAS: enqueue_write_buffer_rect = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (17); + const size_t buf_origin [3] = { buf_x , buf_y , buf_z }; const size_t host_origin[3] = { host_x, host_y, host_z }; const size_t region[3] = { width, height, depth }; STRLEN len; char *ptr = SvPVbyte (data, len); - EVENT_LIST (17); if (!buf_row_pitch) buf_row_pitch = region [0]; @@ -1636,6 +1705,7 @@ if (len < min_len) croak ("clEnqueueWriteImage: data string is shorter than what would be transferred"); + cl_event ev = 0; NEED_SUCCESS (EnqueueWriteBufferRect, (self, buf, blocking, buf_origin, host_origin, region, buf_row_pitch, buf_slice_pitch, host_row_pitch, host_slice_pitch, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1646,12 +1716,13 @@ ALIAS: enqueue_copy_buffer_rect = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (16); + const size_t src_origin[3] = { src_x, src_y, src_z }; const size_t dst_origin[3] = { dst_x, dst_y, dst_z }; const size_t region[3] = { width, height, depth }; - EVENT_LIST (16); + cl_event ev = 0; NEED_SUCCESS (EnqueueCopyBufferRect, (self, 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)); if (ev) @@ -1662,10 +1733,10 @@ ALIAS: enqueue_read_image = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (12); + const size_t src_origin[3] = { src_x, src_y, src_z }; const size_t region[3] = { width, height, depth }; - EVENT_LIST (12); if (!row_pitch) row_pitch = img_row_pitch (src); @@ -1679,6 +1750,8 @@ SvGROW (data, len); SvPOK_only (data); SvCUR_set (data, len); + + cl_event ev = 0; NEED_SUCCESS (EnqueueReadImage, (self, src, blocking, src_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1689,12 +1762,12 @@ ALIAS: enqueue_write_image = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (12); + const size_t dst_origin[3] = { dst_x, dst_y, dst_z }; const size_t region[3] = { width, height, depth }; STRLEN len; char *ptr = SvPVbyte (data, len); - EVENT_LIST (12); if (!row_pitch) row_pitch = img_row_pitch (dst); @@ -1707,6 +1780,7 @@ if (len < min_len) croak ("clEnqueueWriteImage: data string is shorter than what would be transferred"); + cl_event ev = 0; NEED_SUCCESS (EnqueueWriteImage, (self, dst, blocking, dst_origin, region, row_pitch, slice_pitch, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1717,12 +1791,13 @@ ALIAS: enqueue_copy_image = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (12); + const size_t src_origin[3] = { src_x, src_y, src_z }; const size_t dst_origin[3] = { dst_x, dst_y, dst_z }; const size_t region[3] = { width, height, depth }; - EVENT_LIST (12); + cl_event ev = 0; NEED_SUCCESS (EnqueueCopyImage, (self, src, dst, src_origin, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1733,11 +1808,12 @@ ALIAS: enqueue_copy_image_to_buffer = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (10); + const size_t src_origin[3] = { src_x, src_y, src_z }; const size_t region [3] = { width, height, depth }; - EVENT_LIST (10); + cl_event ev = 0; NEED_SUCCESS (EnqueueCopyImageToBuffer, (self, src, dst, src_origin, region, dst_offset, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1748,11 +1824,12 @@ ALIAS: enqueue_copy_buffer_to_image = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (10); + const size_t dst_origin[3] = { dst_x, dst_y, dst_z }; const size_t region [3] = { width, height, depth }; - EVENT_LIST (10); + cl_event ev = 0; NEED_SUCCESS (EnqueueCopyBufferToImage, (self, src, dst, src_offset, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1763,8 +1840,8 @@ ALIAS: enqueue_map_buffer = 0 PPCODE: - cl_event ev; EVENT_LIST (6); + size_t cb = SvIV (cb_); if (!SvOK (cb_)) @@ -1773,6 +1850,7 @@ cb -= offset; } + cl_event ev; NEED_SUCCESS_ARG (void *ptr, EnqueueMapBuffer, (self, buf, blocking, map_flags, offset, cb, event_list_count, event_list_ptr, &ev, &res)); XPUSHs (mapped_new (stash_mappedbuffer, self, buf, map_flags, ptr, cb, ev, 0, 0)); @@ -1835,9 +1913,9 @@ ALIAS: enqueue_task = 0 PPCODE: - cl_event ev = 0; EVENT_LIST (2); + cl_event ev = 0; NEED_SUCCESS (EnqueueTask, (self, kernel, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1848,12 +1926,12 @@ ALIAS: enqueue_nd_range_kernel = 0 PPCODE: - cl_event ev = 0; + EVENT_LIST (5); + size_t *gwo = 0, *gws, *lws = 0; int gws_len; size_t *lists; int i; - EVENT_LIST (5); if (!SvROK (global_work_size) || SvTYPE (SvRV (global_work_size)) != SVt_PVAV) croak ("clEnqueueNDRangeKernel: global_work_size must be an array reference"); @@ -1902,6 +1980,7 @@ } } + cl_event ev = 0; NEED_SUCCESS (EnqueueNDRangeKernel, (self, kernel, gws_len, gwo, gws, lws, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) @@ -1916,20 +1995,11 @@ PPCODE: EVENT_LIST (3); - if (!SvROK (objects) || SvTYPE (SvRV (objects)) != SVt_PVAV) - croak ("OpenCL::Queue::migrate_mem_objects: objects must be an array reference with OpenCL::Memory objects"); - - objects = SvRV (objects); - - cl_uint object_count = av_len ((AV *)objects) + 1; - cl_mem *object_list = tmpbuf (sizeof (*object_list) * object_count); - - int i; - for (i = object_count; i--; ) - object_list [i] = SvCLOBJ ("OpenCL::Queue::migrate_mem_objects", "objects", *av_fetch ((AV *)objects, i, 0), "OpenCL::Memory"); + cl_uint obj_count; + cl_mem *obj_list = object_list (cv, 0, "objects", objects, "OpenCL::Memory", &obj_count); cl_event ev = 0; - NEED_SUCCESS (EnqueueMigrateMemObjects, (self, object_count, object_list, flags, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); + NEED_SUCCESS (EnqueueMigrateMemObjects, (self, obj_count, obj_list, flags, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) XPUSH_CLOBJ (stash_event, ev); @@ -1945,23 +2015,17 @@ enqueue_acquire_gl_objects = 0 enqueue_release_gl_objects = 1 PPCODE: - if (!SvROK (objects) || SvTYPE (SvRV (objects)) != SVt_PVAV) - croak ("OpenCL::Queue::enqueue_acquire/release_gl_objects argument 'objects' must be an arrayref with memory objects, in call"); - - cl_event ev = 0; EVENT_LIST (2); - AV *av = (AV *)SvRV (objects); - cl_uint num_objects = av_len (av) + 1; - cl_mem *object_list = tmpbuf (sizeof (cl_mem) * num_objects); - int i; - for (i = num_objects; i--; ) - object_list [i] = SvCLOBJ ("OpenCL::Queue::acquire/release_gl_objects", "objects", *av_fetch (av, i, 0), "OpenCL::Memory"); + cl_uint obj_count; + cl_mem *obj_list = object_list (cv, 0, "objects", objects, "OpenCL::Memory", &obj_count); + + cl_event ev = 0; if (ix) - NEED_SUCCESS (EnqueueReleaseGLObjects, (self, num_objects, object_list, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); + NEED_SUCCESS (EnqueueReleaseGLObjects, (self, obj_count, obj_list, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); else - NEED_SUCCESS (EnqueueAcquireGLObjects, (self, num_objects, object_list, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); + NEED_SUCCESS (EnqueueAcquireGLObjects, (self, obj_count, obj_list, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) XPUSH_CLOBJ (stash_event, ev); @@ -1985,8 +2049,8 @@ ALIAS: enqueue_marker = 0 PPCODE: - cl_event ev = 0; EVENT_LIST (1); + cl_event ev = 0; #if PREFER_1_1 if (!event_list_count) NEED_SUCCESS (EnqueueMarker, (self, GIMME_V != G_VOID ? &ev : 0)); @@ -2010,8 +2074,8 @@ ALIAS: enqueue_barrier = 0 PPCODE: - cl_event ev = 0; EVENT_LIST (1); + cl_event ev = 0; #if PREFER_1_1 if (!event_list_count && GIMME_V == G_VOID) NEED_SUCCESS (EnqueueBarrier, (self)); @@ -2349,39 +2413,63 @@ ALIAS: build_async = 1 CODE: - void (CL_CALLBACK *pfn_notify)(cl_program program, void *user_data) = 0; - void *user_data = 0; - cl_uint num_devices = 0; - cl_device_id *device_list = 0; + cl_uint device_count = 0; + cl_device_id *device_list = 0; if (SvOK (devices)) - { - if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV) - croak ("clProgramBuild: devices must be undef or an array of OpenCL::Device objects."); + device_list = object_list (cv, 1, "devices", devices, "OpenCL::Device", &device_count); - AV *av = (AV *)SvRV (devices); - num_devices = av_len (av) + 1; + void *user_data; + program_callback pfn_notify = make_program_callback (notify, &user_data); - if (num_devices) + if (ix) + build_program_async (self, device_count, device_list, SvPVbyte_nolen (options), user_data); + else + NEED_SUCCESS (BuildProgram, (self, device_count, device_list, SvPVbyte_nolen (options), pfn_notify, user_data)); + +#if CL_VERSION_1_2 + +void +compile (OpenCL::Program self, SV *devices, SV *options = &PL_sv_undef, SV *headers = &PL_sv_undef, SV *notify = &PL_sv_undef) + CODE: + cl_uint device_count = 0; + cl_device_id *device_list = 0; + + if (SvOK (devices)) + device_list = object_list (cv, 1, "devices", devices, "OpenCL::Device", &device_count); + + cl_uint header_count = 0; + cl_program *header_list = 0; + const char **header_name = 0; + + if (SvOK (headers)) + { + if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVHV) + croak ("clCompileProgram: headers must be undef or a hashref of name => OpenCL::Program pairs"); + + HV *hv = (HV *)SvRV (devices); + + header_count = hv_iterinit (hv); + header_list = tmpbuf (sizeof (*header_list) * header_count); + header_name = tmpbuf (sizeof (*header_name) * header_count); + + HE *he; + int i = 0; + while (he = hv_iternext (hv)) { - device_list = tmpbuf (sizeof (*device_list) * num_devices); - int count; - for (count = 0; count < num_devices; ++count) - device_list [count] = SvCLOBJ ("clBuildProgram", "devices", *av_fetch (av, count, 1), "OpenCL::Device"); + header_name [i] = SvPVbyte_nolen (HeSVKEY_force (he)); + header_list [i] = SvCLOBJ ("clCompileProgram", "headers", HeVAL (he), "OpenCL::Program"); + ++i; } } - if (SvOK (notify)) - { - NEED_SUCCESS (RetainProgram, (self)); - pfn_notify = eq_program_notify; - user_data = SvREFCNT_inc (s_get_cv (notify)); - } + void *user_data; + program_callback pfn_notify = make_program_callback (notify, &user_data); - if (ix) - build_program_async (self, num_devices, device_list, SvPVbyte_nolen (options), user_data); - else - NEED_SUCCESS (BuildProgram, (self, num_devices, device_list, SvPVbyte_nolen (options), pfn_notify, user_data)); + NEED_SUCCESS (CompileProgram, (self, device_count, device_list, SvPVbyte_nolen (options), + header_count, header_list, header_name, pfn_notify, user_data)); + +#endif void build_info (OpenCL::Program self, OpenCL::Device device, cl_program_build_info name)