SlideShare a Scribd company logo
1 of 17
RenderScript
Daniel Kao <daniel.kao@gmail.com>
Agenda
• What is RenderScript and why
• How to use it with REAL example
• Show some data comparison
• Bad side…
• References
What is RenderScript
• A framework for running computationally intensive tasks at
high performance on Android.
• primarily oriented for use with data-parallel computation
• E.g., image processing, computational photography, or computer
vision.
• run operations with automatic parallelization across all
available processor cores, and supports different types of
processors such as the CPU, GPU or DSP.
Why use it?
• If you use NDK
• Lack of portability
• Lack of performance (dealing with CPU, GPU, or DSP)
• Lack of usability (native code => harder, and JNI…)
• RenderScript did them all for you
How it works
1. Android app codes
2. RenderScript codes
(C99-derived
language)
• Reflected Layer Classes
Developer’s job
System generated
Real Case
• Change white color to transparent for an image
Real Case
• Change white color to transparent for an image
Two important component
• compute kernels: written in a C99-derived language.
• Java codes:
• managing the lifetime of RenderScript resources
• controlling kernel execution.
Step 1: write .rs script
• Line 1: declares the version of RenderScript that you are Line
• Line 2: declares the package name of the .java reflection of this RenderScript
• Line 4-6: global static variables that can be accessed from java codes by system
generated java reflected functions
• Line 8: kernel function definition
• Line 9-61: where we write our codes
• Line 62: return the result
Step 2: write java codes
• 121: Initialize a RenderScript context
• 122-124: Create Allocation (a RS object that provides storage for a fixed amount of
data)
• 126: Create RS script object
• 133, 135: System generated func. to invoke computation for each element
Step 3: get data & clean memory
• Get the data from OutAllocation
• Manage memory in java codes
=> Destroy allocations and RenderScript instance
Data Comparison (contour)
• Almost always better than Java
codes
Data Comparison (contour)
• Almost always better than Java
codes
Bad Side….
• A framework that only works on Android platform
• Lack of documentation
• Limited API set
• Hard to debug
• Crashes on Intel Atom devices (my problem?)
References
• http://developer.android.com/guide/topics/renderscript/com
pute.html
• http://android-developers.blogspot.tw/2011/02/introducing-
renderscript.html
• http://android-
developers.blogspot.tw/2011/03/renderscript.html
• http://android-developers.blogspot.tw/2013/01/evolution-of-
renderscript-performance.html
• https://www.youtube.com/watch?v=3ynA92x8WQo
• https://software.intel.com/en-us/articles/how-to-use-
renderscript-on-intel-based-devices

More Related Content

What's hot

WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by Mikael ...
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by  Mikael ...WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by  Mikael ...
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by Mikael ...AMD Developer Central
 
From C++ to JS via Emscripten
From C++ to JS via EmscriptenFrom C++ to JS via Emscripten
From C++ to JS via EmscriptenTomNickson
 
Making cloud native platform by kubernetes
Making cloud native platform by kubernetesMaking cloud native platform by kubernetes
Making cloud native platform by kubernetes어형 이
 
WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...
WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...
WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...AMD Developer Central
 
How to make cloud native platform by kubernetes
How to make cloud native platform by kubernetesHow to make cloud native platform by kubernetes
How to make cloud native platform by kubernetes어형 이
 
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...AMD Developer Central
 
Scarlet SmallTalk
Scarlet SmallTalkScarlet SmallTalk
Scarlet SmallTalkESUG
 
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian Ballantyne
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian BallantyneWT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian Ballantyne
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian BallantyneAMD Developer Central
 
Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web ServersTroy Miles
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overheadCass Everitt
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the networkJeremy Lainé
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programmingICS
 
Qt for Python
Qt for PythonQt for Python
Qt for PythonICS
 
Using Docker for GPU Accelerated Applications
Using Docker for GPU Accelerated ApplicationsUsing Docker for GPU Accelerated Applications
Using Docker for GPU Accelerated ApplicationsNVIDIA
 
WT-4064, Build Rich Applications with HTML5 and WebGL, by Tony Parisi
WT-4064, Build Rich Applications with HTML5 and WebGL, by Tony ParisiWT-4064, Build Rich Applications with HTML5 and WebGL, by Tony Parisi
WT-4064, Build Rich Applications with HTML5 and WebGL, by Tony ParisiAMD Developer Central
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3ICS
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN StackTroy Miles
 

What's hot (20)

Turbo charging v8 engine
Turbo charging v8 engineTurbo charging v8 engine
Turbo charging v8 engine
 
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by Mikael ...
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by  Mikael ...WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by  Mikael ...
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by Mikael ...
 
From C++ to JS via Emscripten
From C++ to JS via EmscriptenFrom C++ to JS via Emscripten
From C++ to JS via Emscripten
 
