WebCL Will Soon Let Web Developers Harness The Power Of Multi-Core GPUs And CPUs From The Browser

Web browsers, for the most part, can’t use the full power of your computer or mobile device. The code they execute tends to run in a sandbox that’s abstracted from your hardware and doesn’t give the browser full access to it. So while your desktop software can, for example, use all the cores in your machine and use a modern GPU for parallel processing to speed up an image filter, for example, the JavaScript code in your browser can’t. But this will soon change.

The Khronos Group, the industry consortium responsible for standards like WebGL, OpenGL and COLLADA, today announced the ratification and public release of the WebCL 1.0 specifications. WebCL is the browser version of OpenCL, and it gives web developers a way to harness GPU and multi-core processing from within the web browser.

The WebCL standard is based on OpenCL, which offers a similar set of capabilities on the desktop.

As Neil Trevett, the chair of the WebCL working group (and Khronos’ president and NVIDIA’s VP for mobile content), told me earlier this week, he expects that once browser vendors adopt this spec, developers will use these capabilities to build things like physics engines for WebGL games, real-time video-editing tools, vision-processing features and photo-editing tools with advanced filters in the browser.

Basically, any app that needs to run code in parallel will be able to run in the browser, too. The standard itself is application agnostic anyway, though it’s fair to assume that games and photo processing will be among the first apps that use these capabilities.

Because the bottleneck for apps like this isn’t the browser, developers also barely incur any performance penalty for running this code from the browser.

Right now, JavaScript with asm.js on Firefox is about the fastest you can run web apps natively in the browser without resorting to things like Chrome’s Native Client or a plug-in. Even though asm.js may get close to native speeds, it’s not meant for parallel processing, so there is really no way for developers to get this kind of power for their apps right now. As Trevett noted, though, asm.js and WebCL are complimentary and because WebCL offers JavaScript bindings, developers could always call WebCL from their asm.js-based apps.

Take a look at this (older) video from Samsung to see what a difference WebCL makes:

Because WebCL is so similar to OpenCL, developers should be able to port their code over pretty easily.

The closer code gets to running on bare metal, though, the more security issues something like WebCL opens up, too. Because of this, Trevett noted, the team left out some features that are available in OpenCL because security couldn’t be guaranteed for them. As part of this process, the team developed an open-source kernel validator, and Trevett stressed that the work on WebCL also motivated the OpenCL community to get more secure.

For web developers, this opens up a whole new range of possibilities and could bring new categories of applications to the web. At the same time, though, this is also very unfamiliar territory for many of them. Trevett expects that just like the WebGL ecosystem is now dominated by relatively easy to use frameworks that abstract most of the grunt work away, WebCL will see a similar development. Just like developers who were well-versed in graphics engines started working on WebGL middleware, he expects engineers who are now working in parallel processing will do something similar for WebCL.

It’s still unclear when browsers will start offering this capability. The standard has been in the works since 2011 and the companies involved in the process include the industry heavyweights like Adobe, AMD, Nvidia, ARM, Intel, Opera Software, Mozilla, Google, Samsung and Qualcomm. Nokia, however, does offer a WebCL extension for Firefox, so if you really want to give it a try, that’s probably the best way right now.

Image credit: Nvidia