Sunday, 15 December 2013

WebCL Parallel processing for web

Posted by Mahesh Doijade 4 Comments
WebCL Parallel processing for web, WebCL, OpenCL, GPUs, Parallel Porcessing
    Nowadays from Desktops to Smartphones all are coming with multicore CPUs and Graphics Processing Units (GPUs) which have immense computational capability provided the task is carried out in parallel fashion. GPUs were mostly used for graphics related processing but with the advent of programming languages like CUDA, OpenCL carrying out general purpose computation on them also became possible. Though CUDA is restricted to GPUs, one can use OpenCL to write parallel programs for multicore CPUs, GPUs and some other modern processors too. But the web world involving complex web applications which essentially requires considerable amount of computation in several cases was still not able to leverage this computational capability offered by the technological boost, until WebCL arrived. WebCL is a framework for carrying out heterogeneous parallel computing in web applications/websites.

WebCL Parallel processing for web

 

    WebCL, that is, Web Computing Language is JavaScript binding for OpenCL to leverage heterogeneous parallel computing at client side initiated by Khronos Group. It announced first working draft of WebCL around April, 2012. WebCL makes feasible to carry out computationally intensive applications such as physics engines for games, photos and video editing to name a few in web browser. So, web developers can tap into massive parallel computation capabilities offered by multicore CPUs,  GPUs and future manycore accelerators. Currently, WebCL is not natively supported by web browsers, but one can find its different implementations developed by Nokia, Motorola, Mozilla and Samsung to get essence of it. Its API has very close to resemblance to OpenCL C API so that it is easy for the developer to adopt it.
    Below is sample JavaScript WebCL detection function which can be called like any other JavaScript function, one need to install OpenCL drivers/SDK as well as WebCL browser extensions form one of the sources mentioned above, for instance one can download OpenCL SDK/drivers from here and WebCL extension from here.

function detectWebCL() {
    if (window.WebCL == undefined) {
       alert("Your system does not support WebCL. Please install both OpenCL driver" +
             "and the WebCL browser extension.");
       return false;
    }

    // Get a list of available WebCL platforms, and another list of the
    // available devices on each platform.
    try {
          var devices = [];
          var platforms = WebCL.getPlatformIDs();
          for (var i in platforms)
          {
              var platform = platforms[i];
              devices[i] = platform.getDeviceIDs(WebCL.CL_DEVICE_TYPE_ALL);
          }
          alert("Great! Your system supports WebCL.");
    }
    catch (e)
    {
         alert("Your platform or device inquiry failed.");
    }
}

Read More