Mar 22, 2010

Learning CUDA

Hi there!

I did not post here for a while because I am very busy right now! I am working on my last paper for my PhD thesis and the deadline is by the end of march... I had do conduct an experiment, process some data and now I am parsing the ANOVA results and this in parallel to the writing of the paper. After this last deadline, I will begin to write my PhD manuscript in English! :) So exciting!

During the few free time I found (almost at night), I test Battlefield Bad Company 2 with friends. Also, I implement spherical harmonic lighting for the purpose of ambient lighting of dynamically moving objects in the current "3d engine" I develop (a light pre-pass renderer with relief-mapping on all surfaces and other cool features).

And, as written in the title, I am currently learning CUDA! Indeed, I have bought the new book by David Kirk and Wen-mei W. Hwu called Programming Massively Parallel Processors: A Hands-on Approach. I found this book well written and it nicely introduces CUDA. Good job authors! I only had a large overview of the CUDA architecture but now it is clear in details.
The first thing I did is to take an example in the nVidia CUDA browser and make it independent of their cutil library and others. To build and run my example, You should just need to install the CUDA Toolkit. You can download this simple program HERE. It features a simple grid of points which height is computed using CUDA and stored in a VBO. The result is finally displayed using OpenGL. Only Debug and Release configurations work (32 and 64bits). Emulation profiles will not compile right now. Also, the CUDA code is nicely separated from the c++ code, something I did not find in every web examples. The other libraries used are glut, glu and glew (everything is in the zip file).
So when I will have finished to read the book (and implemented their examples), I may start writing a little demo... :D

See you soon!


  1. Good luck writing your thesis in English, the extra difficulty will have the consequence that your thesis will be readable by the entire earth, not just a handful of french researchers :)

    Programming Massively Parallel Processors is a good book, I'm reading it by now. The only thing I disliked was the price for such a small book, I like 1000 pages books for that price :)

  2. Thank you! :) The most difficult part will be to translate my previous work section from French to English. Then, all my articles are in english so roughly I will copy-past, add more details, organize section with nice links and finally add more eye-candy pictures!

    Concerning the book, yes: so high price for a small book... (I have already read nearly one third of the book in one day). As compared to the upcoming GPUPro (which I will receive) the ratio price/nbPages is too high.
    In this book, I really apreciated the part talking about hardware evolution from geForce2MX (my first graphic card! Ah good old days) to current GPU. That was fun to read!

  3. I'm wondering how you can write generic CUDA code when the optimizations depend so much on the specifications of each card.
    They give the example of the GF80's limitations, showing how much compute power you could lose if you happened to cut your matrix into chunks "al little" too big (> 16x16).
    Well, I haven't finished the book yet, the answer may hide at the end :D

  4. I agree, it seems that you really need to take care about the device you are using. I think that is why you can query so many properties about the device (block/grid size limit, etc).
    Don't know OpenCL in details yet, but maybe in this language this is hidden to the user... As you said, we need to reach the end of the book! :)

  5. I was tempted to buy the book myself but... I have a radeon :)

  6. Ah, so you may start directly with OpenCL! :)

    Since my first computer, I always bought nVidia cards (geForce2MX, 4Ti4200, 7900GT an now GTX275). This maybe due to my little experience of bad OpenGL ati driver on linux in 2003~4. I stay exclusively on windows since then so maybe one day I'll go ati!