webvk: javascript binding to vulkan for high …onlinepresent.org/proceedings/vol146_2017/3.pdf ·...

7
WebVK: JavaScript binding to Vulkan for High Performance Browser Running on Linux Jae-ho Lee, Cheol Ryu, Sungho Lim, Changhun Jeong, Donghyun Kim and Jeseon Park 1 Embedded Software Research Group, Electronics and Telecommunications Research Institute (ETRI), Daejeon, Korea {bigleap, ryuch, shim}@etri.re.kr 2 Selvas AI Abstract. This paper presents an interface called WebVK that binds JavaScript and Vulkan on a web browser. With WebVK, JavaScript developers can gain maximum benefit from parallel processing on Vulkan-enabled platforms which exploit GPU hardware acceleration. Several benchmarks prove WebVK as the next generation compute API on the web. And WebVK is comparable in performance with WebCL that is currently in use to bridge in-browsing applications and OpenCL. Keywords: WebVK, Vulkan, WebCL, OpenCL, parallel processing, GPU acceleration, Chromium browser. 1 Introduction HTML5, the leading edge of web document markup language, has enabled web programmers to write sophisticated web applications which do not fall behind the native applications [1]. For the high-performance applications on the top of web browser, the Khronos group specified WebCL API [2] which supports the binding of JavaScript and OpenCL. JavaScript is the most favored language by web application programmer, and OpenCL is the cross platform parallel processing hardware control language. So the application on web could benefit from the modern multi-core CPU and CPU architecture. With the wide adoption of HTML5 and heterogeneous parallel processors of the recent computers and smartphones, web technology has been facing a new challenge to overcome its low performance issue, especially in the mobile environment. But WebCL, a JavaScript wrapper around OpenCL, allows in-browser applications to harness multi-core CPUs and GPUs for parallel processing, resulting in significant speedups of JavaScript codes. Vulkan [3] is the next-generation API of the Khronos group which is highly likely to replace OpenGL for graphics and computing hardware. Vulkan is designed to provide a variety of advantages over its predecessor, OpenGL. Vulkan offers lower overhead, more direct control over the GPU, and lower CPU usage. Vulkan is also a cross platform API which is available on Linux, Android, Windows, and other Advanced Science and Technology Letters Vol.146 (FGCN 2017), pp.12-18 http://dx.doi.org/10.14257/astl.2017.146.03 ISSN: 2287-1233 ASTL Copyright © 2017 SERSC

Upload: dohuong

Post on 30-Sep-2018

276 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: WebVK: JavaScript binding to Vulkan for High …onlinepresent.org/proceedings/vol146_2017/3.pdf · WebVK: JavaScript binding to Vulkan for High Performance Browser Running on Linux

WebVK: JavaScript binding to Vulkan for High

Performance Browser Running on Linux

Jae-ho Lee, Cheol Ryu, Sungho Lim, Changhun Jeong, Donghyun Kim

and Jeseon Park

1Embedded Software Research Group, Electronics and Telecommunications Research Institute (ETRI), Daejeon, Korea

{bigleap, ryuch, shim}@etri.re.kr 2Selvas AI

Abstract. This paper presents an interface called WebVK that binds JavaScript

and Vulkan on a web browser. With WebVK, JavaScript developers can gain

maximum benefit from parallel processing on Vulkan-enabled platforms which

exploit GPU hardware acceleration. Several benchmarks prove WebVK as the

next generation compute API on the web. And WebVK is comparable in

performance with WebCL that is currently in use to bridge in-browsing

applications and OpenCL.

Keywords: WebVK, Vulkan, WebCL, OpenCL, parallel processing, GPU

acceleration, Chromium browser.

1 Introduction

HTML5, the leading edge of web document markup language, has enabled web

programmers to write sophisticated web applications which do not fall behind the

native applications [1]. For the high-performance applications on the top of web

browser, the Khronos group specified WebCL API [2] which supports the binding of

JavaScript and OpenCL. JavaScript is the most favored language by web application

programmer, and OpenCL is the cross platform parallel processing hardware control

language. So the application on web could benefit from the modern multi-core CPU

and CPU architecture.

With the wide adoption of HTML5 and heterogeneous parallel processors of the

recent computers and smartphones, web technology has been facing a new challenge

to overcome its low performance issue, especially in the mobile environment. But

WebCL, a JavaScript wrapper around OpenCL, allows in-browser applications to

harness multi-core CPUs and GPUs for parallel processing, resulting in significant

speedups of JavaScript codes.

Vulkan [3] is the next-generation API of the Khronos group which is highly likely

to replace OpenGL for graphics and computing hardware. Vulkan is designed to

provide a variety of advantages over its predecessor, OpenGL. Vulkan offers lower

overhead, more direct control over the GPU, and lower CPU usage. Vulkan is also a

cross platform API which is available on Linux, Android, Windows, and other

