SlideShare a Scribd company logo
1 of 13
Download to read offline
©SIProp Project, 2006-2008 1
How to Build & Use OpenCL on Android
Studio
Noritsuna Imamura
noritsuna@siprop.org
©SIProp Project, 2006-2008 2
Goal
Making OpenCL programming Environment on
Android Studio
Android Studio 1.3 or later
C Language (Android NDK)
OpenCL 1.1 (ARM-Mali)
©SIProp Project, 2006-2008 3
Why?
OpenCL source code is separated “host source
code” as C Language file & “kernel(device)
source code” as CL file.
But Android’s APK can NOT include “kernel(device)
source code” as CL file in APK file.
Solution
Convert CL file to const char* in Single C header file
©SIProp Project, 2006-2008 4
Setup NDK on Android Studio1.3
Requited
Gradle2.5 or later
AS1.3’s Gradel is 2.4.
MUST update 2.4 -> 2.5 .
Setup NDK
Settings->System Setting->Android SDK
Modify “build.gradle”
http://tools.android.com/tech-docs/new-build-
system/gradle-experimental
Informations
Android NDK Support for Android Studio
http://tools.android.com/tech-docs/android-ndk-preview
NDK Samples
https://github.com/googlesamples/android-ndk
©SIProp Project, 2006-2008 5
Setup OpenCL on Android Studio1.3
Setup Header files of OpenCL
Download from ARM-Mali’s OpenCL Dev Site
http://malideveloper.arm.com/resources/sdks/mali-opencl-
sdk/
Copy “[ARM-Mali dir]/include/CL/*.h” to “[your
project dir]/app/main/src/jni/CL/”
Load Shared Lib of OpenCL
Copy “libOpenCL.so” from your Android Device
to “[your Android Studio Dir]/sdk/ndk-
bundle/platforms/android-[your target system]/arch-
arm/usr/lib/”
©SIProp Project, 2006-2008 6
Setup OpenCL on Android Studio1.3
Setup Header files & Shared Lib on Android
Studio
Add “Cflags” & “ldLibs” in “build.gradle”
1. build.gradle : app, android.ndk section
1. android.ndk {
2. moduleName = "openclsample-jni"
3. CFlags += "-I${file("src/main/jni/CL")}".toString()
4. ldLibs = ["android", "log", "OpenCL"]
5. (snip)
©SIProp Project, 2006-2008 7
Setup Plugin “OpenCL CL Generator”
Install Plugin to Android Studio
Select “Setting->plugins”
Click “Browse Repositories”
Search Plugin by “OpenCL” as keyword
Target Plugin URL
https://plugins.jetbrains.com/plugin/7888?pr=androidstudio
Click “Install Plugin”
Restart Android Studio
©SIProp Project, 2006-2008 8
Use Plugin “OpenCL CL Generator”
Click “Tools->Generate OpenCL’s CL files
header”
©SIProp Project, 2006-2008 9
How to Use Plugin: Host Side
Host side programming: standard OpenCL
CL file(kernel side source code) is loaded as “file”.
1. #include “opencl_cl_files.h”
2. (snip)
3. /* Create Kernel Program from the source */
4. program = clCreateProgramWithSource(context, 1, (const char **)&CLCL_HELLO,
(const size_t *)&strlen(CLCL_HELLO), &ret);
1. FILE *fp;
2. char fileName[] = "./hello.cl";
3. char *source_str;
4. size_t source_size;
5. fp = fopen(fileName, "r");
6. source_str = (char*)malloc(MAX_SOURCE_SIZE);
7. source_size = fread( source_str, 1, MAX_SOURCE_SIZE, fp);
8. fclose( fp );
9. (snip)
10. /* Create Kernel Program from the source */
11. program = clCreateProgramWithSource(context, 1, (const char **)&source_str, (const
size_t *)&source_size, &ret);
Host side programming: with Android Plugin
CL file is loaded as “const char*”.
©SIProp Project, 2006-2008 10
How to Use Plugin: Kernel Side
1. Converted Original File: opencl_cl_files.h
1. const char *CLCL_HELLO =
2. "#pragma OPENCL EXTENSION
cl_khr_byte_addressable_store : enablen"
3. "n"
4. "__kernel void hello(__global char*
string)n"
5. "{n"
6. " string[0] = 'H';n"
7. " string[1] = 'e';n"
8. " string[2] = 'l';n"
9. " string[3] = 'l';n"
10. " string[4] = 'o';n"
11. " string[5] = '0';n"
12. "}n"
13. "";
1. Kernel Source Code File: hello.cl
1. #pragma OPENCL EXTENSION
cl_khr_byte_addressable_store : enable
2. __kernel void hello(__global char* string)
3. {
4. string[0] = 'H';
5. string[1] = 'e';
6. string[2] = 'l';
7. string[3] = 'l';
8. string[4] = 'o';
9. string[5] = '0';
10. }
Kernel side programming
1. Write Source Code as CL file(Kernel Source Code)
2. Convert CL file(Kernel Source Code) to Original
Header File as “opencl_cl_files.h”
©SIProp Project, 2006-2008 11
Setup libOpenCL.so on Android
If you(or your Android Device) don’t have
libOpenCL.so in “/system/lib” or
“/system/vendor/lib”, you can download
libOpenCL.so.
Support GPUs
adreno-3xx: Qualcomm's Adreno 3xx GPUs
mali-t6xx: ARM's Mali-T6xx GPUs
Download from:
https://github.com/madeye/opencl-android-proprietary
Setup
Copy All SO files to “/system/lib” or “/system/vendor/lib”
on your Android Device.
©SIProp Project, 2006-2008 12
Appendix
©SIProp Project, 2006-2008 13
Download the Sample Project for AS
The Sample Project for AS that I use in this
slide.
https://github.com/noritsuna/OpenCLCLGenerator_
Sample
Features
“build.gradle” for NDK Support
Setup Plugin
OpenCL Headers & SO lib
The Sample Source Code for OpenCL

