porting android application from arm to x86

13
Porting Android application from ARM to X86 Massimiliano Torregiani Intel CODEFEST Milan 13 Febbraio 2014

Post on 19-Oct-2014

686 views

Category:

Technology


9 download

DESCRIPTION

Presentation from Massimiliano Torregiani (@MaxTorregiani) at the Intel Codefest Milano on February 13th 2014 at Mediateca http://codefestmilano.bemyapp.com

TRANSCRIPT

Page 1: Porting Android application from ARM to x86

Porting Android application

from ARM to X86

Massimiliano Torregiani

Intel CODEFEST Milan 13 Febbraio 2014

Page 2: Porting Android application from ARM to x86

Android SDK e NDK

Programmazione SDK

compile once, run everywhere

2  

Programmazione NDK

compile once, run everywhere

some

oppure oppure

Page 3: Porting Android application from ARM to x86

Concetti di Xcompilazione

nativa Sistema Host

E’ il sistema dove il compilatore è installato e su cui

avviene la compilazione

Sistema target

E’ il sistema dove l’eseguibile generato su host sara’

eseguito.

Cosa serve per la compilazione?

•  Toolchain (compilatore, linker, archiver, assembler, etc)

•  Header file delle librerie

•  Librerie standard, dei framework e altre librerie

accessorie cross-compilate per il sistema target

3  

Page 4: Porting Android application from ARM to x86

Pacchetto NDK di Google

Il pacchetto NDK fornito da Google comprende:

Target Architecture

•  ARMv5TE  &  ARMv7-­‐A  

• MIPS  

•  X86  -­‐  Intel  Atom  

Target operative system

Tipo e versione compilatore (e.g.  GCC  4.8)  

4  

Page 5: Porting Android application from ARM to x86

Supporto Intel per Android:

Beacon Mountain

5  

Page 6: Porting Android application from ARM to x86

Porting da ARM a X86

6  

Sample 1:

HelloJni

Page 7: Porting Android application from ARM to x86

Differenze tra architettura

ARM e X86

Memory Alignment

7  

struct TestStruct { int mVar1; long long mVar2; int mVar3;

};

By Default

“Double Margin”

By default

No margin

GCC flag “-malign-double”

Page 8: Porting Android application from ARM to x86

Differenze tra architettura

ARM e X86

8  

Memory

Alignment

Big  or  li/le  endian  order  

(ARM  is  bi-­‐endian)  li/le-­‐endian  assembly  

Floating

Point

ARMv5  à  So@  FP  opts  

ARMv7  à  Hardware  FPU  

instrucJons  (VFP)  

Intel  Atom  à  IA-­‐32  

instrucJons,  Hardware  Based  

FP  opts  

SIMD

extensions

ARMv5  à  No  SIMD  ext  

ARMv7  à  NEON  ext  

Intel  Atom  à  SSSE3  (Supplemental  

Streaming  SIMD  Extensions  3)  

Page 9: Porting Android application from ARM to x86

Differenze tra architettura

GCC Flags

Memory

Alignment

9  

–mlittle-endian

–mbig-endian

Floating

Point

SIMD

extensions

-mfloat-abi= soft | softfp | hard

-mfpu= vfp | vfpv3-d16 | neon | ...

–mfpmath=sse

-mavx

-maes

-march=armv7-a

-mtune=cortex-a8

–DHAVE_NEON=1

-msse

Page 10: Porting Android application from ARM to x86

Porting da ARM a X86

10  

Sample 2:

HelloNeon

Page 11: Porting Android application from ARM to x86

Utilizzo librerie esterne

11  

Step 1: Porting

librerie esterne

Libreria  Esterna  naJva  

Libreria  compilata  per  

Target  

Codice  naJvo  proprietario  

APP  Android  (Java)  

JNI

Step 2: Porting

codice nativo

proprietario

Step 3: Rebuild

applicazione

Page 12: Porting Android application from ARM to x86

Porting da ARM a X86

12  

Sample 3:

HelloFFmpeg

Page 13: Porting Android application from ARM to x86

KALPA srl

Mail: [email protected]  

Twitter: @maxtorregiani  

Linkedin: h/p://www.linkedin.com/pub/massimiliano-­‐torregiani/3/555/550  

Thanks!