Set Process Affinity Mask

Oct 13, 2014 at 7:06 PM
We need to affinitize all the worked threads to specific cores. I found out on msdn that process affinity mask doesn't work (http://msdn.microsoft.com/en-us/library/gg663535.aspx):
"... The version of the Concurrency Runtime that is shipped as part of Visual Studio 2010 SP1 does not recognize this user-selected process affinity mask. Instead, it uses all available cores up to the maximum specified level of concurrency for each scheduler.
This issue is expected to be resolved in a future version of the Concurrency Runtime."

Has the issue been already fixed? If it has, how can I set the mask?

Thanks,
Vitaly
Coordinator
Oct 15, 2014 at 6:29 PM
Hi Vitaly,

This project is really just for the C++ Rest SDK, and we don't support Visual Studio 2010 any more so you will have to use an older version. The last release with 2010 support was 1.2.0.

Regarding the Concurrency Runtime, I think respecting the process affinity has been fixed in Visual Studio 2012. Take a look at this blog post under the section "ConcRT: Scheduler and resource management enhancements"
http://blogs.msdn.com/b/nativeconcurrency/archive/2012/02/28/ppl-and-concrt-what-s-new-in-visual-studio-11-beta.aspx
Steve
Oct 15, 2014 at 7:29 PM
Hi Steve,
Thanks for your answer and the msdn link.

We, actually, do use Casablanca library, but I had difficulties finding documentation, so this is all that I found.

Can you give me some example/point to documentation of how the affinity can be set?
Coordinator
Oct 16, 2014 at 5:55 PM
Hi Vitaly,

Here is the msdn description for the API I think you need to use. Also you can just use however you normally go about setting the process affinity, for example using the SetProcessAffinityMask API.

Steve
Oct 16, 2014 at 9:38 PM
Hi Steve,

Yes, I saw that. I have difficulties understanding how I can guarantee this: "...It is valid to call this method only before the Resource Manager has been created, or between two Resource Manager lifetimes...". This is why I'm asking for the example.

Vitaly
Coordinator
Oct 18, 2014 at 5:07 PM
Hi Vitaly,

I believe that simply means do all your affinity setting before calling any of the APIs of the Concurrency Runtime, which would cause the Resource Manager to be created. So call set_task_execution_resources before calling any of the PPL algorithms like parallel_for, for example.

Steve
Oct 20, 2014 at 2:10 AM
Thanks Steve,

I can't say I'm happy with that requirement, but at least that's better than nothing :)

Vitaly