More Related Content

What's hot

4章 Linuxカーネル - 割り込み・例外 5
4章 Linuxカーネル - 割り込み・例外 54章 Linuxカーネル - 割り込み・例外 5
4章 Linuxカーネル - 割り込み・例外 5mao999
 
IL2CPPに関する軽い話
IL2CPPに関する軽い話IL2CPPに関する軽い話
IL2CPPに関する軽い話Wooram Yang
 
Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_Linaro
 
Beyond printk: Efficient Zynq UltraScale+ MPSoC Linux Debugging and Development
Beyond printk: Efficient Zynq UltraScale+ MPSoC Linux Debugging and DevelopmentBeyond printk: Efficient Zynq UltraScale+ MPSoC Linux Debugging and Development
Beyond printk: Efficient Zynq UltraScale+ MPSoC Linux Debugging and DevelopmentZach Pfeffer
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)Nanik Tolaram
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming LanguageJaeju Kim
 
UnityによるHoloLens用UWPアプリケーション開発の勘所
UnityによるHoloLens用UWPアプリケーション開発の勘所UnityによるHoloLens用UWPアプリケーション開発の勘所
UnityによるHoloLens用UWPアプリケーション開発の勘所Takahiro Miyaura
 
Android向けUnity製ゲーム最適化のためのCI/CDと連携した自動プロファイリングシステム
Android向けUnity製ゲーム最適化のためのCI/CDと連携した自動プロファイリングシステムAndroid向けUnity製ゲーム最適化のためのCI/CDと連携した自動プロファイリングシステム
Android向けUnity製ゲーム最適化のためのCI/CDと連携した自動プロファイリングシステムKLab Inc. / Tech
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
 
Insecure coding in C (and C++)
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)Olve Maudal
 
Understaing Android EGL
Understaing Android EGLUnderstaing Android EGL
Understaing Android EGLSuhan Lee
 
C++ マルチスレッドプログラミング
C++ マルチスレッドプログラミングC++ マルチスレッドプログラミング
C++ マルチスレッドプログラミングKohsuke Yuasa
 

What's hot (20)

C++11
C++11C++11
C++11
 
C++11 & C++14
C++11 & C++14C++11 & C++14
C++11 & C++14
 
4章 Linuxカーネル - 割り込み・例外 5
4章 Linuxカーネル - 割り込み・例外 54章 Linuxカーネル - 割り込み・例外 5
4章 Linuxカーネル - 割り込み・例外 5
 
