I am testing a program on a server running 64-bit Windows Server 2008 R2 Enterprise and has 4 Intel E7-4870 processors, a total of 40 cores and 80 available threads (I can see 80 CPU usage graphs in Windows Task Manager).
The program code looks like this:
numlist is List contains hundreds of numbers, each of which is a parameter that will be used in some calculation
Parallel.ForEach(numlist, num => {
The problem is that when I run this program on the server, it is shown that only half of the available threads are used in the Windows task manager (of course, the CPU usage is shown at 50%), and the remaining 40 are completely unused and idle.
I also tested the same program on another server, which has only 2 processors and only 24 available threads, and all 24 threads will be fully used, and CPU usage will be shown at 100%.
Is there a way to make a 40-core processor server to run this program and fully use all of its avaialable 80 threads (or about 80 threads)? Performance is not good enough when only 50% of the CPU resources are used.
Here is the complete code of the program that I am testing:
namespace Test { internal class Program { private static void Main(string[] args) { Console.WriteLine("Press any key to start"); Console.ReadLine(); List<int> numlist = new List<int>(); for (int i = 0; i < 100; i++) { numlist.Add(i); } Parallel.ForEach(numlist, num => { while (true) { num++; } }); } } }
when it runs on a server with two Intel X5690 processors (24 threads total), all 24 threads are used, and CPU usage is shown at 100%;
But when I run it on a server with 4 processors with 80 threads, only 40 threads are used, and CPU usage is only 50%. Are there any compiler settings related to this?