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:
  • 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
  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.


pip010 said...
This comment has been removed by the author.
Dr Dr Anastasios Tsiolakidis said...

Peculiar. First I had to get erlang bin in my path, then the rebar directory in my path and build it with bootstrap.bat. My rebar was misbehaving until I actually did set OPEN_CL exactly as you did (I tried first the long pathnames where, I was informed, OpenCL was not to be found). Then I got a git error caused by having downloaded a snapshot, not a git clone. Finally I got success, wondering if the end product is crash-free!

Creating library priv/cl_nif.lib and object priv/cl_nif.exp

Dr Dr Anastasios Tsiolakidis said...

And... it is not crash free, even the one-liners crash, though in all honesty I usualy have fewer crashes in 32 bit and have not tried it yet