… | |
… | |
18 | |
18 | |
19 | #ifdef __APPLE__ |
19 | #ifdef __APPLE__ |
20 | #include <OpenCL/opencl.h> |
20 | #include <OpenCL/opencl.h> |
21 | #else |
21 | #else |
22 | #include <CL/opencl.h> |
22 | #include <CL/opencl.h> |
|
|
23 | #endif |
|
|
24 | |
|
|
25 | #if 0 // testing |
|
|
26 | #undef CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|
|
27 | #undef CL_VERSION_1_2 |
23 | #endif |
28 | #endif |
24 | |
29 | |
25 | typedef cl_platform_id OpenCL__Platform; |
30 | typedef cl_platform_id OpenCL__Platform; |
26 | typedef cl_device_id OpenCL__Device; |
31 | typedef cl_device_id OpenCL__Device; |
27 | typedef cl_context OpenCL__Context; |
32 | typedef cl_context OpenCL__Context; |
… | |
… | |
724 | if (!(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR))) |
729 | if (!(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR))) |
725 | croak ("OpenCL::Context::buffer_sv: you have to specify use or copy host ptr when buffer data is given, use $context->buffer instead?"); |
730 | croak ("OpenCL::Context::buffer_sv: you have to specify use or copy host ptr when buffer data is given, use $context->buffer instead?"); |
726 | NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (self, flags, len, ptr, &res)); |
731 | NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (self, flags, len, ptr, &res)); |
727 | XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); |
732 | XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); |
728 | |
733 | |
729 | #if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
734 | #if !CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
730 | |
735 | |
731 | void |
736 | void |
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) |
737 | 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) |
733 | PPCODE: |
738 | PPCODE: |
734 | STRLEN len; |
739 | STRLEN len; |
… | |
… | |
754 | gl_buffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint bufobj) |
759 | gl_buffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint bufobj) |
755 | PPCODE: |
760 | PPCODE: |
756 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLBuffer, (self, flags, bufobj, &res)); |
761 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLBuffer, (self, flags, bufobj, &res)); |
757 | XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); |
762 | XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); |
758 | |
763 | |
759 | #if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
764 | #if !CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
760 | |
765 | |
761 | void |
766 | void |
762 | gl_texture2d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
767 | gl_texture2d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
763 | PPCODE: |
768 | PPCODE: |
764 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture2D, (self, flags, target, miplevel, texture, &res)); |
769 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture2D, (self, flags, target, miplevel, texture, &res)); |
… | |
… | |
1168 | if (ev) |
1173 | if (ev) |
1169 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1174 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1170 | |
1175 | |
1171 | #endif |
1176 | #endif |
1172 | |
1177 | |
1173 | #if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
1178 | #if !CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
1174 | |
|
|
1175 | void |
|
|
1176 | enqueue_marker (OpenCL::Queue self) |
|
|
1177 | PPCODE: |
|
|
1178 | cl_event ev; |
|
|
1179 | NEED_SUCCESS (EnqueueMarker, (self, &ev)); |
|
|
1180 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
|
|
1181 | |
1179 | |
1182 | void |
1180 | void |
1183 | enqueue_wait_for_events (OpenCL::Queue self, ...) |
1181 | enqueue_wait_for_events (OpenCL::Queue self, ...) |
1184 | CODE: |
1182 | CODE: |
1185 | EVENT_LIST (1, items - 1); |
1183 | EVENT_LIST (1, items - 1); |
1186 | NEED_SUCCESS (EnqueueWaitForEvents, (self, event_list_count, event_list_ptr)); |
1184 | NEED_SUCCESS (EnqueueWaitForEvents, (self, event_list_count, event_list_ptr)); |
1187 | |
1185 | |
|
|
1186 | #endif |
|
|
1187 | |
1188 | void |
1188 | void |
|
|
1189 | enqueue_marker (OpenCL::Queue self, ...) |
|
|
1190 | PPCODE: |
|
|
1191 | cl_event ev = 0; |
|
|
1192 | EVENT_LIST (1, items - 1); |
|
|
1193 | #if CL_VERSION_1_2 |
|
|
1194 | NEED_SUCCESS (EnqueueMarkerWithWaitList, (self, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); |
|
|
1195 | #else |
|
|
1196 | if (event_list_count) |
|
|
1197 | croak ("OpenCL::Queue->enqueue_marker does not support a wait list in OpenCL 1.1 - upgrade to 1.2"); |
|
|
1198 | NEED_SUCCESS (EnqueueMarker, (self, GIMME_V != G_VOID ? &ev : 0)); |
|
|
1199 | #endif |
|
|
1200 | if (ev) |
|
|
1201 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
|
|
1202 | |
|
|
1203 | void |
1189 | enqueue_barrier (OpenCL::Queue self) |
1204 | enqueue_barrier (OpenCL::Queue self, ...) |
1190 | CODE: |
1205 | PPCODE: |
|
|
1206 | cl_event ev = 0; |
|
|
1207 | EVENT_LIST (1, items - 1); |
|
|
1208 | #if CL_VERSION_1_2 |
|
|
1209 | NEED_SUCCESS (EnqueueBarrierWithWaitList, (self, event_list_count, event_list_ptr, &ev)); |
|
|
1210 | #else |
|
|
1211 | if (event_list_count) |
|
|
1212 | croak ("OpenCL::Queue->enqueue_barrier does not support a wait list in OpenCL 1.1 - upgrade to 1.2"); |
|
|
1213 | if (GIMME_V != G_VOID) |
|
|
1214 | croak ("OpenCL::Queue->enqueue_barrier does not return an event object in OpenCL 1.1 - upgrade to 1.2"); |
1191 | NEED_SUCCESS (EnqueueBarrier, (self)); |
1215 | NEED_SUCCESS (EnqueueBarrier, (self)); |
1192 | |
|
|
1193 | #endif |
1216 | #endif |
|
|
1217 | if (ev) |
|
|
1218 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1194 | |
1219 | |
1195 | void |
1220 | void |
1196 | flush (OpenCL::Queue self) |
1221 | flush (OpenCL::Queue self) |
1197 | CODE: |
1222 | CODE: |
1198 | NEED_SUCCESS (Flush, (self)); |
1223 | NEED_SUCCESS (Flush, (self)); |