[Omp] OpenMP spec 2.5 seems to have incorrect flush example on page 12
Marcel Beemster
marcel at ace.nl
Sun May 6 09:27:11 PDT 2007
Greg wrote:
> There is one other option. Instead of the above transformation, do the
> following:
> (initially X=21)
> Thread 0 Thread 1
> -------- --------
> r=X omp_set_lock(&l)
> X2=X X=42
> while(?) omp_unset_lock(&l)
> if(?) r=1
> if(X2!=X) X=r
> omp_set_lock(&l)
> print X
> omp_unset_lock(&l)
>
> This would preserve the desired semantics at a pretty small reduction in
> sequential performance.
This is clever and it is essentially what hardware caches do:
if they are not write-through, they keep a bit to tell that
cached cell is "dirty" and needs to be flushed when the
cached cell is evacuated for new content.
But your assessment that the overhead compared to sequential
performance is pretty small is not correct in my view. It
means that the compiler has to introduce software managed
dirty-bits for every shared memory location that is written.
The additional control flow "IF(dirty-X) X=r" can turn out
to be quite costly.
Marcel
More information about the Omp
mailing list