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

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.55 by root, Wed Apr 25 20:49:13 2012 UTC vs.
Revision 1.56 by root, Wed Apr 25 21:48:45 2012 UTC

2154DESTROY (OpenCL::Kernel self) 2154DESTROY (OpenCL::Kernel self)
2155 CODE: 2155 CODE:
2156 clReleaseKernel (self); 2156 clReleaseKernel (self);
2157 2157
2158void 2158void
2159setf (OpenCL::Kernel self, const char *format, ...)
2160 CODE:
2161 int i;
2162 for (i = 2; ; ++i)
2163 {
2164 while (*format == ' ')
2165 ++format;
2166
2167 char type = *format++;
2168
2169 if (!type)
2170 break;
2171
2172 if (i >= items)
2173 croak ("OpenCL::Kernel::setf format string too long (not enough arguments)");
2174
2175 SV *sv = ST (i);
2176
2177 union
2178 {
2179 cl_char cc; cl_uchar cC; cl_short cs; cl_ushort cS;
2180 cl_int ci; cl_uint cI; cl_long cl; cl_ulong cL;
2181 cl_half ch; cl_float cf; cl_double cd;
2182 cl_mem cm;
2183 cl_sampler ca;
2184 size_t cz;
2185 cl_event ce;
2186 } arg;
2187 size_t size;
2188
2189 switch (type)
2190 {
2191 case 'c': arg.cc = SvIV (sv); size = sizeof (arg.cc); break;
2192 case 'C': arg.cC = SvUV (sv); size = sizeof (arg.cC); break;
2193 case 's': arg.cs = SvIV (sv); size = sizeof (arg.cs); break;
2194 case 'S': arg.cS = SvUV (sv); size = sizeof (arg.cS); break;
2195 case 'i': arg.ci = SvIV (sv); size = sizeof (arg.ci); break;
2196 case 'I': arg.cI = SvUV (sv); size = sizeof (arg.cI); break;
2197 case 'l': arg.cl = SvIV (sv); size = sizeof (arg.cl); break;
2198 case 'L': arg.cL = SvUV (sv); size = sizeof (arg.cL); break;
2199
2200 case 'h': arg.ch = SvUV (sv); size = sizeof (arg.ch); break;
2201 case 'f': arg.cf = SvNV (sv); size = sizeof (arg.cf); break;
2202 case 'd': arg.cd = SvNV (sv); size = sizeof (arg.cd); break;
2203 case 'z': arg.cz = SvUV (sv); size = sizeof (arg.cz); break;
2204
2205 case 'm': arg.cm = SvCLOBJ ("OpenCL::Kernel::setf", "m", sv, "OpenCL::Memory" ); size = sizeof (arg.cm); break;
2206 case 'a': arg.ca = SvCLOBJ ("OpenCL::Kernel::setf", "a", sv, "OpenCL::Sampler"); size = sizeof (arg.ca); break;
2207 case 'e': arg.ca = SvCLOBJ ("OpenCL::Kernel::setf", "e", sv, "OpenCL::Event" ); size = sizeof (arg.ce); break;
2208
2209 default:
2210 croak ("OpenCL::Kernel::setf format character '%c' not supported", type);
2211 }
2212
2213 clSetKernelArg (self, i - 2, size, &arg);
2214 }
2215
2216 if (i != items)
2217 croak ("OpenCL::Kernel::setf format string too short (too many arguments)");
2218
2219void
2159set_char (OpenCL::Kernel self, cl_uint idx, cl_char value) 2220set_char (OpenCL::Kernel self, cl_uint idx, cl_char value)
2160 CODE: 2221 CODE:
2161 clSetKernelArg (self, idx, sizeof (value), &value); 2222 clSetKernelArg (self, idx, sizeof (value), &value);
2162 2223
2163void 2224void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines