Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Schedule clause in OpenMP

Tags:

openmp

I have a piece of code (which is part of an application) that I'm trying to optimize using OpenMP, am trying out various scheduling policies. In my case, I noticed that the schedule(RUNTIME) clause has an edge over others (I am not specifying a chunk_size). I've two questions:

  1. When I do not specify chunk_size, is there a difference between schedule(DYNAMIC) and schedule(GUIDED)?

  2. How does OpenMP determine the default implementation-specific scheduling that is stored in the OMP_SCHEDULE variable?

I learned that if no scheduling scheme is specified, then by default schedule(STATIC) is used. So if I don't modify the OMP_SCHEDULE variable, and use schedule(RUNTIME) in my program, would the scheduling scheme be schedule(STATIC) all the times or does OpenMP have some intelligent way to dynamically devise the schedule strategy and change it from time to time?

like image 882
Sayan Avatar asked Jun 16 '10 17:06

Sayan


People also ask

What is schedule clause in OpenMP?

The schedule clause tells OpenMP how to distribute the loop iterations to the threads.

What is schedule static in OpenMP?

The nice thing with static scheduling is that OpenMP run-time guarantees that if you have two separate loops with the same number of iterations and execute them with the same number of threads using static scheduling, then each thread will receive exactly the same iteration range(s) in both parallel regions.

What is default scheduling in OpenMP?

Static Schedules By default, OpenMP statically assigns loop iterations to threads. When the parallel for block is entered, it assigns each thread the set of loop iterations it is to execute.

What is guided scheduling?

guided is an OpenMP schedule policy. The set of iterations is split in blocks of consecutive iterations called chunks, which are distributed to the threads in the team. Each thread executes a chunk, then requests another chunk, until no chunks remain to be distributed.


1 Answers

  1. Yes, if you do not specify a chunk size then DYNAMIC will make the size of all chunks 1. But GUIDED will make the minimum chunk size 1 but other chunk sizes will be implementation dependent. Perhaps you could figure out your situation by running some experiments or reading the documentation.

  2. As I understand the situation: if the environment variable OMP_SCHEDULE is not set then the runtime schedule is implementation dependent. I think it would be very odd if the same schedule was not chosen for each execution of the program. I do not believe that OpenMP, which is a set of compile-time directives, has any way to understand the run-time performance of your program and to choose a schedule based on such information.

like image 166
High Performance Mark Avatar answered Oct 05 '22 00:10

High Performance Mark