Are named critical sections shared across modules?

General OpenMP discussion

Are named critical sections shared across modules?

Postby mithrandir » Thu Jul 26, 2012 8:40 am

I am not sure if the openmp specification 2.5 is clear on this point. I am working on Windows. Suppose that I have a program (EXE) that calls into a dll. That Dll uses a named critical section:

Code: Select all
#pragma omp critical A1
{
<Block A>
}
Also, the program (EXE) has:

Code: Select all
#pragma omp critical A1
{
<Block B>
}


As I understand the spec, no two threads should be able to execute BlockA and BlockB at the same time i.e. they should be mutually exclusive with respect to each other. The VC 2008 implementation does not share critical sections acorss modules.

So, which is the correct behavior?
mithrandir
 
Posts: 8
Joined: Mon Jun 21, 2010 3:42 pm

Re: Are named critical sections shared across modules?

Postby MarkB » Fri Jul 27, 2012 3:20 am

The intention is that the namespace of critical sections is global across the whole program, and all threads, so this sounds to me like a bug in the VC2008 implementation.

The spec says: "Identifiers used to identify a critical construct have external linkage and are in a name space that is separate from the name spaces used by labels, tags, members, and ordinary identifiers." (page 69 of the 3.1 spec).
MarkB
 
Posts: 428
Joined: Thu Jan 08, 2009 10:12 am

Re: Are named critical sections shared across modules?

Postby mithrandir » Fri Jul 27, 2012 11:49 am

That's how I read the spec as well.

If anyone here can test this out with other compilers/platforms and post the results that would be great. If it turns out that most compiler implementations are similar to VC then it might indicate that this may need to be clarified in the spec.
mithrandir
 
Posts: 8
Joined: Mon Jun 21, 2010 3:42 pm


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 7 guests