#pragma ibm schedule Preprocessor Directive (C Only)

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

Syntax

#pragma ibm schedule (sched-type)
<countable for/while/do loop>

where sched-type represents one of the following options:

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

If n is specified, each local partition is subdivided into chunks of size n. n must be an integral assignment expression of value 1 or greater.

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.

dynamic
dynamic,n
If n is not specified, iterations of a loop are divided into chunks of size 1.

If n is specified, all chunks are set to size n. n must be an integral assignment expression of value 1 or greater.

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

guided
guided,n
Chunks are made progressively smaller until the default minimum chunk size 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).

If n is specified, the minimum chunk size is set to n. n must be an integral assignment expression of value 1 or greater.

If n is not specified, a default value of 1 is assumed.

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

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.

This scheduling policy is also known as block cyclic scheduling.

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

This scheduling policy is also known as cyclic scheduling.

Notes
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 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.



Program Parallelization
Shared and Private Variables in a Parallel Environment
Countable Loops


Control Parallel Processing with Pragmas


#pragma Preprocessor Directives for Parallel Processing
Built-in Functions Used for Parallel Processing
#pragma ibm parallel_loop Preprocessor Directive
IBM Run-time Options for Parallel Processing
smp Compiler Option