iOS Thread affinity control (Big.LITTLE arch)

Hello!

Request for help in this matter:

I want to control the matching of threads and cores on iOS devices with Big.LITTLE architecture). i.e., run the main thread on a BIG core while the application is starting.

I tried to use thread_policy_set/get for this. This solution works on simulators, but definitely doesn't work on iPhone (the return code is KERN_NOT_SUPPORTED on several devices).

Code example:

thread_affinity_policy_data_t = { 2 }; thread_policy_set(pthread_mach_thread_np(pthread_self()), THREAD_AFFINITY_POLICY, (thread_policy_t)&policy, 1);

Does anyone know if we can change the binding of the threads to core on iOS?

Does anyone know if we can change the binding of the threads to core on iOS?

There’s no supported way to do this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

So i can't invoke thread_policy_set with THREAD_AFFINITY_POLICY param on iOS at all?

Regardless of whether you can or can’t call THREAD_AFFINITY_POLICY on iOS, that’s not a supported way to achieve your overall goal, that is, to bind a thread to a specific class of core. Quoting the doc comments in <mach/thread_policy.h> here:

This policy is experimental.

Well, that’s not looking good to start )-:

This may be used to express affinity relationships
between threads in the task. Threads with the same affinity tag will
be scheduled to share an L2 cache if possible. That is, affinity tags
are a hint to the scheduler for thread placement.

This is clearly not about binding a thread to a class of core, but rather tagging threads so that they are scheduled together. Those are very different tasks.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

iOS Thread affinity control (Big.LITTLE arch)
 
 
Q