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

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.3 by root, Tue Nov 15 20:38:07 2011 UTC vs.
Revision 1.21 by root, Mon Apr 16 06:39:54 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines