Blog

Q&A with Adrien Plagnol and Frédéric Langlade-Bellone on WebCL

  |   General, Q&A   |   2 Comments

WebCL_300WebCL is a great technique to have compute-power in the browser. After WebGL which gives high-end graphics in the browser, this is a logical step on the road towards the browser-only operating system (like Chrome OS, but more will follow).

Another way to look at technologies like WebCL, is that it makes it possible to lift the standard base from the OS to the browser. If you remember the trial of Microsoft’s integration of Internet Explorer, the focus was on the OS needing the browser for working well. Now it is the other way around, but it can be any OS. This is because the push doesn’t come from below, but from above.

Last year two guys from Lyon (South-France) got quite some attention, as they wrote a WebCL-plugin. Their names: Adrien Plagnol and Frédéric Langlade-Bellone. Below you’ll find a Q&A with them on WebCL. Enjoy!

Adrien Plagnol

I’m 25 and I live in Lyon, France, I’m currently employed as a Java engineer in a big IT company. I got involved in the Google Summer of Code in 2012 during which I worked on integrating WebCL in Firefox’s core. I am now following the latest advances on the project as a spectator as my current occupation is quite time consuming !  (photo on the left)

adrien frederic

Frédéric Langlade-Bellone

I did my bachelor degree in Montpellier then I moved to Lyon where I was granted my Master’s degree in computer graphics at the end of last year. I now work in the same company as Adrien, as a GIS (Geographic Information System) engineer. I discovered WebGL and WebCL during my studies, during which I worked on an online 3D GIS-data viewer and on some WebCL demos, with the help of Fabien Cellier, the PhD student who is working on WebCL and who was supervising me. Nowadays, I do work on some WebCL projects at a slow-paced rhythm. (photo on the right)

The Q&A

WebCL introduction

Vincent Hindriksen (VH): Could you describe what WebCL actually is ?

Adrien Plagnol (AP): WebCL is a binding of the desktop OpenCL library, but in a Javascript-fashioned way. It is really close to the C++ wrapper in that it is object oriented. It is able to manage standard Javascript types, including TypedArray (which were introduced for WebGL) and DOM events. As the desktop version includes OpenGL interactions, WebCL is also able to use WebGL buffers, even if this feature is described as optional in the specs.

Frédéric Langlade-Bellone (FLB): We were both introduced to OpenCL and WebCL by Fabien Cellier, which was one of the early developers of WebCL and who is now part of the Khronos Group that standardize WebCL as a non-voting member.


VH: There is not one project, but many. And they are not compatible. In the beginning it was Nokia’s implementation which got a lot towards “the standard”, but Khronos initiated a standardisation of WebCL. Could you tell something about the standardisation and your view on it?

FLB: The standardization already had good effects on the Samsung implementation of WebCL, as in the beginning it was working but the API was mainly a litteral conversion of the C API that did not take into account specificities of JavaScript.

The new version is based on the current draft of Khronos WebCL and is way easier to use in a JS environment. Moreover, even if Nokia’s implementation is quite easy to setup, it does not have CL/GL interaction. This interaction is quite useful as it allows you to use the same buffers for WebCL and WebGL, saving simplicity of code and global running speed. The standard will allow the developer to know whether the current implementation has CL/GL interaction, independently of a specific implementation. Nowadays, the three know implementations (Nokia, Mozilla and Samsung) are evolving to get the same API, which for me is the first step of WebCL becoming available for everyone.

