WebCL BOF - SIGGRAPH 2014
Upcoming SlideShare
Loading in...5
×
 

WebCL BOF - SIGGRAPH 2014

on

  • 175 views

WebCL slide presentation from the 2014 SIGGRAPH BOF

WebCL slide presentation from the 2014 SIGGRAPH BOF

Statistics

Views

Total Views
175
Views on SlideShare
175
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

WebCL BOF - SIGGRAPH 2014 WebCL BOF - SIGGRAPH 2014 Presentation Transcript

  • © Copyright Khronos Group 2014 - Page 1 Neil Trevett Vice President Mobile Ecosystem at NVIDIA | President of Khronos SIGGRAPH, Vancouver 2014
  • © Copyright Khronos Group 2014 - Page 2 Khronos Standards Visual Computing - 3D Graphics - Heterogeneous Parallel Computing 3D Asset Handling - 3D authoring asset interchange - 3D asset transmission format with compression Over 100 companies defining royalty-free Acceleration in HTML5 - 3D in browser – no Plug-in APIs to connect software to silicon - Heterogeneous computing for JavaScript Sensor Processing - Vision Acceleration - Camera Control - Sensor Fusion
  • © Copyright Khronos Group 2014 - Page 3 Motivation for WebCL • Parallel acceleration for compute-intensive web applications - Portable and efficient access to heterogeneous multicore devices in JavaScript • Typical Use Cases - 3D asset codecs, video codecs and processing, imaging and vision processing - Physics for WebGL games, Online data visualization, Augmented Reality • WebCL 1.0 specification officially released at GDC March 2014 - https://www.khronos.org/webcl http://www.youtube.com/user/SamsungSISA#p/a/u/1/9Ttux1A-Nuc View slide
  • OpenCL – Portable Heterogeneous Computing • Portable Heterogeneous programming of diverse compute resources - Targeting supercomputers -> embedded systems -> mobile devices • One code tree can be executed on CPUs, GPUs, DSPs and hardware - Dynamically interrogate system load and balance work across available processors © Copyright Khronos Group 2014 - Page 4 • OpenCL = Two APIs and C-based Kernel language - Platform Layer API to query, select and initialize compute devices - Kernel language - Subset of ISO C99 + language extensions - C Runtime API to build and execute kernels across multiple devices OpenCL Kernel Code OpenCL Kernel Code OpenCL Kernel Code OpenCL Kernel Code GPU DSP CPU CPU HW View slide
  • WebCL - Heterogeneous Computing for Web • WebCL defines JavaScript binding to the OpenCL APIs © Copyright Khronos Group 2014 - Page 5 - Enables initiation of Kernels from within the browser • Kernels are still written in OpenCL C - Analogous to WebGL shaders use GLSL - Enables re-use of kernels across OpenCL and WebCL OpenCL Kernel Code OpenCL Kernel Code OpenCL Kernel Code OpenCL C Kernel Code GPU DSP CPU CPU HW JavaScript Platform API To query, select and initialize compute devices JavaScript Runtime API To build and execute kernels across multiple devices
  • © Copyright Khronos Group 2014 - Page 6 WebGL/WebCL Ecosystem Content JavaScript, HTML, CSS, ... JavaScript Middleware JavaScript HTML5 / CSS Content downloaded from the Web Middleware can make WebGL and WebCL accessible to non-expert programmers E.g. three.js library: http://threejs.org/ used by majority of WebGL content Browser provides WebGL and WebCL Alongside other HTML5 technologies No plug-in required OS Provided Drivers WebGL uses OpenGL ES 2.0 or Angle for OpenGL ES 2.0 over DX9 WebCL uses OpenCL 1.X Low-level APIs provide a powerful foundation for a rich JavaScript middleware ecosystem
  • © Copyright Khronos Group 2014 - Page 7 WebCL Programming 1. Query host for OpenCL devices 2. Create a context to associate OpenCL devices 3. Create programs for execution on one or more associated devices 4. Select kernels to execute from the programs 5. Create memory objects accessible from the host and/or the device 6. Copy memory data to the device as needed 7. Provide kernels to command queue for execution 8. Copy results from the device to the host Context Programs Kernels Memory Objects Command Queue Send for execution Progra ms Kernel0 Kernel1 Kernel2 Images Buffers In order & out of order Create data & arguments Compile
  • * * * * * WebCLCommandQueue WebCLEvent WebCLSampler © Copyright Khronos Group 2014 - Page 8 WebCL Architecture • HTMLWindow or WorkerUtils implements WebCLEnvironment - If WebCL object not present, then WebCL is not supported • Three Layers - Platform - Compiler - Runtime HTMLWindow or WorkerUtils WebCL + webcl WebCLPlatform WebCLContext WebCLDevice WebCLProgram WebCLKernel WebCLMemoryObject {abstract} WebCLBuffer WebCLImage WebCLExtension Platform layer Compiler layer Runtime layer
  • WebCL - Designed-in Architectural Security • Leverages OpenCL 1.2 robustness/security extensions - Context Termination: to prevent DoS from long running kernels - Memory Initialization: no leakage from out of bounds memory access © Copyright Khronos Group 2014 - Page 9 • API and Language Restrictions - To ensure no unsafe behavior is possible • WebCL Kernel Validator - Static and dynamic kernel checking
  • WebCL Language Restrictions • WebCL adds OpenCL C language restrictions for security • Structures are not supported as kernel arguments • Kernels name must be less than 256 characters • Mapping of CL memory objects into host memory space is not supported • Program binaries are not supported (for enhanced security) • Some OpenCL API functions & builtin functions may require translation © Copyright Khronos Group 2014 - Page 10
  • © Copyright Khronos Group 2014 - Page 11 WebCL Kernel Validator • Open source on GitHub - https://github.com/KhronosGroup/webcl-validator • Cross platform compatible C API + library + command line client - Runs on Windows (Visual Studio), OSX (XCode) and Linux (Makefiles) • Parses and validates kernel code against specification - Checks that no WebCL restrictions are broken – with extensive error messages • Verifies that all memory accesses are inside valid memory areas - If not validated at compile-time, low overhead run-time checks injected in code • Works on all OpenCL devices - Input WebCL C code -> Output is valid OpenCL C code - Source to source transformation based on Clang 3.4
  • 190 GFlops © Copyright Khronos Group 2014 - Page 12 Validation Overhead Example • NBody Force Simulation No Protection Protected 190 Gflops 148 GFlops 22% Overhead
  • © Copyright Khronos Group 2014 - Page 13 WebCL Test Suite • Source of tests openly available on GitHub - https://github.com/KhronosGroup/WebCL-conformance/ • Full API Test Coverage - WebCL requires a conformant underlying OpenCL on the host system - Input and output validation, and error handling checks for all methods in the API - WebCL validator conformance tests • Tests for security and robustness through exercising… - Data leakage, Denial of service, Out of bounds memory accesses • Test Suite Framework: - Allows selective execution of tests: skip tests per category or individually - Supports selection of available OpenCL platforms and devices - Allows different execution modes: relaxed and strict • Implementers must still become official adopters - If they wish to use the WebCL trademark
  • © Copyright Khronos Group 2014 - Page 14 WebCL Implementations 1. Nokia - Firefox build with integrated WebCL - Firefox extension, open sourced May 2011 - Mozilla Public License 2.0 - https://github.com/toaarnio/webcl-firefox 2. Samsung - uses WebKit, open sourced June 2011 (BSD) - https://github.com/SRA-SiliconValley/webkit-webcl 3. Motorola Mobility: Uses Node.js, open sourced April ‘12 (BSD) - https://github.com/Motorola-Mobility/node-webcl 4. AMD – uses Chromium (open source) - https://github.com/amd/Chromium-WebCL • WebCL Kernel Validator (open source) https://github.com/KhronosGroup/webcl-validator • OpenCL to WebCL Translator https://github.com/wolfviking0/webcl-translator Based on Apple QJulia Based on Iñigo Quilez, Shader Toy Based on Iñigo Quilez, Shader Toy http://fract.ured.me/
  • © Copyright Khronos Group 2014 - Page 15 Chromium with WebCL • Sandboxed architecture Command Buffer  See http://msdn.microsoft.com/en-us/library/bb625960.aspx
  • © Copyright Khronos Group 2014 - Page 16 node-webcl • A cross-platform (Mac, Windows, Linux) implementation of WebCL 1.0 using Node.JS (uses Google Chrome V8 JavaScript engine) - Many examples: ray casting, image processing… - Passing WebCL conformance tests with workarounds for bugs in OpenCL drivers • Extensions - Node’s Buffers for faster processing vs. TypedArrays - Multi-window and monitor support thanks to GLFW - Fully compatible with Node.JS async callbacks - OpenCL 1.1 & 1.2 features not (yet) in WebCL 1.0 - Experimental features for future WebCL specifications • WebGL interoperability and rendering with node-webgl, cross-platform - node-webcl v.1.0 to be released soon at https://github.com/Motorola-Mobility/node-webcl JS APP node-webcl node-webgl OpenCL GLFW OpenGL (ES) V8 native FreeImage Based on Iñigo Quilez, Shader Toy Based on Apple QJulia Raycasting WebGL WebCL
  • JavaScript Canvas © Copyright Khronos Group 2014 - Page 17 Web Acceleration APIs • Khronos and W3C liaison for Web APIs - Leverage proven native APIs - Fast API development/deployment - Designed by hardware community - Familiar foundation reduces developer learning curve Native APIs shipping or Khronos working group WebVX? Vision Processing HTML JavaScript API shipping, acceleration being developed or work underway WebKCAM? Camera control WebStream? Sensor Fusion Possible future JavaScript APIs or acceleration Native Path Rendering