IL2CPPに関する軽い話
IL2CPPに関する軽い話IL2CPPに関する軽い話
IL2CPPに関する軽い話
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
 
Why rust?
Why rust?Why rust?
Why rust?
 
Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_
 
Beyond printk: Efficient Zynq UltraScale+ MPSoC Linux Debugging and Development
Beyond printk: Efficient Zynq UltraScale+ MPSoC Linux Debugging and DevelopmentBeyond printk: Efficient Zynq UltraScale+ MPSoC Linux Debugging and Development
Beyond printk: Efficient Zynq UltraScale+ MPSoC Linux Debugging and Development
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming Language
 
C programming session6
C programming  session6C programming  session6
C programming session6
 
UnityによるHoloLens用UWPアプリケーション開発の勘所
UnityによるHoloLens用UWPアプリケーション開発の勘所UnityによるHoloLens用UWPアプリケーション開発の勘所
UnityによるHoloLens用UWPアプリケーション開発の勘所
 
Android向けUnity製ゲーム最適化のためのCI/CDと連携した自動プロファイリングシステム
Android向けUnity製ゲーム最適化のためのCI/CDと連携した自動プロファイリングシステムAndroid向けUnity製ゲーム最適化のためのCI/CDと連携した自動プロファイリングシステム
Android向けUnity製ゲーム最適化のためのCI/CDと連携した自動プロファイリングシステム
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Insecure coding in C (and C++)
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 
Understaing Android EGL
Understaing Android EGLUnderstaing Android EGL
Understaing Android EGL
 
C++ マルチスレッドプログラミング
C++ マルチスレッドプログラミングC++ マルチスレッドプログラミング
C++ マルチスレッドプログラミング
 
C programming session7
C programming  session7C programming  session7
C programming session7
 

Viewers also liked (8)

Radiation Test -Raspberry PI Zero-
Radiation Test -Raspberry PI Zero-Radiation Test -Raspberry PI Zero-
Radiation Test -Raspberry PI Zero-
 
Protocol of the DNA Extraction in Kitchen
Protocol of the DNA Extraction in KitchenProtocol of the DNA Extraction in Kitchen
Protocol of the DNA Extraction in Kitchen
 
將DNA在廚房抽出的程序
將DNA在廚房抽出的程序將DNA在廚房抽出的程序
將DNA在廚房抽出的程序
 
How to setup mastodon in chinese
How to setup mastodon in chineseHow to setup mastodon in chinese
How to setup mastodon in chinese
 
OpenCV acceleration battle:OpenCL on Firefly-RK3288(MALI-T764) vs. FPGA on Ze...
OpenCV acceleration battle:OpenCL on Firefly-RK3288(MALI-T764) vs. FPGA on Ze...OpenCV acceleration battle:OpenCL on Firefly-RK3288(MALI-T764) vs. FPGA on Ze...
OpenCV acceleration battle:OpenCL on Firefly-RK3288(MALI-T764) vs. FPGA on Ze...
 
5000円で誰でも作れる新世代衛星地上局
5000円で誰でも作れる新世代衛星地上局5000円で誰でも作れる新世代衛星地上局
5000円で誰でも作れる新世代衛星地上局
 
All list of the measuring machines for microwave
All list of the measuring machines for microwaveAll list of the measuring machines for microwave
All list of the measuring machines for microwave
 
衛星追尾用パラボラアンテナ建設記
衛星追尾用パラボラアンテナ建設記衛星追尾用パラボラアンテナ建設記
衛星追尾用パラボラアンテナ建設記
 

Similar to How to Build & Use OpenCL on Android Studio

Wonho Park_20151209
Wonho Park_20151209Wonho Park_20151209
Wonho Park_20151209Wonho Park
 
EclipseOMRBuildingBlocks4Polyglot_TURBO18
EclipseOMRBuildingBlocks4Polyglot_TURBO18EclipseOMRBuildingBlocks4Polyglot_TURBO18
EclipseOMRBuildingBlocks4Polyglot_TURBO18Xiaoli Liang
 
C# Production Debugging Made Easy
 C# Production Debugging Made Easy C# Production Debugging Made Easy
C# Production Debugging Made EasyAlon Fliess
 
Oracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneOracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneDeepti Singh
 
LOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdfLOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdfThninh2
 
Oracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneOracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneDeepti Singh
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application DevelopmentRamesh Prasad
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Opersys inc.
 
The Ring programming language version 1.5.2 book - Part 15 of 181
The Ring programming language version 1.5.2 book - Part 15 of 181The Ring programming language version 1.5.2 book - Part 15 of 181
The Ring programming language version 1.5.2 book - Part 15 of 181Mahmoud Samir Fayed
 
Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011pundiramit
 
OpenCL Programming 101
OpenCL Programming 101OpenCL Programming 101
OpenCL Programming 101Yoss Cohen
 
MattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxMattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxgopikahari7
 
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018Somkiat Khitwongwattana
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Runwesley chun
 

Similar to How to Build & Use OpenCL on Android Studio (20)

Getting Started With Android
Getting Started With AndroidGetting Started With Android
Getting Started With Android
 
Wonho Park_20151209
Wonho Park_20151209Wonho Park_20151209
Wonho Park_20151209
 
Lec05 buffers basic_examples
Lec05 buffers basic_examplesLec05 buffers basic_examples
Lec05 buffers basic_examples
 
EclipseOMRBuildingBlocks4Polyglot_TURBO18
EclipseOMRBuildingBlocks4Polyglot_TURBO18EclipseOMRBuildingBlocks4Polyglot_TURBO18
EclipseOMRBuildingBlocks4Polyglot_TURBO18
 
How to Use OpenMP on Native Activity
How to Use OpenMP on Native ActivityHow to Use OpenMP on Native Activity
How to Use OpenMP on Native Activity
 
C# Production Debugging Made Easy
 C# Production Debugging Made Easy C# Production Debugging Made Easy
C# Production Debugging Made Easy
 
Oracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneOracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid clone
 
LOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdfLOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdf
 
Android
Android Android
Android
 
Oracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneOracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid clone
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application Development
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
 
ColdBox i18N
ColdBox i18N ColdBox i18N
ColdBox i18N
 
The Ring programming language version 1.5.2 book - Part 15 of 181
The Ring programming language version 1.5.2 book - Part 15 of 181The Ring programming language version 1.5.2 book - Part 15 of 181
The Ring programming language version 1.5.2 book - Part 15 of 181
 
Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011
 
OpenCL Programming 101
OpenCL Programming 101OpenCL Programming 101
OpenCL Programming 101
 
MattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxMattsonTutorialSC14.pptx
MattsonTutorialSC14.pptx
 
Toolchain
ToolchainToolchain
Toolchain
 
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
 

More from Industrial Technology Research Institute (ITRI)(工業技術研究院, 工研院)

More from Industrial Technology Research Institute (ITRI)(工業技術研究院, 工研院) (20)

What is the world where you can make your own semiconductors?
What is the world where you can make your own semiconductors?What is the world where you can make your own semiconductors?
What is the world where you can make your own semiconductors?
 
半導体製造(TinyTapeout)に挑戦しよう!
半導体製造(TinyTapeout)に挑戦しよう!半導体製造(TinyTapeout)に挑戦しよう!
半導体製造(TinyTapeout)に挑戦しよう!
 
Introduction of ISHI-KAI with OpenMPW
Introduction of ISHI-KAI with OpenMPWIntroduction of ISHI-KAI with OpenMPW
Introduction of ISHI-KAI with OpenMPW
 
Kernel/VMレイヤーを自分色に染める!By ISHI会
Kernel/VMレイヤーを自分色に染める!By ISHI会Kernel/VMレイヤーを自分色に染める!By ISHI会
Kernel/VMレイヤーを自分色に染める!By ISHI会
 
Principle Representation of The 8 Qubits Quantum Computer by RaspberryPi
Principle Representation of The 8 Qubits Quantum Computer by RaspberryPiPrinciple Representation of The 8 Qubits Quantum Computer by RaspberryPi
Principle Representation of The 8 Qubits Quantum Computer by RaspberryPi
 
Microwaveguquantum
MicrowaveguquantumMicrowaveguquantum
Microwaveguquantum
 