[VH: see also https://github.com/ParapluieDotOrg/CommonWebCL by Frédéric for an effort to unite the various flavours]

VH: What is the current state of WebCL?

AP: WebCL is currently being worked on at Khronos and a public working draft is available at http://www.khronos.org/registry/webcl/specs/latest/1.0/ (updated URL for WebCL 1.0). Chrome, Safari and Firefox already have an available WebCL implementation, but the API is different for each one.

VH: In what way could you compare WebCL to its older brother WebGL? Will WebCL walk the same route?

FLB: I think it will be way harder for WebCL to become as spread as WebGL. Our days everyone can understand why we need OpenGL in our browsers, mainly because it’s visual. But OpenCL is not visual, and it needs more work to be understood, so I don’t think the WebCL community can be as big as the WebGL community, and that means that its integration in web browsers won’t be set as a priority in the years to come.

Demo Time

VH: Could you show off a demo made by you?

AP: I made an opensource bitcoin miner based on the WebCL Firefox API. It is available on Bitbucket : https://bitbucket.org/dalsh/jsoclbm (live demo is available at http://jsoclbm.parapluie.org/ for the few people who has a WebCL-enabled Firefox)

FLB: I made a demo based on simple physics interactions between particles and basic objects. You can watch it here :

https://www.youtube.com/watch?v=tdqBUCvxd4w&feature=g-upl

It is just meant to be an example of what can be done using WebCL, but it is not at all a technical demonstration. The idea is just to show that WebCL development is quite easy. Source code is available at https://github.com/ParapluieDotOrg/PartyingParticles.

VH: What is your favourite demo made by others?

FLB: It’s the GPU-based image editor made by Nokia. Actually, I haven’t played with it for a long time, but to me it is one of the best example of what WebCL could be used for.

Application Areas

Liad Weinberger (LB): Will WebCL be used for more than games and Bitcoins?

AP: WebCL may prove useful for image processing, distributed computing ( like the *@home projects ), etc… For every OpenCL usage we can imagine a WebCL equivalent in a web browser, providing lightweight client advantages and in some cases social interactions (ie. community based image editing, video/audio encoding… ).

Security

VH: What would be the potential dangers of the web due to WebGl and WebCL? Stealing of processor-time is much more doable than with just JavaScript.

FLB: I do know that people are working on the security issues for WebCL, correcting some issues related to privacy but also on the way WebCL will use your processor. Something more reliable than the Windows watchdog, which considers the GPU has crashed when it does not respond for more than two seconds. Moreover, we can imagine asking the user the permission to execute a processor-intensive process, in the same way that it is done for geolocalization.

VH: A possible side-effect. Can WebCL/GL be used to determine the hardware has, without user-interaction? And if so, is this handy for game-developers and computer-shops to propose compatible games and computer-upgrades?

AP: We never really thought about that kind of use but it is true that OpenCL is able to provide hardware discovery features which would be built-in the browser. This would allow a game company to inform the user if its GPU (at least) is powerful enough to run a game directly from the browser without installing any plugins or needing IT knowledge.

FLB: Moreover it could also allow a company to get statistics about hardware configurations of potential game customers, which would help them into optimizing games to the most common configurations.

The OpenCL problems

VH: OpenCL gets much more standardised into libraries and reachable in higher level code. Will WebCL do the same? And if so, how do you see these libraries and higher level programming concepts will get into WebCL?

FLB: I can easily imagine a library that would provide some common algorithms with multiple implementations (WebCL, WebGL using framebuffers, JS), choosing the most powerful one depending on the user hardware : JavaScript is a great langage when it comes to this kind of abstraction For libraries concerning WebCL itself, it would certainly need libraries to provide frequently used routines in the CL language. We can think of a core library, that just provide a way to load third-party CL functions into an already existing CL program. Other libraries would just have to plug onto this library to provide new functions. However, apart from these points, WebCL won’t need a lot of specific library, as the idea for me is that WebCL integration should be done in most already existing Javascript library : I can’t wait to see WebCL in bullet.js, for instance.

VH: A little bit technical. OpenCL is not performance portable. What techniques do you use in WebCL to offer best performance per device? Multi-kernel?

FLB: Yes multiple kernels is for me the simpliest way to get it working. That’s another issue that should be resolved by libraries – seamlessly detecting what can be done using the current device and giving reliable data to know if the program we would like to run won’t be too intensive for this device. Indeed it is quite easy to write the different kernels, but the difficult part is the detection of which one should be running. Running a small benchmark at the beginning is a useful marker but I don’t think it should be the only one as it is related to the current state of the computer (powersaving etc…) but it could also use device informations provided by WebCL.

WebCL could also prove useful in optimizing 3d models on the go based on customer hardware capabilities : performance detection could prove handy in that case.

The future

VH: IE is not the dominant browser anymore, and does not hold back web-innovation as it did for many years. As they did not implement WebGL (yet), what do you think about the influence of IE if it comes to acceptation to WebCL as the GPGPU-standard in the browser?

FLB: I’m quite pessimistic on that one. Officially, Microsoft does not want WebGL because of security issues (reading GL buffers filled by a previous website for instance). WebCL has the same issues, and even if most of them can be resolved at middle-term, they will end up finding a new way of rejecting OpenGL and OpenCL based technologies. We should not forget that IE is still used by 1/2 worldwide visitors and I really hope that Microsoft will provide at least alternatives based on DirectX or DirectCompute allowing us to go further with GPU based technologies instead of being always limited by the poor IE support for those.

VH: say its the end of Q4 2013 – WebGL and WebCL are in all browsers. How do you think the internet looks like? How would my experience on Wikipedia be? (a broad question, but please answer it in a positive way)

AP: It won’t change so much on Wikipedia, except that it might prove useful for live examples ( ie. physic models ). But in a more general way, it will open many new horizons. For instance, high-grade browser games could become a reality. Moreover, this open the doors to smaller projects aiming at a wide audience and using WebCL in a creative manner ( for promotional purpose for instance, as Disney did using WebGL for the Oz movie interactive promotion ).

FLB: It will also spread the idea that even complex applications can be easily shared as we won’t need to go through an installation process. One can imagine creating a very specific app and sharing it in the same day with his community, without having to care about specific OSes or platforms.

Try out WebCL yourself

Start with an introduction on http://www.ibiblio.org/e-notes/webcl/webcl.htm to install WebCL on Firefox. There you’ll find some demo’s, but also on http://webcl.nokiaresearch.com/demos.html

Add your favourite demo in the comments, for others to see. Got questions? Just ask.

Like to hear more of what these guys are doing? Follow them on twitter: @adrienplagnol@fredericlb

  • pip010

    !!!WARNING not TRUE!!! “WebGL and WebCL are in all browsers.”

    in all browsers, but not on all platforms!
    - practically not a single browser by default supports WebGL in Linux
    - even when one is supported it might be broken and no way really to find out rather than users complaining seeing crap or nothing! (All those WinXP machines)

    Care to comment what’s the state of WebCL in Linux? Doubt it is any better than WebGL :(