SlideShare a Scribd company logo
1 of 13
©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

초심자를 위한 도커 소개 및 입문
초심자를 위한 도커 소개 및 입문초심자를 위한 도커 소개 및 입문
초심자를 위한 도커 소개 및 입문Daniel Seo
 
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !Pierre-jean Texier
 
Building beautiful apps using google flutter
Building beautiful apps using google flutterBuilding beautiful apps using google flutter
Building beautiful apps using google flutterAhmed Abu Eldahab
 
Flutter talkshow
Flutter talkshowFlutter talkshow
Flutter talkshowNhan Cao
 
What is flutter and why should i care?
What is flutter and why should i care?What is flutter and why should i care?
What is flutter and why should i care?Sergi Martínez
 
Microservices-DDD-Telosys-Devoxx-FR-2022
Microservices-DDD-Telosys-Devoxx-FR-2022Microservices-DDD-Telosys-Devoxx-FR-2022
Microservices-DDD-Telosys-Devoxx-FR-2022Laurent Guérin
 
Flutter session 01
Flutter session 01Flutter session 01
Flutter session 01DSC IEM
 
Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編OESF Education
 
Project 2 How to modify os161: A Manual
Project 2 How to modify os161: A ManualProject 2 How to modify os161: A Manual
Project 2 How to modify os161: A ManualXiao Qin
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastBartosz Kosarzycki
 
Introduction to Flutter.pptx
Introduction to Flutter.pptxIntroduction to Flutter.pptx
Introduction to Flutter.pptxDiffouoFopaEsdras
 

What's hot (20)

초심자를 위한 도커 소개 및 입문
초심자를 위한 도커 소개 및 입문초심자를 위한 도커 소개 및 입문
초심자를 위한 도커 소개 및 입문
 
Flutter
FlutterFlutter
Flutter
 
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
 
Building beautiful apps using google flutter
Building beautiful apps using google flutterBuilding beautiful apps using google flutter
Building beautiful apps using google flutter
 
Flutter talkshow
Flutter talkshowFlutter talkshow
Flutter talkshow
 
Introduction to Tekton
Introduction to TektonIntroduction to Tekton
Introduction to Tekton
 
Flutter
FlutterFlutter
Flutter
 
What is flutter and why should i care?
What is flutter and why should i care?What is flutter and why should i care?
What is flutter and why should i care?
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Microservices-DDD-Telosys-Devoxx-FR-2022
Microservices-DDD-Telosys-Devoxx-FR-2022Microservices-DDD-Telosys-Devoxx-FR-2022
Microservices-DDD-Telosys-Devoxx-FR-2022
 
Android JNI
Android JNIAndroid JNI
Android JNI
 
Flutter session 01
Flutter session 01Flutter session 01
Flutter session 01
 
Introduction a Flutter
Introduction a FlutterIntroduction a Flutter
Introduction a Flutter
 
Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編
 
Project 2 How to modify os161: A Manual
Project 2 How to modify os161: A ManualProject 2 How to modify os161: A Manual
Project 2 How to modify os161: A Manual
 
Introduction to Flutter
Introduction to FlutterIntroduction to Flutter
Introduction to Flutter
 
Flutter Bootcamp
Flutter BootcampFlutter Bootcamp
Flutter Bootcamp
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fast
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
 
Introduction to Flutter.pptx
Introduction to Flutter.pptxIntroduction to Flutter.pptx
Introduction to Flutter.pptx
 

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

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

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