Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use WebCL in Chrome?

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.

like image 548
LowFieldTheory Avatar asked Jul 17 '12 23:07

LowFieldTheory


People also ask

How do I turn on WebGL in Chrome?

To turn on WebGL start by opening Google Chrome. In the address bar, type chrome://flags/, and press Enter. Scroll to Disable WebGL - Enabling this option prevents web applications from accessing the WebGL API, and click Enable: Click Relaunch Now.

How do I activate WebGL?

To enable WebGL on your browser: Chrome: type "about: flags" in the address bar, then search for WebGL and activate the option. Firefox: type "about: config" in the address bar then search for "webgl. force-enabled" and change the value to "true".

Does WebGL work on Chrome?

WebGL (Web Graphics Library) is an online tool that allows you to render 3D graphics, including parts and builds within Eiger. Google Chrome supports WebGL, and in most cases will have it enabled by default.


3 Answers

(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.

like image 175
Engineer Avatar answered Sep 20 '22 09:09

Engineer


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!

like image 38
Leo Meyerovich Avatar answered Sep 18 '22 09:09

Leo Meyerovich


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.

like image 29
Jack Avatar answered Sep 21 '22 09:09

Jack