The current state of WebCL

Years ago Microsoft was in court as it claimed Internet Explorer could not be removed from Windows without breaking the system, while competitors claimed it could. Why was this so important? Because (as it seems) the browser would get more important than the OS and internet as important as electricity in the office and at home. I was therefore very happy to see the introduction of WebGL, the browser-plugin for OpenGL, as this would push web-interfaces as the default for user-interfaces. WebCL is a browser-plugin to run OpenCL-kernels. Meaning that more powerful hardware-devices are available to JavaScript. This post is work-in-progress as I try to find more resources! Seen stuff like this? Let me know.

How it works

5 months ago I introduced WebCL in a post ‘WebCL – a next step‘. Actually it is like OpenCL host-code, but then not in C or C++, but JavaScript. It means it is still C-like code if it comes to kernels, but also that you can grab an existing kernel and use it on the web. So need some speedy random number generator? Look around in the various examples freely available.

Three implementations

Of the big browsers Internet Explorer, Opera and Chrome/Chromium are currently left out. Chrome/Chromium probably is first to be added to the supported browsers. Opera’s plans are currently unknown and Microsoft doesn’t even have WebGL-plans, so probably we get WebDirectX once. WebCL is seen as dependent on WebGL’s success; Bitcoin is popular, but that will not make the difference. There is more to say on it, as I will discuss below.

Nokia’s WebCL for Firefox (Windows/Linux 32bit)

At http://webcl.nokiaresearch.com/ you can find the actual first implementation of WebCL. The project is still quite active, but no work is being done on getting it to work on other browsers publicly. So for now get an 32 bit Windows/Linux and Firefox if you want to play with it. It seems you need to have Firefox I’ll keep you up-to-date when a new browser or OS is added.

WebCL-branch of Firefox (Windows/Linux)

At http://gfx.parapluie.org/2011/binaries-for-webcl-and-source the GSOC-student, Fabien Cellier, was talking about the progress he made last summer to create a WebCL-plugin for Firefox. This code is part of a special webcl-branch of Firefox nightly: http://hg.mozilla.org/projects/webcl. I did not find any binaries, so here are the build-instructions. Warning: it takes very long to build and actually I did not get this demo working. It seems to work with a bitcoin-demo.

Samsung’s WebCL for Safari (OSX)

The implementation is actually done for Webkit, but the code currently only works with OSX-libaries and Safari. Besides downloading, you can also see an example here. In the readme the few steps are described to build the plugin.

Standardisation

Having several platforms (CPUs, 2 types of GPUs and hybrids) can be seen as an disadvantage, but various ongoing driver-optimisationswill eventually make the kernels more generic for all devices. Till then more implementations are needed if you want maximum results over a generic kernel. What is not good, is what we see in the screenshot: the three implementations seem not to be compatible. Meaning, you need to write JavaScript-code which handles all three version. This probably will be solved after one of the three implementations has won. Currently Nokia has the most examples, but Samsung has the best license to get it to other browsers. We’ll see.

So, well, mmmokay… What can it do?

See for yourself!

http://www.youtube.com/watch?v=OXpHF0TA9fI

Demo-time:

Samsung did not put their demos online, only videos.

Intel RiverTrail (Windows/OSX 32/64)

What you see in the OpenCL-world is that specialised libraries get developed – they get pretty good performance in less development-time as long as the hardware understands OpenCL. RiverTrail is such project which translates JavaScript-extensions to OpenCL and does the tedious things for you. RiverTrail is a plugin for (again) Firefox to “enable parallel programming in JavaScript targeting multi-core CPUs and vector SSE/AVX instructions“. So no support for GPUs, but the idea is promising as it spits out Intel-OpenCL and probably works pretty well on AMD too. This presentation tells you exactly what RiverTrail is, so I don’t have to do it. Dr.Dobbs also has a post on it.

Building

Download https://nodeload.github.com/RiverTrail/RiverTrail/tarball/master and https://developer.mozilla.org/en/gecko_sdk. The Gecko-SDK (which is under /xulrunner-sdk/) has to get into /extension/gecko-sdk/ of the RiverTrail project-location. The exact steps to make the XPI are in the readme under the extension-subdir.

WebCL and Flash

What is neat is to get WebCL into Flash. It is possible to call external JavaScript from Flash. Once I have tested it, I’ll edit in some results – I really want to work together with creative people if this works.

More?

A good start is using Nokia’s WebCL tutorial. My favourite way of learning is learn-by-stealing: take a demo WebCL-project and put in a kernel you have found in an SDK. If you have clean calculations (thus easy to separate from the rest of the code), you can always make a web-version of your software. If you need help, ask your question on StackOverflow. Follow @fcellier for the Firefox-plugin and @NokiaWebCL for Nokia’s plugin. Most news you will get via StreamHPC and Khronos.

Related Posts

7 thoughts on “The current state of WebCL

  1. Gary Frost

    I just stumbled on this writeup trying to get some background on WebCL, thanks for putting it together.

    I like the Rivertrail approach but was turned off because they only supported Apple and Intel OpenCL runtimes in their Firefox plugin version (a quick five minute hack will undo this 😉 and reveals much better performance) but then stumbled on the WebCL based fork which seems a much cleaner solution.

    https://github.com/fifield/RiverTrail/tree/webcl

  2. MySchizoBuddy

    were any progress made since you wrote this post last year

  3. pip010

    ” I was therefore very happy to see the introduction of WebGL, the browser-plugin for OpenGL, as this would push web-interfaces as the default for user-interfaces.” I see no reasoning behind such a statement. Exactly how WebGL will address all the hassle in making a GUI? if you are talking about speed, I couldnt care less. Besides, WebGL and WebCL !?? is WTF as a concept to start with. I rather cut my 2balls than trying to do HPC in a browser! Good luck fighting compatibility and performance issues till you are alive 😀

    • StreamHPC

      One of the views of where computers go to is using web-interfaces for everything. This means that it does not matter where your program runs, and therefore you can keep working at home even if the service is at your work or somewhere else. I was referring to this view.

    • StreamHPC

      Not at the moment. When the the implementations have implemented the WebCL specs and the WebCL-workgroup has agreed on it, then it is time to deeply look at interaction with WebGL and other APIs.

Comments are closed.