Data sharing block local externs

Discussion of the OpenMP 3.1 draft specifications closed May 1, 2011. (Read only)

Data sharing block local externs

Postby jakub » Fri Apr 22, 2011 4:06 am

What should be data sharing for extern decls declared inside of the construct?
void
foo ()
{
#pragma omp parallel default(none)
{
extern int s;
#pragma omp atomic
s++;
}
}

2.9 just says that automatic vars declared in scope inside of the construct are predetermined private and static vars declared in scope inside of the construct are predetermined shared, but local extern is IMHO neither of those.
jakub
 
Posts: 74
Joined: Fri Oct 26, 2007 3:19 am

Re: Data sharing block local externs

Postby ejd » Mon Apr 25, 2011 7:32 am

Thank you for your question.

If you look at the C99 standard, section 6.2.4 Storage durations of objects, states:
An object whose identifier is declared with external or internal linkage, or with the storage-class specifier static has static storage duration. Its lifetime is the entire execution of the program and its stored value is initialized only once, prior to program
startup.

In the C++ standard, section 3.7.1 Static storage duration, states:
All objects which neither have dynamic storage duration nor are local have static storage duration.

and section 3.7.2 Automatic storage duration, states:
Local objects explicitly declared auto or register or not explicitly declared static or extern have automatic storage duration.

So the base languages (C/C++) consider externs to have static storage duration.

In the OpenMP V3.1 specification, section 2.9.1.1 Data-sharing Attribute Rules for Variables Referenced in a Construct (p83, line 30), states:
• Static variables that are declared in a scope inside the construct are shared.

After you posted your comment, someone in the committee reviewed it and agreed with your comment. The current proposal is to change page 83 line 30 to say:
• Static storage duration variables that are declared in a scope inside the construct are shared.

We believe this should take care of your concern. It not, please let us know.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: Data sharing block local externs

Postby jakub » Tue Apr 26, 2011 3:01 am

"Static storage duration variables that are declared in a scope inside the construct are shared."

would be perfect. Thanks.
jakub
 
Posts: 74
Joined: Fri Oct 26, 2007 3:19 am


Return to Draft 3.1 Public Comment

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron