[Cython] OpenCL support

Dimitri Tcaciuc dtcaciuc at gmail.com
Sun Feb 5 23:39:25 CET 2012


Couple of thoughts based on some experience with OpenCL...

1. This may be going outside the proposed purpose, but some algorithms
such as molecular simulations can benefit from a fairly large amount
of constant data loaded at the beginning of the program and persisted
in between invocations of a function. If I understand the proposal,
entire program would need to be within one `with` block, which would
certainly be limiting to the architecture. Eg.

    # run.py
    from cython_module import Evaluator

    # Arrays are loaded into device memory here
    x = Evaluator(params...)
    for i in range(N):
        # Calculations are performed with
        # mostly data in the device memory
        data_i = x.step()

2. AFAIK, given a device, OpenCL basically takes it over (which would
be eg. 8 cores on 2 CPU x 4 cores machine), so I'm not sure how
`num_cores` parameter would work here. There's the fission extension
that allows you to selectively run on a portion of the device, but the
idea is that you're still dedicating entire device to your process,
but merely giving more organization to your processing tasks, where
you have to specify the core numbers you want to use. I may very well
be wrong here, bashing is welcome :)

3. Does it make sense to make OpenCL more explicit? 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)



On Sun, Feb 5, 2012 at 1:57 PM, mark florisson
<markflorisson88 at gmail.com> wrote:
> Hey,
> I created a CEP for opencl support: http://wiki.cython.org/enhancements/opencl
> What do you think?
> Mark
> _______________________________________________
> 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