15 September 2009

Playing with OpenCL

OpenCL (Open Computing Language) is a standard for writing programs that take advantage of all of the computational resources on your machine: multi-core CPUs, GPUs, and even others. From what I understand thus far it's similar to OpenMP but takes it a step further and introduces some generalizations of the parallel programming process. This allow, for one, the ability to use OpenCL to farm out processes to both CPUs and GPUs (even simultaneously) without changing much of the way the main program interfaces with these two devices.

I decided to take a look since I believe that parallel programming will be the next step all computational scientists must take eventually. For now, I'll post some resources for anyone interested in taking a look themselves. Later, perhaps I'll post a step-by-step on how to use OpenCL for parallel programming...once I learn how exactly it's all put together.

Now, from what I understand, OpenCL is a standard. What this means, I think, is that it's up to developers to implement the standard into their...whatever. (Compiler, System, Graphics Cards) What's been getting Mac-olytes excited is that Snow Leopard comes with such an implementation allowing you to write OpenCL-integrated C-programs using their framework. Just be sure to include the -framework OpenCL flag when you run gcc or clang:

$ gcc -framework OpenCL

For now, some resources to get you going:
  • Official Site: The Official Site with the full specifications. Not great for starting off learning how to code with OpenCL but it has a a good reference manual once you're up and running as well as a nifty quick reference card.
  • MacResearch: A series of videos (a new one just popped up as I was writing this) that provide, thus far, an overview of what is OpenCL and how to use it. A good start. There's even a podcast! Also, be sure to download and take a look at the Episode 3 example. You don't need to use XCode to compile it as long you include the -framework OpenCL flag during linking.
  • OpenCL Programming Guide for OS X: Since, to my knowledge, OS X is the only operating system thus far with an OpenCL implementation, this is naturally a good place to go. The general explanation is nice but the examples are only okay. There are some downloadable XCode projects that serve as decent examples.
  • Python OpenCL: As expected, there are Python bindings as well. Haven't tried it out yet. Let me know if it's any good!

0 comments:

Post a Comment