[Cython] OpenCL support

mark florisson markflorisson88 at gmail.com
Tue Feb 7 18:58:20 CET 2012

On 7 February 2012 13:52, Sturla Molden <sturla at molden.no> wrote:
> On 05.02.2012 23:39, Dimitri Tcaciuc wrote:
>> 3. Does it make sense to make OpenCL more explicit?
> No, it takes the usefuness of OpenCL away, which is that kernels are text
> strings and compiled at run-time.

I don't know why you think that is necessary. Obviously Cython's
translated opencl would also be compiled at runtime (or loaded from a
cache). If you mean you can't do string interpolation, I don't see why
you would need that.

>> Heuristics and
>> automatic switching between, say, CPU and GPU is great for eg. Sage
>> users, but maybe not so much if you know exactly what you're doing
>> with your machine resources. E.g just having a library with thin
>> cython-adapted wrappers would be awesome. I imagine this can be
>> augmented by arrays having a knowledge of device-side/client-side
>> (which would go towards addressing the issue 1. above)
> Just use PyOpenCL and manipulate kernels as text. Python is excellent for
> that - Cython is not needed. If you think using Cython instead of Python
> (PyOpenCL and NumPy) will be important, you don't have a CPU bound problem
> that warrants the use of OpenCL.
> Sturla

That is not very constructive input. If you use PyOpenCL you have to
basically rethink and rewrite your kernels just for OpenCL. That is
far from trivial and there is not much pyopencl does to keep you away
from the pain of OpenCL and general GPU computing.

There are existing approaches (compiler directives for C or Fortran)
to do similar things, and an OpenMP (sub-)committee is working on
adding/defining such features to the standard. Why? Because GPU
programming is still a major pain in the ass. And although automatic
translation will probably not yield the best performance for your
particular hardware as a handwritten version, it will have saved you
hours of coding and possibly rewriting.

> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel

More information about the cython-devel mailing list