How to use WebCL in Chrome?

14.1k Views Asked by At

I'm a young developer interested in HPC and parallel programming.

As you can see here http://www.khronos.org/webcl has been "released" (not yet, is a working draft) this porting for the web of OpenCL. I don't know where to start from, because I can't see what to do, because I would like to do it on Chrome that, unfortunately, still doesn't have his experimental plugin like Firefox, and I know that it would have better performance thanks to the v8.

Well, no one knows nothing about it? I know I should use idl files, but I don't know where or what do, actually.


Actually I think that my problem, lately, is first the debugging. Firebug, compared to the debugger of chrome is a pain and confusing. Chrome has less bug, is lighter and can give better performance also for this, what I was saying, lightweight.

And we should also see how is implemented the .idl for Firefox and make some comparisons about performance, on how resources are handled from both engines.

4

There are 4 best solutions below

0
On BEST ANSWER

(Jan 2020) There are other options to do web computation on the GPU:

WebGL compute shaders (old but readily accessible)

This is pretty easy to set up within a WebGL context. Shortcomings compared to WebCL are minor:

  • WebCL Floating point precision guarantees are better (for most uses, doesn't matter)
  • WebCL supports random writes where WebGL Compute doesn't, but for most parallel problems, this doesn't matter, as you'll be writing a result only for the current element operated on.
  • Buffer data comes back to CPU as integers, but you can solve this if you represent your values the right way and encode/decode accordingly on the GPU/CPU. I've done this by multiplying floats by some large value (like 1024) before finalising in compute shader, and dividing by same once you get integers back on CPU (note that using a power of 2 means you can do this integer division very fast by doing value = buffer[n] >> 10 i.e. 1024 = 2^10). I did not have any precision concerns as some scientific / fintech apps do.

You can find the recently-updated spec here.

WebGPU (new standard)

This is the latest standard under implementation, and successor to WebGL 1.0, 2.0 and WebCL.

You can access the GPU's computational power directly from JavaScript, dealing with latency on GPU callouts by using async and await. You will need to write shaders in WHLSL (now WSL), a new, high-level shader language based closely on Direct3D HLSL.

It abstracts the latest low-level 3D graphics APIs such as Metal, Vulkan and Direct3D 12, thereby reducing GPU overheads compared with Open/WebGL.

Choices?

WebGL compute shaders for those who intend to use computational results in WebGL rendering, who are anyway doing WebGL rendering in their app, or who want to prototype on web and then port to native OpenGL.

WebGPU for planned cross-browserness including on Apple devices (where GL has been poorly supported for a long time), newness, and speed. Also used for graphics.

WebCL via the extension for Chrome / Chromium if you ultimately want the opportunity to run the code on CPUs too, without modification, and don't need GPU rendering.

0
On

The performance gains you seem to be expecting with a port of the Firefox WebCL extension to the Chrome browser are, I would surmise, unlikely: Though the V8 engine does indeed process javascript faster than other engines, WebCL is, by definition, processed primarily on the GPU, so the javascript component of the code will more than likely represent a very small percentage of the processing time. For the time being, if you want to experiment with WebCL, you're going to need to stick with the Firefox extension.

0
On

For a Chrome version, Samsung's (the one on Google Code) is the right one to look at. It is for Safari: Safari is based on WebKit, which is also what Chrome is based on. Working with Chrome's renderer might be tricky, however, as I believe it is in a special process. I bet Chrome devs would love to help out on this, however, and I suggest checking with the WebCL project members if anybody has started looking at this already.

Feature-wise, Samsung's version has a big practical difference from Nokia's: it supports moving data directly from WebCL to WebGL. If you want to visualize a computation without going moving all the data off the GPU inbetween (which would kill real-time performance), this is a big deal.

Good luck!

0
On

Chrome with WebCL is now available on github Chromium-WebCL. Source, build instructions and binaries (for windows)