Violet Giraffe
Violet Giraffe

Reputation: 33607

Detecting number of CPU cores on Android from native code

I'm using sysconf( _SC_NPROCESSORS_ONLN ) (which, I believe, is the recommended way) to get the number of CPU cores. It works fine or Mac and Linux, but on my 4-core Android tablet it returns 2. How can I get the actual number of cores on Android from native code (without using JNI to call Java Android API)?

Upvotes: 3

Views: 3975

Answers (1)

Violet Giraffe
Violet Giraffe

Reputation: 33607

Neither sysconf( _SC_NPROCESSORS_ONLN ) nor sysconf( _SC_NPROCESSORS_CONF ) works, but android_getCpuCount() from cpufeatures NDK library works correctly.

Upvotes: 3

Related Questions