firstprivate/reduction restriction

Discuss the OpenMP 3.0 API Specifications with the OpenMP Arch. Review Board. (Read Only)
Forum rules
The OpenMP Forums are now closed to new posts. Please visit Stack Overflow if you are in need of help: https://stackoverflow.com/questions/tagged/openmp
Locked
nathanweeks
Posts: 41
Joined: Sun May 17, 2009 6:19 am
Location: Iowa State University
Contact:

firstprivate/reduction restriction

Post by nathanweeks »

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/

m_van_waveren
Posts: 15
Joined: Tue Dec 11, 2007 12:57 pm
Location: La Roque-Gageac, France
Contact:

Re: firstprivate/reduction restriction

Post by m_van_waveren »

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
        …
    }
}

nathanweeks
Posts: 41
Joined: Sun May 17, 2009 6:19 am
Location: Iowa State University
Contact:

Re: firstprivate/reduction restriction

Post by nathanweeks »

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
Contact:

Re: firstprivate/reduction restriction

Post by nathanweeks »

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/

Locked