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

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.72 by root, Sat May 5 12:54:04 2012 UTC vs.
Revision 1.77 by root, Sat May 5 14:57:32 2012 UTC

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
43typedef cl_platform_id OpenCL__Platform; 60typedef cl_platform_id OpenCL__Platform;
44typedef cl_device_id OpenCL__Device; 61typedef cl_device_id OpenCL__Device;
45typedef cl_device_id OpenCL__SubDevice; 62typedef cl_device_id OpenCL__SubDevice;
46typedef cl_context OpenCL__Context; 63typedef cl_context OpenCL__Context;
175 IV iv; 192 IV iv;
176 const char *name; 193 const char *name;
177 #define const_iv(name) { (IV)CL_ ## name, # name }, 194 #define const_iv(name) { (IV)CL_ ## name, # name },
178} ivstr; 195} ivstr;
179 196
197typedef struct
198{
199 NV nv;
200 const char *name;
201 #define const_nv(name) { (NV)CL_ ## name, # name },
202} nvstr;
203
180static const char * 204static const char *
181iv2str (IV value, const ivstr *base, int count, const char *fallback) 205iv2str (IV value, const ivstr *base, int count, const char *fallback)
182{ 206{
183 int i; 207 int i;
184 static char strbuf [32]; 208 static char strbuf [32];
778 eq_signal_arg = (void*)arg; 802 eq_signal_arg = (void*)arg;
779 803
780BOOT: 804BOOT:
781{ 805{
782 HV *stash = gv_stashpv ("OpenCL", 1); 806 HV *stash = gv_stashpv ("OpenCL", 1);
807
783 static const ivstr *civ, const_iv[] = { 808 static const ivstr *civ, const_iv[] = {
784 { sizeof (cl_char ), "SIZEOF_CHAR" }, 809 { sizeof (cl_char ), "SIZEOF_CHAR" },
785 { sizeof (cl_uchar ), "SIZEOF_UCHAR" }, 810 { sizeof (cl_uchar ), "SIZEOF_UCHAR" },
786 { sizeof (cl_short ), "SIZEOF_SHORT" }, 811 { sizeof (cl_short ), "SIZEOF_SHORT" },
787 { sizeof (cl_ushort), "SIZEOF_USHORT" }, 812 { sizeof (cl_ushort), "SIZEOF_USHORT" },
796#include "constiv.h" 821#include "constiv.h"
797 }; 822 };
798 823
799 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) 824 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
800 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 825 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
826
827 static const nvstr *cnv, const_nv[] = {
828#include "constnv.h"
829 };
830
831 for (cnv = const_nv + sizeof (const_nv) / sizeof (const_nv [0]); cnv > const_nv; cnv--)
832 newCONSTSUB (stash, (char *)cnv[-1].name, newSVnv (cnv[-1].nv));
833
834 newCONSTSUB (stash, "NAN", newSVnv (CL_NAN)); // CL_NAN might be a function call
801 835
802 stash_platform = gv_stashpv ("OpenCL::Platform", GV_ADD); 836 stash_platform = gv_stashpv ("OpenCL::Platform", GV_ADD);
803 stash_device = gv_stashpv ("OpenCL::Device", GV_ADD); 837 stash_device = gv_stashpv ("OpenCL::Device", GV_ADD);
804 stash_subdevice = gv_stashpv ("OpenCL::SubDevice", GV_ADD); 838 stash_subdevice = gv_stashpv ("OpenCL::SubDevice", GV_ADD);
805 stash_context = gv_stashpv ("OpenCL::Context", GV_ADD); 839 stash_context = gv_stashpv ("OpenCL::Context", GV_ADD);
2171void 2205void
2172info (OpenCL::Memory self, cl_mem_info name) 2206info (OpenCL::Memory self, cl_mem_info name)
2173 PPCODE: 2207 PPCODE:
2174 INFO (MemObject) 2208 INFO (MemObject)
2175 2209
2210void
2211destructor_callback (OpenCL::Memory self, SV *notify)
2212 PPCODE:
2213
2176#BEGIN:mem 2214#BEGIN:mem
2177 2215
2178void 2216void
2179type (OpenCL::Memory self) 2217type (OpenCL::Memory self)
2180 PPCODE: 2218 PPCODE:
2509 char *value = tmpbuf (size); 2547 char *value = tmpbuf (size);
2510 NEED_SUCCESS (GetProgramBuildInfo, (self, device, ix, size, value, 0)); 2548 NEED_SUCCESS (GetProgramBuildInfo, (self, device, ix, size, value, 0));
2511 EXTEND (SP, 1); 2549 EXTEND (SP, 1);
2512 const int i = 0; 2550 const int i = 0;
2513 PUSHs (sv_2mortal (newSVpv (value, 0))); 2551 PUSHs (sv_2mortal (newSVpv (value, 0)));
2552
2553void
2554binary_type (OpenCL::Program self, OpenCL::Device device)
2555 PPCODE:
2556 cl_program_binary_type value [1];
2557 NEED_SUCCESS (GetProgramBuildInfo, (self, device, CL_PROGRAM_BINARY_TYPE, sizeof (value), value, 0));
2558 EXTEND (SP, 1);
2559 const int i = 0;
2560 PUSHs (sv_2mortal (newSVuv ((UV)value [i])));
2514 2561
2515#END:program_build 2562#END:program_build
2516 2563
2517void 2564void
2518kernel (OpenCL::Program program, SV *function) 2565kernel (OpenCL::Program program, SV *function)
2768 CODE: 2815 CODE:
2769 clSetKernelArg (self, idx, sizeof (value), value ? &value : 0); 2816 clSetKernelArg (self, idx, sizeof (value), value ? &value : 0);
2770 2817
2771void 2818void
2772set_image (OpenCL::Kernel self, cl_uint idx, OpenCL::Image_ornull value) 2819set_image (OpenCL::Kernel self, cl_uint idx, OpenCL::Image_ornull value)
2773 ALIAS:
2774 set_image2d = 0
2775 set_image3d = 0
2776 CODE: 2820 CODE:
2777 clSetKernelArg (self, idx, sizeof (value), value ? &value : 0); 2821 clSetKernelArg (self, idx, sizeof (value), value ? &value : 0);
2778 2822
2779void 2823void
2780set_sampler (OpenCL::Kernel self, cl_uint idx, OpenCL::Sampler value) 2824set_sampler (OpenCL::Kernel self, cl_uint idx, OpenCL::Sampler value)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines