#pragma ibm schedule

C only

Description

The schedule pragma specifies the scheduling algorithms used for parallel processing.

Syntax

Read syntax diagramSkip visual syntax diagram>>-#--pragma--ibm schedule--(sched-type)-----------------------><

where sched-type represents one of the following options:

affinity Iterations of a loop are initially divided into local partitions of size ceiling(number_of_iterations/number_of_threads). Each local partition is then further subdivided into chunks of size ceiling(number_of_iterations_remaining_in_partition/2).

When a thread becomes available, it takes the next chunk from its local partition. If there are no more chunks in the local partition, the thread takes an available chunk from the partition of another thread.

affinity,n

As above, except that each local partition is subdivided into chunks of size n. n must be an integral assignment expression of value 1 or greater.

dynamic Iterations of a loop are divided into chunks of size 1.

Chunks are assigned to threads on a first-come, first-serve basis as threads become available. This continues until all work is completed.

dynamic,n As above, except that all chunks are set to size n. n must be an integral assignment expression of value 1 or greater.
guided Chunks are made progressively smaller until a chunk size of one is reached. The first chunk is of size ceiling(number_of_iterations/number_of_threads). Remaining chunks are of size ceiling(number_of_iterations_remaining/number_of_threads).

Chunks are assigned to threads on a first-come, first-serve basis as threads become available. This continues until all work is completed.

guided,n As above, except the minimum chunk size is set to n. n must be an integral assignment expression of value 1 or greater.
runtime Scheduling policy is determined at run time.
static Iterations of a loop are divided into chunks of size ceiling(number_of_iterations/number_of_threads). Each thread is assigned a separate chunk.

This scheduling policy is also known as block scheduling.

static,n Iterations of a loop are divided into chunks of size n. Each chunk is assigned to a thread in round-robin fashion.

n must be an integral assignment expression of value 1 or greater.

Note:
if n=1, iterations of a loop are divided into chunks of size 1 and each chunk is assigned to a thread in round-robin fashion. This scheduling policy is also known as block cyclic scheduling

Notes

Pragma must appear immediately before the loop or loop block directive to be affected.

Scheduling algorithms for parallel processing can be specified using any of the methods shown below. If used, methods higher in the list override entries lower in the list.

Scheduling algorithms can also be specified using the schedule argument of the parallel_loop and independent_loop pragma statements. For example, the following sets of statements are equivalent:

#pragma ibm parallel_loop
#pragma ibm schedule (sched_type) 
<countable for|while|do loop>
and

#pragma ibm parallel_loop (sched_type)
<countable for|while|do loop>

If different scheduling types are specified for a given loop, the last one specified is applied.