July 27, 2013

OpenCL and Erlang

I've recently purchased used Tesla C2050 from ebay (new one is still very expensive for personal use) to experiment GPGPU.  I'm especially interested in use with Python, Java and Erlang.  I found and tested Python and Java bindings but for Erlang, there aren't many choices. 

For Erlang, I found this (https://github.com/tonyrog/cl) to be a good choice as it is more complete than other implementations. 

My home development machine is Windows 7 64bit -- I prefer CentOS for general development and Mac for general use (I have all three at both work and home), however for some devices and applications I use, I decided to use Windows.  Windows is actually very convenient when it comes to odd hardware.  Mac -- not supported or some workaround is necessary, and for Linux, too much tinkering is needed which I do not want to spend too much time but focus on actual development.
Anyways, for Tony Rogvall's library, the compiling didn't go well in my environment.  After spending several hours, I finally figured it out.  Again, this difficulty and steps only apply for my case:
Environment:
  • Windows 7 pro, 64bit.
  • Nvidia CUDA 5 SDK installed. (CUDA 5 SDK comes with OpenCL, not a separate SDK)
    • H/W: NVidia Quadro 600 and Tesla C2050.
  • Erlang R15B02 (erts-5.9.2) 64bit.
  • Visual Studio 2010 Pro.
Other tools necessary:
  • rebar
  • Git
How to compile:
  1. open cmd
  2. "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64
  3. git clone https://github.com/tonyrog/cl.git
  4. set OPENCL_DIR=/PROGRA~1/NVIDIA~2/CUDA/v5.0
  5. update c_src\Makefile, adding "MCL=1"
  6. rebar compile
Step #2 is for VS2010 and 64bit only.  And step #4 is due to rebar and/or Makefile.  Step#5 is not necessary but Makefile says so.
Hope this helps someone facing the same problem.
Now it's time to actually explore OpenCL in Erlang!

UPDATE: the author confirmed that Makefile is not used.  Therefore step#5 is not necessary.