Private clause behavior outside and inside a function

Hi all,

I have a OpenMP code like the following:

Hi

I checked this out (you could have too).

It is the latter situation that you mentioned. By using private, the value of C will remain intact. So after for-loop, value of C is the same as its value before the loop.

Bests,
Millad

Hi Simone,

According to the OpenMP specification it is unspecified whether "c" in the function references local or global object. This may depend on compiler, its optimizations, etc. For example, if the function test() is inlined you can easily see reference to local object, if the function is outlined then most probably the global object will be referenced in it.

Also your code fragment has couple of issues (those could be caused by incompleteness of the fragment and may not exist in the complete code): race condition on shared variable "j" and usage of uninitialized variable "eps".

Regards,
Andrey