Module 11: The “lastprivate” Clause
  Lecture 21: Clause and Routines
 


Loop Work-sharing Construct: Schedule Clause

Dynamic [ , chunk ]
  • Fixed portions of work; size is controlled by the value of chunk
  • When a thread finishes one chunk, It is dynamically assigned another
  • The default chunk size is 1.
  • Most work at runtime: complex scheduling logic used at run-time
Guided [ ,chunk ]
  • Special case of dynamic to reduce scheduling overhead
  • The size of the block starts large and shrinks down to size chunk as the calculation proceeds
  • Default chunk size is 1
Runtime
  • Iteration scheduling scheme is set at runtime through environment variable OMP SCHEDULE or the runtime library
Questions
Given loop of length 16 with 4 threads:
How the iterations will be assigned in static schedule with no chunk and chunk=2 ?
What will be the change in case of dynamic scheduling?

Run-Time Library Routines

OMP SET NUM THREADS: Sets the number of threads that will be used in the next parallel region. Must be a positive number.

Format
void omp set num threads(int num threads)
  • This routine can only be called from the serial portion of the code.
  • This call has precedence over the OMP NUM THREADS