java - Is it possible to implement efficiently a parallel mathematic computation in a 4 core Android device? (This has nothing to do with interfaces) -


i know keeping responsive interface in android heavy work must completed in independent thread. understand how accomplish (by using asyntask..., etc), , not point of question, know.

but i've been struggling while simple parallel program. program search lowest integer in array witch length 15000000.

i implemented runnable:

...  run(){      highestinteger = integers[firstindex];      for(int = firstindex; < secondindex; i++){         if(highestinteger<integers[i]){             highestinteger = integers[i];         }     }  } 

... highest integer in first half of array (in 1 thread) , highest integer in other half of array (in second thread).

the program works on computer (as java/not-android program) , mean parallel times shorter (almost half) serial ones.

but on android tablet (4 cores) times same , serial ones shorter.

i have notice (with debugger) in tablet there several threads running:

  1. the main/ui thread (3 cores left)
  2. binder 1 thread (2 cores left)
  3. binder 2 thread (1 core left :( )
  4. binder 3 thread (some times see in debugger times don't).

so there 3 threads running, , need @ least 2 free cores program run efficiently. i've read bit binder threads don't understand well.

is there way solve or not? there way in can avoid automatic creation of binder threads or not? or not possible kind of threading work until have 6 core device?

i have notice (with debugger) in tablet there several threads running

you have several threads have been created. blocked waiting on i/o.

is there way solve or not?

the decision of core allocation made operating system , take account other programs, plus power consumption (keeping 4 cores running @ times bad battery), andy fadden (of core android team) points out in this comment , this comment. note there ~750 million android devices in use today, vast majority of have fewer 4 cores, , of single core, , need take account well.

is there way in can avoid automatic creation of binder threads or not?

only not writing android app. threads used inter-process communication, essential running android app.

or not possible kind of threading work until have 6 core device?

it possible. andy fadden demonstrates in this stackoverflow answer. there may ways reorganize algorithm make better use of smp on android, outlined in the documentation. might consider renderscript compute alternative doing work in java.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -