Вопрос

I'm working on OpenMP fortran. I've a question regarding scheduling.

so from these two options which one will have better performance?

!$OMP PARALLEL DO PRIVATE(j) SCHEDULE(STATIC) 
do j=1,l
  call dgemm("N","N",..)
 end do
!$OMP END PARALLEL DO 


!$OMP PARALLEL DO PRIVATE(j) 
do j=1,l
   call dgemm("N","N",..)
end do
!$OMP END PARALLEL DO 
Это было полезно?

Решение

There are three scheduling clauses defined by OpenMP: Static, Dynamic and Guided.

  1. Static: Split the loop variable evenly between threads beforehand (at compile-time);
  2. Dynamic: Distributes the chunks as the threads finishes at run-time;
  3. Guided: As dynamic, but the chunk size decreases with each successive allocation;

The default scheduling is implementation independant (not specified in the standard). So, for your question, depending on the compiler, it may change nothing (if the default implementation is Static). Here is what happens if it changes something:

  • Static scheduling is the best for regular tasks, meaning that each iteration of the loop takes the same time. It lowers the overheads of synchronizing task distribution.
  • Dynamic scheduling is the best for irregular tasks, which means that your iterations may have different execution time. This is useful because a thread can process multiple small tasks while another can process less longer tasks.
  • Guided scheduling improves the global load balancing by diminishing the granularity of your chunks. It is more efficient to distribute small tasks at the end of your parallel for to diminish the end time difference among your threads.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top