Monday, March 5, 2012

They did it. A smallish OpenCL example running on Mesa's r600.


This happened somewhat unexpected while looking again at the state of open OpenCL implementations (so pocl and clover).

Suddenly some hero told me that there is a smallish OpenCL example which actually works with Mesa's OpenCL implementation (actually this is bound to r600 based devices). So what is awesome if this ain't?

What you need:
  • tstellar's clover-r600-master branch
  • Fedora 16 (okay, it might also work somewhere else), with rawhide clang and llvm
  • and the example code
  • oh - and - important -  an appropriate card e.g. HD6310 (AMD E-350/E-450) or some other evergreen GPU

What actually has to be done is - this time - left to the user.
A few hints:
  • Look at the comment in line 96 of src/gallium/state_trackers/clover/llvm/invocation.cpp and swap comments (there are r600 patches for LLVM which can be applied to get around this).
  • The implementation expects the opencl libs to reside in /usr/local/lib/opencl - so install or softlink
  • Set LD_LIBRARY_PATH to mesa/lib when building the example
  • You need to provide the OpenCL headers
The present support is currently just basic, but it's awesome to see this progress.

What you get:

There are 1 platforms.
There are 1 GPU devices.
clCreateContext() succeeded.
notkernel
main
clCreateCommandQueue() succeeded.
clCreateProgramWithSource() suceeded.
build log:
clBuildProgram() suceeded.
clCreateKernel() suceeded.
clCreateBuffer() succeeded.
clSetKernelArg() succeeded.
--------------------------------------------------
[...]
clEnqueueReadBuffer() suceeded.
pi = 3.141590

Let's see when I can build gst-plugins-opencl against mesa. And "they" include zack, steckdenis, and tstellar.

Some more informations using this tool:
$ make clInfo CFLAGS="-I$PATH_TO_CL_HEADERS" LDFLAGS="-lOpenCL -L$MESAPATH/lib"
$ sudo LD_LIBRARY_PATH="$MESAPATH/lib" ./clInfo
Found 1 platform(s).
platform[(nil)]: profile: FULL_PROFILE
platform[(nil)]: version: OpenCL 1.1 MESA 8.0.0
platform[(nil)]: name: Default
platform[(nil)]: vendor: Mesa
platform[(nil)]: extensions: 
platform[(nil)]: Found 1 device(s).
[...]

No comments:

Post a Comment