I'm wondering if yet-another-python-opencl-interface-layer would be of interest.
This layer is built on top of pyopencl, and is intended to use familiar
RPC definitions to ease the special joys of talking to opencl.
I've implemented this on OS/X and it is working for me and has been stable, oh,
for several days ;-) It eliminates the need for routine glue code,
and can be extended to minimize movement of data between host and opencl
service.
This code is currently private, and I will be happy to either fork pyopencl and
submit a pull after integration, or a separate github project.
-- Sean
Sean True
Swapwizard Consulting
Presumed highlights:
# Use the rpc extension to define and load the kernel as a callable.
from rpc import kernels, interfaces
calc_fractal_opencl = kernels.loadProgram(interfaces.mandelbrot).mandelbrot
# Call it the way we like to call Python callables:
output = calc_fractal(q, maxiter)
# RPC definition language loosely based on Apollo NCS/OSF DCE/Microsoft IDL
# outlike is a novel keyword that says: allocate for me, return as part
of return vals.
interface mandelbrot {
kernel mandelbrot(in complex64 *q, outlike int16 *q, in int32 maxiter);
}
# mandelbrot.mako is just what it has always been.
__kernel void mandelbrot(__global float2 *q,
__global short *output, int const maxiter)
{
int gid = get_global_id(0);
float nreal, real = 0;
float imag = 0;
output[gid] = 0;
for(int curiter = 0; curiter < maxiter; curiter++) {
nreal = real*real - imag*imag + q[gid].x;
imag = 2* real*imag + q[gid].y;
real = nreal;
if (real*real + imag*imag > 4.0f)
output[gid] = curiter;
}
}
_______________________________________________
PyOpenCL mailing list
[email protected]
http://lists.tiker.net/listinfo/pyopencl