Dynamic scheduling in @sync @distributed for constructions


Maybe it is a too simple question, but I couldn’t find it in the documentation.

Constructions like

@sync @distributed for j=1:N

make static schedule of iterations by default. But my iterations can take different time, some are very long, some are short. In OpenMP I can easily set the schedule to dynamic before the loop to optimize performance. Do you have an analog for it?


Maybe you can use pmap.




Thanks. So it seems that there is no easy OpenMP style solution. Bad, static/dynamic schedule seems to be a very simple and useful option.


Could you explain more why pmap is not suitable?

Is it the syntax?
Do you want to dynamically switch between static/dynamic load scheduling?

Could you use something like:

pmap(1:N) do j

It’s suitable but makes very simple things more complicated. I want my loop to start from the word “for” because it’s simple.


Ha, maybe some clever person can write a macro @pfor to sweeten your syntax.


=) May be, but it seems to me that Julia creators are inventing the bicycle in this area. People do not come to Julia from nowhere, and have experience with such old and common things like MPI or OpenMP.
I think problem is also that Julia documentation is very poor, with so few examples. Like now I still don’t get why you need “@sync @distributed for” and “pmap”. Which of this function will vanish in Julia 2.0?