In a member function, I can parallelize using the shared member variable int *x
like this
#pragma omp parallel for default(shared)
for(int i=0;i
Don't know precisiely - but take a look through 32 OpenMP traps for C++ developers for sorting out most OpenMP problems
Most implementations of OpenMP outline the parallel region. That is, they make it a function. Private variables are generally passed to this function and shared variables may be passed or be within the function's scope. The problem with class data members is that they are not the same as variables.
When the compiler outlines a parallel region, variables have storage locations defined that the compiler can set up to pass to the function. Data members may not be instantiated (i.e., storage allocated) until the class is called during execution of the program. This means that the compiler cannot privatize data members by itself. It would also have to be done in the runtime and this would cause a lot more work and would affect performance of both serial and parallel programs. So far no implementation has tried to do this work and since the OpenMP spec is written by consensus the decision was made to disallow data members in all clauses. Otherwise, it seemed too confusing to say that they are allowed in shared clauses, but no other clause.