Discussion:
[PyCUDA] Advice on Switching between C, IDL and PyCUDA
Mcgibbney, Lewis J (398M)
2014-10-29 07:23:12 UTC
Permalink
Hi Folks,

<context>
I have been working with PyCUDA for a while now and monitoring the lists. I think it is an excellent library and thank folks who are actively developing the library.
I’ve been tasked with porting some legacy C and IDL code to run within the CUDA environment and have been working on this for a while now with limited success! The job at hand is implement code which has the main task of spectral unmixing with the aim of generating fractional snow coverage products for use within snow hydrology and other snow related disciplines.
Basically, the existing code I inherited is as follows

1. Do some preprocessing of scientific input data where I calculate surface reflectance values from this data. I then tile each input file into 16 pieces. The output (which is consequently the input for the next stage) is surface reflectance and saturation masks which are used within the spectral unmixing.
2. Execute a C program in multithreaded mode which in turn calls IDL
3. IDL code that cleanses and puts together the various runs from the unmixing C code
4. Run post processing code which reads the final output, mosiacs the tiles, creates masks and saves files.

What I am currently working on is the determination of the correct integration point for using PyCUDA in the above workflow.
</context>

I DO NOT need to use PyCUDA in stages 1 or 4 e.g. Pre and post processing.

What I am looking for is advice on what is ‘common’ practice for NOT reimplementing an entire project (>13,000 C and IDL code) in PyCUDA but instead on using PyCUDA in conjunction with the C and IDL where PyCUDA would be leveraged to to the heavily lifting of the ‘many at once’ pixel classification task which is part of the spectral unmixing.
Is this kind of thing done often?
Is it common to be combining PyCUDA with code in other languages to achieve these types of tasks?
I realize that this thread has ended up being much longer than I wanted it to be but I hope that the context has provided some values as oppose to confusing the underlying picture.
Thanks for any responses.
Lewis

Dr. Lewis John McGibbney B.Sc., PhD
Engineering Applications Software Engineer Level 2
Data Management Systems and Technology Group 398J
Jet Propulsion Laboratory
California Institute of Technology
4800 Oak Grove Drive
Pasadena, California 91109-8099
Mail Stop : 158-256C
Tel: (+1) (818)-393-7402
Cell: (+1) (626)-487-3476
Fax: (+1) (818)-393-1190
Email: ***@jpl.nasa.gov

[cid:5EF353E1-71A7-400D-81CB-BE874A67DE3C]

Dare Mighty Things
Andreas Kloeckner
2014-10-29 15:17:06 UTC
Permalink
Lewis,
Post by Mcgibbney, Lewis J (398M)
I DO NOT need to use PyCUDA in stages 1 or 4 e.g. Pre and post processing.
What I am looking for is advice on what is ‘common’ practice for NOT reimplementing an entire project (>13,000 C and IDL code) in PyCUDA but instead on using PyCUDA in conjunction with the C and IDL where PyCUDA would be leveraged to to the heavily lifting of the ‘many at once’ pixel classification task which is part of the spectral unmixing.
Is this kind of thing done often?
Is it common to be combining PyCUDA with code in other languages to achieve these types of tasks?
While I'm not sure I can speak with authority on how common this type of
usage is, I think I can say with some confidence that Python is probably
one of the easier language in which to pull off a coupling such as what
you describe. In general, Python excels in the role of a 'glue' language
coupling disparate components together.

For instance, there is an existing coupling module that would let you
talk to your IDL code and seamlessly exchange data as numpy arrays:

http://www.cacr.caltech.edu/~mmckerns/pyIDL.html

Python is further very easy to couple with existing C code, and perhaps
the main 'problem' is that there are a large number of approaches
available that you could use, ranging from 'cffi', 'swig',
'boost.python', and many more ways of accomplishing this wrapping.

Hope that helps at least a bit,
Andreas
Mcgibbney, Lewis J (398M)
2014-10-29 15:49:21 UTC
Permalink
Hi Andreas,