Advanced Science and Technology Letters Vol.146 (FGCN 2017), pp.12-18

http://dx.doi.org/10.14257/astl.2017.146.03

ISSN: 2287-1233 ASTL Copyright © 2017 SERSC

Page 2: WebVK: JavaScript binding to Vulkan for High …onlinepresent.org/proceedings/vol146_2017/3.pdf · WebVK: JavaScript binding to Vulkan for High Performance Browser Running on Linux

popular variant game platforms. The Web platform will be a major one and seems to

incorporate the cutting-edge technologies, such as WebAR, WebVR and WebRTC,

which require significant amount of parallel processing power with multi-core CPU

and GPU. It is worthy to find out an alternative solution to fill the gap which made by

the absence of WebCL which is only available on OpenCL-enabled platform.

This paper presents the WebVK prototype for the latest version of the Chromium

browser running on Linux-powered desktop, and measures the performance by

benchmark programs that have been used for measuring WebCL performance in

previous work [4].

2 WebVK Prototype for Chromium

2.1 OpenCL and Vulkan

OpenCL is the cross platform API which allows applications to access both CPU and

GPU to exploit high-performance parallel computing as the same manner as OpenGL

does for graphic rendering. Vulkan, the successor of the OpenGL, is designed for the

latest GPU architecture, not for CPU, and grants application developers more

straightforward control of GPU at the driver level. Fig. 1 shows Khronos standards to

access GPU at the underlying hardware layer and browsers need a new interface that

binds JavaScript and Vulkan.

Fig. 1. Khronos standards for GPU acceleration

2.2 WebVK implementation for Chromium

Chromium is an open-source browser project that allows developers to extend new

experimental functions like Vulkan-based hardware acceleration technology.

Advanced Science and Technology Letters Vol.146 (FGCN 2017)

Copyright © 2017 SERSC 13

Page 3: WebVK: JavaScript binding to Vulkan for High …onlinepresent.org/proceedings/vol146_2017/3.pdf · WebVK: JavaScript binding to Vulkan for High Performance Browser Running on Linux

The Chromium browser is designed to support multi-process architecture that

minimizes the possibility of shutting down the entire system following a crash in a

certain application running on one process.

As shown in Fig 2, Chromium consists largely of three independent processes:

browser, render, and GPU process.

Fig. 2. Access to Vulkan through GPU process

The browser process orchestrates the whole operation and the render process

displays web content per tab while browsing. Chromium with multi-process

architecture prohibits the render process from issuing any commands to the GPU due

to security reasons, where the GPU process is specially designed to provide direct

access to the GPU. WebCL, JavaScript binding to OpenCL, aims at complex computations while

WebGL, JavaScript binding to OpenGL, is mainly used for 3D graphics. Thanks to

the GPU process in the Chromium browser, both WebCL and WebGL can call APIs

in OpenCL and OpenGL library to exploit the GPU to accelerate rendering and

compute.

Fig. 3. Browser binding to the Vulkan via GPU process

Vulkan composes a set of headers and dynamic libraries (libvulkan.so) that is

loaded at runtime by Installable Client Driver (ICD) loader. GPU vendors must

implement each Vulkan API in their driver and support ICD loader. This paper

Advanced Science and Technology Letters Vol.146 (FGCN 2017)

14 Copyright © 2017 SERSC

Page 4: WebVK: JavaScript binding to Vulkan for High …onlinepresent.org/proceedings/vol146_2017/3.pdf · WebVK: JavaScript binding to Vulkan for High Performance Browser Running on Linux

employs dlopen() to load and open vendor-specific Vulkan library loaded by ICD

loader.

This paper implements WebVK by binding JavaScript and Vulkan via GPU

process, as with the same way of implementing WebCL in the previous work [4]. Fig

3 shows the Inter-Process Communication (IPC) between the render process and the

GPU process and it works via a client-server model. The execution path of WebVK is

very similar to that of WebCL. In-browser applications using WebVK APIs can call

Vulkan functions through JavaScript engine that is bound to browser internals by

Web Interface Description language (IDL).

3 WebVK Performance

Since the release of Vulkan 1.0 specification, most of the graphic hardware

manufacturers have supported the standard on their GPUs. This paper especially

focuses on compute-intensive tasks using a Vulkan compute shader while Vulkan

originally aims at graphic-intensive rendering task.

This chapter measures the performance of Vulkan and WebVK in the

computational perspective.

3.1 Vulkan performance

Table 1 shows experiment environment to measure Vulkan performance on two

graphic cards that are available and deployed widely: AMD RX480 and NVIDIA

GTX960.

Table 1. Setting up experiment environment

AMD (RX480) NVIDIA(GTX960)

Memory DDR 16G DDR 16G CPU I7 6700 I7 6700 GPU AMD RX480 ADM GTX960

Software Ubuntu 16.04 Ubuntu 16.04

Vulkan 1.0 Vulkan 1.0

