0

I am confused about dynamic scheduling and LPT scheduling(I think it is static).

What I learnt is dynamic scheduling pick tasks based on chunk sizes and when a thread has done its tasks, it picks another. LPT scheduling picks the tasks based on the longest processing time required for each task.

So, if I sort the tasks based on processing time and then I applied dynamic scheduling with chunk size 1, then is it the same as LPT scheduling or not?

For example, suppose there is a loop with 15 iterations. In each iteration, CartesianProduct of vectors are calculated. But in each itearation, the sizes of vectors are different which means the load is unbalanced. If I calculated the resulting size of each iteration and sorted them in descending order and then schedule(dynamic,1), is that the same as LPT in theory?

nanda
  • 161
  • 1
  • 10
  • 1
    It seems to me you are mixing _task_ and _loop parallelism_ together. What is your question about — scheduling of tasks or scheduling of loop iterations? In task scheduling, there are no chunks and [scheduling is implementation-defined](https://stackoverflow.com/a/23744056/580083). In loop scheduling, there are no tasks. – Daniel Langr Sep 26 '19 at 06:29
  • I guess it would be loop parallelism. What I am talking about is like #pragma omp parallel for schedule(dynamic , 1) would be the same as LPT scheduling if sorted by loads of each iteration. – nanda Sep 26 '19 at 07:45
  • 1
    There is no LPT scheduling in OpenMP. LPT scheduling is mostly related to task parallelism, where you can estimate the load of individual tasks. Even with loop parallelism, you would need to specify the _load of each iteration_. AFAIK, OpenMP does not support any such mechanism. – Daniel Langr Sep 26 '19 at 07:48
  • Yes, it doesn't support LPT. But if I know the load, then can it be the same as LPT? I have edited my question to include an example. – nanda Sep 26 '19 at 07:54
  • 1
    Yes, IMO, it would be the same as LPT. – Daniel Langr Sep 26 '19 at 07:57
  • Just an extra question. Is there a way to implement custom scheduling in OpenMP? – nanda Sep 26 '19 at 07:59
  • 1
    There doesn't seem to be any such option for custom loop scheduling: https://www.openmp.org/spec-html/5.0/openmpsu41.html#x64-1290002.9.2. But you can always "simulate it" by telling each thread what to do without automatic loop parallelization. – Daniel Langr Sep 26 '19 at 08:10

1 Answers1

1

Firstly, OpenMP schedule clauses apply to loops, not tasks, so it is confusing to talk about tasks in this context since OpenMP also has tasks (and, even taskloop). For the avoidance of confusion, I will call the loop scheduled entity a "chunk", since it is a contiguous chunk of iterations.

Assuming you want to discuss the schedule clause on loops, then

  1. There is a fundamental difference between a scheduling algorithm like LPT which assumes prior knowledge of chunk execution time and any of the algorithms permitted by OpenMP, which do not require such knowledge.
  2. As of OpenMP 4.5 there is now a schedule modifier (monotonic or nonmonotonic) which can be applied to the dynamic schedule (as well as others), and that affects the sequences which the schedule can generate.
  3. In OpenMP 5.0 the default, undecorated, schedule(dynamic) is equivalent to schedule(nonmonotonic:dynamic) which allows sequences which which would not be possible with schedule(monotonic:dynamic), and would likely break your mapping (though, you can use schedule(monotonic:dynamic) of course!)
  4. Since all of the OpenMP scheduling behaviour is described in terms of the execution state of the machine, it is certainly possible that a sequence will be produced that is not that which you would expect, since the machine state represents ground-truth, reflecting issues like interference from other machine load, whereas a scheduling scheme like LPT is based on assumed prior knowledge of execution time which may not be reflected in reality.

You can see a discussion of schedule(nonmonotonic:dynamic) at https://www.openmp.org/wp-content/uploads/SC18-BoothTalks-Cownie.pdf

Jim Cownie
  • 2,409
  • 1
  • 11
  • 20