Cores for parallel execution

I installed NCrunch, which is a tool for (among other things) doing parallel tests. It provides two settings, MaxNumberOfUsedCores and MaxNumberOfUsedThreads. The first setup looks intriguing. I do not remember any .NET tools that would allow you to control the kernels that are used to execute your code. So the question is how to do this?

+4
source share
1 answer

Have you tried ProcessThread.ProcessorAffinity ? ProcessorAffinity represents each processor as a bit . Bit 0 represents processor one, bit 1 represents second processor, and so on. For instance:

 var currectProcess = System.Diagnostics.Process.GetCurrentProcess(); foreach(System.Diagnostics.ProcessThread thread in currectProcess.Threads) { // this could give you something similar to MaxNumberOfUsedCores thread.ProcessorAffinity = (IntPtr)0x0007; // Valid processors: 1, 2, or 3 } 

Now I have the following configuration on NCrunch, which looks very similar to the previous C # example:

  • NCrunch-assigned processor cores: 0, 1, 2
  • Processor Cores assigned by Visual Studio: 3

But the only author of NCrunch @ remco-mulder could tell us if this is true or not.

btw: ReSharper has similar options for controlling the number of parallel running unittests threads.

+1
source

All Articles