firstprivate/reduction restriction

Discuss the OpenMP 3.0 API Specifications with the OpenMP Arch. Review Board. (Read Only)

firstprivate/reduction restriction

Postby nathanweeks » Mon Jul 19, 2010 6:10 am

Page 93, lines 19-22 of the OpenMP 3.0 API spec:
A list item that appears in a reduction clause of a parallel construct must not appear in a firstprivate clause on a worksharing or task construct if any of the worksharing or task regions arising from the worksharing or task construct ever bind to any of the parallel regions arising from the parallel construct.

Is this equivalent to saying that a list item that appears in a reduction clause of a parallel construct must not appear in a firstprivate clause of a closely nested worksharing or task region?
--
Nathan Weeks
Iowa State University HPC Group
http://weeks.public.iastate.edu/
nathanweeks
 
Posts: 41
Joined: Sun May 17, 2009 6:19 am
Location: Iowa State University

Re: firstprivate/reduction restriction

Postby m_van_waveren » Wed Jul 28, 2010 8:45 am

Dear Nathan,

I am not sure what you mean by "closely nested worksharing or task region". I list below some examples of conforming and non-conforming code:

Non-conforming code
Code: Select all
#pragma omp parallel reduction (+:a)
{
    #pragma omp for
    for(i=0; i<=n; ++i) {
        #pragma omp task firstprivate(a)  // non-conforming since task binds to parallel w/reduction
        …
    }
}


#pragma omp parallel reduction (+:a)
{
    #pragma omp task shared(a)
    for(i=0; i<=n; ++i) {
        #pragma omp task firstprivate(a)  // non-conforming since task binds to parallel w/reduction
        …
    }
}


Conforming code
Code: Select all
#pragma omp parallel reduction (+:a)
{
    #pragma omp parallel
    {
        #pragma omp task firstprivate(a)   // this is conforming
        …
    }
}
m_van_waveren
 
Posts: 9
Joined: Tue Dec 11, 2007 12:57 pm
Location: Toulouse, France

Re: firstprivate/reduction restriction

Postby nathanweeks » Wed Jul 28, 2010 4:53 pm

The OpenMP 3.0 API spec defines a "closely nested region" on p. 6, lines 1-2, as:
A region nested inside another region with no parallel region nested between them.

The "Non-conforming code" example involves task regions that are closely-nested in the parallel region with the reduction clause, while the "Conforming code" example involves a task region that is not closely nested in the parallel region with the reduction clause.

If I understand the definition correctly, I think a less ambiguous wording would be:
A list item that appears in a reduction clause of a parallel construct must not appear in a firstprivate clause of a closely-nested worksharing or task construct.
--
Nathan Weeks
Iowa State University HPC Group
http://weeks.public.iastate.edu/
nathanweeks
 
Posts: 41
Joined: Sun May 17, 2009 6:19 am
Location: Iowa State University

Re: firstprivate/reduction restriction

Postby nathanweeks » Wed Aug 04, 2010 10:55 am

With respect to explicit tasks, there's already a stronger restriction on page 99, lines 25-26:
A list item that appears in a reduction clause of the innermost enclosing worksharing or parallel construct may not be accessed in an explicit task.
--
Nathan Weeks
Iowa State University HPC Group
http://weeks.public.iastate.edu/
nathanweeks
 
Posts: 41
Joined: Sun May 17, 2009 6:19 am
Location: Iowa State University


Return to OpenMP 3.0 API Specifications

Who is online

Users browsing this forum: No registered users and 3 guests