I have the following C++ code:
#include <iostream>
#include <omp.h>
using namespace std;
class Test{
public:
Test(){
cout << "constructing\n";
}
~Test(){
cout << "destructing\n";
}
};
int main(){
Test x;
cout << "begin parallel\n";
#pragma omp parallel private(x)
{
}
cout << "end parallel\n";
return 0;
}
Since I work on a four processor cluster, I’d expect the following output:
constructing
begin parallel
constructing
destructing
constructing
destructing
constructing
destructing
constructing
destructing
end parallel
destructing
In fact that’s exactly what I get if I compile it with icc. However, if I compile it using pgCC (ie. pgCC -mp -o omptest omptest.cpp), I get something different:
constructing
begin parallel
end parallel
destructing
Why is it so? Why the constructor is not called when a new copy of variable x is created at the beginning of the parallel area? Is it a bug in pgCC?
Thanks a lot for any suggestion
petr