[Omp] atomic directive semantics

Dieter an Mey anmey at rz.rwth-aachen.de
Mon Sep 26 04:17:00 PDT 2005


Hi Sven,

I see your argument.
But as a programmer I could easily use a private variable temp_priv

temp_priv=some_very_hairy_function_with_potentially_lots_of_side_effects_located_in_some_other_compilation_unit(b,c,d);

#pragma omp critical some_atomic_region
{
    a=a+temp_priv;
    b=temp_priv;
}

and then the compiler could find out, if it could use atomic hardware 
instructions. (Consider b being a complex variable or so ...)

best regards
Dieter



Sven Karlsson wrote:

> Hi Dieter,
> 
> Dieter an Mey wrote:
> 
>> Why can't we just go abandon atomic and let the compiler try to 
>> optimize the critical region?
> 
> 
> Well, I know you have that opinion! :-) A compiler will, however, most 
> probably not see the possibility of optimizing the following:
> 
> #pragma omp critical some_atomic_region
> {
>  a=a+
> some_very_hairy_function_with_potentially_lots_of_side_effects_located_in_some_other_compilation_unit(b,c,d); 
> 
> }
> 
> into
> 
> #pragma omp atomic
> 
> a=a+some_very_hairy_function_with_potentially_lots_of_side_effects_located_in_some_other_compilation_unit(b,c,d); 
> 
> 
> although the function could be executed in parallel.
> 
> This because it cannot see, at least not with any analysis method I know 
> of, that the function need not be inside the critical. Naturally, the 
> programmer can rewrite the code to make it easier for the compiler but 
> then we loose source code transparency.
> 
> If someone knows about any way to let the compiler realize the 
> optimization above please let me know.
> 
> Best regards
>  Sven
> 
> 


-- 
--------------------------------------------------------------------
Dieter an Mey
High Performance Computing               Hochleistungsrechnen
RWTH Aachen University                   Rechen- und Kommunikations-
Center for Computing and Communication   zentrum der RWTH Aachen
phone: ++49-(0)241-80-24377              Seffenter Weg 23
fax:   ++49-(0)241-80-22134              52074 Aachen, Germany
email: anmey at rz.rwth-aachen.de
--------------------------------------------------------------------





More information about the Omp mailing list