Note that there are some explanatory texts on larger screens.

plurals
  1. POMaximum speed from IOS/iPad/iPhone
    primarykey
    data
    text
    <p>I done computing intensive app using <code>OpenCV</code> for <code>iOS</code>. Of course it was slow. But it was something like 200 times slower than my PC prototype. So I was optimizing it down. From very first 15 seconds I was able to get 0.4 seconds speed. I wonder if I found all things and what others may want to share. What I did:</p> <ol> <li><p>Replaced "<code>double</code>" data types inside OpenCV to "<code>float</code>". Double is 64bit and 32bit CPU cannot easily handle them, so float gave me some speed. OpenCV uses double very often.</p></li> <li><p>Added "<code>-mpfu=neon</code>" to compiler options. Side-effect was new problem that emulator compiler does not work anymore and anything can be tested on native hardware only.</p></li> <li><p>Replaced <code>sin()</code> and <code>cos()</code> implementation with 90 values lookup tables. Speedup was huge! This is somewhat opposite to PC where such optimizations does not give any speedup. There was code working in degrees and this value was converted to radians for <code>sin()</code> and <code>cos()</code>. This code was removed too. But lookup tables did the job.</p></li> <li><p>Enabled <code>"thumb optimizations"</code>. Some blog posts recommend exactly opposite but this is because thumb makes things usually slower on <code>armv6</code>. <code>armv7</code> is free of any problems and makes things just faster and smaller. </p></li> <li><p>To make sure thumb optimizations and <code>-mfpu=neon</code> work at best and do not introduce crashes I removed armv6 target completely. All my code is compiled to <code>armv7</code> and this is also listed as requirement in app store. This means minimum <code>iPhone</code> will be <code>3GS</code>. I think it is OK to drop older ones. Anyway older ones have slower CPUs and CPU intensive app provides bad user experience if installed on old device.</p></li> <li><p>Of course I use <code>-O3 flag</code></p></li> <li><p>I deleted <code>"dead code"</code> from OpenCV. Often when optimizing OpenCV I see code which is clearly not needed for my project. For example often there is a extra <code>"if()"</code> to check for pixel size being 8 bit or 32 bit and I know that I need 8bit only. This removes some code, provides optimizer better chance to remove something more or replace with constants. Also code fits better into cache.</p></li> </ol> <p>Any other tricks and ideas? For me enabling thumb and replacing trigonometry with lookups were boost makers and made me surprise. Maybe you know something more to do which makes apps fly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload