There’s no place like ::1

OpenCL in MacRuby (Hack, Not Very Useful)

| Comments

Quick post to let you know about my latest hack: basic support for OpenCL on MacRuby and Snow Leopard.

  • it is my first Ruby C extension ever
  • it is my first OpenCL approach ever
  • it is my first MacRuby hack (ever)

With this in mind, don’t expect real world usage from this code, nor that it will get merged into upstream: it was just written for fun!

The MacRuby branch with the changes is located here

Example

The hello world on OpenCL is probably “calculate each element’s square on a given array”. The code below shows how this can be done in MacRuby:

This code runs the same computation on all available OpenCL devices on your hardware. The results on my hardware (2 GPUs, 1CPU) are:

It was fun, and maybe it can inspire someone :) The OpenCL API is kinda complex and I’m not sure if there’s a good way of making it Rubyish enough. Suggestions are welcome! Have fun :)

Comments