WebCL and WebGL interactions demo

A demonstration showing simple WebCL/GL interactions


I developed a basic demonstration of (very fancy) physics with WebCL in order to write a tutorial about WebCL and WebGL interactions in the coming weeks. Please note that this demo only works with the native Firefox implementation of WebCL, as Nokia's one does not support WebCL/GL interactions, and I haven't had the time to write a wrapper for Samsung implementation in Chrome.

It also includes the first version of EmbedGL.js, which is meant to be a lightweight WebGL framework, and to reduce code redundancy while leaving the choice to the developer about how he wants to manage his source code. At the moment it is quite unstable and not documented, but I will eventually write a post for the first public release.

If you are running the Firefox implementation of WebCL, you can check the demo here. Otherwise, you can watch this video :

Github repository : https://bitbucket.org/fredericlb/webcl-simple-particles

Posted in WebCL | 1 Comment

jsoclbm : WebCL bitcoin miner

(lucky) instance of jsoclbm

(lucky) instance of jsoclbm

As promised, here's the project I've been working on for the last 2 weeks of my GSoC !

jsoclbm is a WebCL bitcoin miner, it's actually (mostly) a port of poclbm in JavaSript (hence the name). What you might be thinking now is "what the f*** is a bitcoin miner anyway ?!" (if you're not, skip to the important part)

What is bitcoin ?

As I don't feel like explaining, here and now, what is bitcoin, let's just say it is a peer to peer currency relying on cryptography and an ingenuous distributed timestamp system for validating transactions.

The jsoclbm project

Live demo here ! (Of course you need the Firefox binaries including WebCL for this to function)

This miner uses WebWorkers to connect to a mining pool and uses a cl kernel (phatk.cl) to "solve" a block. Most of the code is about communicating with the pool and converting hexadecimal values to unsigned int (which is quite some "fun" to do in js ...)