The easiest way of setup QuTiP on Windows
The easiest way of setup QuTiP on WindowsThe easiest way of setup QuTiP on Windows
The easiest way of setup QuTiP on Windows
 
GNU Radio Study for Super beginner
GNU Radio Study for Super beginnerGNU Radio Study for Super beginner
GNU Radio Study for Super beginner
 
The Self-Contained SDR Satellite Grand Station with Raspberry Pi 3
The Self-Contained SDR Satellite Grand Station with Raspberry Pi 3The Self-Contained SDR Satellite Grand Station with Raspberry Pi 3
The Self-Contained SDR Satellite Grand Station with Raspberry Pi 3
 
Self‐Contained SDR Grand Station with Raspberry Pi 3
Self‐Contained SDR Grand Station with Raspberry Pi 3Self‐Contained SDR Grand Station with Raspberry Pi 3
Self‐Contained SDR Grand Station with Raspberry Pi 3
 
Zedroid - Android (5.0 and later) on Zedboard
Zedroid - Android (5.0 and later) on ZedboardZedroid - Android (5.0 and later) on Zedboard
Zedroid - Android (5.0 and later) on Zedboard
 
3D Printed Google Cardboard for workshop
3D Printed Google Cardboard for workshop3D Printed Google Cardboard for workshop
3D Printed Google Cardboard for workshop
 
計算機(物理)
計算機(物理)計算機(物理)
計算機(物理)
 
Resume
ResumeResume
Resume
 
How to Make a Scanning Drone in Chinese
How to Make a Scanning Drone in ChineseHow to Make a Scanning Drone in Chinese
How to Make a Scanning Drone in Chinese
 
How to Use OpenGL/ES on Native Activity
How to Use OpenGL/ES on Native ActivityHow to Use OpenGL/ES on Native Activity
How to Use OpenGL/ES on Native Activity
 
How to Make Hand Detector on Native Activity with OpenCV
How to Make Hand Detector on Native Activity with OpenCVHow to Make Hand Detector on Native Activity with OpenCV
How to Make Hand Detector on Native Activity with OpenCV
 
How to Make Android Native Application
How to Make Android Native ApplicationHow to Make Android Native Application
How to Make Android Native Application
 
How to Add Original Library to Android NDK
How to Add Original Library to Android NDKHow to Add Original Library to Android NDK
How to Add Original Library to Android NDK
 
How to Customize Android Framework&System
How to Customize Android Framework&SystemHow to Customize Android Framework&System
How to Customize Android Framework&System
 

Recently uploaded

VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 

Recently uploaded (20)

VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 

