Question

I have recently discovered the power of GP-GPU (general purpose graphics processing unit) and want to take advantage of it to perform 'heavy' scientific and math calculations (that otherwise require big CPU clusters) on a single machine.

I know that there are several interfaces to operate on a GPU, the most prominent of those being CUDA and OpenCL. The latter has the advantage against CUDA to run on most graphics cards (NVIDIA, AMD, Intel) rather than NVIDA cards only. In my case, I have an ordinary Intel 4000 GPU that seems to be well cooperating with OpenCL.

Now, I need to learn how to operate with PyOpenCL to get it on further! So here comes the question:

How can I get started with PyOpenCL? What are the prerequisites? Do I really need to be experienced in Python and/or OpenCL?

My background is in fortran and as a matter of fact I need to translate and parallelize a lengthy fortran code to python (or pyopencl) that mainly deals with solving PDEs and diagonalizing matrices.

I have read the two relevant websites http://enja.org/2011/02/22/adventures-in-pyopencl-part-1-getting-started-with-python/ and http://documen.tician.de/pyopencl/ but they are not really helpful for newbies (ie, dummies).

I just don't know what to begin with. I do not aspire on becoming an expert on the field, just to get to know how one can parallelize simple math and linear algebra on pyopencl.

Any advice and help is highly welcome!

Was it helpful?

Solution

It seems you are looking for the fastest and most effective path to learn PyOpenCL. You do not need to know OpenCL (the hard part) at the start, but it will be helpful to know Python when you begin.

For learning Python syntax quickly, I recommend Codecademy's Python track: http://www.codecademy.com/tracks/python

Then, the Udacity parallel programming course is a great place to start with GPGPU (even though the course is taught in CUDA). https://www.udacity.com/course/cs344 This course will teach you fundamental GPGPU concepts very quickly. You will not need a NVIDIA GPU to participate, because all the course assessments are done online.

After (or during) the Udacity course, I recommend you read, run, and customize PyOpenCL code examples: https://github.com/inducer/pyopencl/tree/master/examples

OTHER TIPS

Irrespective of the language of adoption for GPGPU computing such as Java,C/C++, Python, I would recommend you first get started with the basics of GPGPU computing and OpenCL.

You can use the following resources all are C/C++ oriented but this should you give enough knowledge about OpenCL, GPGPU hardware to get you started.

  1. AMD OpenCL University Tool kit

  2. Hetergeneous Computing with OpenCL Book 2nd Edition

  3. NVIDIA OpenCL pages is another Excellent resorce

  4. Streamcomputing.eu has nice openCL starter articles.

  5. Intel OpenCL SDK tutorial

PyOpenCL specific

  1. OpenCL in Action: How to Accelerate Graphics and Computation has a chapter on PyOpenCL
  2. OpenCL Programming Guide has chapter PyOpenCL

Both the books contain OpenCL 1.1 implementation but it should be good starting point for you.

As someone new to GPU programming I found the relevant articles you mentioned fairly straightforward though I found the sample code ran perfectly from the command line but not in Eclipse with Anaconda. I think this may be because the Eclipse pyopencl from anaconda is different from the command line version, and I have yet to work out how to resolve this.

For learning python there are a large number of resources online including free ebooks.

https://wiki.python.org/moin/BeginnersGuide http://codecondo.com/10-ways-to-learn-python/

should be good starters. If you use Eclipse you should install pydev. In any case install Anaconda https://docs.continuum.io/anaconda/install as this will save you a lot of hassle.

I estimate a week or so to get to the level of proficiency you need in Python as long as you picj a few simple mini projects. You may also find that with numpy and scipy and possibly ipython notebook you may not need to delve into GPU programming

These links may help you avoid GPU programming or at least delay having to learn it. Be aware that thr cost of switching between cores means you have ot assign a singificant amount of work to each core

http://blog.dominodatalab.com/simple-parallelization/ https://pythonhosted.org/joblib/parallel.html

Generally I find it more efficient, if less fun, to learn only one thing at a time.

I hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top