Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting started with PyOpenCL

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!

like image 895
mariotoss Avatar asked Aug 24 '13 00:08

mariotoss


People also ask

What is PyOpenCL?

PyOpenCL lets you access GPUs and other massively parallel compute devices from Python. It tries to offer computing goodness in the spirit of its sister project PyCUDA: Object cleanup tied to lifetime of objects. This idiom, often called RAII in C++, makes it much easier to write correct, leak- and crash-free code.

What is OpenCL and Cuda?

CUDA is a proprietary API and set of language extensions that works only on NVIDIA's GPUs. OpenCL, by the Khronos Group, is an open standard for parallel programming using Central Processing Units (CPUs), GPUs, Digital Signal Processors (DSPs), and other types of processors.


2 Answers

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

like image 79
benshope Avatar answered Oct 15 '22 15:10

benshope


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.

like image 23
kiranputtur Avatar answered Oct 15 '22 14:10

kiranputtur