2

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).

Marcel Braasch
  • 1,083
  • 1
  • 10
  • 19

1 Answers1

3

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.

Jérôme Richard
  • 41,678
  • 6
  • 29
  • 59
  • 2
    Looking at the `OMP_SCHEDULE` envirable tells you what schedule `schedule(runtime)` will use, but not which `schedule(auto)` will. One possible way to see that (assuming that a compiler always makes the same choice independent of the code), would be to use Compiler Explorer (https://godbolt.org) and look at the generated code for a simple loop (though working back to the schedule is not entirely trivial!). The most likely answer is just "schedul(static)", though. – Jim Cownie Jul 06 '21 at 08:03
  • Thanks both of you! I ended up collecting which process does what in a map and printed the map. Indeed `schedule(auto)` picked `static` as I am operating on nice matrices. What was odd though was e.g., for a 8x8 matrix and 4 workers when I distributed rows to do calculations on, process 0 would not necesarilly get rows 1 and 2 but any two adjacent rows. – Marcel Braasch Jul 07 '21 at 18:50
  • 2
    Indeed, in GCC source code (https://github.com/gcc-mirror/gcc/blob/master/libgomp/loop_ull.c line 192) you can read : `/* For now map to schedule(static), later on we could play with feedback driven choice. */` – Laci Jul 12 '21 at 14:24
  • Ah wow. So it's really just hard coded.. Interesting :D! – Marcel Braasch Jul 12 '21 at 22:44