… | |
… | |
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 | |
|
|
764 | void |
|
|
765 | gl_renderbuffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint renderbuffer) |
|
|
766 | PPCODE: |
|
|
767 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLRenderbuffer, (self, flags, renderbuffer, &res)); |
|
|
768 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
|
|
769 | |
|
|
770 | #if CL_VERSION_1_2 |
|
|
771 | |
|
|
772 | void |
|
|
773 | gl_texture (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
|
|
774 | PPCODE: |
|
|
775 | char *klass = "OpenCL::Memory"; |
|
|
776 | cl_gl_object_type t; |
|
|
777 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture2D, (self, flags, target, miplevel, texture, &res)); |
|
|
778 | NEED_SUCCESS (GetGLObjectInfo, (mem, &t, 0)); |
|
|
779 | switch (t) |
|
|
780 | { |
|
|
781 | case CL_GL_OBJECT_TEXTURE_BUFFER: klass = "OpenCL::Image1DBuffer"; break; |
|
|
782 | case CL_GL_OBJECT_TEXTURE1D: klass = "OpenCL::Image1D"; break; |
|
|
783 | case CL_GL_OBJECT_TEXTURE1D_ARRAY: klass = "OpenCL::Image2DArray"; break; |
|
|
784 | case CL_GL_OBJECT_TEXTURE2D: klass = "OpenCL::Image2D"; break; |
|
|
785 | case CL_GL_OBJECT_TEXTURE2D_ARRAY: klass = "OpenCL::Image2DArray"; break; |
|
|
786 | case CL_GL_OBJECT_TEXTURE3D: klass = "OpenCL::Image3D"; break; |
|
|
787 | } |
|
|
788 | XPUSH_NEW_OBJ (klass, mem); |
|
|
789 | |
|
|
790 | #endif |
|
|
791 | |
759 | #if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
792 | #if !CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
760 | |
793 | |
761 | void |
794 | void |
762 | gl_texture2d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
795 | gl_texture2d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
763 | PPCODE: |
796 | PPCODE: |
764 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture2D, (self, flags, target, miplevel, texture, &res)); |
797 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture2D, (self, flags, target, miplevel, texture, &res)); |
… | |
… | |
769 | PPCODE: |
802 | PPCODE: |
770 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture3D, (self, flags, target, miplevel, texture, &res)); |
803 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture3D, (self, flags, target, miplevel, texture, &res)); |
771 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
804 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
772 | |
805 | |
773 | #endif |
806 | #endif |
774 | |
|
|
775 | void |
|
|
776 | gl_renderbuffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint renderbuffer) |
|
|
777 | PPCODE: |
|
|
778 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLRenderbuffer, (self, flags, renderbuffer, &res)); |
|
|
779 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
|
|
780 | |
807 | |
781 | #endif |
808 | #endif |
782 | |
809 | |
783 | void |
810 | void |
784 | supported_image_formats (OpenCL::Context self, cl_mem_flags flags, cl_mem_object_type image_type) |
811 | supported_image_formats (OpenCL::Context self, cl_mem_flags flags, cl_mem_object_type image_type) |
… | |
… | |
1168 | if (ev) |
1195 | if (ev) |
1169 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1196 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1170 | |
1197 | |
1171 | #endif |
1198 | #endif |
1172 | |
1199 | |
1173 | #if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS |
1200 | #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 | |
1201 | |
1182 | void |
1202 | void |
1183 | enqueue_wait_for_events (OpenCL::Queue self, ...) |
1203 | enqueue_wait_for_events (OpenCL::Queue self, ...) |
1184 | CODE: |
1204 | CODE: |
1185 | EVENT_LIST (1, items - 1); |
1205 | EVENT_LIST (1, items - 1); |
1186 | NEED_SUCCESS (EnqueueWaitForEvents, (self, event_list_count, event_list_ptr)); |
1206 | NEED_SUCCESS (EnqueueWaitForEvents, (self, event_list_count, event_list_ptr)); |
1187 | |
1207 | |
|
|
1208 | #endif |
|
|
1209 | |
1188 | void |
1210 | void |
|
|
1211 | enqueue_marker (OpenCL::Queue self, ...) |
|
|
1212 | PPCODE: |
|
|
1213 | cl_event ev = 0; |
|
|
1214 | EVENT_LIST (1, items - 1); |
|
|
1215 | #if CL_VERSION_1_2 |
|
|
1216 | NEED_SUCCESS (EnqueueMarkerWithWaitList, (self, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); |
|
|
1217 | #else |
|
|
1218 | if (event_list_count) |
|
|
1219 | croak ("OpenCL::Queue->enqueue_marker does not support a wait list in OpenCL 1.1 - upgrade to 1.2"); |
|
|
1220 | NEED_SUCCESS (EnqueueMarker, (self, GIMME_V != G_VOID ? &ev : 0)); |
|
|
1221 | #endif |
|
|
1222 | if (ev) |
|
|
1223 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
|
|
1224 | |
|
|
1225 | void |
1189 | enqueue_barrier (OpenCL::Queue self) |
1226 | enqueue_barrier (OpenCL::Queue self, ...) |
1190 | CODE: |
1227 | PPCODE: |
|
|
1228 | cl_event ev = 0; |
|
|
1229 | EVENT_LIST (1, items - 1); |
|
|
1230 | #if CL_VERSION_1_2 |
|
|
1231 | NEED_SUCCESS (EnqueueBarrierWithWaitList, (self, event_list_count, event_list_ptr, &ev)); |
|
|
1232 | #else |
|
|
1233 | if (event_list_count) |
|
|
1234 | croak ("OpenCL::Queue->enqueue_barrier does not support a wait list in OpenCL 1.1 - upgrade to 1.2"); |
|
|
1235 | if (GIMME_V != G_VOID) |
|
|
1236 | croak ("OpenCL::Queue->enqueue_barrier does not return an event object in OpenCL 1.1 - upgrade to 1.2"); |
1191 | NEED_SUCCESS (EnqueueBarrier, (self)); |
1237 | NEED_SUCCESS (EnqueueBarrier, (self)); |
1192 | |
|
|
1193 | #endif |
1238 | #endif |
|
|
1239 | if (ev) |
|
|
1240 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1194 | |
1241 | |
1195 | void |
1242 | void |
1196 | flush (OpenCL::Queue self) |
1243 | flush (OpenCL::Queue self) |
1197 | CODE: |
1244 | CODE: |
1198 | NEED_SUCCESS (Flush, (self)); |
1245 | NEED_SUCCESS (Flush, (self)); |