Making cloud native platform by kubernetes
Making cloud native platform by kubernetesMaking cloud native platform by kubernetes
Making cloud native platform by kubernetes
 
WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...
WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...
WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...
 
QtQuick Day 4
QtQuick Day 4QtQuick Day 4
QtQuick Day 4
 
How to make cloud native platform by kubernetes
How to make cloud native platform by kubernetesHow to make cloud native platform by kubernetes
How to make cloud native platform by kubernetes
 
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
 
Scarlet SmallTalk
Scarlet SmallTalkScarlet SmallTalk
Scarlet SmallTalk
 
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian Ballantyne
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian BallantyneWT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian Ballantyne
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian Ballantyne
 
Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web Servers
 
Approaching zero driver overhead
Approaching zero driver overheadApproaching zero driver overhead
Approaching zero driver overhead
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the network
 
Qt Qml
Qt QmlQt Qml
Qt Qml
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programming
 
Qt for Python
Qt for PythonQt for Python
Qt for Python
 
Using Docker for GPU Accelerated Applications
Using Docker for GPU Accelerated ApplicationsUsing Docker for GPU Accelerated Applications
Using Docker for GPU Accelerated Applications
 
WT-4064, Build Rich Applications with HTML5 and WebGL, by Tony Parisi
WT-4064, Build Rich Applications with HTML5 and WebGL, by Tony ParisiWT-4064, Build Rich Applications with HTML5 and WebGL, by Tony Parisi
WT-4064, Build Rich Applications with HTML5 and WebGL, by Tony Parisi
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 

Viewers also liked

Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScriptJungsoo Nam
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVMJohn Lee
 
Calliplus 開發經驗分享
Calliplus 開發經驗分享Calliplus 開發經驗分享
Calliplus 開發經驗分享Daniel Kao
 
Gradle Play Publisher Plugin
Gradle Play Publisher PluginGradle Play Publisher Plugin
Gradle Play Publisher PluginDaniel Kao
 
Chinese Characters Dictionary link Telegram Bot
Chinese Characters Dictionary link Telegram BotChinese Characters Dictionary link Telegram Bot
Chinese Characters Dictionary link Telegram BotDaeHyun Sung
 
香港中文開源軟件翻譯
香港中文開源軟件翻譯香港中文開源軟件翻譯
香港中文開源軟件翻譯Sammy Fung
 

Viewers also liked (8)

Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScript
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVM
 
Calliplus 開發經驗分享
Calliplus 開發經驗分享Calliplus 開發經驗分享
Calliplus 開發經驗分享
 
Gradle Play Publisher Plugin
Gradle Play Publisher PluginGradle Play Publisher Plugin
Gradle Play Publisher Plugin
 
COSCUP 2013
COSCUP 2013COSCUP 2013
COSCUP 2013
 
Chinese Characters Dictionary link Telegram Bot
Chinese Characters Dictionary link Telegram BotChinese Characters Dictionary link Telegram Bot
Chinese Characters Dictionary link Telegram Bot
 
Renderscript in Android 3.x
Renderscript in Android 3.xRenderscript in Android 3.x
Renderscript in Android 3.x
 
香港中文開源軟件翻譯
香港中文開源軟件翻譯香港中文開源軟件翻譯
香港中文開源軟件翻譯
 

Similar to RenderScript

Typhoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitTyphoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitDimitry Snezhkov
 
3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)mistercteam
 
Intro to big data analytics using microsoft machine learning server with spark
Intro to big data analytics using microsoft machine learning server with sparkIntro to big data analytics using microsoft machine learning server with spark
Intro to big data analytics using microsoft machine learning server with sparkAlex Zeltov
 
Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...
Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...
Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...Codemotion
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...Malin Weiss
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...Speedment, Inc.
 
Nodejs Native Add-Ons from zero to hero
Nodejs Native Add-Ons from zero to heroNodejs Native Add-Ons from zero to hero
Nodejs Native Add-Ons from zero to heroNicola Del Gobbo
 
How to double .net code value
How to double .net code valueHow to double .net code value
How to double .net code valuejavOnet
 
02 direct3 d_pipeline
02 direct3 d_pipeline02 direct3 d_pipeline
02 direct3 d_pipelineGirish Ghate
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseSpeedment, Inc.
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSpeedment, Inc.
 
java database connectivity for java programming
java database connectivity for java programmingjava database connectivity for java programming
java database connectivity for java programmingrinky1234
 
Seattle Spark Meetup Mobius CSharp API
Seattle Spark Meetup Mobius CSharp APISeattle Spark Meetup Mobius CSharp API
Seattle Spark Meetup Mobius CSharp APIshareddatamsft
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5David Voyles
 

Similar to RenderScript (20)

Typhoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitTyphoon Managed Execution Toolkit
Typhoon Managed Execution Toolkit
 
