flush on vectors in C

General OpenMP discussion

flush on vectors in C

Postby bda » Sat Nov 24, 2007 4:38 pm

Hi,

According to the specs, a pointer in the flush list flushes only the pointer, but not the object it references. Then I don't understand the example A18.1 for C (in the 2.5 specs), because it uses

Code: Select all
int synch[MAX_THREADS];
...
synch[iam]=1;
#pragma omp flush(synch)

where synch is clearly a pointer!

I have written a similar pipelining code, which hangs if I use the same mechanism as described in example A18.1.
The solution for me was to use
Code: Select all
....
#pragma omp atomic
synch[iam]++;

instead of
Code: Select all
synch[iam]++;
#pragma omp flush(synch)


The Fortran version of my pipelining code works fine, and here I can see the effect of removing/inserting flushes. Without flushes the code hangs, with flushes it works as expected.

Is this a compiler problem (I am using Sun Studio 11 and 12), or is this a language problem, and the example in the specs is wrong? Or is it something else?

Regards,
Bernd
bda
 
Posts: 2
Joined: Wed Nov 07, 2007 12:48 pm

Re: flush on vectors in C

Postby ejd » Mon Mar 17, 2008 8:58 am

The C standard differentiates between "array of type" and "pointer to type" and the OpenMP spec uses that distinction. If the variable is an "array of type", then the directive applies to the array (because we have the size of the array available). If the variable is a "pointer to type", then the directive applies to the pointer.

In example A.18.1.c in the OpenMP V2.5 spec, synch is an array of type int and the flush is suppose to flush the array.

The examples in the OpenMP spec are run against all of the Sun Studio releases and I have not seen a problem with any of the examples. Of course, that doesn't mean there isn't a problem. I know that Nawal contacted you about this and you said you would send us an example when you had time.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am


Return to Using OpenMP

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 9 guests