It is of course open sourced, which I believe is a mandatory prerequisite for such a piece of software (I actually don't understand how people from the bitcoin community accept to use services such as coined.com which sends all their info to a undocumented private backend)

Posted in GSoC 2011, WebCL | Tagged , , , , | Leave a comment

WebCL in Firefox : statuts report

Last week I put the WebCL binding's development on hold and I started making a WebCL bitcoin miner.

I am taking a two days holiday, I will post more info about this project as soon as I am back.

See you!

Posted in GSoC 2011, WebCL | Leave a comment

Binaries for WebCL, and source

For those of you who are interested in testing WebCL, you can compile Firefox directly from source, or simply download a precompiled version of Firefox with WebCL included (currently available for Linux and Windows).

There you go, binaries whoo !

And if you have time (or a mac) :

If you intend to build, don't forget you need OpenCL 1.1 headers in your path.

You can find the N-Body demo here : http://liris.cnrs.fr/~fcellier/webcl-tests/

Making it work :

You need to change some settings in about:config for WebCL to be enabled and functionning :

  • webcl.force-enabled: true
  • webcl.opencllib: [path to opencl lib file]
  • webgl.prefer-native-gl: true (for Windows)
Posted in GSoC 2011, WebCL | Tagged , , , , | 4 Comments

Howto : running WebCL with a Nvidia Optimus video card

While the Optimus technology is a great idea, there is no official support for it using Linux. The problem here is not to judge the choice made by Nvidia, but to find a way to flawlessly run WebCL content even if you can't use Nvidia drivers out of the box.

In fact, it is not difficult to get it working, as the linux community is doing a very great work to support Nvidia Optimus : the main idea of this post is to show that it can be done, for those who doubt of the compatiblity of WebCL with the Bumblebee hack.

To summarize the problem briefly, the main problem with Optimus technology is that the Nvidia card doesn't have any standard output : it just computes data and returns them to the Intel video card, which is the only one used to display the results. Bumblebee is a well done hack (and a well found pun) that is based on Virtual GL - a software that is able to use accelerated graphics in a remote display - to render images using the Nvidia video card.

So, as you have already guessed, you will need to apply the Bumblebee hack. Don't worry, everything has been done to be as simple as possible. Using Ubuntu is the easier way to get it working, as you just have to add a PPA repository. For other distribs, you have to clone the git repository and launch a script (please note though that last time I tried it did not work with ArchLinux). After some questions, you can restart your computer and normally you can now run programs with your Nvidia video card by launching them using optirun32 or optirun64, depending on the program's architecture.

Then, you need - of course - the binaries released by Adrien. And now let's launch firefox using your Nvidia video card :
optirun64 ./firefox
Then in about:config, we need to change two values :

  • webcl.force_enabled must be set to true
  • webcl.opencllib must point to the OpenCL library, which can be found here if you use optirun64 : /usr/lib/nvidia-current/libOpenCL.so; and here if you use optirun32 : /usr/lib32/nvidia-current/libOpenCL.so.

That's it, WebCL will use your Nvidia video card for computation.

PS : Please note that kernel updates can be a problem with bumblebee, as you will need to apply it again after each new version. If you use apt, you have to purge bumblebee and nvidia-current packages, and then re-install them.

Posted in Linux, WebCL | Tagged , , , , , | Leave a comment

WebCL in Firefox : First results

Fabien Cellier (@fcellier) and I have worked together and we implemented the minimal set of methods needed for the average WebCL program to run.

I'm proud to present this demo, now running in Firefox :

This is Samsung's N-Body demo, adapted to the Firefox's WebCL API.

A very broad overview of what's left to implement :

  • Image buffers
  • Event management
  • Error management

Coming soon :

  • Source code
  • Binaries
  • Bitcoin miner

 

Posted in GSoC 2011, WebCL | Tagged , , , , | Leave a comment

WebCL in Firefox : status report

I've been strugling with quick stubs these last days and I don't have enough time to write a detailed article about what I've achieved so far.

A few points regarding my advancement :

  • Library loading works fine except it make Firefox crash if the libOpenCL.so (or .dll) file is not found
  • All WebCL functionnalities are disabled by default. webcl.force-enabled must be set to true (via about:config) to activate them.
  • We're starting to implement the main methods for WebCL objects, using quick stubs

Bye !

Posted in GSoC 2011, WebCL | Tagged , , | Leave a comment

WebCL in Firefox : Thread safe library loading

Last week has been entirely dedicated to coding and we now have some patches soon to be pushed in the webcl repository.

As I mentionned in my last status report, the first features to be implemented would be the idl interface for the WebCL component, and the OpenCL library linking. The last has been my main occupation last week.

Run-time OpenCL library linking

In order to make OpenCL symbols available we're using the NSPR dynamic library linking functionnalities to load them from the OpenCL library at run-time.

/* Pseudo C++ code */
// Loading the library
openCLLib = PR_LoadLibrary("libOpenCL.so");
// Declaring a function pointer
typedef cl_int (*ns_clReleaseProgram_t)(cl_program);
ns_clReleaseProgram_t ReleaseProgram;
// Fetching the symbol
ReleaseProgram =
        PR_FindFunctionSymbol(openCLLib, "clReleaseProgram");

Doing so we obtain one function pointer for each function in the library.

Thread safety

The library name can be set in a preference. If the user sets the webcl.opencllib setting (from about:config), then this is the value that will be used as an argument for PR_LoadLibrary.

In order to do this in a thread-safe manner, the responsibility of instanciating an OpenCLLib object (which is responsible of dynamically loading the library) as been given to a factory class. This entirely static class possess only one public method returning an OpenCLLib object, and which can be called only by one process at a time. This forbids conflicts that could be created in such cases where the user changes the webcl.opencllib setting while one tab is already using WebCL.

Posted in GSoC 2011, WebCL | Tagged , , , , | Leave a comment

WebCL in Firefox : status report

Not much has happened since my last post. I had school projects to finish and exams coming shortly after. This all ended tuesday 14th and I am now entirely committed to my Summer of Code project.

Moving on!

  • Things are now getting started as we have a mercurial repository to work on for which I've been granted commit access.
  • Discussions are going on about the best way to integrate WebCL to Firefox.
  • We will soon have the OpenCL binding inside Firefox along with a first idl interface for the component.

Yesterday my Ubuntu self-destructed when I asked it to update... I hope this won't happen again as this is way too much time lost way too stupidly!

See you soon for more details!

Posted in GSoC 2011, WebCL | Tagged , , , , | 2 Comments

Fixing Firefox build issues on non US Windows

If you've been trying to build Firefox from mozilla-central using MozillaBuild, you might have experienced the following error during the configure step :

This version () of the MSVC compiler is unsupported.

I found the following relevant lines in the configure script :

_MSVC_VER_FILTER='s|.* ([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
...
# Determine compiler version
CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
...
AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler
is unsupported. ... )

I'm using Visual Studio 2010 Ultimate, ${CC} value is correct ("cl") but the french translated usage message (see below) returned by cl -v is not parsed correctly by the _MSVC_VER_FILTER regexp and $CC_VERSION is therefore empty.


French translated message :

$ cl -v
Compilateur d'optimisation Microsoft (R) 32 bits C/C++ version
16.00.30319.01
pour 80x86
Copyright (C) Microsoft Corporation. Tous droits réservés.

cl : Ligne de commande warning D9002 : option '-v' inconnue ignorée
cl : Ligne de commande error D8003 : nom de fichier de la source
absent

I finally solved this problem by changing the codepage used in the command shell opened by start-msvc10.bat as such :

# Changing codepage to US :
$ /c/Windows/System32/chcp.com 437

$ cl -v
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01
for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9002 : ignoring unknown option '-v'
cl : Command line error D8003 : missing source filename

References :

Posted in GSoC 2011 | Tagged , , , | 3 Comments