3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)
 
Nodejs overview
Nodejs overviewNodejs overview
Nodejs overview
 
Intro to big data analytics using microsoft machine learning server with spark
Intro to big data analytics using microsoft machine learning server with sparkIntro to big data analytics using microsoft machine learning server with spark
Intro to big data analytics using microsoft machine learning server with spark
 
Ml2
Ml2Ml2
Ml2
 
Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...
Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...
Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
Nodejs Native Add-Ons from zero to hero
Nodejs Native Add-Ons from zero to heroNodejs Native Add-Ons from zero to hero
Nodejs Native Add-Ons from zero to hero
 
How to double .net code value
How to double .net code valueHow to double .net code value
How to double .net code value
 
NoSQL and ACID
NoSQL and ACIDNoSQL and ACID
NoSQL and ACID
 
02 direct3 d_pipeline
02 direct3 d_pipeline02 direct3 d_pipeline
02 direct3 d_pipeline
 
Chap3 3 12
Chap3 3 12Chap3 3 12
Chap3 3 12
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
desktop_resume
desktop_resumedesktop_resume
desktop_resume
 
Ow
OwOw
Ow
 
java database connectivity for java programming
java database connectivity for java programmingjava database connectivity for java programming
java database connectivity for java programming
 
Seattle Spark Meetup Mobius CSharp API
Seattle Spark Meetup Mobius CSharp APISeattle Spark Meetup Mobius CSharp API
Seattle Spark Meetup Mobius CSharp API
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
 

RenderScript

  • 2. Agenda • What is RenderScript and why • How to use it with REAL example • Show some data comparison • Bad side… • References
  • 3. What is RenderScript • A framework for running computationally intensive tasks at high performance on Android. • primarily oriented for use with data-parallel computation • E.g., image processing, computational photography, or computer vision. • run operations with automatic parallelization across all available processor cores, and supports different types of processors such as the CPU, GPU or DSP.
  • 4. Why use it? • If you use NDK • Lack of portability • Lack of performance (dealing with CPU, GPU, or DSP) • Lack of usability (native code => harder, and JNI…) • RenderScript did them all for you
  • 5. How it works 1. Android app codes 2. RenderScript codes (C99-derived language) • Reflected Layer Classes Developer’s job System generated
  • 6. Real Case • Change white color to transparent for an image
  • 7. Real Case • Change white color to transparent for an image
  • 8. Two important component • compute kernels: written in a C99-derived language. • Java codes: • managing the lifetime of RenderScript resources • controlling kernel execution.
  • 9. Step 1: write .rs script
  • 10. • Line 1: declares the version of RenderScript that you are Line • Line 2: declares the package name of the .java reflection of this RenderScript • Line 4-6: global static variables that can be accessed from java codes by system generated java reflected functions • Line 8: kernel function definition • Line 9-61: where we write our codes • Line 62: return the result
  • 11. Step 2: write java codes
  • 12. • 121: Initialize a RenderScript context • 122-124: Create Allocation (a RS object that provides storage for a fixed amount of data) • 126: Create RS script object • 133, 135: System generated func. to invoke computation for each element
  • 13. Step 3: get data & clean memory • Get the data from OutAllocation • Manage memory in java codes => Destroy allocations and RenderScript instance
  • 14. Data Comparison (contour) • Almost always better than Java codes
  • 15. Data Comparison (contour) • Almost always better than Java codes
  • 16. Bad Side…. • A framework that only works on Android platform • Lack of documentation • Limited API set • Hard to debug • Crashes on Intel Atom devices (my problem?)
  • 17. References • http://developer.android.com/guide/topics/renderscript/com pute.html • http://android-developers.blogspot.tw/2011/02/introducing- renderscript.html • http://android- developers.blogspot.tw/2011/03/renderscript.html • http://android-developers.blogspot.tw/2013/01/evolution-of- renderscript-performance.html • https://www.youtube.com/watch?v=3ynA92x8WQo • https://software.intel.com/en-us/articles/how-to-use- renderscript-on-intel-based-devices

Editor's Notes

  1. Emphasize system generated classes
  2. using (1 is the only value for now). . The next feature is the in argument and its type. In a RenderScript kernel, this is a special argument that is automatically filled in based on the input Allocation passed to the kernel launch. By default, the kernel is run across an entire Allocation, with one execution of the kernel body per Element in the Allocation. The third notable feature is the return type of the kernel. An optional init() function. An init() function is a special type of invokable function that is run when the script is first instantiated.
  3. 119: an application will have only a single RenderScript context at a time. => You should consider context creation to be a potentially long-running operation, since it may create resources on different pieces of hardware; Methods to launch a given kernel will be reflected in the same ScriptC_filename class with methods named forEach_kernelname(). Argb_8888
  4. an application will have only a single RenderScript context at a time