Reduction of Member variables in C++?

General OpenMP discussion

Reduction of Member variables in C++?

Postby gururise » Thu Feb 28, 2008 2:56 pm

Hello,
Can someone tell me if OpenMP allows the use of directives such as static or reduction on member variables? For example:

Code: Select all
class A {
public:
void count();
private:
int m_Count;
};

void A::count() {
#pragma omp parallel for reduction(+: m_Count)
for (int i=0;i<100;i++) {
  m_Count += i;
}
}


Whenever I try something like this, I get A::m_Count is not a variable in clause reduction.
gururise
 

Re: Reduction of Member variables in C++?

Postby ejd » Tue Apr 08, 2008 2:41 am

The OpenMP spec has a hard time trying to use terminology that is correct and consistent for the points it is trying to make and the standards to which it applies. In this case, reduction applies to "list items" which are variables. The problem you are having, is that m_Count is a class member and not a variable. The reason that most (if not all) implementations do not support this, is because m_Count doesn't exist until it is instantiated when some variable is declared to be of type "A". An implementation could support it, but it is much harder to do and thus far has not been required by the OpenMP spec.

As for "static", this is not an OpenMP clause, but a base language keyword and applies to storage duration. I am not a C++ expert, so I am afraid that I can not tell you whether or not or if static can be applied to class members.


Last bumped by Anonymous on Tue Apr 08, 2008 2:41 am.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am


Return to Using OpenMP

Who is online

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