I thought about which factors would influence the static scheduling overhead in OpenMP. In my opinion it is influenced by:
- CPU performance
- specific implementation of the OpenMP run-time library
- the number of threads
But am I missing further factors? Maybe the size of the tasks, ...?
And furthermore: Is the overhead linearly dependent on the number of iterations? In this case I would expect that having static scheduling and 4 cores, the overhead increases linearly with 4*i iterations. Correct so far?
EDIT: I am only interested in the static (!) scheduling overhead itself. I am not talking about thread start-up overhead and time spent in synchronisation and critical section overhead.
You need to separate the overhead for OpenMP to create a team/pool of threads and the overhead for each thread to operate separate sets of iterators in a for loop.
Static scheduling is easy to implement by hand (which is sometimes very useful). Let's consider what I consider the two most important static scheduling
schedule(static)
andschedule(static,1)
then we can compare this toschedule(dynamic,chunk)
.is equivalent to (but not necessarily equal to)
and
is equivalent to
From this you can see that it's quite trivial to implement static scheduling and so the overhead is negligible.
On the other hand if you want to implement
schedule(dynamic)
(which is the same asschedule(dynamic,1)
) by hand it's more complicated:This requires OpenMP >=3.1. If you wanted to do this with OpenMP 2.0 (for MSVC) you would need to use critical like this
Here is an equivalent to
schedule(dynamic,chunk)
(I have not optimized this using atomic accesss):Clearly using atomic accesses is going to cause more overhead. This also shows why using larger chunks for
schedule(dynamic,chunk)
can reduce the overhead.