… | |
… | |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | #ifdef I_DLFCN |
5 | #ifdef I_DLFCN |
6 | #include <dlfcn.h> |
6 | #include <dlfcn.h> |
7 | #endif |
7 | #endif |
|
|
8 | |
|
|
9 | // how stupid is that, the 1.2 header files define CL_VERSION_1_1, |
|
|
10 | // but then fail to define the api functions unless you ALSO define |
|
|
11 | // this. This breaks 100% of the opencl 1.1 apps, for what reason? |
|
|
12 | // after all, the functions are deprecated, not removed. |
|
|
13 | // in addition, you cannot test for this in any future-proof way. |
|
|
14 | // each time a new opencl version comes out, you need to make a new |
|
|
15 | // release. |
|
|
16 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|
|
17 | #define CL_USE_DEPRECATED_OPENCL_1_2_APIS /* just guessing, you stupid idiots */ |
8 | |
18 | |
9 | #ifdef __APPLE__ |
19 | #ifdef __APPLE__ |
10 | #include <OpenCL/opencl.h> |
20 | #include <OpenCL/opencl.h> |
11 | #else |
21 | #else |
12 | #include <CL/opencl.h> |
22 | #include <CL/opencl.h> |
… | |
… | |
36 | typedef SV *FUTURE; |
46 | typedef SV *FUTURE; |
37 | |
47 | |
38 | /*****************************************************************************/ |
48 | /*****************************************************************************/ |
39 | |
49 | |
40 | // name must include a leading underscore |
50 | // name must include a leading underscore |
|
|
51 | // all of this horrors would be unneceesary if somebody wrote a proper OpenGL module |
|
|
52 | // for perl. doh. |
41 | static void * |
53 | static void * |
42 | getsym (const char *name) |
54 | glsym (const char *name) |
43 | { |
55 | { |
|
|
56 | void *fun = 0; |
|
|
57 | |
44 | #if defined I_DLFCN && defined RTLD_DEFAULT |
58 | #if defined I_DLFCN && defined RTLD_DEFAULT |
45 | #if !DLSYM_NEEDS_UNDERSCORE |
59 | fun = dlsym (RTLD_DEFAULT, name + 1); |
46 | ++name; // skip _ |
|
|
47 | #endif |
|
|
48 | return dlsym (RTLD_DEFAULT, name); |
60 | if (!fun) fun = dlsym (RTLD_DEFAULT, name); |
49 | #else |
61 | |
50 | return 0; |
62 | if (!fun) |
|
|
63 | { |
|
|
64 | static void *libgl; |
|
|
65 | static const char *glso[] = { |
|
|
66 | "libGL.so.1", |
|
|
67 | "libGL.so.3", |
|
|
68 | "libGL.so.4.0", |
|
|
69 | "libGL.so", |
|
|
70 | "/usr/lib/libGL.so", |
|
|
71 | "/usr/X11R6/lib/libGL.1.dylib" |
|
|
72 | }; |
|
|
73 | int i; |
|
|
74 | |
|
|
75 | for (i = 0; !libgl && i < sizeof (glso) / sizeof (glso [0]); ++i) |
|
|
76 | { |
|
|
77 | libgl = dlopen (glso [i], RTLD_LAZY); |
|
|
78 | if (libgl) |
|
|
79 | break; |
|
|
80 | } |
|
|
81 | |
|
|
82 | if (libgl) |
|
|
83 | { |
|
|
84 | fun = dlsym (libgl, name + 1); |
|
|
85 | if (!fun) fun = dlsym (libgl, name); |
|
|
86 | } |
|
|
87 | } |
51 | #endif |
88 | #endif |
|
|
89 | |
|
|
90 | return fun; |
52 | } |
91 | } |
53 | |
92 | |
54 | /*****************************************************************************/ |
93 | /*****************************************************************************/ |
55 | |
94 | |
56 | /* up to two temporary buffers */ |
95 | /* up to two temporary buffers */ |
… | |
… | |
60 | enum { buffers = 3 }; |
99 | enum { buffers = 3 }; |
61 | static int idx; |
100 | static int idx; |
62 | static void *buf [buffers]; |
101 | static void *buf [buffers]; |
63 | static size_t len [buffers]; |
102 | static size_t len [buffers]; |
64 | |
103 | |
65 | idx = ++idx % buffers; |
104 | idx = (idx + 1) % buffers; |
66 | |
105 | |
67 | if (len [idx] < size) |
106 | if (len [idx] < size) |
68 | { |
107 | { |
69 | free (buf [idx]); |
108 | free (buf [idx]); |
70 | len [idx] = ((size + 31) & ~4095) + 4096 - 32; |
109 | len [idx] = ((size + 31) & ~4095) + 4096 - 32; |
… | |
… | |
178 | |
217 | |
179 | for (i = 0; i < len; i += 2) |
218 | for (i = 0; i < len; i += 2) |
180 | { |
219 | { |
181 | cl_context_properties t = SvIV (*av_fetch (av, i , 0)); |
220 | cl_context_properties t = SvIV (*av_fetch (av, i , 0)); |
182 | SV *p_sv = *av_fetch (av, i + 1, 0); |
221 | SV *p_sv = *av_fetch (av, i + 1, 0); |
183 | cl_context_properties v; |
222 | cl_context_properties v = SvIV (p_sv); // code below can override |
184 | |
223 | |
185 | switch (t) |
224 | switch (t) |
186 | { |
225 | { |
|
|
226 | case CL_GLX_DISPLAY_KHR: |
|
|
227 | if (!SvOK (p_sv)) |
|
|
228 | { |
|
|
229 | void *func = glsym ("_glXGetCurrentDisplay"); |
|
|
230 | if (func) |
|
|
231 | v = (cl_context_properties)((void *(*)(void))func)(); |
|
|
232 | } |
|
|
233 | break; |
|
|
234 | |
|
|
235 | case CL_GL_CONTEXT_KHR: |
|
|
236 | if (!SvOK (p_sv)) |
|
|
237 | { |
|
|
238 | void *func = glsym ("_glXGetCurrentContext"); |
|
|
239 | if (func) |
|
|
240 | v = (cl_context_properties)((void *(*)(void))func)(); |
|
|
241 | } |
|
|
242 | break; |
|
|
243 | |
187 | default: |
244 | default: |
188 | /* unknown property, treat as int */ |
245 | /* unknown property, treat as int */ |
189 | v = SvIV (p_sv); |
|
|
190 | break; |
246 | break; |
191 | } |
247 | } |
192 | |
248 | |
193 | *l++ = t; |
249 | *l++ = t; |
194 | *l++ = v; |
250 | *l++ = v; |
… | |
… | |
211 | clGetImageInfo (img, CL_IMAGE_ROW_PITCH, sizeof (res), &res, 0); |
267 | clGetImageInfo (img, CL_IMAGE_ROW_PITCH, sizeof (res), &res, 0); |
212 | return res; |
268 | return res; |
213 | } |
269 | } |
214 | |
270 | |
215 | static cl_event * |
271 | static cl_event * |
216 | event_list (SV **items, int count) |
272 | event_list (SV **items, cl_uint *rcount) |
217 | { |
273 | { |
|
|
274 | cl_uint count = *rcount; |
|
|
275 | |
218 | if (!count) |
276 | if (!count) |
219 | return 0; |
277 | return 0; |
220 | |
278 | |
221 | cl_event *list = tmpbuf (sizeof (cl_event) * count); |
279 | cl_event *list = tmpbuf (sizeof (cl_event) * count); |
|
|
280 | int i = 0; |
222 | |
281 | |
223 | while (count--) |
282 | do |
|
|
283 | { |
|
|
284 | --count; |
|
|
285 | if (SvOK (items [count])) |
224 | list [count] = SvPTROBJ ("clEnqueue", "wait_events", items [count], "OpenCL::Event"); |
286 | list [i++] = SvPTROBJ ("clEnqueue", "wait_events", items [count], "OpenCL::Event"); |
|
|
287 | } |
|
|
288 | while (count); |
225 | |
289 | |
|
|
290 | *rcount = i; |
|
|
291 | |
226 | return list; |
292 | return i ? list : 0; |
227 | } |
293 | } |
228 | |
294 | |
229 | #define EVENT_LIST(items,count) \ |
295 | #define EVENT_LIST(items,count) \ |
230 | cl_uint event_list_count = (count); \ |
296 | cl_uint event_list_count = (count); \ |
231 | cl_event *event_list_ptr = event_list (&ST (items), event_list_count) |
297 | cl_event *event_list_ptr = event_list (&ST (items), &event_list_count) |
232 | |
298 | |
233 | #define INFO(class) \ |
299 | #define INFO(class) \ |
234 | { \ |
300 | { \ |
235 | size_t size; \ |
301 | size_t size; \ |
236 | NEED_SUCCESS (Get ## class ## Info, (self, name, 0, 0, &size)); \ |
302 | NEED_SUCCESS (Get ## class ## Info, (self, name, 0, 0, &size)); \ |
… | |
… | |
268 | } |
334 | } |
269 | |
335 | |
270 | cl_int |
336 | cl_int |
271 | errno () |
337 | errno () |
272 | CODE: |
338 | CODE: |
273 | errno = res; |
339 | RETVAL = res; |
|
|
340 | OUTPUT: |
|
|
341 | RETVAL |
274 | |
342 | |
275 | const char * |
343 | const char * |
276 | err2str (cl_int err) |
344 | err2str (cl_int err) |
277 | |
345 | |
278 | const char * |
346 | const char * |
… | |
… | |
297 | context_from_type (cl_context_properties *properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0) |
365 | context_from_type (cl_context_properties *properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0) |
298 | PPCODE: |
366 | PPCODE: |
299 | NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (properties, type, 0, 0, &res)); |
367 | NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (properties, type, 0, 0, &res)); |
300 | XPUSH_NEW_OBJ ("OpenCL::Context", ctx); |
368 | XPUSH_NEW_OBJ ("OpenCL::Context", ctx); |
301 | |
369 | |
|
|
370 | #if 0 |
|
|
371 | |
302 | void |
372 | void |
303 | context (cl_context_properties *properties = 0, FUTURE devices, FUTURE notify = 0) |
373 | context (cl_context_properties *properties = 0, FUTURE devices, FUTURE notify = 0) |
304 | PPCODE: |
374 | PPCODE: |
305 | /* der Gipfel der Kunst */ |
375 | /* der Gipfel der Kunst */ |
|
|
376 | |
|
|
377 | #endif |
306 | |
378 | |
307 | void |
379 | void |
308 | wait_for_events (...) |
380 | wait_for_events (...) |
309 | CODE: |
381 | CODE: |
310 | EVENT_LIST (0, items); |
382 | EVENT_LIST (0, items); |
… | |
… | |
652 | if (!(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR))) |
724 | if (!(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR))) |
653 | croak ("OpenCL::Context::buffer_sv: you have to specify use or copy host ptr when buffer data is given, use $context->buffer instead?"); |
725 | croak ("OpenCL::Context::buffer_sv: you have to specify use or copy host ptr when buffer data is given, use $context->buffer instead?"); |
654 | NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (self, flags, len, ptr, &res)); |
726 | NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (self, flags, len, ptr, &res)); |
655 | XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); |
727 | XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); |
656 | |
728 | |
|
|
729 | #if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|
|
730 | |
657 | void |
731 | void |
658 | image2d (OpenCL::Context self, 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) |
732 | image2d (OpenCL::Context self, 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) |
659 | PPCODE: |
733 | PPCODE: |
660 | STRLEN len; |
734 | STRLEN len; |
661 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
735 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
… | |
… | |
670 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
744 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
671 | const cl_image_format format = { channel_order, channel_type }; |
745 | const cl_image_format format = { channel_order, channel_type }; |
672 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (self, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res)); |
746 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (self, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res)); |
673 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
747 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
674 | |
748 | |
|
|
749 | #endif |
|
|
750 | |
675 | #if cl_apple_gl_sharing || cl_khr_gl_sharing |
751 | #if cl_apple_gl_sharing || cl_khr_gl_sharing |
676 | |
752 | |
677 | void |
753 | void |
678 | gl_buffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint bufobj) |
754 | gl_buffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint bufobj) |
679 | PPCODE: |
755 | PPCODE: |
680 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLBuffer, (self, flags, bufobj, &res)); |
756 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLBuffer, (self, flags, bufobj, &res)); |
681 | XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); |
757 | XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); |
682 | |
758 | |
|
|
759 | #if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|
|
760 | |
683 | void |
761 | void |
684 | gl_texture2d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
762 | gl_texture2d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
685 | PPCODE: |
763 | PPCODE: |
686 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture2D, (self, flags, target, miplevel, texture, &res)); |
764 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture2D, (self, flags, target, miplevel, texture, &res)); |
687 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
765 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
… | |
… | |
689 | void |
767 | void |
690 | gl_texture3d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
768 | gl_texture3d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
691 | PPCODE: |
769 | PPCODE: |
692 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture3D, (self, flags, target, miplevel, texture, &res)); |
770 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture3D, (self, flags, target, miplevel, texture, &res)); |
693 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
771 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
|
|
772 | |
|
|
773 | #endif |
694 | |
774 | |
695 | void |
775 | void |
696 | gl_renderbuffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint renderbuffer) |
776 | gl_renderbuffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint renderbuffer) |
697 | PPCODE: |
777 | PPCODE: |
698 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLRenderbuffer, (self, flags, renderbuffer, &res)); |
778 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLRenderbuffer, (self, flags, renderbuffer, &res)); |
… | |
… | |
809 | cl_event ev = 0; |
889 | cl_event ev = 0; |
810 | STRLEN len; |
890 | STRLEN len; |
811 | char *ptr = SvPVbyte (data, len); |
891 | char *ptr = SvPVbyte (data, len); |
812 | EVENT_LIST (5, items - 5); |
892 | EVENT_LIST (5, items - 5); |
813 | |
893 | |
814 | NEED_SUCCESS (EnqueueReadBuffer, (self, mem, blocking, offset, len, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); |
894 | NEED_SUCCESS (EnqueueWriteBuffer, (self, mem, blocking, offset, len, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); |
815 | |
895 | |
816 | if (ev) |
896 | if (ev) |
817 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
897 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
818 | |
898 | |
819 | void |
899 | void |
… | |
… | |
885 | size_t min_len = host_row_pitch * host_slice_pitch * region [2]; |
965 | size_t min_len = host_row_pitch * host_slice_pitch * region [2]; |
886 | |
966 | |
887 | if (len < min_len) |
967 | if (len < min_len) |
888 | croak ("clEnqueueWriteImage: data string is shorter than what would be transferred"); |
968 | croak ("clEnqueueWriteImage: data string is shorter than what would be transferred"); |
889 | |
969 | |
890 | NEED_SUCCESS (EnqueueWriteBufferRect, (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)); |
970 | 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)); |
891 | |
971 | |
892 | if (ev) |
972 | if (ev) |
893 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
973 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
894 | |
974 | |
895 | void |
975 | void |
… | |
… | |
950 | size_t min_len = slice_pitch ? slice_pitch * depth : row_pitch * height; |
1030 | size_t min_len = slice_pitch ? slice_pitch * depth : row_pitch * height; |
951 | |
1031 | |
952 | if (len < min_len) |
1032 | if (len < min_len) |
953 | croak ("clEnqueueWriteImage: data string is shorter than what would be transferred"); |
1033 | croak ("clEnqueueWriteImage: data string is shorter than what would be transferred"); |
954 | |
1034 | |
955 | NEED_SUCCESS (EnqueueWriteImage, (self, dst, blocking, dst_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); |
1035 | 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)); |
956 | |
1036 | |
957 | if (ev) |
1037 | if (ev) |
958 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1038 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
959 | |
1039 | |
960 | void |
1040 | void |
… | |
… | |
1042 | gwo [i] = SvIV (AvARRAY (SvRV (global_work_offset))[i]); |
1122 | gwo [i] = SvIV (AvARRAY (SvRV (global_work_offset))[i]); |
1043 | } |
1123 | } |
1044 | |
1124 | |
1045 | if (SvOK (local_work_size)) |
1125 | if (SvOK (local_work_size)) |
1046 | { |
1126 | { |
1047 | if (SvOK (local_work_size) && !SvROK (local_work_size) || SvTYPE (SvRV (local_work_size)) != SVt_PVAV) |
1127 | if ((SvOK (local_work_size) && !SvROK (local_work_size)) || SvTYPE (SvRV (local_work_size)) != SVt_PVAV) |
1048 | croak ("clEnqueueNDRangeKernel: global_work_size must be undef or an array reference"); |
1128 | croak ("clEnqueueNDRangeKernel: global_work_size must be undef or an array reference"); |
1049 | |
1129 | |
1050 | if (AvFILLp (SvRV (local_work_size)) + 1 != gws_len) |
1130 | if (AvFILLp (SvRV (local_work_size)) + 1 != gws_len) |
1051 | croak ("clEnqueueNDRangeKernel: local_work_local must be undef or an array of same size as global_work_size"); |
1131 | croak ("clEnqueueNDRangeKernel: local_work_local must be undef or an array of same size as global_work_size"); |
1052 | |
1132 | |
… | |
… | |
1064 | |
1144 | |
1065 | void |
1145 | void |
1066 | enqueue_acquire_gl_objects (OpenCL::Queue self, SV *objects, ...) |
1146 | enqueue_acquire_gl_objects (OpenCL::Queue self, SV *objects, ...) |
1067 | ALIAS: |
1147 | ALIAS: |
1068 | enqueue_release_gl_objects = 1 |
1148 | enqueue_release_gl_objects = 1 |
1069 | CODE: |
1149 | PPCODE: |
1070 | if (!SvROK (objects) || SvTYPE (SvRV (objects)) != SVt_PVAV) |
1150 | if (!SvROK (objects) || SvTYPE (SvRV (objects)) != SVt_PVAV) |
1071 | croak ("OpenCL::Queue::enqueue_acquire/release_gl_objects argument 'objects' must be an arrayref with memory objects, in call"); |
1151 | croak ("OpenCL::Queue::enqueue_acquire/release_gl_objects argument 'objects' must be an arrayref with memory objects, in call"); |
1072 | |
1152 | |
1073 | cl_event ev = 0; |
1153 | cl_event ev = 0; |
1074 | EVENT_LIST (2, items - 2); |
1154 | EVENT_LIST (2, items - 2); |
… | |
… | |
1088 | if (ev) |
1168 | if (ev) |
1089 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1169 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1090 | |
1170 | |
1091 | #endif |
1171 | #endif |
1092 | |
1172 | |
|
|
1173 | #if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|
|
1174 | |
1093 | void |
1175 | void |
1094 | enqueue_marker (OpenCL::Queue self) |
1176 | enqueue_marker (OpenCL::Queue self) |
1095 | PPCODE: |
1177 | PPCODE: |
1096 | cl_event ev; |
1178 | cl_event ev; |
1097 | NEED_SUCCESS (EnqueueMarker, (self, &ev)); |
1179 | NEED_SUCCESS (EnqueueMarker, (self, &ev)); |
… | |
… | |
1105 | |
1187 | |
1106 | void |
1188 | void |
1107 | enqueue_barrier (OpenCL::Queue self) |
1189 | enqueue_barrier (OpenCL::Queue self) |
1108 | CODE: |
1190 | CODE: |
1109 | NEED_SUCCESS (EnqueueBarrier, (self)); |
1191 | NEED_SUCCESS (EnqueueBarrier, (self)); |
|
|
1192 | |
|
|
1193 | #endif |
1110 | |
1194 | |
1111 | void |
1195 | void |
1112 | flush (OpenCL::Queue self) |
1196 | flush (OpenCL::Queue self) |
1113 | CODE: |
1197 | CODE: |
1114 | NEED_SUCCESS (Flush, (self)); |
1198 | NEED_SUCCESS (Flush, (self)); |
… | |
… | |
1484 | { |
1568 | { |
1485 | SV *sv = sv_2mortal (newSV (sizes [i])); |
1569 | SV *sv = sv_2mortal (newSV (sizes [i])); |
1486 | SvUPGRADE (sv, SVt_PV); |
1570 | SvUPGRADE (sv, SVt_PV); |
1487 | SvPOK_only (sv); |
1571 | SvPOK_only (sv); |
1488 | SvCUR_set (sv, sizes [i]); |
1572 | SvCUR_set (sv, sizes [i]); |
1489 | ptrs [i] = SvPVX (sv); |
1573 | ptrs [i] = (void *)SvPVX (sv); |
1490 | PUSHs (sv); |
1574 | PUSHs (sv); |
1491 | } |
1575 | } |
1492 | |
1576 | |
1493 | NEED_SUCCESS (GetProgramInfo, (self, CL_PROGRAM_BINARIES , sizeof (*ptrs ) * n, ptrs , &size)); |
1577 | NEED_SUCCESS (GetProgramInfo, (self, CL_PROGRAM_BINARIES , sizeof (*ptrs ) * n, ptrs , &size)); |
1494 | if (size != sizeof (*ptrs) * n) XSRETURN_EMPTY; |
1578 | if (size != sizeof (*ptrs) * n) XSRETURN_EMPTY; |
… | |
… | |
1644 | set_sampler (OpenCL::Kernel self, cl_uint idx, OpenCL::Sampler value) |
1728 | set_sampler (OpenCL::Kernel self, cl_uint idx, OpenCL::Sampler value) |
1645 | CODE: |
1729 | CODE: |
1646 | clSetKernelArg (self, idx, sizeof (value), &value); |
1730 | clSetKernelArg (self, idx, sizeof (value), &value); |
1647 | |
1731 | |
1648 | void |
1732 | void |
|
|
1733 | set_local (OpenCL::Kernel self, cl_uint idx, size_t size) |
|
|
1734 | CODE: |
|
|
1735 | clSetKernelArg (self, idx, size, 0); |
|
|
1736 | |
|
|
1737 | void |
1649 | set_event (OpenCL::Kernel self, cl_uint idx, OpenCL::Event value) |
1738 | set_event (OpenCL::Kernel self, cl_uint idx, OpenCL::Event value) |
1650 | CODE: |
1739 | CODE: |
1651 | clSetKernelArg (self, idx, sizeof (value), &value); |
1740 | clSetKernelArg (self, idx, sizeof (value), &value); |
1652 | |
1741 | |
1653 | void |
1742 | void |