Work-Sharing

  • DO / END DO
      • The classic parallel loop
      • Inside parallel region
      • Iterations distributed across existing threads
      • Loop index is private to thread by default
      • Loop index must be of type INTEGER
      • If used, the END DO must appear immediately after the loop
      • Branching out of loop is illegal
      • More on clauses (data environment) later

        !$OMP DO [clause[[,]clause]...]
        do_loop
        [!$OMP END DO [NOWAIT]]

Do Scheduling

                    

  

 

!$OMP PARALLEL DO &
!$OMP  SCHEDULE(STATIC,3)
DO J = 1, 36

     Work (j)

END DO
!$OMP END DO
!$OMP PARALLEL DO &
!$OMP  SCHEDULE(DYNAMIC,1)
DO J = 1, 36

     Work (j)

END DO
!$OMP END DO
!$OMP PARALLEL DO &
!$OMP  SCHEDULE(GUIDED,1)
DO J = 1, 36

     Work (j)

END DO
!$OMP END DO