I have a question about Parallel.For
method.
I want to make comparision between using 1 to 4 threads in image processing algorithm. Im setting up my Parallel.For
like this:
ParallelOptions po = new ParallelOptions();
po.MaxDegreeOfParallelism = 4;
Parallel.For(0, height - 1, po, y =>
{
int offset = y * stride; //row
for (int x = 0; x < width - 1; x++)
{
//do stuff here
}
});
Time is counted by Stopwatch
class.
var stopwatch = Stopwatch.StartNew();
MethodWithParallelFor.Execute();
stopwatch.Stop();
My question is, why when i set up MaxDegreeOfParallelism
to any value (my CPU have 8 thread) i get exactly same times? When i set Degree
to 1 or 4 i get same executing times.
So, how to debug Parallel.For
to get information, how many threads are running in my loop? How to force program to use that many threads that i want to? If needed, i can share with my full code
Im implemented my test program in c# 7.3 and WPF 4.6.2