Is there a way to find out what scheduling scheme the OMP runtime chooses for schedule(auto)
? I found that (and intuitvely it makes sense) for my problemschedule(static)
is the fastest, so I am wondering if that's what the runtime chooses when is set schedule(auto)
(they're equally fast).
Yes. You can set the environment variable OMP_DISPLAY_ENV
to TRUE
to get this information before running your program. It should print the OMP_SCHEDULE
variable when the OpenMP runtime is initialized. For example, on my system, GOMP (GCC) choose DYNAMIC
while IOMP (Clang/ICC) choose static
by default. You can select this default value by setting the environment variable OMP_SCHEDULE
yourself. You can also retrieve the information at runtime in your program using the OpenMP function omp_get_schedule
.
Unless you know that a schedule is fundamentally better than another one (for example due to the algorithm itself), it is a good practice to let the default (runtime-based) behaviour. Indeed, the result can be sharply different between two OpenMP runtime or two machines. For example, a dynamic schedule can be theoretically better than a static one, but the overhead with one runtime can be so high that it seems a very bad choice while this could not be a problem with another implementation. The number of core and they layout (eg NUMA systems) are also important parameters impacting the performance of the different scheduling strategies.