mercredi 29 juillet 2015

how to know if threads uses all cores android

On an Android NDK application, I'm using several threads, with c++11 threads. I think all threads are using only one of the 4 cores on my device, because the cpu usage percentage sums up to only 74%.

While running my app, I profile using top with the "showing threads" option:

top -t | grep "com.myapp"

31015  9824  1   9% R 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015  9821  1   9% R 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015  9819  0   9% R 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015  9826  2   9% S 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015  9823  2   9% R 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015 31015  0   8% R 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015  9822  1   7% S 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015  9820  1   7% S 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015  9825  2   4% R 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015  9493  1   3% S 1697312K 421060K  fg u0_a742  Thread-1068     com.myapp
31015  9497  1   0% S 1697312K 421060K  fg u0_a742  GL updater      com.myapp
31015  9793  0   0% S 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015  9495  0   0% S 1697312K 421060K  fg u0_a742  GL updater      com.myapp
31015 31268  1   0% S 1697312K 421060K  fg u0_a742  Thread-1061     com.myapp
31015 31016  2   0% S 1697312K 421060K  fg u0_a742  GC              com.myapp
31015 31017  0   0% S 1697312K 421060K  fg u0_a742  Signal Catcher  com.myapp
31015 31018  0   0% S 1697312K 421060K  fg u0_a742  JDWP            com.myapp
31015 31019  0   0% S 1697312K 421060K  fg u0_a742  Compiler        com.myapp
31015 31021  3   0% S 1697312K 421060K  fg u0_a742  ReferenceQueueD com.myapp
31015 31022  2   0% S 1697312K 421060K  fg u0_a742  FinalizerDaemon com.myapp
31015 31023  0   0% S 1697312K 421060K  fg u0_a742  FinalizerWatchd com.myapp
31015 31026  0   0% S 1697312K 421060K  fg u0_a742  Binder_1        com.myapp
31015 31027  3   0% S 1697312K 421060K  fg u0_a742  Binder_2        com.myapp
31015 31188  1   0% S 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015 31189  2   0% S 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015 31190  1   0% S 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015 31191  2   0% S 1697312K 421060K  fg u0_a742  com.myapp       com.myapp
31015 31254  2   0% S 1697312K 421060K  fg u0_a742  Binder_2        com.myapp
31015 31255  0   0% S 1697312K 421060K  fg u0_a742  Binder_2        com.myapp
31015 31256  1   0% S 1697312K 421060K  fg u0_a742  Binder_2        com.myapp
31015 31260  2   0% S 1697312K 421060K  fg u0_a742  Binder_3        com.myapp
31015 31261  3   0% S 1697312K 421060K  fg u0_a742  Binder_4        com.myapp
31015 31270  3   0% S 1697312K 421060K  fg u0_a742  FileObserver    com.myapp
31015 31337  2   0% S 1697312K 421060K  fg u0_a742  Binder_5        com.myapp

I calculate the number of threads to use with a Maximum of android_getCpuCount() from cpufeatures.h on NDK, And it adds the top most 9 threads.

How can I know if all the cores are in use ? (Pressing "1" option is not included in the android's top application.)

And if I'm using only one core, as I suspect, how can I make the threads use multiple cores ?

Aucun commentaire:

Enregistrer un commentaire