OpenMP® Forum

Discussion on the OpenMP specification run by the OpenMP ARB. OpenMP and the OpenMP logo are registered trademarks of the OpenMP Architecture Review Board in the United States and other countries. All rights reserved.

In C/C++ if you declare a pointer to be private it is making the pointer private and not the area that it points to. In C++, you can not make class members private. The OpenMP spec allows variables to be made private but not class members.

Hello,thanks to address this topic: i have the same problem.how can i do?i have a pointer on a variable and i can get only a pointer on the variable because the a pointer will be returned from a CAD-function that i am not allowed to change.for example: vartyp * myvar = functioncal();

if i make the variable private with private(myvar) then only the pointer will become private. therefore it's not difference if myvar is private or shared.the problem that i have that i get also always a read-error when i access later the variable (which i called here myvar) in parallel from different CPU-Cores.i dont understand why i get a read-error because i think that its no problem to read variables simultaneously from different CPU-cores.thanks for your help.

What i dont undestand in my program and the explane that i showed before is why i get a read-error in the api_function because the function only reads the pointer and the data which the pointers shows to.i dont know why parallel reading from different CPU's is a problem in my example because i though that parallel reading is no problem and that only parallel-writing makes problems.plz help me.thx

As you can see from this, the pointer p has been privatized (all of the loc(p) values are different). However, what p is pointing to - the variable a - has not (all of the loc(*p) are the same). If you run this program multiple times, you will see that the value of *p printed within the parallel region is sometimes 5 for both print lines and sometimes 5 for one line and 10 for the other. There is indeed a data race between lines 17 (the print of "a" or *p) and 18 (the setting of "a" or *p).

Last edited by ejd on Thu Apr 17, 2008 7:05 am, edited 1 time in total.