Hi Martin,

first of all, sorry for taking so long to reply to this. I had a busy
end of the (US) semester, with teaching, projects and all.

On Wed, 14 Dec 2011 23:22:48 +0100, Martin Kempf <martin.ke...@gmail.com> wrote:
> Although this is the PyCuda mailing list and my question is more related 
> to CodePy, I think I could find some clarifications here.
> While reading about CodePy, I came across this sentence: "In particular, 
> the code generation facilities work well in conjunction with PyCuda" 
> [1]. So I had a look on PyCuda and I did not yet find the advantages in 
> the combination of CodePy and PyCuda while the general idea on using 
> RTCG in GPU programming is quite clear. Also the internal structure of 
> PyCuda seems clear to me with a C++ Wrapper for CUDA and the usage of 
> Boost-Python to expose the C++ functions of the Wrapper to Python.
> But back on CodePy. I have some hints but in neither explanation I do 
> get the point:

First thing I should clarify: CodePy used to be two packages mashed into
one, more or less. The first package is a way to generate C source code
From an in-memory abstract syntax tree. This is what is demonstrated in
[1], and that's what I usually meant when I said 'using PyCUDA/PyOpenCL
with CodePy'. The other half of CodePy provides a facility to compile
host-side programs and link them back into the interpreter, with caching
of compiled binaries, dependency checking and other bells and whistles.

To lessen the confusion, the C generation package (used to be
codepy.cgen) is now a separate package [2,3] called cgen. ('codepy.cgen'
still works for now, but is deprecated and forwards to cgen.)

Now onward to the usefulness of both of these packages in conjunction
with PyCUDA. cgen can be useful if more 'textual' ways of generating
code don't work for your specific application. That said, I have found
that textual generation is sufficient in very many settings, and only
very few types of codegen require the flexibility that cgen offers. (but
those do exist!) However, I've made the experience using cgen when it
isn't required ends up resulting in odd-looking code that's harder to
maintain than necessary. I am still using cgen in my projects (loopy,
yet to be announced, being the most recent one)--I'm just more judicious
about its use.

codepy (in its compile-link variety) can also be used with PyCUDA. Bryan
Catanzaro has done this in Copperhead, where he uses codepy to drive
nvcc to compile host-side (!) Python extension modules that execute CUDA
code. This removes much of PyCUDA from the picture, as now you're using
the CUDA run-time interface, rather than the driver interface.

[1] http://documen.tician.de/pycuda/metaprog.html#metaprogramming-using-codepy
[2] http://pypi.python.org/pypi/cgen
[3] https://github.com/inducer/cgen


Hope this clarifies things,
Andreas

Attachment: pgpugSSDjVDdB.pgp
Description: PGP signature

_______________________________________________
PyCUDA mailing list
PyCUDA@tiker.net
http://lists.tiker.net/listinfo/pycuda

Reply via email to