Data-sharing attribute of class member variables in OpenMP

General OpenMP discussion

Data-sharing attribute of class member variables in OpenMP

Postby cellard0or » Fri Feb 14, 2014 2:06 am

The title is what my problem seems to boil down to. I have posted a more detailed question to stackoverflow [1] yesterday and would like to point you there. If full replication of the question is appreciated I'll do that.
Anyway, any help is higly appreciated as I worked several hours on this problem yet.

[1] http://stackoverflow.com/questions/21758104/data-sharing-attribute-of-class-member-variables-in-openmp
cellard0or
 
Posts: 10
Joined: Thu Feb 13, 2014 8:17 am

Re: Data-sharing attribute of class member variables in Open

Postby MarkB » Fri Feb 14, 2014 3:46 am

Data members of private objects are indeed private, whereas static data members of classes are shared. Local variables declared inside routines called from within a parallel region are private unless they are declared static.

To check for race conditions: are there any static data members, local variables declared as static, or other global variables modified inside the parallel region? Are there any concurrent accesses to the same file by different threads?
MarkB
 
Posts: 431
Joined: Thu Jan 08, 2009 10:12 am

Re: Data-sharing attribute of class member variables in Open

Postby cellard0or » Fri Feb 14, 2014 6:23 am

There are no static variables in the code. Also there are no files accessed by more than one thread. But I just discovered that in the files from which functions are called in run() global variables are present. I guess this might be a problem?!
cellard0or
 
Posts: 10
Joined: Thu Feb 13, 2014 8:17 am

Re: Data-sharing attribute of class member variables in Open

Postby ftinetti » Fri Feb 14, 2014 6:42 am

Hi,

What do you mean by
in the files from which functions are called in run() global variables are present.

?

If it means that some function called from run() contains global variables, then that's what Mark was asking in
To check for race conditions: are there any static data members, local variables declared as static, or other global variables modified inside the parallel region?

(and the specific answer to the question would be, of course, "yes").

HTH,

Fernando.
ftinetti
 
Posts: 577
Joined: Wed Feb 10, 2010 2:44 pm

Re: Data-sharing attribute of class member variables in Open

Postby cellard0or » Fri Feb 14, 2014 6:50 am

run() calls functions which are defined in the file, say, "help.cpp". These functions are actually working on global variables defined inside "help.cpp". And yes, I was dumb not to see that. Hope I can get the thing running now :)
So far,
thank you very much!
cellard0or
 
Posts: 10
Joined: Thu Feb 13, 2014 8:17 am

Re: Data-sharing attribute of class member variables in Open

Postby cellard0or » Fri Feb 14, 2014 7:55 am

To close this:
The problem was the use of global variables declared in other files. Nasty. But now it works!
Thanks again.
cellard0or
 
Posts: 10
Joined: Thu Feb 13, 2014 8:17 am

Re: Data-sharing attribute of class member variables in Open

Postby MarkB » Fri Feb 14, 2014 8:51 am

Great, glad you fixed it!
MarkB
 
Posts: 431
Joined: Thu Jan 08, 2009 10:12 am


Return to Using OpenMP

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests