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

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.73 by root, Sat May 5 13:30:07 2012 UTC vs.
Revision 1.78 by root, Sat May 5 15:11:19 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];
594 xthread_t id; 618 xthread_t id;
595 thread_create (&id, build_program_thread, arg); 619 thread_create (&id, build_program_thread, arg);
596} 620}
597 621
598/*****************************************************************************/ 622/*****************************************************************************/
623/* mem object destructor notify */
624
625static void ecb_noinline
626eq_destructor_push (void *data1, void *data2, void *data3)
627{
628}
629
630static eq_vtbl eq_destructor_vtbl = { 0, eq_destructor_push };
631
632static void CL_CALLBACK
633eq_destructor_notify (cl_mem memobj, void *user_data)
634{
635 eq_enq (&eq_destructor_vtbl, (SV *)user_data, (void *)memobj, 0, 0);
636}
637
638/*****************************************************************************/
599/* event objects */ 639/* event objects */
600 640
601static void 641static void
602eq_event_push (void *data1, void *data2, void *data3) 642eq_event_push (void *data1, void *data2, void *data3)
603{ 643{
778 eq_signal_arg = (void*)arg; 818 eq_signal_arg = (void*)arg;
779 819
780BOOT: 820BOOT:
781{ 821{
782 HV *stash = gv_stashpv ("OpenCL", 1); 822 HV *stash = gv_stashpv ("OpenCL", 1);
823
783 static const ivstr *civ, const_iv[] = { 824 static const ivstr *civ, const_iv[] = {
784 { sizeof (cl_char ), "SIZEOF_CHAR" }, 825 { sizeof (cl_char ), "SIZEOF_CHAR" },
785 { sizeof (cl_uchar ), "SIZEOF_UCHAR" }, 826 { sizeof (cl_uchar ), "SIZEOF_UCHAR" },
786 { sizeof (cl_short ), "SIZEOF_SHORT" }, 827 { sizeof (cl_short ), "SIZEOF_SHORT" },
787 { sizeof (cl_ushort), "SIZEOF_USHORT" }, 828 { sizeof (cl_ushort), "SIZEOF_USHORT" },
796#include "constiv.h" 837#include "constiv.h"
797 }; 838 };
798 839
799 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) 840 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)); 841 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
842
843 static const nvstr *cnv, const_nv[] = {
844#include "constnv.h"
845 };
846
847 for (cnv = const_nv + sizeof (const_nv) / sizeof (const_nv [0]); cnv > const_nv; cnv--)
848 newCONSTSUB (stash, (char *)cnv[-1].name, newSVnv (cnv[-1].nv));
849
850 newCONSTSUB (stash, "NAN", newSVnv (CL_NAN)); // CL_NAN might be a function call
801 851
802 stash_platform = gv_stashpv ("OpenCL::Platform", GV_ADD); 852 stash_platform = gv_stashpv ("OpenCL::Platform", GV_ADD);
803 stash_device = gv_stashpv ("OpenCL::Device", GV_ADD); 853 stash_device = gv_stashpv ("OpenCL::Device", GV_ADD);
804 stash_subdevice = gv_stashpv ("OpenCL::SubDevice", GV_ADD); 854 stash_subdevice = gv_stashpv ("OpenCL::SubDevice", GV_ADD);
805 stash_context = gv_stashpv ("OpenCL::Context", GV_ADD); 855 stash_context = gv_stashpv ("OpenCL::Context", GV_ADD);
2171void 2221void
2172info (OpenCL::Memory self, cl_mem_info name) 2222info (OpenCL::Memory self, cl_mem_info name)
2173 PPCODE: 2223 PPCODE:
2174 INFO (MemObject) 2224 INFO (MemObject)
2175 2225
2226void
2227destructor_callback (OpenCL::Memory self, SV *notify)
2228 PPCODE:
2229 clSetMemObjectDestructorCallback (self, eq_destructor_notify, SvREFCNT_inc (s_get_cv (notify)));
2230
2176#BEGIN:mem 2231#BEGIN:mem
2177 2232
2178void 2233void
2179type (OpenCL::Memory self) 2234type (OpenCL::Memory self)
2180 PPCODE: 2235 PPCODE:
2517 PPCODE: 2572 PPCODE:
2518 cl_program_binary_type value [1]; 2573 cl_program_binary_type value [1];
2519 NEED_SUCCESS (GetProgramBuildInfo, (self, device, CL_PROGRAM_BINARY_TYPE, sizeof (value), value, 0)); 2574 NEED_SUCCESS (GetProgramBuildInfo, (self, device, CL_PROGRAM_BINARY_TYPE, sizeof (value), value, 0));
2520 EXTEND (SP, 1); 2575 EXTEND (SP, 1);
2521 const int i = 0; 2576 const int i = 0;
2522 PUSHs (sv_2mortal (newSVuv (UV)value [i]))); 2577 PUSHs (sv_2mortal (newSVuv ((UV)value [i])));
2523 2578
2524#END:program_build 2579#END:program_build
2525 2580
2526void 2581void
2527kernel (OpenCL::Program program, SV *function) 2582kernel (OpenCL::Program program, SV *function)
2777 CODE: 2832 CODE:
2778 clSetKernelArg (self, idx, sizeof (value), value ? &value : 0); 2833 clSetKernelArg (self, idx, sizeof (value), value ? &value : 0);
2779 2834
2780void 2835void
2781set_image (OpenCL::Kernel self, cl_uint idx, OpenCL::Image_ornull value) 2836set_image (OpenCL::Kernel self, cl_uint idx, OpenCL::Image_ornull value)
2782 ALIAS:
2783 set_image2d = 0
2784 set_image3d = 0
2785 CODE: 2837 CODE:
2786 clSetKernelArg (self, idx, sizeof (value), value ? &value : 0); 2838 clSetKernelArg (self, idx, sizeof (value), value ? &value : 0);
2787 2839
2788void 2840void
2789set_sampler (OpenCL::Kernel self, cl_uint idx, OpenCL::Sampler value) 2841set_sampler (OpenCL::Kernel self, cl_uint idx, OpenCL::Sampler value)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines