Intel ndk - a few Benchmarks

29
Intel NDK x86 A few Benchmarks Francesca Tosi - Alberto Mancini 13 Febbraio 2013

description

Intel NDK - A few Benchmarks Francesca Tosi, Alberto Mancini - GDG Firenze - Mobile & Embedded

Transcript of Intel ndk - a few Benchmarks

Page 1: Intel ndk - a few Benchmarks

Intel NDK x86A few Benchmarks

Francesca Tosi - Alberto Mancini13 Febbraio 2013

Page 2: Intel ndk - a few Benchmarks

?!?● Ma che ci fanno

Alberto e Francesca!??!?!

Page 3: Intel ndk - a few Benchmarks

?!?● Ma che ci fanno

Alberto e Francesca!??!?!

● Ma non erano quelli fissati con le app web!??!?!

Page 4: Intel ndk - a few Benchmarks

Inte

l

Francesco BaldassarriItalian Community ManagerIntel Software and Services Group

email: [email protected]: @francesco_1985facebook: www.facebook.com/francesco1985linkedin: it.linkedin.com/in/fbaldassarri/

Page 5: Intel ndk - a few Benchmarks

Inte

l Dev

ices I devices Intel sono compatibili con l’

ecosistema Android*.

- Android* Dalvik* apps

- These will directly work, Dalvik has beenoptimized for Intel® platforms.

- Android NDK apps

- Most will run without any recompilation on consumer platforms.

- Android NDK provides an x86 toolchain since 2011

- A simple recompile using the Android NDK yields the best performance

- If there is specific processor dependent code, porting may be necessary

Page 6: Intel ndk - a few Benchmarks

Inte

l Dev

ices Intel Investe molto in tool di sviluppo per

Android

- Faster Android Emulator on Intel (Intel HAXM)

- Intel Threading Building Blocks (TBB)

- Intel Graphics Performance Analyzer (GPA)

- Intel Integrated Performance Primitives (IPP)

- Intel Optimizing Compiler (C++)

- Intel Beacon Mountain

- Project Anarchy

Page 7: Intel ndk - a few Benchmarks

Inte

l Dev

ices Cosa sta facendo intel per Android

Page 8: Intel ndk - a few Benchmarks

Inte

l Dev

ices Intel devices on the market with Intel Inside

Page 9: Intel ndk - a few Benchmarks

Libr

erie

nat

ive

3rd party Libraries with x86 support

Page 10: Intel ndk - a few Benchmarks

???

Ma voi due che c’entrate con le app

native !?!?

Page 11: Intel ndk - a few Benchmarks

ND

KA noi interessa sperimentare la

rapidità/potenzialità della NDK

App NDK

Applicazione Android che usa librerie native

Page 12: Intel ndk - a few Benchmarks

Ben

chm

arks

e testarne le performance

Benchmark

C/Java/Javascript

Page 13: Intel ndk - a few Benchmarks

AR

on

mob

ile Nei lavori che facciamo una operazione semplice ma costosa è fare il grayscale sulle immagini

picshare.jooink.com

Page 14: Intel ndk - a few Benchmarks

GW

T-B

oofc

vGWT-Boofcv sample at:http://goo.gl/3IJQgs

Page 15: Intel ndk - a few Benchmarks

Ben

chm

arks -

Page 16: Intel ndk - a few Benchmarks

Test

are

na Galaxy Tab3

Intel Atom CPU Z25602 core - 1.60 GHz Android 4.4.2Architettura i686

Page 17: Intel ndk - a few Benchmarks

Rul

es RGB jbyte[1024*1024*3]

Average on 1000 runs

grayjbyte[1024*1024]

1

0.299*R+0.587*G+0.114*B → Y2

3

Page 18: Intel ndk - a few Benchmarks

Com

petit

ors Benchmarks on:

Chrome <Uint8Array>Firefox <Uint8Array>Aurora <Uint8Array>Java <byte> NDK <jbyte>IPP <Ipp8u>

Page 19: Intel ndk - a few Benchmarks

Det

ails

(HA

XM) Bundled in BeaconMountain

http://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager

cambia la vita con le immagini x86

Attenzione pianta OSX, maverickinstallare lo hotfix

Page 20: Intel ndk - a few Benchmarks

Cod

ice

(Jav

a) Java:

void compute(byte[] in, byte[] out) { for(int i=0, j=0; i< out.length; i++, j+=3) out[i] =

(byte)(0.299 * in[j] + 0.587 * in[j+1] + 0.114 * in[j+2]); }

Page 21: Intel ndk - a few Benchmarks

Det

ails

(ND

K) https://developer.android.com/tools/sdk/ndk/index.html

La documentazione non e’ il suo forte ...

https://github.com/jooink/ndk-cpuid

● start the (intel) avd (url)● enter in the jni folder & execute 'ndk-build'● from the CPUIDApp root dir execute 'ant debug'● adb install -r bin/CPUIdApp-debug.apk

Page 22: Intel ndk - a few Benchmarks

Cod

ice

(C, j

ni) void JNICALL … jbyteArray in, jbyteArray out) {

jsize len_out = (*env)->GetArrayLength(env, out); ... jbyte *body_out = (*env)->GetByteArrayElements(env, out, 0); for(i=0, j=0; i< len_out; i++, j+=3) body_out[i] = (jbyte)(0.299 * body_in[j] + … );

(*env)->ReleaseByteArrayElements(env, in, body_in, 0); ... }

Page 23: Intel ndk - a few Benchmarks

Det

ails

(IPP

) Bundled in BeaconMountain beh … la ‘preview’

http://software.intel.com/en-us/intel-ipp

… ed avete la IPP per android x86 !!!

Scaricate la versione per linux ( la evaluation, or 199$ :( )

Installatela ( vi serve una macchina linux )

Copiate le librerie (*.a) e gli include (*.h) (32bit statici non-threaded)

Page 24: Intel ndk - a few Benchmarks

Cod

ice

(IPP)

… jni ...

IppiSize srcRoi = { 1024, 1024 }; Ipp8u* pSrc = body_in; Ipp8u* pDst = body_out; ippiRGBToGray_8u_C3C1R(pSrc ,1024, pDst, 1024, srcRoi);

… jni ...

Page 25: Intel ndk - a few Benchmarks

Res

ults

nat

ive

Page 26: Intel ndk - a few Benchmarks

Res

ults

nat

ive

minmaxavg

Page 27: Intel ndk - a few Benchmarks

Cod

ice

(js) var len_out = outb.length;

var i,j;for(i=0, j=0; i< len_out; i++, j+=3)

outb[i] = (0.299 * inb[j] + 0.587 * inb[j+1] + 0.114 *inb[j+2]);

var buffer_in = new ArrayBuffer(size*3);var buffer_out = new ArrayBuffer(size);

var inb = new Uint8Array(buffer_in);var out = new Uint8Array(buffer_out);

Page 28: Intel ndk - a few Benchmarks

Res

ults

jsminmaxavg

Page 29: Intel ndk - a few Benchmarks

Gra

zie Francesca Tosi

[email protected]

Alberto Mancini [email protected]

Github: github.com/jooink/

www.jooink.comjooink.blogspot.com