The SCHEDULE clause of the DO or PARALLEL DO directive specifies a scheduling algorithm that determines how iterations of the DO loop are divided among and dispatched to the threads of the team. The SCHEDULE clause applies only to the current DO or PARALLEL DO directive.
Within the SCHEDULE clause, you must specify a schedule type and, optionally, a chunk size. A chunk is a contiguous group of iterations dispatched to a thread. Chunk size must be a scalar integer expression.
The following list describes the schedule types and how the chunk size affects scheduling:
Schedule Type |
Description |
---|---|
STATIC |
The iterations are divided into pieces having a size specified by chunk. The pieces are statically dispatched to threads in the team in a round-robin manner in the order of thread number. When chunk is not specified, the iterations are first divided into contiguous pieces by dividing the number of iterations by the number of threads in the team. Each piece is then dispatched to a thread before loop execution begins. |
DYNAMIC |
The iterations are divided into pieces having a size specified by chunk. As each thread finishes its currently dispatched piece of the iteration space, the next piece is dynamically dispatched to the thread. When no chunk is specified, the default is 1. |
GUIDED |
The chunk size is decreased exponentially with each succeeding dispatch. Chunk specifies the minimum number of iterations to dispatch each time. If there are less than chunk number of iterations remaining, the rest are dispatched. When no chunk is specified, the default is 1. |
RUNTIME |
The decision regarding scheduling is deferred until run time. The schedule type and chunk size can be chosen at run time by using the OMP_SCHEDULE environment variable. When you specify RUNTIME, you cannot specify a chunk size. |
The following list shows which schedule type is used, in priority order:
The schedule type specified in the SCHEDULE clause of the current DO or PARALLEL DO directive.
If the schedule type for the current DO or PARALLEL DO directive is RUNTIME, the default value specified in the OMP_SCHEDULE environment variable.
The compiler default schedule type of STATIC.
The following list shows which chunk size is used, in priority order:
The chunk size specified in the SCHEDULE clause of the current DO or PARALLEL DO directive.
For RUNTIME schedule type, the value specified in the OMP_SCHEDULE environment variable.
For DYNAMIC and GUIDED schedule types, the default value 1.
If the schedule type for the current DO or PARALLEL DO directive is STATIC, the loop iteration space divided by the number of threads in the team.