Modifying thread affinity to improve performance

Modifying thread affinity to improve performance

Nils S.'s picture

Hello,

I have a math-intensive Android application here that does realtime audio generation. I generates sound data and this process is difficult if not impossible to modify to support multithreading.

The test system is a dual core Atom SoC with hyperthreading.

The problem that I'm facing is that the android scheduler keeps moving my thread around on multiple cores and the performance could be much better. I get a huge performance boost when I set the affinity of the thread to a single core.

Would you recommend to do it that way on mobile devices or is this a "no go"?

Thank you,

Nils

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
JudLup Luna's picture

Hi, it's very interesting, I don't know how you can make this, but I right now know is that your idea is amazing and nice!

JudLup Luna
Alexander Weggerle (Intel)'s picture

Nils,

really interesting question. I don't think setting the CPU affinity is a No-Go, but it might impact the battery lifetime. If you have a noticeably better performance I would set the affinity but revise this for future CPUs and Android versions that are released. 

Hope this helps,
Alex

Nils S.'s picture

Hello Alex,

thanks for clearing this up, cache misses seem to be reduced dramatically if the scheduler doesn't move me around on multiple cores with own caches.

I got all that data though when using VTune on a Core i5 desktop machine. Most performance is lost when data is not inside the cache. My CPI rate varies from function to function between 0.33 and 0.7.

I didn't test it, but another idea that I had is that for Atom SoCs with hyperthreading, it should be okay to set the affinity to 2 cores that share the same cache. So one core isn't burnt alone but I still have the advantage of keeping the cache happy. Is this a correct assumption?

Regards,

Nils

Alexander Weggerle (Intel)'s picture

Hi Nils,

The Silvermont Core (e.g. Baytrail) doesn't use Hyperthreading. So setting the affinity to 2 cores would just work for the privious hardware generation. 

BTW: pretty good CPI rate. 

Thanks,
Alex

Nils S.'s picture

Hello Alex,

glad you mentioned it, I didn't think of that.

I really hope that the Bay Trail SoCs can keep up with the Clover Trail+ SoCs although the clock rate is lower. According to wikipedia, the lowest clock rate is 1,33ghz, compared to my test device with 1,6ghz this is a little bit lower. Hopefully out-of-order execution will make me happy :)

Thank you,

Nils

Alexander Weggerle (Intel)'s picture

Hi Nils,

Bay Trail does support additional Burst Modes compared to Clovertrail+. So your single threaded application should actually run on a higher clockspeed than 1.6GHz. 

Alex

Login to leave a comment.