It really does help. I was just not sure if it was an advised approach.
I am going to press on with a bit more confidence now and will most likely
be back here with some more cryptic context in due course.
Thank you very much for the reply.
Lewis
Post by Andreas Kloeckner
While I'm not sure I can speak with authority on how common this type of
usage is, I think I can say with some confidence that Python is probably
one of the easier language in which to pull off a coupling such as what
you describe. In general, Python excels in the role of a 'glue' language
coupling disparate components together.
For instance, there is an existing coupling module that would let you
http://www.cacr.caltech.edu/~mmckerns/pyIDL.html
Python is further very easy to couple with existing C code, and perhaps
the main 'problem' is that there are a large number of approaches
available that you could use, ranging from 'cffi', 'swig',
'boost.python', and many more ways of accomplishing this wrapping.
Hope that helps at least a bit,
Andreas
Ashwin Srinath
2014-10-29 17:48:43 UTC
Permalink
I just wanted to add Cython to the list of available options to wrap C code
with Python - I've found this to work nicely in conjunction with PyCUDA.

Thanks,
Ashwin

On Wed, Oct 29, 2014 at 11:49 AM, Mcgibbney, Lewis J (398M) <
Post by Mcgibbney, Lewis J (398M)
Hi Andreas,
It really does help. I was just not sure if it was an advised approach.
I am going to press on with a bit more confidence now and will most likely
be back here with some more cryptic context in due course.
Thank you very much for the reply.
Lewis
Post by Andreas Kloeckner
While I'm not sure I can speak with authority on how common this type of
usage is, I think I can say with some confidence that Python is probably
one of the easier language in which to pull off a coupling such as what
you describe. In general, Python excels in the role of a 'glue' language
coupling disparate components together.
For instance, there is an existing coupling module that would let you
http://www.cacr.caltech.edu/~mmckerns/pyIDL.html
Python is further very easy to couple with existing C code, and perhaps
the main 'problem' is that there are a large number of approaches
available that you could use, ranging from 'cffi', 'swig',
'boost.python', and many more ways of accomplishing this wrapping.
Hope that helps at least a bit,
Andreas
_______________________________________________
PyCUDA mailing list
http://lists.tiker.net/listinfo/pycuda
Mcgibbney, Lewis J (398M)
2014-10-29 18:09:36 UTC
Permalink
Thank you Ashwin,
I has also been using Cython recently.
Thank you for the heads up :)
Best
Lewis

Dr. Lewis John McGibbney B.Sc., PhD
Engineering Applications Software Engineer Level 2
Data Management Systems and Technology Group 398J
Jet Propulsion Laboratory
California Institute of Technology
4800 Oak Grove Drive
Pasadena, California 91109-8099
Mail Stop : 158-256C
Tel: (+1) (818)-393-7402
Cell: (+1) (626)-487-3476
Fax: (+1) (818)-393-1190
Email: ***@jpl.nasa.gov

[cid:E468BCB6-EFF9-4235-B4CC-4BEEC4DE2832]

Dare Mighty Things

From: Ashwin Srinath <***@gmail.com<mailto:***@gmail.com>>
Date: Wednesday, October 29, 2014 at 10:48 AM
To: Lewis John McGibbney <***@jpl.nasa.gov<mailto:***@jpl.nasa.gov>>
Cc: Andreas Kloeckner <***@informa.tiker.net<mailto:***@informa.tiker.net>>, "***@tiker.net<mailto:***@tiker.net>" <***@tiker.net<mailto:***@tiker.net>>
Subject: Re: [PyCUDA] Advice on Switching between C, IDL and PyCUDA

I just wanted to add Cython to the list of available options to wrap C code with Python - I've found this to work nicely in conjunction with PyCUDA.

Thanks,
Ashwin

On Wed, Oct 29, 2014 at 11:49 AM, Mcgibbney, Lewis J (398M) <***@jpl.nasa.gov<mailto:***@jpl.nasa.gov>> wrote:
Hi Andreas,


It really does help. I was just not sure if it was an advised approach.
I am going to press on with a bit more confidence now and will most likely
be back here with some more cryptic context in due course.
Thank you very much for the reply.
Lewis
Post by Andreas Kloeckner
While I'm not sure I can speak with authority on how common this type of
usage is, I think I can say with some confidence that Python is probably
one of the easier language in which to pull off a coupling such as what
you describe. In general, Python excels in the role of a 'glue' language
coupling disparate components together.
For instance, there is an existing coupling module that would let you
http://www.cacr.caltech.edu/~mmckerns/pyIDL.html
Python is further very easy to couple with existing C code, and perhaps
the main 'problem' is that there are a large number of approaches
available that you could use, ranging from 'cffi', 'swig',
'boost.python', and many more ways of accomplishing this wrapping.
Hope that helps at least a bit,
Andreas
Loading...