long lngSum = 0;
Parallel.ForEach(Partitioner.Create(0L, lngMax + 1), range =>
{
long local = 0;
//4cores : 9 ranges
//64cores : 97 ranges
for (long i = range.Item1; i <= range.Item2 - 1; i++)
{
if (i % 2 == 0)
{
local += i;
}
else
{
local -= i;
}
}
Interlocked.Add(ref lngSum, local);
});
When I run this C# code in 4 cores machine, total CPU usage was 100%.
but
When I run this C# code in 64 cores machine, total CPU usage was not 100%, just only 50~60%
How can I use 100% of machine power?