… | |
… | |
28 | #if PREFER_1_1 |
28 | #if PREFER_1_1 |
29 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS |
29 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS |
30 | #endif |
30 | #endif |
31 | |
31 | |
32 | #ifdef __APPLE__ |
32 | #ifdef __APPLE__ |
33 | #include <OpenCL/opencl.h> |
33 | #define CLHDR(name) <OpenCL/name> |
34 | #else |
34 | #else |
|
|
35 | #define CLHDR(name) <CL/name> |
|
|
36 | #endif |
|
|
37 | |
35 | #include <CL/opencl.h> |
38 | #include CLHDR(opencl.h) |
|
|
39 | |
|
|
40 | #ifndef CL_VERSION_1_2 |
|
|
41 | #include CLHDR(cl_d3d9.h) |
|
|
42 | #endif |
|
|
43 | |
|
|
44 | #if _WIN32 |
|
|
45 | #include CLHDR(cl_d3d10.h) |
|
|
46 | #if CL_VERSION_1_2 |
|
|
47 | #include CLHDR<cl_d3d11.h> |
|
|
48 | #endif |
|
|
49 | #include CLHDR<cl_dx9_media_sharing.h.h> |
36 | #endif |
50 | #endif |
37 | |
51 | |
38 | #ifndef CL_VERSION_1_2 |
52 | #ifndef CL_VERSION_1_2 |
39 | #undef PREFER_1_1 |
53 | #undef PREFER_1_1 |
40 | #define PREFER_1_1 1 |
54 | #define PREFER_1_1 1 |
41 | #endif |
55 | #endif |
|
|
56 | |
|
|
57 | // make sure all constants we might use are actually defined |
|
|
58 | #include "default.h" |
42 | |
59 | |
43 | typedef cl_platform_id OpenCL__Platform; |
60 | typedef cl_platform_id OpenCL__Platform; |
44 | typedef cl_device_id OpenCL__Device; |
61 | typedef cl_device_id OpenCL__Device; |
45 | typedef cl_device_id OpenCL__SubDevice; |
62 | typedef cl_device_id OpenCL__SubDevice; |
46 | typedef cl_context OpenCL__Context; |
63 | typedef cl_context OpenCL__Context; |
… | |
… | |
790 | { sizeof (cl_long ), "SIZEOF_LONG" }, |
807 | { sizeof (cl_long ), "SIZEOF_LONG" }, |
791 | { sizeof (cl_ulong ), "SIZEOF_ULONG" }, |
808 | { sizeof (cl_ulong ), "SIZEOF_ULONG" }, |
792 | { sizeof (cl_half ), "SIZEOF_HALF" }, |
809 | { sizeof (cl_half ), "SIZEOF_HALF" }, |
793 | { sizeof (cl_float ), "SIZEOF_FLOAT" }, |
810 | { sizeof (cl_float ), "SIZEOF_FLOAT" }, |
794 | { sizeof (cl_double), "SIZEOF_DOUBLE" }, |
811 | { sizeof (cl_double), "SIZEOF_DOUBLE" }, |
|
|
812 | { PREFER_1_1 , "PREFER_1_1" }, |
795 | #include "constiv.h" |
813 | #include "constiv.h" |
796 | }; |
814 | }; |
797 | |
815 | |
798 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
816 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
799 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
817 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
… | |
… | |
2509 | NEED_SUCCESS (GetProgramBuildInfo, (self, device, ix, size, value, 0)); |
2527 | NEED_SUCCESS (GetProgramBuildInfo, (self, device, ix, size, value, 0)); |
2510 | EXTEND (SP, 1); |
2528 | EXTEND (SP, 1); |
2511 | const int i = 0; |
2529 | const int i = 0; |
2512 | PUSHs (sv_2mortal (newSVpv (value, 0))); |
2530 | PUSHs (sv_2mortal (newSVpv (value, 0))); |
2513 | |
2531 | |
|
|
2532 | void |
|
|
2533 | binary_type (OpenCL::Program self, OpenCL::Device device) |
|
|
2534 | PPCODE: |
|
|
2535 | cl_program_binary_type value [1]; |
|
|
2536 | NEED_SUCCESS (GetProgramBuildInfo, (self, device, CL_PROGRAM_BINARY_TYPE, sizeof (value), value, 0)); |
|
|
2537 | EXTEND (SP, 1); |
|
|
2538 | const int i = 0; |
|
|
2539 | PUSHs (sv_2mortal (newSVuv ((UV)value [i]))); |
|
|
2540 | |
2514 | #END:program_build |
2541 | #END:program_build |
2515 | |
2542 | |
2516 | void |
2543 | void |
2517 | kernel (OpenCL::Program program, SV *function) |
2544 | kernel (OpenCL::Program program, SV *function) |
2518 | PPCODE: |
2545 | PPCODE: |
… | |
… | |
2767 | CODE: |
2794 | CODE: |
2768 | clSetKernelArg (self, idx, sizeof (value), value ? &value : 0); |
2795 | clSetKernelArg (self, idx, sizeof (value), value ? &value : 0); |
2769 | |
2796 | |
2770 | void |
2797 | void |
2771 | set_image (OpenCL::Kernel self, cl_uint idx, OpenCL::Image_ornull value) |
2798 | set_image (OpenCL::Kernel self, cl_uint idx, OpenCL::Image_ornull value) |
2772 | ALIAS: |
|
|
2773 | set_image2d = 0 |
|
|
2774 | set_image3d = 0 |
|
|
2775 | CODE: |
2799 | CODE: |
2776 | clSetKernelArg (self, idx, sizeof (value), value ? &value : 0); |
2800 | clSetKernelArg (self, idx, sizeof (value), value ? &value : 0); |
2777 | |
2801 | |
2778 | void |
2802 | void |
2779 | set_sampler (OpenCL::Kernel self, cl_uint idx, OpenCL::Sampler value) |
2803 | set_sampler (OpenCL::Kernel self, cl_uint idx, OpenCL::Sampler value) |