Fig 4 shows the average execution time of a benchmark running on the two

different vendor’s Vulkan drivers: NVIDIA and AMD. The benchmark includes executing clEnqueueNDRangeKernel 50,000 times that

adds a certain number to all elements of each array. The benchmark with the heavy

parallel workload was repeated 5 times and the average execution time was

calculated.

Advanced Science and Technology Letters Vol.146 (FGCN 2017)

Copyright © 2017 SERSC 15

Page 5: WebVK: JavaScript binding to Vulkan for High …onlinepresent.org/proceedings/vol146_2017/3.pdf · WebVK: JavaScript binding to Vulkan for High Performance Browser Running on Linux

Fig. 4. Vulkan performance (unit: ms, faster is better)

The performance is subjected to change depending on GPU and GPU device driver

version. The NVIDIA’s poor computational performance is supposed that NVIDIA’s

driver does not handle properly job distribution comparing with AMD’s – all jobs are

processed in a single queue, stemming from NVIDIA’s vendor-specific architecture.

Given the Vulkan performance at this moment, we decide to use AMD RX480 to

measure WebVK performance.

3.2 Benchmarking WebVK against WebCL

The WebVK-enabled browser has been prototyped by extending the latest Chromium

browser (version. 48.0.2528.0). The performance evaluation was done with Vulkan,

WebCL and JavaScript running on Ubuntu-powered desktop.

This section presents the speedup of Vulkan over WebCL and JavaScript by

measuring the execution time of compute-intensive applications such as in-browser

physics and image processing.

Two benchmarks, Deform and N-body, are used to measure the performance of

WebVK benefiting from GPU hardware acceleration.

The Deform benchmark renders the surface of spheres using a fractal noise

function; the benchmark simulates the deformed spheres with shaders for Fresnel and

reflective effects. Figure 5 shows the speedups of parallel code for Deform

benchmark using hardware acceleration over sequential code only using JavaScript.

WebVK’s performance is similar to WebCL’s that was also superior to JavaScript’s.

The N-Body benchmark simulates the dynamics of given number of particles,

calculating the positions and velocities of the particles under the influence of mutual

gravitational forces. Figure 6 shows also the speedups of parallel codes for N-Body

benchmark using hardware acceleration over sequential code only using JavaScript.

WebVK shows the better performance to WebCL. N-Body benchmark is involved in

parallel processing of GPU while Deform benchmark is involved in graphic

rendering.

Advanced Science and Technology Letters Vol.146 (FGCN 2017)

16 Copyright © 2017 SERSC

Page 6: WebVK: JavaScript binding to Vulkan for High …onlinepresent.org/proceedings/vol146_2017/3.pdf · WebVK: JavaScript binding to Vulkan for High Performance Browser Running on Linux

Fig. 5. Deform benchmark (cumulative average)

Fig. 6. N-Body benchmark (cumulative average)

Advanced Science and Technology Letters Vol.146 (FGCN 2017)

Copyright © 2017 SERSC 17

Page 7: WebVK: JavaScript binding to Vulkan for High …onlinepresent.org/proceedings/vol146_2017/3.pdf · WebVK: JavaScript binding to Vulkan for High Performance Browser Running on Linux

5 Conclusions

This paper introduced a WebVK-enabled browser that allows for in-browser

applications to gain a maximum benefit from direct access to GPU leading to high

performance. The WebVK prototype is an interface binding JavaScript to Vulkan, and

is well incorporated into the latest version of Chromium browser with multi-process

architecture. Web application developers can write their code using WebVK in the

same way they write code using WebCL.

The test result shows that benchmarks using WebVK outperform the same

benchmarks written in only JavaScript, and WebVK is comparable in performance

with WebCL.

Given Vulkan becomes one of the major hardware acceleration technologies, the

WebVK-enabled browser will be very useful for compute-intensive in-browser

applications. The WebVK implementation and benchmark source are available at the

developer website [5-6].

The current work is limited to Linux-based desktop computers, but we will step up

efforts to implement and benchmark a mobile browser running on Android-powered

mobile devices.

Acknowledgments. This work was supported by Institute for Information &

communications Technology Promotion (IITP) grant funded by the Korea

government (MSIT) (R0126-15-1100, Development of web-accelerated software

framework for web-based mobile service ecosystem).

References

1. G. Anthes, “HTML5 leads a web revolution”, Communications of the ACM, vol. 55, (2012)

July, pp. 16-17.

2. OpenCL, https://www.khronos.org/opencl/

3. Vulkan, https://www.khrnos.org/vulkan/

4. J.-h. Lee, “WebCL prototype for high performance browser running on Android-powered

mobile device”, ICTC on IEEE, (2016).

5. https://github.com/highweb-project/libvc/.

6. https://github.com/highweb-project/.

Advanced Science and Technology Letters Vol.146 (FGCN 2017)

18 Copyright © 2017 SERSC