Rookie HPC

About

Docs

Tools

Tests

runtime

Definition

runtime is the OpenMP schedule policy that applies the scheduling contained in the environment variable OMP_SCHEDULE at the time the scheduling clause is met. Other OpenMP schedule policies are static, dynamic, auto and guided.

Example

Copy

Feedback

#include <stdio.h>
#include <stdlib.h>
#include <omp.h>

/**
 * @brief Illustrates the use the runtime schedule.
 * @details A for loop is parallelised across 4 threads using the runtime schedule policy.
 **/
int main(int argc, char* argv[])
{
    // Use 4 threads when creating OpenMP parallel regions
    omp_set_num_threads(4);

    // Parallelise the for loop using the runtime schedule
    #pragma omp parallel for schedule(runtime)
    for(int i = 0; i < 10; i++)
    {
        printf("Thread %d processes iteration %d.\n", omp_get_thread_num(), i);
    }

    return EXIT_SUCCESS;
}