How to Build & Use OpenCL on Android Studio

  • 1. ©SIProp Project, 2006-2008 1 How to Build & Use OpenCL on Android Studio Noritsuna Imamura noritsuna@siprop.org
  • 2. ©SIProp Project, 2006-2008 2 Goal Making OpenCL programming Environment on Android Studio Android Studio 1.3 or later C Language (Android NDK) OpenCL 1.1 (ARM-Mali)
  • 3. ©SIProp Project, 2006-2008 3 Why? OpenCL source code is separated “host source code” as C Language file & “kernel(device) source code” as CL file. But Android’s APK can NOT include “kernel(device) source code” as CL file in APK file. Solution Convert CL file to const char* in Single C header file
  • 4. ©SIProp Project, 2006-2008 4 Setup NDK on Android Studio1.3 Requited Gradle2.5 or later AS1.3’s Gradel is 2.4. MUST update 2.4 -> 2.5 . Setup NDK Settings->System Setting->Android SDK Modify “build.gradle” http://tools.android.com/tech-docs/new-build- system/gradle-experimental Informations Android NDK Support for Android Studio http://tools.android.com/tech-docs/android-ndk-preview NDK Samples https://github.com/googlesamples/android-ndk
  • 5. ©SIProp Project, 2006-2008 5 Setup OpenCL on Android Studio1.3 Setup Header files of OpenCL Download from ARM-Mali’s OpenCL Dev Site http://malideveloper.arm.com/resources/sdks/mali-opencl- sdk/ Copy “[ARM-Mali dir]/include/CL/*.h” to “[your project dir]/app/main/src/jni/CL/” Load Shared Lib of OpenCL Copy “libOpenCL.so” from your Android Device to “[your Android Studio Dir]/sdk/ndk- bundle/platforms/android-[your target system]/arch- arm/usr/lib/”
  • 6. ©SIProp Project, 2006-2008 6 Setup OpenCL on Android Studio1.3 Setup Header files & Shared Lib on Android Studio Add “Cflags” & “ldLibs” in “build.gradle” 1. build.gradle : app, android.ndk section 1. android.ndk { 2. moduleName = "openclsample-jni" 3. CFlags += "-I${file("src/main/jni/CL")}".toString() 4. ldLibs = ["android", "log", "OpenCL"] 5. (snip)
  • 7. ©SIProp Project, 2006-2008 7 Setup Plugin “OpenCL CL Generator” Install Plugin to Android Studio Select “Setting->plugins” Click “Browse Repositories” Search Plugin by “OpenCL” as keyword Target Plugin URL https://plugins.jetbrains.com/plugin/7888?pr=androidstudio Click “Install Plugin” Restart Android Studio
  • 8. ©SIProp Project, 2006-2008 8 Use Plugin “OpenCL CL Generator” Click “Tools->Generate OpenCL’s CL files header”
  • 9. ©SIProp Project, 2006-2008 9 How to Use Plugin: Host Side Host side programming: standard OpenCL CL file(kernel side source code) is loaded as “file”. 1. #include “opencl_cl_files.h” 2. (snip) 3. /* Create Kernel Program from the source */ 4. program = clCreateProgramWithSource(context, 1, (const char **)&CLCL_HELLO, (const size_t *)&strlen(CLCL_HELLO), &ret); 1. FILE *fp; 2. char fileName[] = "./hello.cl"; 3. char *source_str; 4. size_t source_size; 5. fp = fopen(fileName, "r"); 6. source_str = (char*)malloc(MAX_SOURCE_SIZE); 7. source_size = fread( source_str, 1, MAX_SOURCE_SIZE, fp); 8. fclose( fp ); 9. (snip) 10. /* Create Kernel Program from the source */ 11. program = clCreateProgramWithSource(context, 1, (const char **)&source_str, (const size_t *)&source_size, &ret); Host side programming: with Android Plugin CL file is loaded as “const char*”.
  • 10. ©SIProp Project, 2006-2008 10 How to Use Plugin: Kernel Side 1. Converted Original File: opencl_cl_files.h 1. const char *CLCL_HELLO = 2. "#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enablen" 3. "n" 4. "__kernel void hello(__global char* string)n" 5. "{n" 6. " string[0] = 'H';n" 7. " string[1] = 'e';n" 8. " string[2] = 'l';n" 9. " string[3] = 'l';n" 10. " string[4] = 'o';n" 11. " string[5] = '0';n" 12. "}n" 13. ""; 1. Kernel Source Code File: hello.cl 1. #pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable 2. __kernel void hello(__global char* string) 3. { 4. string[0] = 'H'; 5. string[1] = 'e'; 6. string[2] = 'l'; 7. string[3] = 'l'; 8. string[4] = 'o'; 9. string[5] = '0'; 10. } Kernel side programming 1. Write Source Code as CL file(Kernel Source Code) 2. Convert CL file(Kernel Source Code) to Original Header File as “opencl_cl_files.h”
  • 11. ©SIProp Project, 2006-2008 11 Setup libOpenCL.so on Android If you(or your Android Device) don’t have libOpenCL.so in “/system/lib” or “/system/vendor/lib”, you can download libOpenCL.so. Support GPUs adreno-3xx: Qualcomm's Adreno 3xx GPUs mali-t6xx: ARM's Mali-T6xx GPUs Download from: https://github.com/madeye/opencl-android-proprietary Setup Copy All SO files to “/system/lib” or “/system/vendor/lib” on your Android Device.
  • 13. ©SIProp Project, 2006-2008 13 Download the Sample Project for AS The Sample Project for AS that I use in this slide. https://github.com/noritsuna/OpenCLCLGenerator_ Sample Features “build.gradle” for NDK Support Setup Plugin OpenCL Headers & SO lib The Sample Source Code for OpenCL