Additional Loop Scheduling Techniques

Hi all

I am completely new to the LLVM OpenMP runtime library. I am currently interested to implement additional loop scheduling techniques to the runtime library and then test them with different benchmarks. I wanted to ask you if one of you could help me getting things sorted out, like, which techniques are already implemented and where I can find documents to get more Information about the implementation that already exists. I am happy for every information!

Have a nice day



The first thing to do is to look at the manual that accompanies the code. (See or the equivalent place in your checked out code). It should clearly be updated (since it hasn’t been built since 2015); maybe this could be your first commit request…), but it does try to give you some introduction. For scheduling look at the chapter on Work Sharing. That also points you at the functions you should be interested in, and the enumerations which list the supported schedules.

I expect that your new schedules will need to use the dynamic schedule interface, since that has a call into the runtime for each chunk of iterations a thread should execute, whereas the static schedule interface calls the runtime only once, then computes the iteration locally from the chunked block-cyclic distribution described by that initial call.

For prototyping purposes, it is probably easiest to add some new call of your own (do not use the omp_* namespace!) to set a flag inside the runtime that you can then check in the dynamic loop initialization code to choose your schedule at the next dynamic loop.

So, something like


#pragma omp for schedule(dynamic)

for (…)

… etc …

You’d then also need to define ay_set_schedule_magic() somewhere in the runtime and export it, and also have a null version of that in another shared library so that you can to the comparison between your code and the existing schedules on the same executable.

You could just force all dynamic loops to use your new schedule (via some envirable you checked for), but that may be more confusing, since it’s harder to do experiments on real code with many dynamic loops.

If you want to do history based scheduling (remembering how a particular lexical loop behaved and using that information the next time it is executed), note that the first argument to all of these functions is a pointer to an ident_t which, in turn, points to a source location string. (With the Intel compiler you need to compile the code with –parallel-source-info=2 to get the full filename in there; I’m not sure what LLVM does about that). Without that flag there is still some source info it’s just not complete.

(Hmm… it looks as if clang puts in the source file info without requiring extra compiler flags, look at and note the


.asciz “;/tmp/compiler-explorer-compiler1181022-56-1lbfx2g.w69k/example.cpp;square;4;9;;”

for instance).

(If you’re not familiar with the compiler explorer, it may prove useful to you as a quick way to see what code is generated for a given OpenMP construct).

Good luck, and keep asking.