View Source

{section:border=true}
{column:width=70%}

h2. AUTO Loop Schedule in OpenMP 3.0

The AUTO loop schedule is a new loop schedule introduced in OpenMP 3.0. When SCHEDULE(AUTO) is specified on a do/for loop directive, the decision regarding scheduling is delegated to the compiler and/or OpenMP runtime support library. The programmer gives the compiler and/or libmtsk the freedom to choose any possible mapping of iterations to threads in the team.

The AUTO loop schedule is described in Section 2.5.1 (p. 38) of the OpenMP specification.

*Example (Fortran):*
{noformat}
Program Test
integer A(10), B(10)

A = -1
B = 20

!$OMP PARALLEL DO PRIVATE (A), SHARED(B), SCHEDULE(AUTO)
do i = 1, 10
A(i) = i
B(i) = B(i) + A(i)
end do

do i = 1, 10
PRINT *, B(i)
end do
end


% f90 -xopenmp -xO3 test.f
% a.out
21
22
23
24
25
26
27
28
29
30
{noformat}

*Example (C/C++):*
{noformat}
#include <stdio.h>
#include <omp.h>

#define SIZE 10

int main(void)
{
int i;
int buffer[SIZE];

#pragma omp parallel for schedule(auto)
for (i = 0; i < SIZE; i++)
{
buffer[i] = i;
}

for (i = 0; i < SIZE; i++)
{
printf ("%d\n", buffer[i]);
}

return 0;
}


% cc -xopenmp -xO3 test.c
% a.out
0
1
2
3
4
5
6
7
8
9
{noformat}
{column}
{column:width=30%}
{panel:title=OpenMP 3.0 Features in Express 7.08}
{children:page=Sun Studio OpenMP}
{panel}
{column}
{section}

The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact